Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(sidebar): publish the effective maximum to every resize consumer

M3gA-Mind7b295cad23c8
diff --git a/app/src/components/ui/Sidebar.tsx b/app/src/components/ui/Sidebar.tsx
index 92619a1fa0..cf3a3d43fa 100644
--- a/app/src/components/ui/Sidebar.tsx
+++ b/app/src/components/ui/Sidebar.tsx
@@ -202,11 +202,15 @@ export const SidebarProvider = forwardRef<HTMLDivElement, SidebarProviderProps>(
const setWidth = useCallback(
(next: number) => {
- const clamped = clampWidth(Math.round(next), minWidth, maxWidth);
+ // `effectiveMax`, not `maxWidth`: a drag in a narrow window must not be
+ // able to STORE a width the column can never render. Clamping here
+ // against the raw maximum would put the stored value and the rendered
+ // one back into disagreement — the same defect one layer up.
+ const clamped = clampWidth(Math.round(next), minWidth, effectiveMax);
if (widthProp === undefined) setUncontrolledWidth(clamped);
onWidthChange?.(clamped);
},
- [widthProp, onWidthChange, minWidth, maxWidth]
+ [widthProp, onWidthChange, minWidth, effectiveMax]
);
useEffect(() => {
@@ -230,9 +234,13 @@ export const SidebarProvider = forwardRef<HTMLDivElement, SidebarProviderProps>(
width,
setWidth,
minWidth,
- maxWidth,
+ // The ACTIVE maximum, so every consumer agrees on the ceiling as well
+ // as on the current value. `SidebarRail` publishes this as
+ // `aria-valuemax`; exposing the raw 420 here announced a ceiling the
+ // column could not reach in a narrow window.
+ maxWidth: effectiveMax,
}),
- [open, setOpen, toggleSidebar, width, setWidth, minWidth, maxWidth]
+ [open, setOpen, toggleSidebar, width, setWidth, minWidth, effectiveMax]
);
return (
diff --git a/app/src/components/ui/Sidebar.viewport-clamp.test.tsx b/app/src/components/ui/Sidebar.viewport-clamp.test.tsx
index 9375dbf409..7ee6c5c932 100644
--- a/app/src/components/ui/Sidebar.viewport-clamp.test.tsx
+++ b/app/src/components/ui/Sidebar.viewport-clamp.test.tsx
@@ -74,6 +74,16 @@ describe('Sidebar viewport clamp', () => {
expect(screen.getByTestId('rail')).toHaveAttribute('aria-valuenow', '207');
});
+ it('announces the reachable ceiling, not the configured one', () => {
+ // The same class of defect as the `aria-valuenow` one, one level up: the
+ // context published the raw 420 as the maximum, so the separator advertised
+ // a ceiling the column cannot reach at this viewport (#5941, CodeRabbit).
+ setViewport(414);
+ renderSidebar(420);
+
+ expect(screen.getByTestId('rail')).toHaveAttribute('aria-valuemax', '207');
+ });
+
it('never goes below the minimum, however narrow the window', () => {
// Below 2 * minWidth a fraction stops being meaningful; the floor wins so
// the two clamps cannot disagree.