Skip to content

fix(dashboard): clamp every stored sidebar width to fit a narrow window - #16183

Closed
dodgeblaster wants to merge 1 commit into
mainfrom
fix/16094-sidebar-width-overhang
Closed

dodgeblaster wants to merge 1 commit into
mainfrom
fix/16094-sidebar-width-overhang

Conversation

@dodgeblaster

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A session-sidebar width saved on a wide window never overhangs a narrower one — the chat pane stays usable and the resize handle stays reachable.

On a window where (width − nav rail − chat-pane minimum) is under 1400px — a 1440px window with the rail expanded, for example — a stored sidebar width of up to 1400px painted exactly as stored. The sidebar then overhung: the chat pane dropped below its minimum and the handle on the sidebar's right edge sat at or past the window edge, so the user could not grab it to narrow the sidebar again.

Why it matters

A user who sets a wide sidebar on a big monitor and later opens the dashboard on a laptop is stuck with a sidebar they cannot shrink — the one control that would fix it is off-screen. Two adjacent preferences also behaved differently: a saved 2884 was already held gracefully, while a saved 1400 overhung, because the earlier hold skipped widths of 1400 or less.

Not a goal

  • Changing board-view geometry: the board's automatic widening and its own chat reserve are unchanged.
  • Re-validating the stored preference itself: a wide width is still remembered and painted in full the moment the window can seat it.

What changed (motivation → approach → change)

A stored width is validated only against the sidebar's own min/max, never the window, so a width from a wide window arrives verbatim on a narrow one. The paint-time clamp (clampSidebarWidth in website/src/pages/chat/sidebarWidth.ts) narrowed that width to the room beside the nav rail but reserved nothing for the chat pane — so the sidebar could take the whole width left over, pushing the chat below its minimum and the handle off the edge.

The clamp now keeps a chat-pane reserve clear beside the rail, applied to every stored width and floored at SIDEBAR_MIN; website/src/pages/ChatPage.tsx passes CHAT_PANE_MIN_W. On a window too narrow to seat both the reserve and the floor, the sidebar keeps its minimum and the chat pane yields the rest, rather than the sidebar collapsing below where it is usable.

The board view's automatic widening already reserves BOARD_CHAT_RESERVE (≥ CHAT_PANE_MIN_W), so a board-widened width already fits this clamp and is never cut — only a hand-dragged width wider than the window can spare is held.

Backwards compatibility

Compatible: the clamp affects only render geometry on a window too narrow for the stored width; the persisted preference is unchanged and is painted in full once the window can seat it. The default chatReserve is 0, so clampSidebarWidth's other callers (the board sidebar) keep their current behavior.

Tests

  • clampSidebarWidth.test.ts: with the chat reserve, a stored 1400 on a 1440px window is clamped to 884 — chat pane ≥ CHAT_PANE_MIN_W, handle inside the window — and a saved 1400 and a saved 2884 are now held identically; without a reserve the pre-existing board behavior is unchanged; the floor-at-SIDEBAR_MIN case is pinned.
  • boardSidebarWidth.test.ts: existing board geometry assertions are unchanged, plus a new check that every board auto-widened width survives the chat-pane clamp untouched, so the two never fight.

Manual verification

N/A — unit coverage sufficient. The change is a deterministic width calculation whose reproduce case (stored 1400, 1440px window, rail expanded) is asserted directly, including the two symptoms (chat pane below its minimum, handle past the window edge).

Screenshots / video

Why no screenshot: the only rendered change is at window sizes where a stored width would otherwise overhang; the sidebar then paints narrower by exactly the computed clamp (e.g. 1400 → 884 at a 1440px window) rather than past the window edge. No component, layout, theme, or copy changes, and a before/after could not be captured on the build host (no browser panel; the preview pod's token mint is blocked by the sandbox). The geometry is pinned by the unit tests above.

Related Issues

Closes #16094

Pattern harvest

Not generalizable: a one-off missing reserve term in a single viewport clamp; no broader class of call sites shares the shape.

Checklist

  • At most two commits (one here), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — N/A
  • No secrets, credentials, or internal references in the diff

@dodgeblaster
dodgeblaster requested a review from a team October 2, 2026 15:51
@dodgeblaster
dodgeblaster requested a review from a team as a code owner October 2, 2026 15:51
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 2, 2026
@dodgeblaster
dodgeblaster marked this pull request as draft October 2, 2026 15:54
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

The rescue drag has a dead zone: grabbing the now-reachable handle moves nothing for up to ~516px of travel before the sidebar responds.

Watch

  • Drag starts from the stored width, not the painted one: resize.ts onStart seeds sidebarStartW.current = sidebarWidthRef.current (1400) while the root paints paintWidth ?? sidebarWidth (884), so in the PR's own reproduce case (stored 1400, 1440px window) the first 516px of a narrowing drag — and ~30 arrow-key nudges — produce no visible change, and releasing early persists a value that changed nothing on screen. Hits exactly the users this fix targets, on every rescue drag, as perceived handle breakage. Fix: seed the drag start and the nudge base from the effective painted width (e.g. pass effectiveSidebarWidth into useSidebarResize and use Math.min(stored, painted)).
  • Same root cause, AT-facing: ResizeHandle gets value={sidebarWidth} (ChatSidebar.tsx:4440), so a screen reader hears 1400 while 884 is painted; pass the painted width as the slider value.

[UX-REVIEWED] e9e5e8b

Description read

[DESCRIPTION-READ] 8e30a3ee9b614abd2fa81bba7321e7407a16bc72e0aab9dba7e612ecb2121f12

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e9e5e8b

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Description documents an earlier design: no default chatReserve exists, the board is spared via a reserve-0 branch, and the paintWidth/board-lift machinery is unmentioned.

Watch

  • Stale description vs. shipped diff, one root cause in three places. (1) "## Backwards compatibility" says "The default chatReserve is 0, so clampSidebarWidth's other callers (the board sidebar) keep their current behavior" — the diff makes chatReserve "a REQUIRED operand, not an option with a default," and ChatPage.tsx:3302 is the only production caller; the claimed mechanism and caller don't exist. (2) "a board-widened width already fits this clamp and is never cut" is contradicted by the diff's own test ("it MUST NOT be cut to 1800-236-320 = 1244"): the board survives because of the boardActive ? 0 : CHAT_PANE_MIN_W branch, not because it fits. (3) The two new ChatSidebar props (paintWidth, onBoardActiveChange) — the load-bearing half of the fix, since the inner root previously painted the raw stored width — and the two new test files are absent from "What changed"/"Tests". A future reader (or a revert decision) will reason from the wrong design.
    Clears when: the "What changed", "Backwards compatibility", and "Tests" sections are rewritten against the shipped diff (required chatReserve, the boardActive reserve branch, the lifted board signal, paintWidth), with the frozen Goal/Why/Not-a-goal sections untouched.

[DESIGN-REVIEWED] e9e5e8b

Description read

[DESCRIPTION-READ] e221f71d89a107f798991d8794d484acda3452578d3ac60c218e4ecd83767505

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Description claims "the default chatReserve is 0" keeps other callers unchanged; the diff ships it required, with an undeclared lifted boardActive toggle and paintWidth prop instead.

Not justified as shipped

  • Item 4 — undeclared: the description's compat claim — "The default chatReserve is 0, so clampSidebarWidth's other callers (the board sidebar) keep their current behavior" — contradicts the diff, whose own comment says "a REQUIRED operand, not an option with a default"; grep clampSidebarWidth in website/src counts exactly 1 production call site (ChatPage.tsx:3302) and no board caller. The board is instead exempted by a lifted boardActive state the description never mentions, and "a board-widened width already fits this clamp and is never cut" is contradicted by the new test pinning that the reserve WOULD cut a hand-primed 1400 @ 1800 to 1244.
    Clears when: the ## What changed / ## Backwards compatibility sections describe the shipped mechanism — required chatReserve, the lifted onBoardActiveChange signal, and paintWidth.
  • Item 5 — undeclared: new public onBoardActiveChange prop, 1 consumer (ChatPage), never mentioned in the description.
  • Item 6 — undeclared: new public paintWidth prop; the sidebar root's painted-width source changed, attributed only to a code comment ("Session sidebar: a stored width up to 1400 px overhangs a narrow window #16094 review finding c").
  • Item 7 — undeclared: every future clampSidebarWidth caller must now pass chatReserve; the description asserts the opposite (a default).
  • Item 8 — rides along: board users get the list reserve for the first frame before columns load.

What this change ships

Inventory (8 items) — 3 justified

Intent: a sidebar width saved on a wide window must not overhang a narrower one — the chat pane stays usable and the resize handle grabbable. FIX (#16094, reproduce pinned by tests failing on base).

  1. A too-wide stored width now paints clamped in list/chat view; chat pane keeps its minimum, handle stays on-screen — justified
  2. A saved 1400 and a saved 2884 are now held identically on a narrow window — justified
  3. On a window too narrow for reserve + floor, the sidebar keeps its minimum and the chat pane yields — justified
  4. Board view is exempted from the new hold via a lifted board-lane signal — undeclared: description claims a 0 default does this
  5. New onBoardActiveChange prop on ChatSidebar — undeclared
  6. Inner sidebar paints the host-clamped width via new paintWidth prop, not the raw stored width — undeclared
  7. chatReserve is a required parameter for every future caller — undeclared, contradicts the description
  8. Board users see the list reserve for the first frame — rides along

[FIRST-PRINCIPLES-REVIEWED] e9e5e8b

Description read

[DESCRIPTION-READ] 7ba336133256d34150508727a485f9c87065078e68d09ea0c923230e6379c514

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@dodgeblaster
dodgeblaster force-pushed the fix/16094-sidebar-width-overhang branch from 71c9425 to c509d07 Compare October 2, 2026 15:59
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in website/src/pages/ChatPage.tsx (same-file) and website/src/pages/chat/ (same-dir) since this head went green (26ae742 -> 7f79ba2); CI re-running.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4 — this comment is updated in place on each push.

Review details

Nothing blocks; the new paintWidth is consumed only by the root's style, so the drag model and the header breakpoints still act on the unclamped stored width.

FINDING — website/src/pages/ChatSidebar.tsx:4428 — the root now paints paintWidth ?? sidebarWidth but useSidebarResize still seeds sidebarStartW.current = sidebarWidthRef.current and bounds onMove at SIDEBAR_MAX, so on a 1440px window (max painted 1440-236-320 = 884) dragging the grip right freezes the painted edge and the absolutely-positioned ResizeHandle at 884 while stored climbs to 1400 and onEnd persists it — the next drag (and nudgeSidebar) is then inert until the pointer travels 516px left → Fix: bound the drag and the nudge to the host's effective max instead of SIDEBAR_MAX (pass the clamped max down into useSidebarResize), which means editing the untouched src/pages/chat-sidebar/resize.ts, so it cannot land inside this diff.

FINDING — website/src/pages/ChatSidebar.tsx:4423 — compactHeader = sidebarWidth < 256 / tinyHeader = sidebarWidth < 200 and compact={sidebarWidth < 220} (6470, 6478) still read the unclamped preference, so at a non-mobile winW = 790 with rail 236 and a stored 1000 the root paints 234px while the header keeps its wide form (full "New chat" label + kebab squeezing the truncated "Sessions" title) — the collapse the comment at 4420 describes never fires anywhere in the reachable 212–255px painted range → Fix: derive const paintedW = paintWidth ?? sidebarWidth once and use it for those three breakpoints and ResizeHandle's value, keeping sidebarWidth as the persisted preference only.

[OPUS-REVIEWED] e9e5e8b

Verdict parsed from the review's SHA-scoped output markers for commit e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e9e5e8be59f6374b1fb06dbce92bfe0127b9ceb4: <one-sentence reason>

@dodgeblaster
dodgeblaster force-pushed the fix/16094-sidebar-width-overhang branch from c509d07 to fc88cd6 Compare October 2, 2026 16:16
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 2, 2026
…n list view

A stored session-sidebar width is validated only against SIDEBAR_MIN..SIDEBAR_MAX, so a width saved on a wide window is carried verbatim onto a narrow one. In list/chat view the sidebar reserved nothing for the chat pane, so a stored width up to SIDEBAR_MAX overhung: the chat pane dropped below CHAT_PANE_MIN_W and the resize handle landed at or past the window edge, out of reach.

clampSidebarWidth takes a required chatReserve. ChatPage passes CHAT_PANE_MIN_W in list view and 0 in board view, deciding which from ChatSidebar's own boardLaneActive (feature on AND columns exist, lifted up via onBoardActiveChange) so the clamp and the rendered lane never disagree and there is one source of truth. The clamped effectiveSidebarWidth is passed down to ChatSidebar as paintWidth, so the inner sidebar paints to the same edge as the OverlayDrawer instead of overflowing it with the raw stored width. The board column strip keeps its full width (reserve 0), preserving the geometry commit 9406a36 restored.

Closes #16094
@dodgeblaster
dodgeblaster force-pushed the fix/16094-sidebar-width-overhang branch from fc88cd6 to e9e5e8b Compare October 2, 2026 17:07
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Rebased onto fresh main and pushed the review repair: the chat-pane reserve is now gated on ChatSidebar's own boardLaneActive (lifted via onBoardActiveChange, one source of truth — no cold-query flash, feature-on-but-zero-columns correctly stays list), and the clamped width is passed down as paintWidth so the inner sidebar and the OverlayDrawer paint to the same edge. Board view keeps reserve 0. CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 5, 2026

Copy link
Copy Markdown
Contributor

Automated rebase attempt onto origin/main (cc7e79894e) stopped on conflicts, so nothing was pushed. The branch is unchanged at e9e5e8be59.

Conflicting files:

  • website/src/pages/chat/sidebarWidth.ts
  • website/src/pages/ChatSidebar.tsx
  • website/src/pages/ChatPage.tsx
  • website/src/test/clampSidebarWidth.test.ts

This is a semantic conflict, not a textual one. #14870 (7cb4aa3e84) has since merged and added parseStoredSidebarWidth, sidebarRoomWidth and sidebarPaintWidth:

  • At render, the sidebar root is now held to winW - railW - chatMin, on both sides of SIDEBAR_MAX.
  • clampSidebarWidth is now documented to reserve nothing for the chat pane, because ChatPage passes it the painted width.

This PR adds a required chatReserve operand to clampSidebarWidth instead. Combining the two approaches would subtract the chat minimum twice. Please decide which mechanism fixes #16094 on top of current main; much of this may already be covered by sidebarPaintWidth. Then rebase, or close if it is already covered.

@iamwhatever

Copy link
Copy Markdown
Contributor

Closing this draft as part of a stale-PR cleanup: it has had no activity for 14+ days. Nothing is lost: the branch stays, and you can reopen this PR anytime (or open a fresh one rebased on main). Thanks for the work here!

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 27, 2026
@bolichen97
bolichen97 deleted the fix/16094-sidebar-width-overhang branch November 6, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session sidebar: a stored width up to 1400 px overhangs a narrow window

3 participants