Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(desktop): keep toolbar controls clear of macOS traffic lights (#1983)

Andrew Mikofalvy82e1d366dd7a
diff --git a/.changeset/fix-titlebar-traffic-light-collision.md b/.changeset/fix-titlebar-traffic-light-collision.md
new file mode 100644
index 000000000..c7747daac
--- /dev/null
+++ b/.changeset/fix-titlebar-traffic-light-collision.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Fix the macOS desktop toolbar controls (collapse, search) sliding under the window traffic lights. Dragging the sidebar rail to collapse no longer leaves the editor-header reserve lagging behind the now-vanished sidebar, and the sidebar action cluster now keeps clear of the traffic lights structurally regardless of how many buttons it holds.
diff --git a/packages/app/src/components/EditorHeader.dom.test.tsx b/packages/app/src/components/EditorHeader.dom.test.tsx
index 812ad64b6..c0df8ef89 100644
--- a/packages/app/src/components/EditorHeader.dom.test.tsx
+++ b/packages/app/src/components/EditorHeader.dom.test.tsx
@@ -19,6 +19,7 @@ mock.module('@lingui/react/macro', () => ({
let activeDocName: string | null = 'docs/notes';
let activeTarget: unknown = { kind: 'doc' };
let sidebarState: 'expanded' | 'collapsed' = 'expanded';
+let isDraggingRail = false;
let workspace: { contentDir: string; pathSeparator: string } | null = {
contentDir: '/tmp/project',
pathSeparator: '/',
@@ -34,7 +35,7 @@ mock.module('@/lib/use-workspace', () => ({
}));
mock.module('@/components/ui/sidebar', () => ({
- useSidebar: () => ({ state: sidebarState }),
+ useSidebar: () => ({ state: sidebarState, isDraggingRail }),
SidebarTrigger: ({ className }: { className?: string }) => (
<button type="button" data-testid="sidebar-trigger" className={className}>
sidebar
@@ -107,6 +108,7 @@ describe('EditorHeader runtime behavior', () => {
activeDocName = 'docs/notes';
activeTarget = { kind: 'doc' };
sidebarState = 'expanded';
+ isDraggingRail = false;
workspace = { contentDir: '/tmp/project', pathSeparator: '/' };
latestHandoffInput = undefined;
});
@@ -129,7 +131,10 @@ describe('EditorHeader runtime behavior', () => {
'items-center',
'shadow-[inset_0_-1px_0_var(--border)]',
]);
- expectVisualClassTokensAbsent(header.className, ['[-webkit-app-region:drag]', 'pl-[78px]']);
+ expectVisualClassTokensAbsent(header.className, [
+ '[-webkit-app-region:drag]',
+ 'pl-[var(--ok-titlebar-reserve-left,1rem)]',
+ ]);
expectVisualClassTokensAbsent(screen.getByTestId('sidebar-trigger').className, [
'[-webkit-app-region:no-drag]',
]);
@@ -143,7 +148,7 @@ describe('EditorHeader runtime behavior', () => {
expect(header.getAttribute('data-electron-drag')).toBe('');
expectVisualClassTokens(header.className, [
'[-webkit-app-region:drag]',
- 'pl-[78px]',
+ 'pl-[var(--ok-titlebar-reserve-left,1rem)]',
'motion-safe:transition-[padding]',
]);
expectVisualClassTokens(screen.getByTestId('sidebar-trigger').className, [
@@ -159,7 +164,17 @@ describe('EditorHeader runtime behavior', () => {
const header = await renderHeader();
expectVisualClassTokens(header.className, ['[-webkit-app-region:drag]']);
- expectVisualClassTokensAbsent(header.className, ['pl-[78px]']);
+ expectVisualClassTokensAbsent(header.className, ['pl-[var(--ok-titlebar-reserve-left,1rem)]']);
+ });
+
+ test('rail drag keeps the reserve but drops the padding transition so it snaps with the sidebar', async () => {
+ setElectronHost(true);
+ sidebarState = 'collapsed';
+ isDraggingRail = true;
+ const header = await renderHeader();
+
+ expectVisualClassTokens(header.className, ['pl-[var(--ok-titlebar-reserve-left,1rem)]']);
+ expectVisualClassTokensAbsent(header.className, ['motion-safe:transition-[padding]']);
});
test('renders tabs and action cluster without project or asset-title chrome', async () => {
diff --git a/packages/app/src/components/EditorHeader.tsx b/packages/app/src/components/EditorHeader.tsx
index 40ed33ae8..91488445d 100644
--- a/packages/app/src/components/EditorHeader.tsx
+++ b/packages/app/src/components/EditorHeader.tsx
@@ -50,7 +50,7 @@ export function EditorHeader({
}: EditorHeaderProps) {
const { t } = useLingui();
const { activeDocName, activeTarget } = useDocumentContext();
- const { state: sidebarState } = useSidebar();
+ const { state: sidebarState, isDraggingRail } = useSidebar();
const singleFile = useSingleFileMode();
const sidebarShortcut = formatShortcut('toggle-files-sidebar');
const searchShortcut = formatShortcut('command-palette');
@@ -90,8 +90,9 @@ export function EditorHeader({
className={cn(
'flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]',
isElectronHost && '[-webkit-app-region:drag]',
- isElectronHost && isCollapsed && 'pl-[78px]',
+ isElectronHost && isCollapsed && 'pl-[var(--ok-titlebar-reserve-left,1rem)]',
isElectronHost &&
+ !isDraggingRail &&
'motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear',
)}
>
diff --git a/packages/app/src/components/FileSidebar.dom.test.tsx b/packages/app/src/components/FileSidebar.dom.test.tsx
index bb4903453..b6ff702f2 100644
--- a/packages/app/src/components/FileSidebar.dom.test.tsx
+++ b/packages/app/src/components/FileSidebar.dom.test.tsx
@@ -427,8 +427,12 @@ describe('FileSidebar runtime behavior', () => {
const header = screen.getByTestId('sidebar-header');
expect(screen.getByText('Files')).toBeTruthy();
expectVisualClassTokens(header.className, ['justify-between']);
- expectVisualClassTokensAbsent(header.className, ['[-webkit-app-region:drag]']);
+ expectVisualClassTokensAbsent(header.className, [
+ '[-webkit-app-region:drag]',
+ 'overflow-x-clip',
+ ]);
expect(header.getAttribute('data-electron-drag')).toBeNull();
+ expect(screen.queryByTestId('sidebar-traffic-light-reserve')).toBeNull();
expect(screen.queryByText('Project switcher')).toBeNull();
fireEvent.click(screen.getByTestId('sidebar-search'));
@@ -440,13 +444,23 @@ describe('FileSidebar runtime behavior', () => {
await renderSidebar();
const header = screen.getByTestId('sidebar-header');
- const toolbar = header.querySelector('div') as HTMLElement;
+ const toolbar = screen.getByTestId('sidebar-toolbar');
const pillRow = screen.getByTestId('sidebar-search').parentElement as HTMLElement;
expect(screen.queryByText('Files')).toBeNull();
expect(screen.getByText('Project switcher')).toBeTruthy();
expect(header.getAttribute('data-electron-drag')).toBe('');
- expectVisualClassTokens(header.className, ['justify-end', '[-webkit-app-region:drag]']);
+ expectVisualClassTokens(header.className, [
+ 'justify-between',
+ 'overflow-x-clip',
+ '[-webkit-app-region:drag]',
+ ]);
+ const reserve = screen.getByTestId('sidebar-traffic-light-reserve');
+ expectVisualClassTokens(reserve.className, [
+ 'w-[var(--ok-titlebar-reserve-left,0px)]',
+ 'shrink-0',
+ 'self-stretch',
+ ]);
expectVisualClassTokens(toolbar.className, ['[&>*]:[-webkit-app-region:no-drag]']);
expectVisualClassTokens(pillRow.className, ['[-webkit-app-region:no-drag]']);
expect(screen.getByTestId('sidebar-rail').getAttribute('data-enable-toggle')).toBe('false');
diff --git a/packages/app/src/components/FileSidebar.tsx b/packages/app/src/components/FileSidebar.tsx
index d032514e0..ed09166a0 100644
--- a/packages/app/src/components/FileSidebar.tsx
+++ b/packages/app/src/components/FileSidebar.tsx
@@ -455,7 +455,8 @@ function FileSidebarInner({ onOpenSearch }: FileSidebarProps) {
data-electron-drag={isElectronHost ? '' : undefined}
className={cn(
'flex-row h-12 items-center py-0 px-3',
- isElectronHost ? 'justify-end' : 'justify-between',
+ 'justify-between',
+ isElectronHost && 'overflow-x-clip',
isElectronHost &&
'motion-safe:transition-opacity motion-safe:duration-100 motion-safe:ease-out',
isElectronHost && isExpanded && 'motion-safe:delay-100',
@@ -463,12 +464,20 @@ function FileSidebarInner({ onOpenSearch }: FileSidebarProps) {
isElectronHost && '[-webkit-app-region:drag]',
)}
>
+ {isElectronHost ? (
+ <div
+ aria-hidden="true"
+ data-testid="sidebar-traffic-light-reserve"
+ className="w-[var(--ok-titlebar-reserve-left,0px)] shrink-0 self-stretch"
+ />
+ ) : null}
{isExpanded && !isElectronHost ? (
<span className="shrink-0 font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50">
<Trans>Files</Trans>
</span>
) : null}
<div
+ data-testid="sidebar-toolbar"
className={cn(
'flex items-center gap-1',
isElectronHost && '[&>*]:[-webkit-app-region:no-drag]',
diff --git a/packages/app/src/globals.css b/packages/app/src/globals.css
index eca3bf844..f5676360e 100644
--- a/packages/app/src/globals.css
+++ b/packages/app/src/globals.css
@@ -2446,8 +2446,10 @@ html.electron-mode {
`packages/desktop/src/main/index.ts`), placing OS-drawn close/min/zoom
buttons in the renderer's top-left at x=22..~100. Any full-viewport
overlay must reserve enough left padding to clear that footprint.
- 78px = trafficLightPosition.x (22) + 3 buttons × ~18px + margin —
- mirrors the inline literal in `EditorHeader.tsx:69` (PR #677).
+ 78px = trafficLightPosition.x (22) + 3 buttons × ~18px + margin. This
+ token is the single source for that reserve — EditorHeader, FileSidebar's
+ SidebarHeader, GraphPanel, and ConnectingBanner all consume it rather than
+ re-declaring the literal.
Web hosts (no `window.okDesktop`) never gain the `electron-mode` class,
so the variable is undefined there. Consumers MUST use the fallback
form `pl-[var(--ok-titlebar-reserve-left,1rem)]` — `,1rem` matches the
diff --git a/packages/app/tests/integration/fullscreen-overlay-safe-area-coverage.test.ts b/packages/app/tests/integration/fullscreen-overlay-safe-area-coverage.test.ts
index c2e302fd3..6a07f613c 100644
--- a/packages/app/tests/integration/fullscreen-overlay-safe-area-coverage.test.ts
+++ b/packages/app/tests/integration/fullscreen-overlay-safe-area-coverage.test.ts
@@ -29,7 +29,7 @@ const CLASS_PATTERNS: readonly ClassPattern[] = [
},
];
-const SAFE_AREA_AFFORDANCE_MARKERS = ['pl-[78px]', 'pl-[var(--ok-titlebar-reserve-left,1rem)]'];
+const SAFE_AREA_AFFORDANCE_MARKERS = ['pl-[var(--ok-titlebar-reserve-left,1rem)]'];
const SAFE_AREA_WRAPPER_FILES = new Set<string>();