The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(shell): make the sidebar drag regions cover their subtrees
Shanub135e3c8ba12
diff --git a/app/src/components/layout/shell/AppSidebar.test.tsx b/app/src/components/layout/shell/AppSidebar.test.tsxindex 0984731b63..4135b411f6 100644--- a/app/src/components/layout/shell/AppSidebar.test.tsx+++ b/app/src/components/layout/shell/AppSidebar.test.tsx@@ -80,9 +80,28 @@ describe('AppSidebar — collapsed rail', () => {expect(screen.getByRole('button', { name: 'nav.chat' })).toBeInTheDocument();});- it('reserves a draggable strip above the reopen trigger for the macOS traffic lights', () => {+ it('reserves a strip above the reopen trigger for the macOS traffic lights', () => {const { container } = renderAppSidebar({ initialEntries: ['/chat'] }, { open: false });- expect(container.querySelector('[data-tauri-drag-region]')).toBeInTheDocument();+ // A spacer now, not a drag region of its own — the column around it drags.+ expect(container.querySelector('.h-7.w-full.flex-none')).toBeInTheDocument();+ });++ // The drag region is the whole column, not just that strip. `drag.js` drags a+ // bare region only on a direct hit, so the ~12px of column either side of each+ // 32px rail button — the band sitting between the traffic lights and the rail+ // — was dead chrome. Assert the *value* and that the controls are inside it:+ // presence alone passed before the fix and would pass again after a revert.+ it('marks the whole collapsed column as a deep drag region', () => {+ const { container } = renderAppSidebar({ initialEntries: ['/chat'] }, { open: false });+ const region = container.querySelector('[data-tauri-drag-region]') as HTMLElement;+ expect(region.getAttribute('data-tauri-drag-region')).toBe('deep');+ expect(region.className).toContain('h-full');+ // Only `"deep"` reaches descendants, so containment is what makes the+ // margins around these controls draggable. They stay clickable because+ // `isDragRegion` short-circuits on a clickable element first — which is+ // what resolving them by button role here asserts.+ expect(region).toContainElement(screen.getByTestId('root-shell-reopen'));+ expect(region).toContainElement(screen.getByRole('button', { name: 'nav.chat' }));});it('gives the reopen trigger the expected analytics id and label', () => {diff --git a/app/src/components/layout/shell/AppSidebar.tsx b/app/src/components/layout/shell/AppSidebar.tsxindex d7da786bf4..9993a54207 100644--- a/app/src/components/layout/shell/AppSidebar.tsx+++ b/app/src/components/layout/shell/AppSidebar.tsx@@ -88,13 +88,26 @@ export default function AppSidebar() {// body below — no fill of its own, chrome shows through (see the// expanded-branch comment for why). `items-center` centers the// fixed-size trigger/rail buttons in the narrow column.- <div className="flex h-full min-h-0 flex-col items-center gap-0.5">+ //+ // The whole column is the drag region, not just the strip below it. At+ // {@link SIDEBAR_ICON_WIDTH} (56px) around 32px buttons, the margins+ // either side of every rail icon — plus the `gap-0.5` bands and the+ // wrapper above `CollapsedNavRail` — are unmarked container, and Tauri's+ // `drag.js` drags a bare region only on a direct hit, so all of that was+ // dead window chrome sitting directly under the traffic lights. `"deep"`+ // covers the subtree instead. Nothing in this column scrolls or selects,+ // and clickable elements short-circuit `isDragRegion` before the `deep`+ // branch, so the reopen trigger and every rail button still click.+ <div+ data-tauri-drag-region="deep"+ className="flex h-full min-h-0 flex-col items-center gap-0.5">{/* macOS overlay title bar (titleBarStyle: Overlay) floats the trafficlights over the top-left. The expanded SidebarHeader dodges them by- right-aligning, but this narrow rail can't — so reserve a draggable- strip the height of the window controls and start the rail below- it, clear of the lights. */}- <div className="h-7 w-full flex-none" data-tauri-drag-region />+ right-aligning, but this narrow rail can't — so reserve a strip the+ height of the window controls and start the rail below it, clear of+ the lights. It carries no drag region of its own: the column above+ already drags, and this only has to hold that height open. */}+ <div className="h-7 w-full flex-none" /><Tooltip label={t('layout.showSidebar')}>{/* The primitive's own trigger, so reopening goes through the samecontrolled `onOpenChange` `RootShellLayout` drives every otherdiff --git a/app/src/components/layout/shell/SidebarHeader.test.tsx b/app/src/components/layout/shell/SidebarHeader.test.tsxindex 4bdd9518c2..ca46f79d42 100644--- a/app/src/components/layout/shell/SidebarHeader.test.tsx+++ b/app/src/components/layout/shell/SidebarHeader.test.tsx@@ -78,6 +78,21 @@ describe('SidebarHeader', () => {expect(screen.queryByRole('button', { name: 'nav.feedback' })).not.toBeInTheDocument();});+ // The band is window chrome. `drag.js` drags a bare region only on a direct+ // hit (`el === composedPath[0]`), so with the icon row nested inside, the+ // row's own box did not drag; `"deep"` covers the subtree. Assert the value+ // and the nesting — presence alone passed before the fix.+ it('marks the header band as a deep drag region around the icon row', () => {+ const { container } = renderWithProviders(<SidebarHeader />, { initialEntries: ['/home'] });+ const region = container.querySelector('[data-tauri-drag-region]') as HTMLElement;+ expect(region.getAttribute('data-tauri-drag-region')).toBe('deep');+ // The icons sit inside the region and keep their clicks: `isDragRegion`+ // short-circuits on a clickable element before it reaches `deep`, and+ // resolving them by button role is what asserts they are still clickable.+ expect(region).toContainElement(screen.getByRole('button', { name: 'nav.settings' }));+ expect(region).toContainElement(screen.getByRole('button', { name: 'chat.hideSidebar' }));+ });+it('Collapse button calls hide()', () => {renderWithProviders(<SidebarHeader />, { initialEntries: ['/home'] });fireEvent.click(screen.getByRole('button', { name: 'chat.hideSidebar' }));diff --git a/app/src/components/layout/shell/SidebarHeader.tsx b/app/src/components/layout/shell/SidebarHeader.tsxindex 84cd04ac48..4f59620f77 100644--- a/app/src/components/layout/shell/SidebarHeader.tsx+++ b/app/src/components/layout/shell/SidebarHeader.tsx@@ -64,7 +64,19 @@ export default function SidebarHeader() {// `data-tauri-drag-region` lives directly on the primitive (rather than a// wrapping div in `AppSidebar`) so the header band is draggable window// chrome without an extra hand-rolled layout element.- <SidebarHeaderShell data-tauri-drag-region className="flex-row items-center justify-end gap-1">+ //+ // Its value is `"deep"`, not the bare attribute. Tauri's injected `drag.js`+ // reads a bare region (React renders the JSX shorthand as `="true"`) as+ // direct-hit-only — `return el === composedPath[0]` — so with the icon row+ // nested below, only this element's own uncovered box dragged and the+ // wrapper's box did not. `"deep"` makes the subtree draggable, which also+ // keeps any non-button content added to that row later draggable. The icons+ // are unaffected: `isDragRegion` bails out on a clickable element before it+ // reaches the `deep` branch, so every button here still clicks. Bare is only+ // correct on a band with no children — see `WindowDragBar`.+ <SidebarHeaderShell+ data-tauri-drag-region="deep"+ className="flex-row items-center justify-end gap-1"><div className="flex items-center gap-0.5">{/* Keyboard shortcuts — one-click open of the help directory (also ? / ⌘/). */}<Tooltip label={t('shortcuts.title')}>diff --git a/app/src/components/layout/shell/WindowDragBar.test.tsx b/app/src/components/layout/shell/WindowDragBar.test.tsxindex d2da4ee104..b2bf8f4b5f 100644--- a/app/src/components/layout/shell/WindowDragBar.test.tsx+++ b/app/src/components/layout/shell/WindowDragBar.test.tsx@@ -26,6 +26,21 @@ describe('WindowDragBar', () => {expect((bar as HTMLElement).className).toContain('absolute');});+ // Presence is what the assertions above cover, and presence is exactly what a+ // regression keeps: `drag.js` drags a bare region only on a direct hit+ // (`el === composedPath[0]`), so the attribute's *value* is the behaviour.+ // Bare is right for this band only because it has no children — assert both+ // halves, so giving it a child without switching to `"deep"` fails here+ // rather than silently killing the drag the way it did in the sidebar.+ it('marks the band bare, which is only correct because it has no children', () => {+ isMac.mockReturnValue(true);+ isTauri.mockReturnValue(true);+ const { container } = render(<WindowDragBar />);+ const bar = container.querySelector('[data-tauri-drag-region]') as HTMLElement;+ expect(bar.getAttribute('data-tauri-drag-region')).toBe('true');+ expect(bar.children).toHaveLength(0);+ });+it('renders nothing on macOS outside Tauri (plain browser)', () => {isMac.mockReturnValue(true);isTauri.mockReturnValue(false);diff --git a/app/src/components/layout/shell/WindowDragBar.tsx b/app/src/components/layout/shell/WindowDragBar.tsxindex 39c1b5e6f7..3d0b02c34a 100644--- a/app/src/components/layout/shell/WindowDragBar.tsx+++ b/app/src/components/layout/shell/WindowDragBar.tsx@@ -24,6 +24,12 @@ export const WINDOW_DRAG_BAR_HEIGHT = 28;* through; that's a platform limit, not this band. The sidebar is intentionally* excluded — its header already drags in place.*+ * The attribute is deliberately bare (React renders it as `="true"`). `drag.js`+ * reads that as direct-hit-only — `el === composedPath[0]` — which is exactly+ * right for a band with no children, since the pointer target always *is* this+ * element. Keep it childless: a container needs `="deep"` instead, or only its+ * own uncovered box drags. `SidebarHeader` and `AppSidebar` were that bug.+ ** macOS-only: Windows/Linux keep their native decorated title bar (the* `Overlay` style is a no-op there), so reserving a band would only waste* vertical space. Outside the Tauri runtime (browser/iOS) there is no window to