Skip to content

Commit 031325d

Browse files
feat(console): the sidebar's docking model: 1280 px starts expanded, the expand/collapse button is the one control, Recent lists this app (#36112) (#36297)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X6okWxYPWAsooBsJoAhnT1u)_ repo:objectstack#4 · os-project-manager · session_01FEkQ5oK4fFfnLADcipbEeT Fixes #36112 This is PR B of two for the card: the sidebar's docking model. PR A (#36187) moved everything off the desktop top bar. Clause-②: no Metadata-protocol: none Seat claim: [#36112 claim](#36112 (comment)). Ruling: [F1, 7069868269](#36112 (comment)). ## 维护者速读 - 电脑上打开应用:窗口 1280 宽及以上侧边栏默认展开,更窄默认收起;收起和展开按钮是唯一开关,浏览器按宽窄两边各自记住;「保持侧边栏展开」开关去掉;侧边栏的「最近使用」只列当前应用里的;手机不变。 - 「去掉顶栏、侧栏常驻」这张卡的后一半,按你 11 月 21 日的裁定(1280 起默认展开,更窄才收起)收尾,合并后这张卡关闭。 - 出错时用户看到的是侧边栏开始时的展开或收起不对,点一下按钮就能改回,选择会被记住;只改界面,不动数据,可以直接撤回;以前选过「保持展开」的人在窄窗口上照旧是展开的。 - 无 ## Upgrade change and accepted cost - **Upgrade change (stated as the ruling asks):** on 1280–1415 px windows, a user who never set 「保持展开」 now starts with the sidebar expanded (it folded before), unless they had collapsed it on a wide window. - **Accepted cost (stated on the card):** on a 1280 px window the list beside an open record drawer is 304 px wide (560 today), and on 1280–1415 px with the sidebar expanded, opening the comment panel returns the record page's fields to the tab row; collapsing the sidebar restores the three columns. The 304 / 560 figures are pinned in `consoleSidebarRail.width-27593.test.tsx` against the primitive's sidebar width and plugin-view's drawer width. ## What changes `@object-ui/app-shell` - `layout/consoleSidebarRail.ts` - `CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH` is `1280`, one constant, no longer derived (`RECORD_DRAWER_MIN_CONTENT_WIDTH` removed; the drawer and list constants stay, to state the accepted cost). - The narrow-window choice is `CONSOLE_SIDEBAR_NARROW_OPEN_PREFERENCE` (was `CONSOLE_SIDEBAR_KEEP_OPEN_PREFERENCE`), stored under the same name `console.sidebar.keepOpen`, so an existing `on` reads as "expanded on narrow" with no migration. The wide-window choice keeps its key (`os:console-sidebar:wide-open`). Wide and narrow stay stored separately. - New `startingSidebarOpen(wide)`: the reader's choice for that side, else expanded on wide and collapsed on narrow. `primeConsoleSidebarOpen` writes it into the primitive's cookie before the first frame; `seedWideWindowOpen` is gone (with an explicit wide default it has nothing to seed). - `useConsoleSidebarRail` answers `narrowOpen` / `setNarrowOpen` instead of `keepOpen` / `setKeepOpen`; `railMode` is "narrow and collapsed by the narrow choice". - `useConsoleSidebarRailPanel`: `keepOpenControl`, `dock` / `undock` and the `'dock'` closer are removed. While the sidebar is hidden, a press on a sidebar trigger (the page header's expand button, or the corner fallback) now docks it: on a narrow window the capture phase sets the narrow choice to expanded before the provider's toggle opens it, so the open is not a float. ⌘B still floats the menu over a collapsed sidebar (unchanged), and so does the left edge. - `hooks/useResponsiveSidebar.ts`: gives a window its starting state on load and when it crosses 1280 px or the phone breakpoint; keeps an open/close on a wide window as the wide choice (only on a change, so a default is never recorded as a choice), and a close of the docked sidebar on a narrow window as the narrow choice; a narrow choice turned collapsed (this tab or another) collapses an open sidebar. Public signature unchanged. - `layout/UnifiedSidebar.tsx`: the 「保持侧边栏展开」 footer row is gone (the foot holds only the account menu). From 768 px up the Recent group lists only entries whose address names the current app (resolved by `matchAppBySegment`, as Home resolves a recent row's app); the phone drawer is unchanged. `@object-ui/i18n`: `sidebar.keepOpen` removed from all 11 packs (zh-Hant regenerated with `gen:zh-hant`). Text that named 1416 (the ruling's list, plus one more found by grep): - `ui/packages/plugin-detail/src/synth/recordPageColumns.ts` comment (also corrected: it still described the retired 48 px icon rail). Comment only, no bump for plugin-detail. - `docs/qa/platform-checklist/areas/platform-core.json` `platform-core.builtin-apps-nav-render` steps[2], revision 17 → 18 with a history row. - `examples/app-showcase/e2e/detail-shapes.spec.ts`: its comment cited 1416 and the case docked the sidebar with the retired "Keep sidebar open"; it now docks with the page header's expand button. ## Tests New (card-named): - `layout/__tests__/consoleSidebarRail.docking-36112.test.tsx`: threshold 1280; first frame at 1279 collapsed and 1280 expanded whatever the cookie, 768 / 1920 edges, phone keeps the cookie; the mounted layout at 1279 → 1280; a stored choice beats the default on each side and the two sides stay apart; a raw legacy `os:pref:console.sidebar.keepOpen` record `{"value":"on","v":1}` reads as expanded on a narrow window. - `layout/__tests__/UnifiedSidebar.recentThisApp-36112.test.tsx`: Recent lists only this app's entries (other app, Setup, Studio item left out), its five are this app's newest five, no group when this app has none, and the phone drawer still lists every app's. Rewritten (they encoded 1416 or the keep-open switch): - `hooks/__tests__/useResponsiveSidebar.test.tsx`: defaults at 1279 / 1280, no choice recorded by a default, each side's state across the threshold, wide collapse kept, narrow close kept as the narrow choice, a narrow choice turned collapsed elsewhere, phone untouched. - `layout/__tests__/ConsoleLayout.sidebarFirstFrame-28077.test.tsx`: 1280 → 1279 for the collapsed first frame; new cases for 1280 expanded against a collapsed cookie, a wide collapse, and a narrow expand. - `layout/__tests__/consoleSidebarRail.width-27593.test.tsx`: no longer pins the derived 1416; pins 1280, the 256 px width (F2) and the 304 / 560 cost. - `layout/__tests__/UnifiedSidebar.hiddenCollapse-35062.test.tsx`: narrow width 1280 → 1024; the trigger-floats cases now float with ⌘B; the "Keep sidebar open" cases are replaced by "the expand button docks (wide and narrow), a reload keeps it, the collapse button takes it back", the legacy keep-open read, and "the expand button docks even when React renders between the capture phase and the trigger's handler" (the old render-between case, now for the dock). - `layout/__tests__/UnifiedSidebar.railOverlay-27593.test.tsx`: 1280 / 1360 → 1024; floats with ⌘B; the three "Keep sidebar open" cases and the Esc-on-keep-open case are replaced by the expand-button dock and the narrow/wide choices kept apart (objectstack#28079). - `examples/app-showcase/e2e/detail-shapes.spec.ts` (see above). Retired: none as a file. The removed cases are the ones that drove the retired control; each behaviour they pinned that still exists (float, Esc, focus, fold on navigation, choices kept apart) is pinned in the rewritten files above. <details><summary>Local runs (head ce00125)</summary> All at head `ce00125fc`, under the shared verify lock unless marked lock-free. - `pnpm --filter @object-ui/app-shell type-check && pnpm --filter @object-ui/i18n test && vitest run` the seven changed or new app-shell test files: VERDICT command-exit 0; i18n `Test Files 105 passed (105)`, `Tests 1962 passed | 13 skipped`; app-shell `Test Files 7 passed (7)`, `Tests 71 passed (71)`. - Earlier, at `114ccd7a7` (source identical to the head; the last commit adds one import line to a test): `vitest run` app-shell `layout`, `hooks`, `chrome`: `Test Files 279 passed (279)`, `Tests 2217 passed (2217)`. - Derived gate families (`dispatch-gates.mjs`, 65 derived, `--ran` reconciliation: 65 run, 0 unrun): 62 lock-free families re-run at the head, exit 0 each; `check:type-check-debt` exit 0 under the lock; `vitest run scripts/` under `ui/` exit 0 under the lock (the lock-free attempt was SIGKILLed by the box's memory limit, not a red); `check:test-source-alias` red on the first run, fixed by `ce00125fc` and green since. - NOT MEASURED: `check:dual-build-cjs-loads` exit 3, PREREQUISITE NOT MET (needs a full `pnpm build` of 36 framework packages this PR does not touch); CI runs it. - Declared to CI: `test:repo` and the full lint farm. </details> <details><summary>Ablations (one per leg; each mutation committed-first, landed on disk by `scripts/ablation-replace.mjs`, restored to HEAD and proven by blob hash)</summary> Six legs, one lock hold (VERDICT command-exit 0), at head `ce00125fc`. Each leg red, each restored with `git diff HEAD` empty and the file's blob equal to HEAD's. | Leg | Mutation | Suite | Result | |:---|:---|:---|:---| | L1 | threshold 1280 back to 1416 | `consoleSidebarRail.docking-36112` | 4 failed / 8 | | L2 | the narrow choice (legacy keep-open) read always false | `consoleSidebarRail.docking-36112` | 2 failed / 8 | | L3 | the expand press no longer sets the narrow choice | `UnifiedSidebar.hiddenCollapse-35062` | 2 failed / 20 | | L4 | Recent filter removed | `UnifiedSidebar.recentThisApp-36112` | 3 failed / 4 | | L5 | Recent filter applied on the phone too | `UnifiedSidebar.recentThisApp-36112` | 1 failed / 4 | | L6 | a narrow-window close no longer kept | `useResponsiveSidebar` | 1 failed / 7 | The suites import the edited modules by relative path (source), so no build sits between the mutation and the run. </details> ## Acceptance notes Card acceptance, walked against main after PR A (a5a5312) and this branch: | Card acceptance line | Met by | |:---|:---| | Desktop app page: no top bar; sidebar on the left, content beside it, not covered | PR A (no top bar); this PR (docked by default from 1280 px; below it collapsed by default, as ruled) | | Collapse: sidebar disappears, content widens, expand button top-left; left edge slides it out; still collapsed after refresh | PR A (collapse, expand button, edge); this PR (the expand button docks instead of floating; the choice is kept on both sides of 1280) | | App name opens only the app list (search when many) and 「添加应用」; Setup for admins only; switching works | PR A | | Sidebar search works, shortcut works | PR A | | Avatar at the bottom; its menu has switch organization and sign out | PR A | | Bell beside search; panel and count as before | PR A | | Impersonation banner at the content top, exit works; lost-connection notice | PR A | | List, record, dashboard, report, custom page all carry the page-actions group | #36111 and PR A (always on) | | Phone width unchanged | PR A; this PR leaves the phone drawer's Recent unfiltered and the phone sidebar state untouched | | Setup and Account use the new shell, menus unchanged | PR A | | Onboarding walks through | PR A (the walkthrough component renders nothing on main; no step points at the top bar) | | PR body: before/after desktop screenshots (expanded, collapsed, app menu, banner) and the changed components and rewritten tests | this PR (before/after shots at 1440, 1280 and 1279 (expanded, collapsed, app menu open, the 1279 expand press, and a reload after it), saved with the seat's evidence; the banner was not shot, see Acceptance notes; components and tests above) | | Item 2: 「保持侧边栏展开」 removed | this PR | | Item 5: Recent lists this app's items | this PR | The PR A rows are read from PR A's body and main's code, not re-driven here except where the screenshots show them. Browser evidence (showcase booted on a private port, console served by Vite from this branch; the before set from the same server with the three sidebar files and the English pack swapped back to the merge base, then restored to HEAD and checked by blob hash): - Fresh profile, 1440 px: expanded, before and after. 1280 px: collapsed before, expanded after. - 1279 px: collapsed on load in both. Pressing the expand button: before, the menu floats over the page with the 「Keep sidebar open」 row at its foot, and a reload brings back the collapsed state; after, the sidebar docks beside the page (content reflows), and a reload keeps it docked. - App menu open at 1440: same in both (Showcase, Setup, Add app). - The impersonation banner was not shot: it needs a second user to impersonate on a fresh database, and its surface is PR A's and is not changed here. - Recent was not shot: a fresh profile has no recent items; the filter is pinned by `UnifiedSidebar.recentThisApp-36112` and its ablations L4 and L5. Reading taken where the ruling is literal, carried as an open question in the report: - The expand button's tooltip names ⌘B (it draws the chord the sidebar primitive answers to), but with ⌘B kept unchanged as ruled, ⌘B over a collapsed sidebar floats the menu while a press on the button docks it. Before this PR both floated. Either ⌘B docks too, or the tooltip stops naming it; this PR does neither and leaves it to the seat. Out of scope, noted not filed: none. Overlap: `overlap-check.mjs` exit 1 against #34223 (a draft from 2026-11-19 that already conflicts with main on another file) in `docs/qa/platform-checklist/areas/platform-core.json`; not merged around, per the order. #36234 and #36208 share the i18n packs and merge cleanly. ## Verification Read first (riskiest first): 1. `ui/packages/app-shell/src/layout/consoleSidebarRail.ts`, the capture listener in `useConsoleSidebarRailPanel` (expand docks; ⌘B floats) and `startingSidebarOpen`. 2. `ui/packages/app-shell/src/hooks/useResponsiveSidebar.ts`, the layout effect (which transitions write which choice). 3. `ui/packages/app-shell/src/layout/UnifiedSidebar.tsx`, the `recentItems` filter. Two-minute check: in a fresh browser profile open any app at a 1280 px window: the sidebar is expanded beside the page. Resize to 1279 px: it collapses and the page header shows the expand button; press it: the sidebar docks, and a reload keeps it docked. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5oK4fFfnLADcipbEeT)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5oK4fFfnLADcipbEeT --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d33bf5a commit 031325d

25 files changed

Lines changed: 843 additions & 576 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): the sidebar's docking model — 1280 px starts expanded, the expand/collapse button is the one control, and Recent lists this app's items
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
- **Which state a window starts in.** From 768 px up, a browser with no choice kept starts with the sidebar expanded on a window 1280 px wide and up, and collapsed from 768 to 1279 px. The threshold was 1416 px, and below it the sidebar folded on its own. `CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH` is now 1280 (one constant).
12+
- **The reader's choice wins, on each side.** The sidebar's collapse button and, while it is collapsed, the page header's expand button are the one control, and this browser keeps each press: a wide-window choice and a narrow-window choice, kept apart as before. The expand button now docks the sidebar beside the page; before, it floated the menu over the page. Resting the pointer on the window's left edge and ⌘B still float the menu over a collapsed sidebar without changing the choice. Phone widths are unchanged, and the sidebar stays 256 px wide.
13+
- **"Keep sidebar open" is gone.** Its stored choice (the workspace preference `console.sidebar.keepOpen`) is now the narrow-window choice, so a reader who kept the sidebar open starts expanded on a narrow window. Nothing to migrate.
14+
- **Upgrade change.** On a 1280 to 1415 px window, a reader who never kept the sidebar open now starts with it expanded (it folded before), unless they collapsed it on a wide window. The accepted cost: on a 1280 px window with the sidebar expanded, the list beside an open record drawer is 304 px wide (560 before), and on 1280 to 1415 px, opening the record page's comment panel moves its fields back to the tab row; collapsing the sidebar gives the width back.
15+
- **Recent is this app's.** From 768 px up, the sidebar's Recent group lists only the items opened in the current app. Home's "Recently accessed" and the phone drawer still list every app's.
16+
17+
`@object-ui/i18n`: the `sidebar.keepOpen` key, which no surface reads any more, is dropped from all eleven packs (zh-Hant regenerated).

‎docs/qa/platform-checklist/areas/platform-core.json‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@
640640
"title": "The built-in apps a stock boot REGISTERS (Setup / Account) render every merged-nav destination; app-level and entry-level gates are enforced, not errored — and Studio's deliberate absence is asserted, never hunted",
641641
"since": "v15",
642642
"status": "active",
643-
"revision": 17,
643+
"revision": 18,
644644
"priority": "P0",
645645
"surface": "browser",
646646
"personas": [
@@ -662,7 +662,7 @@
662662
"steps": [
663663
"as admin, GET /api/v1/meta/app?id=setup and extract every merged nav destination — Setup is a SHELL of empty group anchors (packages/platform-objects/src/apps/setup.app.ts: group_overview/apps/people_org/access_control/approvals/configuration/diagnostics/integrations/advanced) filled by SETUP_NAV_CONTRIBUTIONS (setup-nav.contributions.ts) plus capability-plugin contributions (plugin-security Positions/Permission Sets, plugin-sharing Sharing Rules/Record Shares, plugin-approvals, plugin-webhooks)",
664664
"GET /api/v1/meta/app with NO query first and record the names actually served — a stock boot answers exactly showcase_app, setup, account. Then GET /api/v1/meta/app?id=account (account.app.ts — Profile + Inbox/Security/Developer groups). ⚠️ GET /api/v1/meta/app?id=studio answers 200 {\"items\":[]} on every stock boot and that is the expected result (knownGap): record the absence as an assertion and move on — do NOT install @objectstack/studio to make the step runnable",
665-
"as admin, hand-walk each destination in each app. At a window narrower than 1416 px (1280 px included) the console folds the sidebar, and Setup and Account open that way (ui/packages/app-shell/src/layout/consoleSidebarRail.ts CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH, objectstack#27593; QA run #29877 met it at 1280 px). Folded, the sidebar is hidden, with no icon column (ruling 6973617688 on objectstack#35062): press the sidebar toggle at the app bar's left edge (Ctrl/⌘+B), or rest the pointer on the window's left edge, to float the full menu over the page before expanding any group. The float folds back after each chosen entry, so float it again for the next destination. EXPAND every nav group first: some render collapsed by default — Setup's Advanced group and Account's Developer group declare `expanded: false` (packages/platform-objects/src/apps/setup.app.ts, account.app.ts), and QA run #24557 found Setup's Configuration group collapsed as well — so a walk that never expands them never reaches their entries. Then navigate, wait for render, SCREENSHOT FIRST, then read the DOM — assert no pageerror, no 'failed to load', no blank <main>, no 'no actions configured' placeholder",
665+
"as admin, hand-walk each destination in each app. At a window narrower than 1280 px a browser with no choice kept opens Setup and Account with the sidebar collapsed, and from 1280 px expanded (ui/packages/app-shell/src/layout/consoleSidebarRail.ts CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH, ruling 7069868269 on objectstack#36112); a reader's own collapse or expand is kept per browser, on each side of that width. Collapsed, the sidebar is hidden, with no icon column (ruling 6973617688 on objectstack#35062): press the expand button at the page header's left edge to put it back beside the page before expanding any group — or press Ctrl/⌘+B, or rest the pointer on the window's left edge, to float the full menu over the page; the float folds back after each chosen entry, so float it again for the next destination. EXPAND every nav group first: some render collapsed by default — Setup's Advanced group and Account's Developer group declare `expanded: false` (packages/platform-objects/src/apps/setup.app.ts, account.app.ts), and QA run #24557 found Setup's Configuration group collapsed as well — so a walk that never expands them never reaches their entries. Then navigate, wait for render, SCREENSHOT FIRST, then read the DOM — assert no pageerror, no 'failed to load', no blank <main>, no 'no actions configured' placeholder",
666666
"Setup detail: confirm each settings URL entry (nav_settings_* → /apps/setup/system/settings/<namespace>) opens the settings namespace form — the 11 namespaces of a stock single-posture boot, localization/company/branding/auth/access_policy/mail/sms/storage/ai/knowledge/lifecycle: the nav_settings_* entries of packages/platform-objects/src/apps/setup-nav.contributions.ts, plus nav_settings_branding, which packages/services/service-settings/src/settings-service-plugin.ts contributes only where no organization wall stands, and Users / Organization / Business Units / Teams / Sessions / OAuth Applications render. User preferences and identity links are not Setup destinations: open a user's record page, /_console/apps/setup/sys_user/record/ID (a row click on the Users list opens a side panel at ?recordId=, which is not that page: take the id from the row or the panel), and confirm the user page's Preferences and Linked Accounts tabs (packages/platform-objects/src/pages/sys-user.page.ts#SysUserDetailPage) render that user's rows",
667667
"Studio detail is NOT walked from here — the app is not registered on a stock boot (knownGap), so there is no merged nav to render. Its metadata:resource lists and component surfaces (App Builder, All Metadata Types, Packages, API Console, Flow Runs, Public Forms) are reached through the console surface at /_console/studio/<pkg>/<pillar> and are covered by area studio-authoring. What THIS item asserts about Studio is the absence itself, per clause 6",
668668
"Account detail: confirm Profile (account:profile_card), Notifications (sys_inbox_message/mine), Approvals (nav_account_approvals, the approvals:inbox component, served as …/component/approvals/inbox — the Approvals Inbox, not the sys_approval_request grid; account.app.ts), Linked Accounts (sys_account), Active Sessions (sys_session/mine), API Keys (sys_api_key/mine), OAuth Applications (sys_oauth_application/mine) and Connect an Agent (nav_connect_agent) each render — 8 Account destinations and 47 Setup destinations for the admin on a stock single-org showcase boot, read from source after objectstack#34724 retired Setup › Packaged Actions (nav_packaged_actions; its switch moved onto the action in Studio); QA runs #32953 (at 5fb79bc0) and #33087 (at 8e3d4a54) read 48 before it (GET /api/v1/meta/app leaves, which match the nav source minus its gates). QA run #29877 read 46 at 589049b0, before Access policy (nav_settings_access_policy, the access_policy namespace) joined the Configuration group. Since QA run #28545's reading Setup's Packaged automation page retired under ADR-0146 D11, leaving Packaged Actions (nav_packaged_actions, automation:packaged-actions; #28785, itself retired by objectstack#34724), and its unfiltered Packages entry moved to Studio (#29547) (47 for #28927, 50 at eeec88d1 for QA run #28545, 48 re-measured at 3fd80337 for #28338, QA run #27481 read 44 and 8, QA run #24557 read 42 at 5b14b7f3, 45 on 2026-10-01, and #9453 recorded 43 and 7). Recount from the payload each run",
@@ -822,6 +822,12 @@
822822
"date": "2026-11-18",
823823
"change": "steps[2]: below 1416 px the fold now hides the sidebar instead of leaving its icon rail (ruling 6973617688 on #35062): the walk floats the full menu with the toggle (Ctrl/⌘+B) or by resting the pointer on the window's left edge, and floats it again after each chosen entry, since the float folds back on navigation. The walk is unchanged in substance. No clause changed. Read from source, and measured on a CRM boot (at 1280×800 the toggle floated the menu with focus on its entry; at 1600×900 choosing an entry in the float folded it); not yet re-run by a QA run.",
824824
"ref": "#35187"
825+
},
826+
{
827+
"revision": 18,
828+
"date": "2026-11-22",
829+
"change": "steps[2]: the threshold is 1280 px, not 1416 px, and it sets only where a browser with no choice kept starts — collapsed below it, expanded from it (ruling 7069868269 on #36112); the reader's own collapse or expand is kept per browser on each side, and the 'Keep sidebar open' switch is gone, so the walk docks the sidebar with the page header's expand button, or floats it with Ctrl/⌘+B or the window's left edge as before. The app bar named in revision 17 is gone from 768 px up (#36187). No clause changed. Read from source; not yet re-run by a QA run.",
830+
"ref": "#36112"
825831
}
826832
]
827833
},

‎examples/app-showcase/e2e/detail-shapes.spec.ts‎

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -178,30 +178,28 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({
178178
//
179179
// The window and the sidebar are derived, not picked. A collapsed console
180180
// sidebar draws no icon rail from 768 px up — ruling 6973617688 on
181-
// objectstack#35062: "Both collapsed states hide the sidebar completely:
182-
// the manual collapse (`UnifiedSidebar` `collapsible="icon"`) and the
183-
// automatic fold between 768 px and the record-drawer threshold (#27593,
184-
// `consoleSidebarRail.ts`, below 1416 px). No icon column remains." So in a
185-
// fresh browser context no desktop window stacks: measured on this harness,
186-
// from a 768 px window (`MOBILE_BREAKPOINT`, the desktop shell) to 1415 px
187-
// the sidebar folds hidden and the record view is the whole window (two
188-
// columns at 768), and from 1416 px it is expanded and the view is at least
189-
// 1160. The case therefore docks the sidebar the way a reader does — the
190-
// app bar's trigger floats the menu and its "Keep sidebar open" keeps the
191-
// 256 px sidebar beside the page — and the view is the window minus it:
192-
// one column at 1015 px (759 of view), two at 1016 px (760), the same after
193-
// a reload. So the docked stack tier is a window of 768 to 1015 px. 900
194-
// sits inside it with headroom on both sides: 644 px of view against the
195-
// 760 floor, 132 px above the mobile breakpoint. ⛔ Not 780 px with the
196-
// sidebar left as it comes up: that window now draws two columns (780 px of
197-
// view). ⛔ Not below 768 px: that is the mobile shell, where the off-canvas
198-
// sidebar gives the view the whole window (stack below 760), but where the
199-
// details draw no Invoices body table (measured at 720 and 740 px).
181+
// objectstack#35062: "Both collapsed states hide the sidebar completely" —
182+
// and a browser with no choice kept starts it collapsed below 1280 px and
183+
// expanded from 1280 px (ruling 7069868269 on objectstack#36112,
184+
// `consoleSidebarRail.ts` CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH). So in a fresh
185+
// browser context no window below 1280 px stacks: the sidebar is hidden and
186+
// the record view is the whole window (two columns at 768). The case
187+
// therefore docks the sidebar the way a reader does — the page header's
188+
// expand button puts the 256 px sidebar beside the page, and this browser
189+
// keeps that choice — and the view is the window minus it: one column at
190+
// 1015 px (759 of view), two at 1016 px (760). So the docked stack tier is
191+
// a window of 768 to 1015 px. 900 sits inside it with headroom on both
192+
// sides: 644 px of view against the 760 floor, 132 px above the mobile
193+
// breakpoint. ⛔ Not 780 px with the sidebar left as it comes up: that
194+
// window draws two columns (780 px of view). ⛔ Not below 768 px: that is
195+
// the mobile shell, where the off-canvas sidebar gives the view the whole
196+
// window (stack below 760), but where the details draw no Invoices body
197+
// table (measured at 720 and 740 px).
200198
await page.setViewportSize({ width: 900, height: 800 });
201199
const errors = await openRecord(page, recordUrl('showcase_account', contosoId));
202-
await page.locator('[data-sidebar="trigger"]').click();
203-
await page.getByTestId('sidebar-keep-open').click();
204-
await expect(page.getByTestId('sidebar-keep-open')).toHaveAttribute('aria-pressed', 'true');
200+
await page.getByTestId('shell-sidebar-expand').click();
201+
await expect(page.getByTestId('sidebar-collapse')).toBeVisible();
202+
await expect(page.getByTestId('shell-sidebar-expand')).toHaveCount(0);
205203

206204
// objectstack#35891: no stage bar, no key-field strip; the heuristic stage
207205
// (account.status is a select named "status") is the header's tag.

‎ui/packages/app-shell/src/hooks/__tests__/useResponsiveSidebar.test.tsx‎

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

33
/**
4-
* useResponsiveSidebar — the sidebar folds to its icon rail on a window
5-
* narrower than `CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH` and unfolds when it widens
6-
* (objectstack#27593). The wide window's open state survives the fold, a
7-
* reader's "keep open" turns the fold off, and the phone drawer is left alone.
8-
* Only an open or close on a wide window is kept as the wide-window choice
9-
* (objectstack#28079).
4+
* useResponsiveSidebar — a window starts in the reader's choice for its side
5+
* of `CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH` (1280 px), else expanded on a wide
6+
* window and collapsed on a narrow one (objectstack#27593, ruling 7069868269
7+
* on objectstack#36112). The two choices are kept apart: an open or close on a
8+
* wide window is the wide-window choice (objectstack#28079), a close of the
9+
* docked sidebar on a narrow window the narrow-window choice; the phone drawer
10+
* is left alone.
1011
*/
1112

1213
import '@testing-library/jest-dom/vitest';
@@ -15,10 +16,10 @@ import { SidebarProvider, useSidebar } from '@object-ui/components';
1516
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
1617
import { useResponsiveSidebar } from '../useResponsiveSidebar';
1718
import {
18-
CONSOLE_SIDEBAR_KEEP_OPEN_PREFERENCE,
19+
CONSOLE_SIDEBAR_NARROW_OPEN_PREFERENCE,
1920
readWideWindowOpen,
2021
} from '../../layout/consoleSidebarRail';
21-
import { writeWorkspacePreference } from '../../utils/workspacePreference';
22+
import { readWorkspacePreference, writeWorkspacePreference } from '../../utils/workspacePreference';
2223

2324
/**
2425
* Size the test window: happy-dom's own viewport, so `innerWidth`, the
@@ -78,73 +79,76 @@ afterEach(() => {
7879
document.cookie = 'sidebar_state=; path=/; max-age=0';
7980
});
8081

81-
describe('useResponsiveSidebar (objectstack#27593)', () => {
82-
it('folds the sidebar on a 1280 px window and leaves it open on a 1440 px one', () => {
83-
renderAt(1280);
82+
const narrowChoice = () => readWorkspacePreference(CONSOLE_SIDEBAR_NARROW_OPEN_PREFERENCE, 'user');
83+
84+
describe('useResponsiveSidebar (objectstack#27593, objectstack#36112)', () => {
85+
it('starts collapsed on a 1279 px window and expanded on a 1280 px one', () => {
86+
renderAt(1279);
8487
expect(openState()).toBe('false');
8588
cleanup();
8689

87-
renderAt(1440);
90+
renderAt(1280);
8891
expect(openState()).toBe('true');
8992
});
9093

91-
it('keeps a manual expand on a narrow window (the rail expanded over the content)', () => {
92-
renderAt(970);
93-
expect(openState()).toBe('false');
94-
95-
fireEvent.click(screen.getByRole('button', { name: 'Expand sidebar' }));
96-
expect(openState()).toBe('true');
94+
it('a state it gives a window is not a choice: nothing is kept until the reader toggles', () => {
95+
renderAt(1440);
96+
resizeTo(1024);
97+
resizeTo(1440);
98+
expect(readWideWindowOpen()).toBeUndefined();
99+
expect(narrowChoice()).toBeUndefined();
97100
});
98101

99-
it('hands the wide state back when the window widens, and folds again when it narrows', () => {
102+
it('hands each side its own state as the window crosses the threshold', () => {
100103
renderAt(1440);
101104
expect(openState()).toBe('true');
102105

103-
resizeTo(1280);
106+
resizeTo(1279);
104107
expect(openState()).toBe('false');
105-
expect(readWideWindowOpen()).toBe(true);
106108

107-
resizeTo(1440);
109+
resizeTo(1280);
108110
expect(openState()).toBe('true');
109-
expect(readWideWindowOpen()).toBe(true);
110111
});
111112

112-
it('hands back a collapsed wide state as collapsed', () => {
113+
it('keeps a collapse on a wide window, and gives it back when the window widens again', () => {
113114
renderAt(1440);
114115
fireEvent.click(screen.getByRole('button', { name: 'Toggle sidebar' }));
115116
expect(openState()).toBe('false');
117+
expect(readWideWindowOpen()).toBe(false);
116118

117-
resizeTo(1280);
118-
// The reader expands the rail over the content on the narrow window…
119-
fireEvent.click(screen.getByRole('button', { name: 'Expand sidebar' }));
120-
expect(openState()).toBe('true');
121-
122-
// …and the wide window gets back the state the reader left it in.
119+
resizeTo(1024);
120+
expect(openState()).toBe('false');
123121
resizeTo(1440);
124122
expect(openState()).toBe('false');
125123
});
126124

127-
it('a load that opens wide after a narrow one gets the wide state back, not the fold', () => {
128-
renderAt(1280);
129-
expect(openState()).toBe('false');
130-
cleanup();
131-
132-
// The primitive's cookie recorded the fold; the wide-window choice is kept apart.
133-
renderAt(1440);
125+
it('keeps a collapse of the docked sidebar on a narrow window as the narrow-window choice', () => {
126+
writeWorkspacePreference(CONSOLE_SIDEBAR_NARROW_OPEN_PREFERENCE, 'user', 'on');
127+
renderAt(1024);
134128
expect(openState()).toBe('true');
135-
expect(readWideWindowOpen()).toBe(true);
129+
130+
fireEvent.click(screen.getByRole('button', { name: 'Toggle sidebar' }));
131+
expect(openState()).toBe('false');
132+
expect(narrowChoice()).toBe('off');
133+
// The wide-window choice is not touched.
134+
expect(readWideWindowOpen()).toBeUndefined();
136135
});
137136

138-
it('"keep open" turns the fold off: a narrow window keeps the sidebar open', () => {
139-
writeWorkspacePreference(CONSOLE_SIDEBAR_KEEP_OPEN_PREFERENCE, 'user', 'on');
140-
renderAt(1280);
137+
it('a narrow-window choice turned collapsed elsewhere collapses an open sidebar', () => {
138+
writeWorkspacePreference(CONSOLE_SIDEBAR_NARROW_OPEN_PREFERENCE, 'user', 'on');
139+
renderAt(1024);
141140
expect(openState()).toBe('true');
142-
expect(readWideWindowOpen()).toBeUndefined();
141+
142+
act(() => {
143+
writeWorkspacePreference(CONSOLE_SIDEBAR_NARROW_OPEN_PREFERENCE, 'user', 'off');
144+
});
145+
expect(openState()).toBe('false');
143146
});
144147

145148
it('leaves the open state alone below the phone breakpoint, where the drawer takes over', () => {
146149
renderAt(700);
147150
expect(openState()).toBe('true');
148151
expect(readWideWindowOpen()).toBeUndefined();
152+
expect(narrowChoice()).toBeUndefined();
149153
});
150154
});

0 commit comments

Comments
 (0)