Skip to content

Commit 6a73185

Browse files
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 | | ![docked 256](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/1-docked-256.jpg?raw=true) | ![dragged 350](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/2-dragged-350.jpg?raw=true) | | 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) | | ![float card](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/3-float-card.jpg?raw=true) | ![before](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/4-before-app-menu-clipped.jpg?raw=true) | | **After**: the same race, the menu is whole and the float stays | The account menu from the float | | ![after](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/5-after-app-menu-from-float.jpg?raw=true) | ![account](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/6-avatar-menu-from-float.jpg?raw=true) | | 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) | | ![item menu](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/7-item-menu-from-float.jpg?raw=true) | ![preview](https://github.com/objectstack-ai/objectstack/blob/4f5a0a89c9ea040826ec4b9c946a24246f720a4f/pr-assets/36227/8-preview-unaffected.jpg?raw=true) | ## 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
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): the left sidebar resizes by its right edge, the collapsed sidebar floats as a card, and a menu opened from the float no longer leaves it folded with the menu cut off
7+
8+
Clause-②: yes (widening) — one new `@object-ui/i18n` key (`sidebar.resize`) in all 11 locales; no spec, schema, server or published export change
9+
Metadata-protocol: none
10+
11+
- **Resize** (`@object-ui/app-shell`): from 768 px up, the docked sidebar's right edge drags it between 200 and 350 px; a double-click comes back to 256; ← → move it 16 px, Home and End to either end. The width is kept in this browser (`console.sidebar.width`) and the menu floating over a collapsed sidebar takes it too. A phone's drawer keeps its own width.
12+
- **The float is a card:** 8 px off the window's left, top and bottom edges, with rounded corners, a border and a shadow; the page under it is not dimmed or moved. Resting the pointer at the window's left edge still floats it and moving away still folds it.
13+
- **A menu opened from the float keeps it out:** pressing the app name (or the account, or an entry's `…`) while the float was still sliding in under the pointer opened the menu and folded the float a moment later, leaving the menu cut off at the window's left edge. A press in the float now stops the fold's clock, and the fold does not happen while a menu or dialog is open, or while the pointer is on the float.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* SidebarWidthHandle — the docked console sidebar's right edge, which resizes
5+
* it (objectstack#36227, as Attio): dragged with the pointer between
6+
* {@link CONSOLE_SIDEBAR_MIN_WIDTH} and {@link CONSOLE_SIDEBAR_MAX_WIDTH}, or
7+
* moved with ← → (Home / End to either end). A double-click comes back to
8+
* {@link CONSOLE_EXPANDED_SIDEBAR_WIDTH}. `onPreview` follows a drag;
9+
* `onCommit` keeps the width once it ends. The same shape as the record page's
10+
* details-column handle (`RecordPageColumns` in `@object-ui/plugin-detail`).
11+
*/
12+
13+
import * as React from 'react';
14+
import { useObjectTranslation } from '@object-ui/i18n';
15+
import {
16+
CONSOLE_EXPANDED_SIDEBAR_WIDTH,
17+
CONSOLE_SIDEBAR_MAX_WIDTH,
18+
CONSOLE_SIDEBAR_MIN_WIDTH,
19+
clampConsoleSidebarWidth,
20+
} from './consoleSidebarRail.js';
21+
22+
/** How far one arrow-key press moves the sidebar's edge, in CSS pixels. */
23+
export const SIDEBAR_WIDTH_KEY_STEP = 16;
24+
25+
export interface SidebarWidthHandleProps {
26+
/** The width the sidebar has now, a drag's included. */
27+
width: number;
28+
/** A drag in progress: its width, or `null` once it ends. */
29+
onPreview: (width: number | null) => void;
30+
/** Keep this width. */
31+
onCommit: (width: number) => void;
32+
}
33+
34+
export function SidebarWidthHandle({ width, onPreview, onCommit }: SidebarWidthHandleProps) {
35+
const { t } = useObjectTranslation();
36+
const drag = React.useRef<{ x: number; width: number; last: number } | null>(null);
37+
38+
const end = (commit: boolean) => {
39+
const start = drag.current;
40+
drag.current = null;
41+
document.body.style.removeProperty('cursor');
42+
document.body.style.removeProperty('user-select');
43+
onPreview(null);
44+
if (commit && start && start.last !== start.width) onCommit(start.last);
45+
};
46+
47+
// The handle can go away mid-drag: ⌘/Ctrl+B folds the sidebar, or the window
48+
// narrows past 768 px, while the edge is still held. The drag then ends as a
49+
// cancel: the page is selectable again and the sidebar goes back to the
50+
// width it had when the drag began, the way a pointer-cancel ends it.
51+
const previewRef = React.useRef(onPreview);
52+
React.useEffect(() => {
53+
previewRef.current = onPreview;
54+
});
55+
React.useEffect(
56+
() => () => {
57+
if (!drag.current) return;
58+
drag.current = null;
59+
document.body.style.removeProperty('cursor');
60+
document.body.style.removeProperty('user-select');
61+
previewRef.current(null);
62+
},
63+
[],
64+
);
65+
66+
return (
67+
<div
68+
role="separator"
69+
aria-orientation="vertical"
70+
aria-label={t('sidebar.resize', { defaultValue: 'Resize sidebar' })}
71+
aria-valuenow={width}
72+
aria-valuemin={CONSOLE_SIDEBAR_MIN_WIDTH}
73+
aria-valuemax={CONSOLE_SIDEBAR_MAX_WIDTH}
74+
tabIndex={0}
75+
data-testid="console-sidebar-resize"
76+
className="group/resize absolute inset-y-0 -right-1 z-20 flex w-2 cursor-col-resize touch-none justify-center focus-visible:outline-none"
77+
onPointerDown={(event) => {
78+
if (event.button !== 0) return;
79+
event.preventDefault();
80+
event.currentTarget.setPointerCapture?.(event.pointerId);
81+
drag.current = { x: event.clientX, width, last: width };
82+
document.body.style.setProperty('cursor', 'col-resize');
83+
document.body.style.setProperty('user-select', 'none');
84+
}}
85+
onPointerMove={(event) => {
86+
const start = drag.current;
87+
if (!start) return;
88+
start.last = clampConsoleSidebarWidth(start.width + event.clientX - start.x);
89+
onPreview(start.last);
90+
}}
91+
onPointerUp={(event) => {
92+
event.currentTarget.releasePointerCapture?.(event.pointerId);
93+
end(true);
94+
}}
95+
onPointerCancel={() => end(false)}
96+
onDoubleClick={() => {
97+
end(false);
98+
onCommit(CONSOLE_EXPANDED_SIDEBAR_WIDTH);
99+
}}
100+
onKeyDown={(event) => {
101+
const next =
102+
event.key === 'ArrowLeft' ? width - SIDEBAR_WIDTH_KEY_STEP
103+
: event.key === 'ArrowRight' ? width + SIDEBAR_WIDTH_KEY_STEP
104+
: event.key === 'Home' ? CONSOLE_SIDEBAR_MIN_WIDTH
105+
: event.key === 'End' ? CONSOLE_SIDEBAR_MAX_WIDTH
106+
: null;
107+
if (next === null) return;
108+
event.preventDefault();
109+
const clamped = clampConsoleSidebarWidth(next);
110+
if (clamped !== width) onCommit(clamped);
111+
}}
112+
>
113+
<span
114+
aria-hidden="true"
115+
className="h-full w-0.5 bg-transparent transition-colors group-hover/resize:bg-sidebar-border group-active/resize:bg-primary/60 group-focus-visible/resize:bg-ring"
116+
/>
117+
</div>
118+
);
119+
}

‎ui/packages/app-shell/src/layout/UnifiedSidebar.tsx‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ import { InboxBell } from './InboxBell.js';
8585
import { AccountMenu } from './AccountMenu.js';
8686
import { useCommandPalette, useCommandPaletteProviderMounted } from '../context/CommandPaletteProvider.js';
8787
import { confirmUnsavedLeave } from '../chrome/unsavedEdits.js';
88-
import { SIDEBAR_EDGE_ZONE, useConsoleSidebarRail, useConsoleSidebarRailPanel } from './consoleSidebarRail.js';
88+
import {
89+
CONSOLE_EXPANDED_SIDEBAR_WIDTH,
90+
CONSOLE_SIDEBAR_WIDTH_PREFERENCE,
91+
SIDEBAR_EDGE_ZONE,
92+
SIDEBAR_RESIZING_FRAME,
93+
useConsoleSidebarRail,
94+
useConsoleSidebarRailPanel,
95+
} from './consoleSidebarRail.js';
96+
import { SidebarWidthHandle } from './SidebarWidthHandle.js';
97+
import { useWorkspacePreference } from '../utils/workspacePreference.js';
8998
import { SidebarItemMenu, sidebarItemDesignPath, favoriteDesignPath } from './SidebarItemMenu.js';
9099
import { SortableFavoriteRows, type FavoriteRowDragProps } from './SortableFavoriteRows.js';
91100
import { favoriteAppSegment } from './listViewFavorites.js';
@@ -214,6 +223,16 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false
214223
const rail = useConsoleSidebarRail({ enabled: railOverlay });
215224
const sidebarRef = React.useRef<HTMLDivElement | null>(null);
216225
const railPanel = useConsoleSidebarRailPanel(rail, sidebarRef);
226+
// objectstack#36227 — from 768 px up the reader drags the docked sidebar's
227+
// right edge to resize it; this browser keeps the width, and the menu
228+
// floating over a collapsed sidebar takes it too.
229+
const [keptWidth, setKeptWidth] = useWorkspacePreference(
230+
CONSOLE_SIDEBAR_WIDTH_PREFERENCE,
231+
'user',
232+
CONSOLE_EXPANDED_SIDEBAR_WIDTH,
233+
);
234+
const [dragWidth, setDragWidth] = React.useState<number | null>(null);
235+
const sidebarWidth = dragWidth ?? keptWidth;
217236
// objectstack#36112 — from 768 px up the console draws no top bar: the
218237
// sidebar starts at the top of the window and carries the app menu, the
219238
// search and the bell in its head, and the account at its foot.
@@ -743,7 +762,11 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false
743762
);
744763

745764
return (
746-
<div data-testid="console-sidebar-frame" className={railPanel.frameClassName}>
765+
<div
766+
data-testid="console-sidebar-frame"
767+
className={cn(railPanel.frameClassName, dragWidth !== null && SIDEBAR_RESIZING_FRAME)}
768+
style={rail.desktop ? ({ '--sidebar-width': `${sidebarWidth}px` } as React.CSSProperties) : undefined}
769+
>
747770
<Sidebar
748771
ref={sidebarRef}
749772
collapsible={railPanel.collapsible}
@@ -952,6 +975,9 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false
952975
{/* No footer trigger: from 768 px up the trigger is the head's collapse
953976
button and, while collapsed, the page header's expand button; on a
954977
phone the app bar's left slot holds it. */}
978+
{railPanel.docked && (
979+
<SidebarWidthHandle width={sidebarWidth} onPreview={setDragWidth} onCommit={setKeptWidth} />
980+
)}
955981
</Sidebar>
956982
{/* objectstack#35062 — the window's left edge while the sidebar is
957983
hidden: resting the pointer on it, or a press, floats the menu. For

0 commit comments

Comments
 (0)