Diff viewer: responsive toolbar that never overlaps at small widths
What
At very small diff-panel widths, the toolbar controls overlapped/overlaid the accessory icon buttons and looked broken (reported with a screenshot). This makes the toolbar degrade gracefully via the priority+ overflow pattern: low-priority controls collapse into the existing ⋯ options menu as width shrinks, and nothing ever overlaps.
Root cause
#toolbar was a rigid grid minmax(0,1.1fr) minmax(124px,0.9fr) auto with a non-shrinking toolbar-actions. At small widths the middle 124px floor + the fixed actions column starved the left cell, whose contents overflowed (grid cells don't clip) and overlaid the accessory icons.
How
- No-overlap guarantee: all toolbar grid tracks are
minmax(0,…)and the cells useoverflow-x: clip(withoverflow-y: visibleso the base picker / options popovers still drop below the bar);toolbar-actionscan shrink. Overlap is now structurally impossible regardless of measurement. - Measured priority overflow: a
ResizeObserveron#toolbardrives a pure resolver (toolbar-overflow.ts, unit-tested) that keeps the highest-priority controls and drops the rest as a clean priority suffix into the always-present⋯menu. Drop order (lowest first): external link → layout toggle → files toggle → repo select. The Base picker (primary, with its own internal shedding) and the⋯button are always visible. The options menu always lists the layout + external actions so anything dropped from the bar stays reachable.
At the reported extreme width the bar cleanly shows roughly [source] [Base… ▾] [⋯], accessories in the menu, no overlap.
Verification
- New pure-resolver unit tests (8 cases: all-fit, single drop, priority-suffix, repo-dropped-last, extreme narrow, zero-width repo, non-finite budget, empty). 164 webviews tests pass; typecheck/lint/build green.
- Visually verified at an extreme-narrow panel: controls truncate/collapse into
⋯, no overlap (vs the prior overlapping layout).
Note
This branch is stacked on https://github.com/manaflow-ai/cmux/pull/6484 (the branch picker), so the diff currently includes those commits. Once #6484 merges, I'll rebase this onto main so it shows only the toolbar change.
🤖 Generated with Claude Code
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.
Summary by cubic
Make the diff viewer toolbar responsive with priority+ overflow so controls never overlap at small widths. Only accessory icons collapse into ⋯; the repo selector and Base picker stay usable at any width.
-
New Features
- Priority+ toolbar overflow: only accessory icons overflow into
⋯as width shrinks (drop order: external → layout → files). The repo select is always shown and truncates; Base and⋯are always visible. Measured withResizeObserverand a pureresolveToolbarOverflowresolver; overflowed actions remain in the options menu. - Searchable Base picker: grouped refs with fuzzy filter, keyboard nav, and raw‑ref escape; shows head → base with reason and +ahead/−behind; regenerates the diff on pick. Works under HTTP and restored
cmux-diff-viewer://pages.
- Priority+ toolbar overflow: only accessory icons overflow into
-
Bug Fixes
- No overlap at any width: toolbar tracks use
minmax(0, …)and cellsoverflow-x: clip(popovers still escape). Per‑file diff headers pin the diffstat and clip the header so counts never overlap the status icon. - Base picker popover no longer clips: now viewport‑anchored (
position: fixed), portaled todocument.body, clamped to the viewport, and flips above when space is tight. Outside‑click handling respects the portaled popover.
- No overlap at any width: toolbar tracks use
Summary by CodeRabbit
Release Notes
- New Features
- Toolbar actions now adapt to available space by prioritizing what stays visible and moving lower-priority controls into the options menu; external and layout actions are shown contextually.
- Bug Fixes
- Improved narrow-layout rendering by tightening toolbar column shrink behavior and preventing horizontal spill/overlap in toolbar and diff headers.
- Updated picker/popover to be viewport-anchored and portal-rendered for correct initial placement above diff content.
- Tests
- Added unit coverage for the toolbar overflow decision logic, including edge cases.