Repository navigation
Commit 6a73185
feat(app-shell): the left sidebar resizes by its edge and floats as a card; a menu opened from the float keeps it out (#36655)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8Q1S7wY1gUVUGBELhQFqBHt)_
Fixes #36227
Fixes #36471
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:电脑上左侧栏钉住时,拖右边缘可以调宽(200 到
350),双击回到默认宽度,刷新后宽度还在;侧栏收起后从屏幕最左边浮出来时,变成四周留边、圆角、带阴影的卡片,宽度和钉住时一样;从浮出的侧栏点应用名,菜单完整显示,侧栏不再缩回去把菜单切掉。
- 为什么做:外壳专题里「左侧栏照 Attio 改」这一张,加上验收时发现的应用菜单被切掉的缺陷。
- 出错会怎样:最坏是侧栏宽度或浮出样式不对、浮出的侧栏收回时机不对,菜单和页面内容都不受影响;可以直接撤回本次合并。
- 要你做什么:无。
## What changes
**Resize (#36227)** —
`ui/packages/app-shell/src/layout/SidebarWidthHandle.tsx` (new),
`UnifiedSidebar.tsx`, `consoleSidebarRail.ts`
- From 768 px up, the docked sidebar's right edge is a
`role="separator"` handle: a pointer drag resizes it between 200 and 350
px (Attio's range, the card's numbers), a double-click comes back to 256
(unchanged default), ← → move it 16 px, Home / End go to either end.
- The width is a per-browser reader preference, `console.sidebar.width`
(`CONSOLE_SIDEBAR_WIDTH_PREFERENCE`, stored `{"width":N,"v":1}`, read
back clamped to the range). Kept on drag end, not mid-drag.
- The width reaches the primitive by setting `--sidebar-width` on the
console's `display: contents` frame around the sidebar, so the in-flow
gap, the docked panel and the float all take it. While a drag runs the
frame turns off the primitive's width transition so the panel follows
the pointer. The phone drawer is untouched (it sets its own width), and
so is `@object-ui/components`.
- The float has no handle: the card asks for a resizable docked sidebar
only.
**The float is a card (#36227 items 2–4)** — `RAIL_OVERLAY_PANEL`,
`RAIL_HIDDEN_PANEL` in `consoleSidebarRail.ts`
- Floating over the collapsed sidebar, the panel is a card 8 px off the
window's left, top and bottom edges, with `rounded-lg`, a border and
`shadow-xl`. Nothing dims or moves the page under it (no backdrop, the
gap stays at 0).
- Hidden, the panel keeps the card's shape and is parked its width plus
2 rem past the edge, so the shadow does not show at the window edge and
the card does not change shape while it slides.
- Item 3 (rest on the left edge floats it, moving off it folds it, a
press on the expand button docks it) was already on `main` (#35062 /
#36112). Unchanged except as below.
**A menu opened from the float keeps it out (#36471)** —
`useConsoleSidebarRailPanel`
- Root cause, reproduced in a browser on this branch's base: the pointer
moves onto the app name while the float is still sliding in, so for a
moment it is past the panel's edge. That starts the 150 ms "pointer
away" clock. The press on the app name opens the menu, but the clock was
never stopped: it fires and folds the float, and the menu stays anchored
to a trigger now off-screen (the card's second screenshot). The timer
only checked "is a menu open" on later pointer moves, never when it
fired.
- Fix: a press in the float (the app name, the account, an entry's `…`,
an entry) stops the clock; and when the clock fires it folds only if no
menu or dialog is open and the pointer is not on the float. "On the
float" includes the 8 px margin the card now keeps from the window edge,
where the pointer that floated it rests.
- After the menu closes (Esc, or a choice), the float folds by the usual
rules: a move away, a navigation, a press outside.
- Card item 2 (the account menu, the notification panel, an entry's
`…`): the same press path, so the same fix. The account menu and an
entry's `…` were checked in the browser (screenshots 6 and 7).
**i18n** — `sidebar.resize` ("Resize sidebar", the handle's accessible
name) in all 11 locales.
## Screenshots (1440 × 900, local showcase app, this branch)
| | |
|:--|:--|
| Docked, default 256 | Dragged to the widest, 350 |
| 
| 
|
| Collapsed, floated from the left edge: a card (kept width 321) |
**Before**: app name pressed while the float slid in, the float folded
and the menu is cut off (same race, base code) |
| 
|

|
| **After**: the same race, the menu is whole and the float stays | The
account menu from the float |
|

|

|
| An entry's `…` menu from the float | Side preview open, sidebar
dragged wider: the preview keeps its place and width (left 972, width
460 before and after) |
| 
|

|
## Tests
- `UnifiedSidebar.hiddenCollapse-35062.test.tsx` (the shared harness,
two new top-level `describe`s, 10 tests):
- #36227: drag clamps at 350 and 200, the frame turns its transition off
mid-drag and keeps nothing until the drag ends, the width is kept and a
reload reads it; double-click returns 256; End / ArrowRight / ArrowLeft
/ Home; an out-of-range kept width reads as the nearest end; the handle
unmounting mid-drag (⌘B, then a narrow window) ends the drag as a
cancel, restoring the body's `user-select` / `cursor` and the width;
collapsed there is no handle, the float takes the kept width with the
card classes and the hidden panel the parked card; a phone sets no
width.
- #36471: the app name pressed while the fold's clock runs opens the
menu and the float stays past 3× the delay; a menu opened from the float
by the keyboard (no press) holds it too; a press in the float stops the
clock and a later move away folds it; once the menu closes, moving away
folds it.
- Run at `eb24661e2` (from `ui/`, `pnpm exec vitest run
packages/app-shell/src/layout/__tests__/`): **Test Files 155 passed
(155), Tests 1276 passed (1276)**. `tsc --noEmit` of
`@object-ui/app-shell`: exit 0; eslint on the changed files: clean. At
`eebb75006` the 30 `dispatch-gates --commands` families ran locally, all
exit 0.
- Ablation (one-off, `scripts/ablation-replace.mjs`, restored to the
HEAD blob each time): removing both halves of the #36471 fix turns the
three press/keyboard tests red; removing only the press half turns "a
press in the float stops the fold's clock" red; removing only the
fire-time check turns the keyboard test red. Each half is pinned by its
own test. Dropping the handle's unmount cleanup turns the mid-drag test
red.
- `consoleSidebarRail.width-27593.test.tsx`: comment only (the 256 it
pins is now the default, not a fixed width).
## Acceptance notes
- The sidebar's background is the theme's translucent `bg-sidebar` with
a backdrop blur (pre-existing). Over page content the card shows a
blurred hint of what is under it near its edge (visible in screenshot
3). Attio's card is opaque; not changed here.
- On a touch screen nothing new: the float still opens by the expand
button or a press on the edge, the handle takes a drag.
- The card's "what width folds automatically" stays out of scope, as the
card says.
## Verification
Read first, by risk: `consoleSidebarRail.ts` (the fold timer and
`pointerOnFloat`), `UnifiedSidebar.tsx` (the frame's `--sidebar-width`),
`SidebarWidthHandle.tsx`.
Two-minute check: at 1440 wide, drag the sidebar's right edge right,
then double-click it; collapse with the sidebar's button, rest the mouse
on the window's left edge, and as the card slides in click the app name:
the app menu shows whole and the sidebar stays until you press Esc and
move away.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbWjfzbfpWXFKqr1sFF)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbWjfzbfpWXFKqr1sFF -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 9348f02 commit 6a73185
17 files changed
Lines changed: 463 additions & 10 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/layout
- __tests__
- i18n/src/locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
89 | 98 | | |
90 | 99 | | |
91 | 100 | | |
| |||
214 | 223 | | |
215 | 224 | | |
216 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
217 | 236 | | |
218 | 237 | | |
219 | 238 | | |
| |||
743 | 762 | | |
744 | 763 | | |
745 | 764 | | |
746 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
747 | 770 | | |
748 | 771 | | |
749 | 772 | | |
| |||
952 | 975 | | |
953 | 976 | | |
954 | 977 | | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
955 | 981 | | |
956 | 982 | | |
957 | 983 | | |
| |||
0 commit comments