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(sidebar): clamp the sidebar to half the window on a narrow viewport\n\nThe sidebar width was clamped against SIDEBAR_MIN_WIDTH (188) and\nSIDEBAR_MAX_WIDTH (420) and never against the window, so a narrow window left it\nowning most of the screen: 224px of a 414px viewport, 54%, with a hard 188px\nfloor below that. tauri.conf.json declares the main window `resizable: true`\nwith no `minWidth`, so that state is reachable by dragging.\n\nFixed with `max-w-[50vw]` on the sidebar column rather than a JS clamp, for a\nreason worth recording: the width arrives as an inline style, and `max-width`\nalways constrains `width`, so the browser applies this continuously with no\nlistener, no re-render and no extra state.\n\nA JS clamp would have needed BOTH halves — the arithmetic and something that\nre-renders on resize — because `clamp()` in RootShellLayout only runs at render\nand nothing in the shell listens for `resize`: no handler, no matchMedia, no\nuseMediaQuery anywhere in components/layout/shell or components/ui/Sidebar.tsx.\nThat is measured, not assumed: injecting a viewport clamp into `clamp()` during\nthe earlier investigation changed the rendered width not at all.\n\nInert on desktop by construction. 50vw exceeds SIDEBAR_MAX_WIDTH above an 840px\nwindow, so at the 1280x900 default the clamp can never bind and the stored width\ndecides exactly as before. The collapsed icon column is far below it.\n\nKnown wart, deliberately accepted: dragging past 50vw on a narrow window stores\na width larger than the one rendered, so widening the window later reveals the\nstored value. That preserves the user's preference rather than silently\nrewriting it, and clamping the stored value instead would need the resize\nlistener this change exists to avoid.\n\nTests: app-shell-responsive.spec.ts had a characterization test asserting the\nOPPOSITE — `width > 414 / 2` — written with a note that adding a viewport clamp\nshould be the thing that makes it fail. This is that flip, and it now asserts\nthe clamp holds. A second test asserts the clamp is inert at 1280px, so it\ncannot become a quieter second way to shrink the sidebar on a normal window.\n\nNOT EXECUTED. Local builds and test runs are prohibited in this phase, so this\nis reasoned from source: Sidebar.tsx:47-49 (constants), :232 (inline width),\nRootShellLayout.tsx:37-38 (clamp), tauri.conf.json (no minWidth). Prettier\nclean, tsc reports no errors in the touched files. CI is the check.\n\n## Related\n\nCloses #5907\n
M3gA-Mind81f1755ca2b0
diff --git a/app/src/components/ui/Sidebar.tsx b/app/src/components/ui/Sidebar.tsxindex eae4bb9451..85ec9ede1a 100644--- a/app/src/components/ui/Sidebar.tsx+++ b/app/src/components/ui/Sidebar.tsx@@ -226,6 +226,24 @@ export const Sidebar = forwardRef<HTMLDivElement, SidebarProps>(data-collapsible={collapsible}className={cn('flex h-full min-h-0 min-w-0 flex-none flex-col overflow-hidden text-content',+ // Viewport clamp (#5907). The stored width is clamped against+ // SIDEBAR_MIN_WIDTH/SIDEBAR_MAX_WIDTH only, never against the window,+ // so a narrow window left the sidebar owning most of it — 224px of a+ // 414px viewport, 54%, with a hard 188px floor below that.+ //+ // `max-w-[50vw]` rather than a resize listener, deliberately. The+ // width arrives as an inline style, and `max-width` always constrains+ // `width`, so the browser applies this continuously with no listener,+ // no re-render and no extra state. A JS clamp would need both halves:+ // the arithmetic AND something that re-renders on resize, because+ // `clamp()` in RootShellLayout only runs at render and nothing in the+ // shell listens for `resize` — measured, by injecting a viewport clamp+ // there and observing no change at all.+ //+ // Inert on desktop: 50vw exceeds SIDEBAR_MAX_WIDTH (420) above an+ // 840px window, so this can only engage on a genuinely narrow one.+ // The collapsed icon column is far below it and unaffected.+ 'max-w-[50vw]',className)}style={{ width: collapsed ? SIDEBAR_ICON_WIDTH : width, ...(style ?? {}) }}diff --git a/app/test/playwright/specs/app-shell-responsive.spec.ts b/app/test/playwright/specs/app-shell-responsive.spec.tsindex a338fd0e80..14ab2374c6 100644--- a/app/test/playwright/specs/app-shell-responsive.spec.ts+++ b/app/test/playwright/specs/app-shell-responsive.spec.ts@@ -71,23 +71,22 @@ test.describe('App shell — narrow viewports', () => {});}- test('PINS CURRENT BEHAVIOUR: the sidebar width has no viewport-relative clamp', async ({- page,- }) => {- // Measured, not assumed. `clampWidth` (`RootShellLayout.tsx:38`) clamps the- // sidebar against the constants `SIDEBAR_MIN_WIDTH = 188` and- // `SIDEBAR_MAX_WIDTH = 420` (`components/ui/Sidebar.tsx:48-49`) and never- // against `window.innerWidth`. So the sidebar keeps its full width however- // narrow the window gets, and takes a majority of the screen below ~450px.+ test('the sidebar never takes more than half a narrow window (#5907)', async ({ page }) => {+ // This test used to pin the OPPOSITE — it asserted `width > 414 / 2`, as a+ // deliberate characterization of the defect, with a note saying that adding+ // a viewport clamp should be the thing that makes it fail. #5907 added the+ // clamp, so this is that flip.//- // Whether that matters is a product call, and `tauri.conf.json` does not- // settle it: the window is `resizable: true` with NO `minWidth`, so a user- // can drag below 414px and the 188px floor then owns half the app.+ // Before: `clamp()` (`RootShellLayout.tsx:38`) constrained the width against+ // SIDEBAR_MIN_WIDTH = 188 and SIDEBAR_MAX_WIDTH = 420 and never against the+ // window, so the sidebar measured 224px of a 414px viewport — 54% — with a+ // hard 188px floor below that. `tauri.conf.json` declares the main window+ // `resizable: true` with no `minWidth`, so that was reachable by dragging.//- // I originally wrote this as `expect(width).toBeLessThan(414 / 2)` — an- // invariant the product never promised. It failed at 224px. Pinning the- // real behaviour instead, so that adding a viewport clamp is a deliberate- // change that updates this test rather than a silent one. See W5 BUG-10.+ // After: `max-w-[50vw]` on the sidebar column (`components/ui/Sidebar.tsx`).+ // A CSS max-width rather than a JS clamp, because the width arrives as an+ // inline style and nothing in the shell listens for `resize` — a JS clamp+ // alone changes nothing at all until some unrelated render happens.await page.setViewportSize({ width: 414, height: 896 });await expect.poll(() => page.evaluate(() => window.innerWidth)).toBe(414);@@ -97,11 +96,25 @@ test.describe('App shell — narrow viewports', () => {const box = await sidebar(page).boundingBox();if (box === null || box.width === 0) return; // collapsed away entirely- // The floor is absolute: never below SIDEBAR_MIN_WIDTH, whatever the window.+ // 1px of slack for sub-pixel rounding on a fractional device pixel ratio.+ expect(box.width).toBeLessThanOrEqual(414 / 2 + 1);+ });++ test('the clamp is inert at desktop widths (#5907)', async ({ page }) => {+ // The clamp must not become a second, quieter way to shrink the sidebar on+ // a normal window. 50vw exceeds SIDEBAR_MAX_WIDTH (420) above an 840px+ // viewport, so at the 1280x900 default it can never bind — the stored width+ // decides, exactly as before.+ await page.setViewportSize({ width: 1280, height: 900 });+ await expect.poll(() => page.evaluate(() => window.innerWidth)).toBe(1280);++ const box = await sidebar(page).boundingBox();+ if (box === null || box.width === 0) return;++ // Well clear of the 640px the clamp would allow here, and at or above the+ // 188px floor — i.e. the clamp is not what is deciding this width.expect(box.width).toBeGreaterThanOrEqual(188);- // And it currently exceeds half the window at this size. If this ever- // stops being true, the clamp changed — update the test with the reason.- expect(box.width).toBeGreaterThan(414 / 2);+ expect(box.width).toBeLessThan(640);});test('resizing back to full width restores the layout', async ({ page }) => {