Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/app-core/src/components/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { isArchiveTabPath } from '@shared/archive'
import { isTrashTabPath } from '@shared/trash'
import { isQuickNotesTabPath } from '@shared/quick-notes'
import { resolveSystemFolderLabels } from '../lib/system-folder-labels'
import { shouldShowWindowControls } from '../lib/titlebar'

export function TitleBar(): JSX.Element {
const vault = useStore((s) => s.vault)
Expand All @@ -14,6 +15,7 @@ export function TitleBar(): JSX.Element {
const systemFolderLabels = useStore((s) => s.systemFolderLabels)
const workspaceMode = useStore((s) => s.workspaceMode)
const isMac = window.zen.platformSync() === 'darwin'
const runtime = window.zen.getAppInfo().runtime
const labels = resolveSystemFolderLabels(systemFolderLabels)

const title = activeNote
Expand Down Expand Up @@ -47,7 +49,7 @@ export function TitleBar(): JSX.Element {
</span>
)}
</div>
{!isMac && (
{shouldShowWindowControls(isMac ? 'darwin' : 'other', runtime) && (
<div className="flex items-center gap-1">
<WinButton onClick={() => window.zen.windowMinimize()} label="–" />
<WinButton onClick={() => window.zen.windowToggleMaximize()} label="▢" />
Expand Down
19 changes: 19 additions & 0 deletions packages/app-core/src/lib/titlebar.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest'
import { shouldShowWindowControls } from './titlebar'

describe('shouldShowWindowControls — hidden on mac and in the web runtime', () => {
it('shows controls on desktop, non-mac', () => {
expect(shouldShowWindowControls('win32', 'desktop')).toBe(true)
expect(shouldShowWindowControls('linux', 'desktop')).toBe(true)
})

it('hides controls in the web runtime, regardless of platform', () => {
expect(shouldShowWindowControls('win32', 'web')).toBe(false)
expect(shouldShowWindowControls('linux', 'web')).toBe(false)
})

it('hides controls on mac, regardless of runtime', () => {
expect(shouldShowWindowControls('darwin', 'desktop')).toBe(false)
expect(shouldShowWindowControls('darwin', 'web')).toBe(false)
})
})
9 changes: 9 additions & 0 deletions packages/app-core/src/lib/titlebar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Whether the native window controls (minimize/maximize/close) should
* be shown. They call Electron-only APIs, so they're hidden on mac
* (native traffic lights instead) and in the web runtime, where there
* is no native window to control.
*/
export function shouldShowWindowControls(platform: string, runtime: string): boolean {
return platform !== 'darwin' && runtime !== 'web'
}