Repository navigation
Studio: make the sidebar width draggable - #7561
Conversation
|
@codex review |
The sidebar was locked at 17.5rem. Long chat titles truncated early with no way to trade content width for sidebar width. Adds a drag handle on the sidebar edge. Drag to resize between 264px and 480px (also capped at 40% of the window), click to collapse or expand, arrow keys to nudge, Home to restore the default. The width persists in localStorage next to the existing pin flag and syncs across tabs. Dragging in stops at the minimum rather than collapsing, so an overshoot while resizing cannot snap the sidebar shut. The minimum is set by the header: the logo lockup and the search and collapse buttons need ~258px. The wordmark now truncates instead of letting the search icon ride over the logo when the UI font scale pushes the lockup wider. Resizing relayouts the whole shell, so the live width is painted straight to the wrapper's custom property once per animation frame instead of on every pointermove, and only committed to the store on release.
9b44ced to
f363a63
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b44ced584
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (typeof window === "undefined") { | ||
| return () => listeners.delete(cb); | ||
| } | ||
| // Keep tabs in sync, same as the pin flag. | ||
| const onStorage = (e: StorageEvent) => { |
There was a problem hiding this comment.
Re-clamp the width when the viewport changes
On the desktop layout, the 40%-of-window cap is evaluated only when the module loads, a width is explicitly set, or a storage event arrives. If a user stores a 480px width and then narrows the browser or Tauri window, widthValue remains 480px, so the sidebar can exceed the promised viewport cap until another resize interaction or reload occurs. Subscribe to viewport resize changes and update the snapshot when the current width exceeds the new cap.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in fdd4e9d.
Rather than clamping the stored value on resize, which would have thrown away the preference the moment you narrowed the window, the store now keeps the preference whole and derives an effective width from it. Narrowing shrinks the sidebar, widening restores what you had.
Added unit tests covering the cap, including the case where 40% falls below the 264px floor and the floor has to win.
| wrapperRef.current?.style.setProperty( | ||
| "--sidebar-width", | ||
| `${pendingRef.current}px`, | ||
| ) |
There was a problem hiding this comment.
Restore the committed width when a drag is canceled
When the browser emits pointercancel after the handle has moved, endDrag leaves the live --sidebar-width DOM mutation in place (and even flushes a pending value) without updating widthValue. The sidebar therefore displays an unpersisted width, and the next drag starts from the stale stored width and jumps. On cancellation, restore ${width}px instead of retaining the pending drag value, or explicitly commit it if cancellation is intended to finish the resize.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in fdd4e9d, and it was worse than described.
The same gap hits a non-cancelled path: a drag on the collapsed rail that never reaches the minimum returns without committing, so the flushed pending value was the rail width. Because the provider does not re-render on drag state, React never rewrote the property, and the next expand could render the sidebar at 48px.
Drag end now always hands the property back to the committed value. A commit re-renders with the new width straight after, so the DOM and the store cannot drift.
There was a problem hiding this comment.
Correction to my earlier reply on this thread. I said the same gap also hit a collapsed-rail drag that never reaches the minimum, and that the next expand could render at 48px. I have since simulated the pre-fix commit under Playwright and that second case does not reproduce: the flush was conditional on a queued frame, and no frame is queued when the drag never paints. Only the cancellation you described was real.
That one does reproduce cleanly. Against f363a63 the cancelled drag leaves the DOM at 370px while the store holds 280px. After the fix both agree. Sorry for overstating it.
| { | ||
| "--sidebar-width": SIDEBAR_WIDTH, | ||
| // The drag handle writes this same property live while resizing. | ||
| "--sidebar-width": `${width}px`, | ||
| "--sidebar-width-icon": SIDEBAR_WIDTH_ICON, |
There was a problem hiding this comment.
Propagate the resized width to the custom titlebar
In the Windows/Linux Tauri layout, this updates --sidebar-width only on the nested sidebar wrapper, while WindowTitlebar still positions its sidebar section, content border, and window-drag region from the fixed --studio-sidebar-expanded-width value in window-titlebar.tsx:113-118. After resizing away from 280px, the titlebar seam no longer aligns with the sidebar and, when widening it, the window-drag hit area begins over the sidebar's top section. The live width must also drive the custom titlebar geometry.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in fdd4e9d.
WindowTitlebar renders as a sibling of the content under the chrome div, so it is outside the sidebar wrapper and genuinely cannot inherit --sidebar-width. It reads the width from the same store now.
One limitation worth stating: the store only updates on release, so during a drag the seam trails the sidebar and settles when you let go. Live tracking would mean a React render per pointer move, which is what the frame-coalesced painting exists to avoid. Correct at rest on every platform, and this path only renders on the Windows and Linux custom titlebar.
| className={cn( | ||
| "absolute inset-y-0 -right-1 z-30 hidden w-2 touch-none select-none sm:block", | ||
| // `!` overrides the app-wide hand cursor on buttons. | ||
| open ? "cursor-col-resize!" : "cursor-e-resize!", |
There was a problem hiding this comment.
Place the resize handle on the configured sidebar edge
When the reusable Sidebar is rendered with its supported side="right" option, the handle is still placed at -right-1, which is the viewport-facing outer edge rather than the content-facing left edge. The drag calculation also always adds a rightward pointer delta, so widening a right sidebar would require the opposite motion. Pass side into the handle and mirror both its placement and delta calculation; otherwise resizing is unusable or inverted for this valid configuration.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fair point on the primitive, fixed in fdd4e9d. Placement, cursor, tooltip side and the pointer delta now all follow the configured side, and the start width is measured from the sidebar container so it is side-agnostic.
For context, nothing renders side="right" today. AppSidebar is the only Sidebar in the app and it takes the default. So this is correctness for the shared primitive rather than a live bug, and the mirrored path is reasoned rather than exercised.
Four fixes from the review: Re-clamp on viewport change. The 40% window cap was only evaluated on load and on an explicit set, so a stored 480px stayed 480px after the window narrowed. The store now keeps the preference whole and derives an effective width from it, recomputed on resize, so narrowing shrinks the sidebar and widening restores the preference instead of discarding it. Keep the DOM and the store in step when a drag does not commit. On pointercancel, and on a collapsed-rail drag that never reached the minimum, the live width was left painted on the wrapper without being stored. Since the provider does not re-render, React never rewrote the property and the next expand could render at the rail's 48px. Drag end now hands the property back to the committed value; a commit re-renders with the new width. Feed the resized width to the custom titlebar. WindowTitlebar sits outside the sidebar wrapper so it cannot inherit --sidebar-width, and it was positioning its seam and drag region from a fixed 17.5rem. It reads the same store now. Mirror the handle for side="right". Placement, cursor, tooltip side and the pointer delta all follow the configured side. Measuring the rail from the sidebar container makes the start width side-agnostic too. Adds unit tests for the clamp, including the viewport cap and the floor winning when 40% falls below it.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdd4e9d131
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const { width } = useSidebarWidth(); | ||
| const sidebarWidth = showSidebarSurface | ||
| ? pinned | ||
| ? "var(--studio-sidebar-expanded-width,17.5rem)" | ||
| ? `${width}px` |
There was a problem hiding this comment.
Keep the custom titlebar aligned during live resizing
On Windows/Linux Tauri builds with showSidebarSurface enabled, this width changes only when the external store is updated, but SidebarResizeHandle paints each drag frame directly to the sidebar wrapper and does not call setWidth until pointer-up. Consequently, throughout a drag the sidebar and content move while the titlebar’s sidebar surface, rounded corner, border, and drag-region boundary remain at the previous width, visibly splitting the custom chrome from the sidebar. The transient drag width needs to reach the titlebar as well, rather than relying solely on the committed store value.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in ee9f653. The drag now mirrors the live width onto the root as --studio-sidebar-live-width and the titlebar reads that, falling back to the committed width, so the seam tracks per frame instead of jumping on release. Cleared on pointer-up and on cancel.
Verified under Playwright that the property is published while dragging, tracks the sidebar to within a pixel, and is removed afterwards. The custom titlebar itself only renders on Windows and Linux Tauri, which I cannot exercise from macOS, so that part is the mechanism verified rather than the chrome.
| const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => { | ||
| if (event.key === "ArrowLeft" || event.key === "ArrowRight") { | ||
| if (!open) return |
There was a problem hiding this comment.
Handle keyboard activation on the resize control
For keyboard users who focus this separator, Enter and Space cannot perform the collapse/expand action advertised by its accessible label: that action exists only in handlePointerUp, while this handler recognizes only arrows and Home. The button's synthesized click is consumed by TooltipTrigger rather than calling toggleSidebar, and when the sidebar is collapsed the arrow paths also return immediately, so the focused handle cannot expand it without knowing the separate global shortcut. Handle Enter/Space or route the action through an actual click handler.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in ee9f653. Enter and Space now toggle, and the outward arrow reopens a collapsed rail instead of returning early, so a focused handle is no longer a dead end.
Reproduced the old behaviour first to be sure: against the pre-fix commit, Enter on the focused handle leaves the width at 280 and ArrowRight on a collapsed rail leaves it at 48. Both pass after the fix, in all three engines.
| aria-valuenow={open ? width : SIDEBAR_WIDTH_MIN} | ||
| aria-valuemin={SIDEBAR_WIDTH_MIN} | ||
| aria-valuemax={SIDEBAR_WIDTH_MAX} |
There was a problem hiding this comment.
Report the viewport-capped maximum to assistive technology
On desktop windows narrower than 1200px, the real maximum is below 480px because clampSidebarWidth caps it at 40% of the viewport, but the separator always announces 480 as its maximum. For example, at an 800px window the sidebar stops changing at 320px while a screen reader reports that another 160px of adjustment is available, making repeated ArrowRight input appear broken. Expose the effective viewport-dependent maximum here instead of the absolute storage limit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in ee9f653. The store now derives the effective maximum alongside the effective width and recomputes both on resize, so the separator announces what is actually reachable.
Verified at an 800px window: previously aria-valuemax stayed 480 while the sidebar stopped at 320, now it reports 320 and returns to 480 when the window widens.
Three more from review, and the handle is extracted so the run settings panel can reuse it. Keyboard activation. The handle advertises collapse and expand in its label, but that only ran from pointer-up, and a button's synthesized click is swallowed by the tooltip trigger. Enter and Space now toggle, and the outward arrow reopens a collapsed rail rather than returning early, so a focused handle is not a dead end. Announced maximum. aria-valuemax was the absolute 480 even when the 40% viewport cap put the real limit lower, so a screen reader offered adjustment that could not happen. The store now exposes the effective maximum and recomputes it on resize. Titlebar during a drag. The custom titlebar reads the committed store value, so its seam sat still while the sidebar moved. The drag now mirrors the live width onto the root for it to read, and clears it on release. The drag mechanics move to PanelResizeHandle and the store to a createPanelWidthStore factory. Behaviour is unchanged; both exist so the run settings panel gets the same edge without a second copy.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee9f653c27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // A drag below the minimum leaves the stored width alone. | ||
| if (!open) return | ||
| // Commit the last requested width; a frame may still be queued. | ||
| setWidth(pendingRef.current) |
There was a problem hiding this comment.
Preserve the preferred width after a capped drag
When a saved width exceeds the current viewport cap, an outward drag cannot visibly enlarge the panel because clamp leaves pendingRef.current at the effective maximum, but this unconditional commit overwrites the larger stored preference with that capped value. For example, save 480px, narrow the window until the effective width is 320px, drag outward, and release: widening the window later now leaves the sidebar at 320px instead of restoring 480px, defeating the store's preference-preservation behavior. Skip the commit when a capped drag made no effective change, or preserve the underlying stored value in this case.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in a87b7e5. I reproduced it first under Playwright to be sure of the mechanism: store 480, narrow to a 900px window so the effective width is 360, drag outward, release. The stored value went 480 to 360, and re-widening left it at 360.
The commit now records what the pointer asked for rather than what was painted. setWidth still clamps to the absolute range, so a deliberate inward drag on a narrow window is honoured exactly as before; only the capped case stops writing back a smaller preference than the user chose.
Same trace after the fix: stored stays 480 across the capped drag and re-widening restores 480. Added two regression tests, one for the capped outward drag and one asserting an inward drag while capped is still committed, so the fix cannot silently swallow real shrink intent.
Dragging outward while the 40% cap is active committed the capped value, so a 480px preference became 320px on a narrow window and never came back when the window widened again. The drag now commits what the pointer asked for rather than what was painted. setWidth still clamps to the absolute range, so a deliberate inward drag is honoured as before; only the capped case stops writing a smaller preference than the user chose.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a87b7e5148
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function subscribe(cb: () => void) { | ||
| listeners.add(cb); |
There was a problem hiding this comment.
Recompute the width when a subscriber mounts
When all consumers are unmounted, no resize listener remains and the cached effectiveWidth and effectiveMax stop tracking the viewport. On web or native macOS, resizing while /login, /onboarding, or /change-password hides SidebarProvider and then returning to the app restores the stale width indefinitely, potentially bypassing the 40% cap until another resize occurs. Recompute from the current viewport when subscribing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 41ff1dd. With no subscribers there is no resize listener, so the cache goes stale, and the auth routes do hide the provider entirely. The store recomputes when a subscriber attaches now.
Reproduced first: widen to 480, unmount, narrow the window to 800, remount. It came back at 480, past the 320 cap. After the fix it comes back at 320.
| // Commit what was asked for, not the capped paint, so a drag on a narrow | ||
| // window cannot shrink a larger stored preference. setWidth clamps. | ||
| setWidth(rawRef.current) |
There was a problem hiding this comment.
Preserve the stored width on capped outward resizes
When a stored preference exceeds the viewport cap, rawRef starts from the effective width rather than the stored preference. For example, with 480px stored in an 800px viewport, the rendered width is 320px; dragging outward to 330px remains visually capped at 320px but release writes 330px, permanently discarding the 480px preference. The outward-arrow path has the same effective-width behavior, so capped outward attempts should retain the hidden stored value.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and it survived the earlier fix in a87b7e5. That one stopped committing the painted value, but rawRef still starts from the effective width, so the preference leaks away more slowly rather than being preserved. Fixed in 41ff1dd: the commit and the outward arrow leave the stored value alone when the panel is already pinned at the cap.
Your example reproduces exactly. Store 480, narrow so the effective width is 360, nudge outward: the store went to 380 and re-widening stopped there. It now stays 480 and re-widening restores 480. I also added a test asserting an inward drag while capped is still committed, so the guard cannot swallow a real shrink.
| "after:absolute after:inset-y-0 after:w-px after:bg-transparent after:transition-colors after:duration-150", | ||
| edge === "left" ? "after:left-1" : "after:right-1", | ||
| "hover:after:bg-sidebar-ring/25 data-dragging:after:bg-sidebar-ring/25", |
There was a problem hiding this comment.
Add a visible keyboard focus state to the resize handle
Keyboard users can tab to this otherwise transparent button, but its visual states cover only hover and dragging. The global button:focus rule in index.css removes the browser outline, and the controlled tooltip opens only when hovered, so keyboard focus on the handle is completely invisible. Add a focus-visible line or ring and expose the hint on focus.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in 41ff1dd. index.css zeroes the native outline on every button, and the tooltip was hover-only, so a tabbed handle was completely invisible. It now paints its line on focus-visible and opens the hint on focus.
Verified by diffing the computed ::after background before and after focusing: unchanged before the fix, visible after.
| data-dragging={dragging || undefined} | ||
| aria-label={open ? label : toggleLabel} | ||
| aria-orientation="vertical" | ||
| aria-valuenow={open ? width : min} |
There was a problem hiding this comment.
Report the collapsed separator state accurately
When the sidebar is collapsed, this reports min (264px) as the current value even though the rendered rail is 48px and the next expanded width may be a different stored value such as 480px. Screen readers therefore announce a width that describes neither the current nor restored state; condition the range attributes on open or expose an accurate collapsed value and range.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in 41ff1dd. It reported 264 while the rail renders at 48 and may restore to something else again. The range attributes are dropped when collapsed, so the label describes the control instead of a number that matches nothing. Verified aria-valuenow is absent while collapsed and returns on expand.
| {open ? "Click to collapse" : "Click to expand"} | ||
| {hint ? ` ${hint}` : ""} | ||
| </span> | ||
| <span className="opacity-70">Drag to resize</span> |
There was a problem hiding this comment.
Localize the new resize-handle copy
In every non-English locale, the newly visible tooltip remains English because both messages are hardcoded inside this shared component; the caller also supplies English-only accessible labels even though localized sidebar open/close strings already exist. Route these strings through the translation layer or accept translated tooltip text as props so the new control follows the selected language.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in 41ff1dd. The tooltip is visible copy, so English in ten other locales is a real regression rather than the usual sr-only strings this file already hardcodes.
The strings are props now, supplied through the translation layer by each caller, with shell.resize.* and the aria labels added across all eleven locales. Parity passes. Worth a native speaker glancing at the non-English strings before merge; I wrote them and they are short UI phrases, but I would rather flag that than imply they were reviewed.
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Five more from review. Stale width after a resize with nothing mounted. With no subscribers there is no resize listener, so a resize on /login or /onboarding left the cached width and cap stale, and returning to the app restored the old width past the viewport cap. The store now recomputes when a subscriber attaches. Capped outward drags no longer lower the stored preference. The drag starts from the effective width, so with 480 stored in a capped window a small outward pull committed a smaller number and discarded the preference for good. The commit and the outward arrow now leave it alone when the panel is already pinned at the cap. A deliberate inward drag still commits. Keyboard focus was invisible. The app zeroes the native outline on buttons, so a tabbed handle showed nothing at all. It now paints its line on focus-visible and opens the hint. Collapsed aria. The separator reported 264 as its current value while the rail renders at 48 and may restore to something else entirely. The range attributes are dropped when collapsed, leaving the label to describe it. Localised copy. The tooltip is visible text and was hardcoded English in all eleven locales. The strings are props now, supplied through the translation layer, with keys added across every locale.
|
Correction on my earlier replies in this PR. I cited 41ff1dd as containing the keyboard, aria, focus, capped-preference and localisation fixes, but that commit went onto the stacked run-settings branch by mistake, so this PR did not actually have any of them. The replies were describing code that was not here. Now cherry-picked as b5b9fd8, which is this branch head. Verified standalone: typecheck, unit tests, locale parity and build all pass, and the sidebar suite is 144/144 across Chromium, Firefox and WebKit with the run-settings harness removed so nothing from the stacked branch leaks in. One thing worth naming: the locale block in that commit also adds resizeRunSettings and openRunSettings, which nothing in this PR uses. They are consumed by #7566 stacked directly on top. I kept the i18n addition atomic rather than splitting one block across two PRs, but happy to strip them if you would rather this PR carried only keys it uses. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5b9fd8815
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| onPointerDown={handlePointerDown} | ||
| onPointerMove={handlePointerMove} | ||
| onPointerUp={handlePointerUp} | ||
| onPointerCancel={endDrag} | ||
| onKeyDown={handleKeyDown} |
There was a problem hiding this comment.
Handle synthesized clicks on the resize control
When switch control, voice control, or other assistive technology activates this element by dispatching a click without preceding pointer or keyboard events, the sidebar does not toggle: all panel behavior is wired to pointer-up or keydown, while TooltipTrigger supplies an onClick that only manages the tooltip. Handle the click activation path as well, while avoiding a duplicate toggle after ordinary pointer activation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed. Everything was wired to pointer-up and keydown, so a dispatched click reached nothing but the tooltip trigger. There is a click path now, armed only after a sequence that actually started so an ordinary mouse release does not toggle twice.
Two things the suite caught on the way, both worth naming. Arming on release alone meant a cancelled drag still collapsed the panel on the following click. Then arming inside endDrag unconditionally broke the very case being fixed, since endDrag doubles as the effect cleanup, so a bare click with no preceding drag was swallowed.
| aria-label={open ? label : toggleLabel} | ||
| aria-orientation="vertical" | ||
| {...(open | ||
| ? { "aria-valuenow": width, "aria-valuemin": min, "aria-valuemax": max } | ||
| : {})} | ||
| role="separator" |
There was a problem hiding this comment.
Use button semantics while the panel is collapsed
When the sidebar is collapsed, this remains focusable but is exposed as a separator without aria-valuenow; a focusable separator is an adjustable range widget and requires a current value, so assistive technology receives an invalid range control rather than an actionable “Open sidebar” button. Switch to button semantics while closed, or otherwise provide a valid range representation that matches the collapsed state.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed, and it is fallout from the earlier fix in this PR. Dropping the range attributes while collapsed left a focusable separator with no current value, which is an invalid adjustable widget rather than a neutral one. It reports as a button when closed and a separator with a value when open.
Two more from review. Switch and voice control activate a control by dispatching a bare click with no pointer or key events. Everything here hung off pointer-up or keydown, so those users could not toggle the panel at all. There is now a click path, guarded so the click the browser sends after a real pointer release does not toggle a second time. The guard is set when any sequence ends, not only on release: a cancelled drag also ends without a toggle, and its click would otherwise collapse the panel. The suite caught that on the first attempt. A focusable separator is an adjustable widget and needs a current value. Dropping the range attributes while collapsed left an invalid range control, so it reports as a button when closed and a separator with a value when open.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa8a655f24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // handles it for the mouse; a synthesized click never reaches it. | ||
| if (event.key === "Enter" || event.key === " ") { | ||
| event.preventDefault() | ||
| handledRef.current = true |
There was a problem hiding this comment.
Clear click suppression after keyboard toggles
For Enter or Space, preventDefault() cancels the button's native synthesized click, so this assignment leaves handledRef set after onToggle() completes. If the user next activates the control through switch or voice input—which dispatches the bare click handled below—that activation is mistaken for a duplicate and ignored, requiring a second attempt. Only arm the guard for sequences that will actually emit a follow-up click, or clear it after the keyboard toggle.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and a good catch on my own fix from an hour ago. preventDefault does cancel the native synthesized click, so there was nothing following to guard against and the flag stayed armed, making the next switch or voice activation look like a duplicate.
The keyboard path no longer arms it at all. Added a regression test that presses Enter and then dispatches a bare click, asserting the panel reopens rather than staying collapsed. 258 assertions passing across Chromium, Firefox and WebKit.
endDrag doubles as the effect cleanup, so setting the guard there unconditionally swallowed the first click from switch or voice control when no drag had happened. It now only arms after a sequence that actually started, whether it ended in a release or a cancel.
preventDefault cancels the native synthesized click, so nothing followed to guard against and the flag stayed set. The next switch or voice activation was then read as a duplicate and ignored.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dff3473093
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| paintWidth(clamp(next)) | ||
| onToggle() |
There was a problem hiding this comment.
Preserve the live width when reopening during a drag
When dragging outward from a collapsed sidebar whose stored width is larger than min, paintWidth(clamp(next)) queues the pointer-aligned width, but onToggle() immediately rerenders SidebarProvider with the stored --sidebar-width value. The edge and custom titlebar therefore jump—potentially from 264px to 480px—until the animation-frame paint runs, and a quick release can leave the sidebar expanded at the old stored width. Reopen using the live dragged width, or prevent the toggle render from overwriting it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I tried to reproduce this and it does not happen. Both halves of the sequence hold up:
The paint is not late relative to the toggle. onToggle() schedules a React update from a pointermove, which flushes in a microtask, while the queued requestAnimationFrame callback runs after microtasks and before the browser's style and paint step. So the painted live width is the last write of the frame and the stored value never reaches the screen.
The release does not commit the old width either. By the time pointerup fires, the re-render has already happened, so the handler sees open as true and falls through to setWidth(rawRef.current), which is the dragged value, not the stored one.
Added a test that seeds a stored width of 480, collapses, drags the rail out by 250px and samples the rendered width while the button is still held:
pg.mouse.move(x + 250, y, steps=14) # rail 48 + 250 = ~298, past min
mid = width(pg) # still held down
pg.mouse.up()
Mid-drag measures ~298 and the committed width is ~298, on Chromium 149, Firefox 151 and WebKit 26.5. A snap to the stored width would read 480, which is 182px outside the 25px tolerance.
The test also asserts the seed applied (stored == "480") before dragging, since with the default 280 the tolerance would have let a snap pass unnoticed. Suite is 273/273.
Happy to look again if you have a specific sequence in mind that I have not covered.
| const endDrag = React.useCallback(() => { | ||
| // Only a sequence that actually started should suppress the click the | ||
| // browser sends next, whether it ended in a release or a cancel. This also | ||
| // runs as the effect cleanup, where no drag happened and a bare click from | ||
| // assistive tech must still get through. | ||
| if (dragRef.current) handledRef.current = true |
There was a problem hiding this comment.
Clear the click guard after pointer cancellation
When a drag ends through pointercancel—for example after an OS-level pointer interruption—no click is generated afterward, but endDrag still leaves handledRef armed. The next switch/voice-control activation that dispatches only a click is consequently swallowed by the onClick guard. Arm the guard only on the pointer-up path where a compatibility click can follow, or explicitly clear it after cancellation.
Useful? React with 👍 / 👎.
A canceled drag emits no compatibility click, so the boolean guard stayed armed and swallowed the next click from a switch or voice control. Record when the pointer sequence ended instead and ignore only a click that lands inside the browser's compatibility window.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0938f4501
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export const SIDEBAR_WIDTH_MAX = 480; | ||
|
|
||
| const store = createPanelWidthStore({ | ||
| key: "sidebar_width", |
There was a problem hiding this comment.
Include the sidebar width in preference resets
The new persisted sidebar_width key is not included in PREFS_KEYS in features/settings/tabs/general-tab.tsx. Consequently, choosing “Reset all local preferences” reloads the page but immediately restores the previously saved sidebar width instead of the 280px default, violating the reset action’s user-visible contract. Add this key to the reset list alongside sidebar_pinned.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct. resetAllPrefs walks PREFS_KEYS calling localStorage.removeItem and then reloads, so any key not on the list survives the reset. sidebar_pinned was there but sidebar_width was not, so the reload restored the old width instead of the 280px default.
Added it next to sidebar_pinned in 4007557, and chat_settings_width on the stacked branch for the run settings panel.
Also added a unit test so the next persisted panel width cannot miss the list. It reads the PREFS_KEYS block out of general-tab.tsx and asserts each width key appears:
for (const key of PANEL_WIDTH_KEYS) {
assert.ok(keys.includes(`"${key}"`), `${key} missing from PREFS_KEYS`);
}Confirmed it is not vacuous: removing the entry again gives sidebar_width missing from PREFS_KEYS and 14 pass / 1 fail, and restoring it gives 15 pass / 0 fail. typecheck, i18n:check and build all clean.
Reset all local preferences dropped every other UI key but left sidebar_width, so the reload restored the old width instead of the default.
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The search and collapse buttons carried 8px of padding each side of a 16px icon, so the pair read as one wide block. Narrow them to 28px and close the gap to 1px, which brings the glyphs from 18px apart to 13px. That frees room in the header lockup, so the drag floor drops from 264px to 260px. 260 is the narrowest width that leaves the wordmark unclipped in Firefox, which renders it ~3px wider than Chromium and WebKit.
|
Pushed 5f58e80, which tightens the header actions and lowers the drag floor. The search and collapse buttons were 32px wide around a 16px icon, so each carried 8px of internal padding and the pair read as one wide block. They are now 28px with the gap closed to 1px, taking the glyphs from 18px apart to 13px. The collapsed rail toggle stays at 32px since it sits alone with nothing to crowd. That freed room in the lockup, so the floor drops from 264px to 260px. I measured it this time instead of deriving it from the CSS. Sweeping the header from 236px to 286px and comparing
So 260px is the narrowest value that holds in all three, and the earlier 264px had a little more slack than it needed. I also strengthened the header test while I was in there. It only checked that the brand and action boxes do not overlap, which Suite is 276/276 across Chromium 149, Firefox 151 and WebKit 26.5. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The sidebar has been locked at 17.5rem since it landed. Long chat titles truncate early and there is no way to trade content width for sidebar width, so this adds a drag handle on the sidebar edge.
What you get
localStoragenext to the existingsidebar_pinnedflag and syncs across tabs, so it survives reloads.Dragging inward stops at the minimum instead of collapsing. Collapsing stays a deliberate click or Cmd+B, so an overshoot while resizing cannot snap the sidebar shut.
Why 260px
The header sets the floor. The padding, logo mark, wordmark, beta badge and the two action buttons have to fit, and below that the search icon starts riding over the logo. The lockup now truncates the wordmark rather than overlapping, so a larger UI font scale degrades cleanly instead of colliding.
The floor is measured rather than derived. Sweeping the header from 236px to 286px in 2px steps and checking
scrollWidthagainstclientWidthon the wordmark puts the clip-free point at 256px in Chromium and WebKit, but 260px in Firefox, which renders the heading about 3px wider. 260px is the narrowest value that is clean in all three.While measuring this I also tightened the header actions. The search and collapse buttons were 32px wide around a 16px icon, so 8px of padding each side made the pair read as one wide block. They are now 28px with a 1px gap, which brings the glyphs from 18px apart to 13px and is what freed the 4px at the bottom of the range. The collapsed rail toggle stays at 32px, since it sits alone and should match the other rail icons.
Performance
A live resize relayouts the whole shell, including the chat list and the composer's autosize measurement, and
pointermovefires well above the display refresh rate. The in-progress width is painted straight to the wrapper's--sidebar-widthcustom property once per animation frame, and only committed to the store on release, so there is no React render per pointer move and the work stays bounded by the refresh rate. Pointer events on the shell are dropped for the duration of the drag.Notes
!, since two app-wide rules give every button the hand cursor, and holds it through the drag as the pointer travels over buttons and text.Testing
npm run typecheck,npm run test,npm run i18n:checkandnpm run buildpass.Behaviour is covered by a Playwright suite driving a harness that imports the real sources, run against Chromium 149, Firefox 151 and WebKit 26.5. 276 checks pass on all three. It covers the drag maths and clamping, collapse and expand by click and by keyboard, persistence and cross-tab sync, corrupt and unavailable
localStorage, viewport reclamping, pointer cancellation, unmount mid-drag, and the header lockup at the floor.The header check asserts the wordmark is not clipped, not just that the boxes fail to overlap.
truncatemakes a literal overlap nearly impossible, so the weaker assertion passed regardless of the constant. Dropping the floor back to 256px fails it with[firefox] clip: 3.Still worth a manual pass at a non-default UI font scale and in both themes, since the sweep above was run at the default scale.