Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: report actual sidebar resize bounds (#4158)
Adam Eivy9b359e1d706b
diff --git a/client/src/components/writers-room/WorkEditor.jsx b/client/src/components/writers-room/WorkEditor.jsxindex 2cbc483505..85ae2c428f 100644--- a/client/src/components/writers-room/WorkEditor.jsx+++ b/client/src/components/writers-room/WorkEditor.jsx@@ -701,6 +701,7 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseOconst {containerRef: splitRef,width: sidebarWidth,+ maxWidth: sidebarMaxWidth,onMouseDown: onSplitMouseDown,reset: resetSidebarWidth,} = useSidebarResize({@@ -709,12 +710,6 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseOminWidth: SIDEBAR_MIN,maxFraction: SIDEBAR_MAX_FRACTION,});- const sidebarMaxWidth = Math.max(- SIDEBAR_MIN + 1,- Math.round(sidebarWidth),- Math.round((splitRef.current?.getBoundingClientRect().width ?? SIDEBAR_DEFAULT / SIDEBAR_MAX_FRACTION) * SIDEBAR_MAX_FRACTION),- );-const toggleReadingTheme = useCallback(() => {setReadingTheme((prev) => {const next = prev === 'dark' ? 'light' : 'dark';@@ -957,7 +952,7 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseOaria-label="Resize storyboard sidebar"aria-orientation="vertical"aria-valuemin={SIDEBAR_MIN}- aria-valuemax={sidebarMaxWidth}+ aria-valuemax={Math.round(sidebarMaxWidth)}aria-valuenow={Math.round(sidebarWidth)}title="Drag to resize · double-click to reset"className="hidden lg:block w-1 shrink-0 cursor-col-resize bg-port-border hover:bg-port-accent/60 active:bg-port-accent transition-colors"diff --git a/client/src/components/writers-room/WorkEditor.test.jsx b/client/src/components/writers-room/WorkEditor.test.jsxindex f21d109fa4..cfe0bc29a9 100644--- a/client/src/components/writers-room/WorkEditor.test.jsx+++ b/client/src/components/writers-room/WorkEditor.test.jsx@@ -141,12 +141,26 @@ describe('WorkEditor header layout (#3568)', () => {});it('exposes the storyboard resizer as a bounded separator', async () => {- await renderEditor();- const separator = screen.getByRole('separator', { name: 'Resize storyboard sidebar' });-- expect(separator).toHaveAttribute('aria-orientation', 'vertical');- expect(Number(separator.getAttribute('aria-valuemin'))).toBeLessThanOrEqual(Number(separator.getAttribute('aria-valuenow')));- expect(Number(separator.getAttribute('aria-valuenow'))).toBeLessThanOrEqual(Number(separator.getAttribute('aria-valuemax')));+ class ResizeObserverStub {+ constructor(callback) { this.callback = callback; }+ observe() { this.callback(); }+ disconnect() {}+ }+ const rect = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({ width: 1000 });+ vi.stubGlobal('ResizeObserver', ResizeObserverStub);++ try {+ await renderEditor();+ const separator = screen.getByRole('separator', { name: 'Resize storyboard sidebar' });++ expect(separator).toHaveAttribute('aria-orientation', 'vertical');+ expect(separator).toHaveAttribute('aria-valuemax', '600');+ expect(Number(separator.getAttribute('aria-valuemin'))).toBeLessThanOrEqual(Number(separator.getAttribute('aria-valuenow')));+ expect(Number(separator.getAttribute('aria-valuenow'))).toBeLessThanOrEqual(Number(separator.getAttribute('aria-valuemax')));+ } finally {+ rect.mockRestore();+ vi.unstubAllGlobals();+ }});it('gives the header controls a 44px touch target on mobile', async () => {diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex f1f1d262ef..808251ed7a 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -117,7 +117,7 @@ grep -i "what you want to do" client/src/hooks/README.md| `usePersistedOptions` | Registry for "saved default + per-run override" form options: one spec row per option (`{ defaultValue, read, clamp, persistOnEdit }`) owns the state, per-field dirty flag, hydrate-if-untouched pass and edited-only override collection. Returns `{ values, edit, hydrate, collectOverrides, inputProps }`, all identity-stable and ref-backed so a caller's `useCallback` needs one dep instead of one per option. | Any panel where each option must load a saved default, persist edits, and send ONLY edited fields as per-run overrides (AutopilotPanel) — use this instead of hand-copying the state/editedRef/hydrate/collect scaffold per option. || `usePopoverPosition` | Viewport-clamped `{ left, top, width }` for a fixed-position portal popover anchored to a trigger; re-measures on open and rAF-coalesced on capture-phase scroll/resize. Returns `{ triggerRef, popoverRef, style, reposition }`; pass `anchorRef` to follow a parent-owned trigger. | Any portal-into-`<body>` menu/popover placed relative to a button (ThemeSwitcher, CollectionPickerShell) — use this instead of re-rolling the measure/flip/clamp/reflow plumbing. || `useScrollLock` | Body-scroll lock with ref-count. | Modals, drawers, lightboxes. |-| `useSidebarResize` | Drag-to-resize split-pane width persisted to `localStorage`; returns `{ containerRef, width, onMouseDown, reset }` and caps the drag at `maxFraction` of the measured container. | A desktop sidebar/split pane with a draggable divider (WorkEditor's storyboard sidebar). |+| `useSidebarResize` | Drag-to-resize split-pane width persisted to `localStorage`; returns `{ containerRef, width, maxWidth, onMouseDown, reset }` and caps the drag at `maxFraction` of the measured container. | A desktop sidebar/split pane with a draggable divider (WorkEditor's storyboard sidebar). || `useSwipeNav` | Horizontal swipe prev/next. | Mobile swipe between siblings. || `useTokenPopover` | Hover/click/pin state machine for an anchored token popover (200ms open, 150ms grace close) plus the `hotRef` cross-link highlight; returns `{ pop, hotRef, onTokenEnter/Leave/Click, onPopoverEnter/Leave, closePopover }`. | Prose (or any) tokens that open a detail popover on hover and pin on click (WorkEditor ↔ ProseTokenPopover). || `useUnsavedChangesGuard` | `useUnsavedChangesGuard(isDirty, { beforeUnload, scopePath })` → `{ blocked, proceed, reset }` — parks router navigation (sidebar link, ⌘K, voice nav, browser Back) behind react-router's `useBlocker` while a draft is dirty, and arms `beforeunload` for tab close/reload. Auto-proceeds once the draft goes clean. `scopePath` is the path prefix the editor owns, exempting its own pathname-changing in-page moves (a splat route's tab switch). Requires the data router in `main.jsx`; tests must mount `createMemoryRouter` + `<RouterProvider>`. | Any editor holding an unsaved draft (SongBookViewer, PipelineManuscriptEditor, writers-room WorkEditor) — render the confirm with `<UnsavedChangesConfirm guard={…} when={!saving}>`, never `window.confirm`. |diff --git a/client/src/hooks/useSidebarResize.js b/client/src/hooks/useSidebarResize.jsindex 85c859fb39..fba05c8992 100644--- a/client/src/hooks/useSidebarResize.js+++ b/client/src/hooks/useSidebarResize.js@@ -26,6 +26,7 @@ export default function useSidebarResize({const n = raw ? parseInt(raw, 10) : NaN;return Number.isFinite(n) && n >= minWidth ? n : defaultWidth;});+ const [maxWidth, setMaxWidth] = useState(() => Math.max(minWidth + 1, width));const containerRef = useRef(null);const widthRef = useRef(width);@@ -40,10 +41,34 @@ export default function useSidebarResize({safeWriteStorage(configRef.current.storageKey, String(Math.round(next)));}, []);+ const updateBounds = useCallback(() => {+ const containerWidth = containerRef.current?.getBoundingClientRect().width ?? 0;+ if (!containerWidth) return;+ const max = Math.max(minWidth + 1, containerWidth * maxFraction);+ setMaxWidth(max);+ setWidth((prev) => Math.min(max, Math.max(minWidth, prev)));+ }, [maxFraction, minWidth]);++ useEffect(() => {+ if (typeof ResizeObserver === 'undefined' || !containerRef.current) return undefined;+ const observer = new ResizeObserver(updateBounds);+ observer.observe(containerRef.current);+ updateBounds();+ return () => observer.disconnect();+ }, [updateBounds]);+const onMouseDown = useCallback((e) => {e.preventDefault();const containerWidth = containerRef.current?.getBoundingClientRect().width ?? 0;- dragStartRef.current = { startX: e.clientX, startWidth: widthRef.current, containerWidth };+ const { minWidth: min, maxFraction: frac } = configRef.current;+ const max = Math.max(min + 1, containerWidth * frac);+ const startWidth = Math.min(max, Math.max(min, widthRef.current));+ setMaxWidth(max);+ if (startWidth !== widthRef.current) {+ widthRef.current = startWidth;+ setWidth(startWidth);+ }+ dragStartRef.current = { startX: e.clientX, startWidth, containerWidth };document.body.style.cursor = 'col-resize';document.body.style.userSelect = 'none';}, []);@@ -83,5 +108,5 @@ export default function useSidebarResize({persist(defaultWidth);}, [defaultWidth, persist]);- return { containerRef, width, onMouseDown, reset };+ return { containerRef, width, maxWidth, onMouseDown, reset };}