Skip to content

Commit 8316d3d

Browse files
feat(studio): the left menu reads the placement table — 常用 types first, the rest in one 「高级」 fold (#37341)
Fixes #37201 Fixes #37211 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:在 Studio 里打开一个软件包,左侧菜单先列常用的十项(对象 · 应用、页面、仪表盘、报表 · 流程 · 权限集 · 智能体、工具、技能),其余全部收进底部默认收起的「高级」;分组名变成灰色小字、不再带数字,条目旁的灰色数字只表示有多少条。 - 为什么做:这是 Studio 重构专题里「左侧菜单分常用和高级两层」那项裁决的落地,解决菜单二十多项一样重、重点不清的问题,也让新建的空软件包能看到应用、页面、仪表盘、报表的入口。 - 出错会怎样:受影响的只是菜单怎么排、怎么折叠,地址和收藏链接一个没改,打不开的页面不会因此出现;撤回只需回退这一个改动。 - 要你做什么:无。 ## What changes `buildStudioMenu` (`studioMenuModel.ts`) now reads the placement table `STUDIO_MENU_PLACEMENT` (landed in #37232): - **Order.** Inside each group the type entries follow the table's row order; a type with no row comes after the placed ones in served order; the four entries that are not a type (organization flows, diagnostics, default sharing, the environment catalog) follow the types of their group, as before. - **Tier.** Every entry carries `tier: 'common' | 'advanced'` from its row; a type with no row is `advanced`; the four non-type entries are `advanced` (ruling 7151834490, ADR-0084 amendment of 2026-11-25). - **Always listed.** The directory rule's `always` list is now `STUDIO_MENU_ALWAYS_TYPES`, the table's 常用 rows (it was `STUDIO_MENU_DESIGNER_TYPES`, object · flow · permission). A new package shows app, page, dashboard, report and the three AI types before it holds one. - **Empty.** A 常用 entry on a package is `empty` only when the diagnostics sweep has answered (`settled`) and counts none of it. The menu passes `countsAnswered` (`studioMenuData.ts`): settled **and** not failed, because a server without the sweep answers no counts, not "none of each". The palette's own `settled` is unchanged. - **Groups.** A group is returned only where it holds an entry, on every scope; `studioMenuTiers()` splits the menu into the 常用 groups and the 高级 fold's groups, each holding only its tier's entries. `StudioMenu.tsx` draws it: - Group labels: 11 px, muted, no count, no link, not focusable (the icon stays at reduced opacity). The group-count test id `studio-menu-group-count-GROUP` is gone; nothing else's id changes. - Entry counts: muted, items only (unchanged class; new test id `studio-menu-count-KEY`). - An empty 常用 entry: dimmed label, no number (never "0"), still a link, with a tooltip; marked `data-empty="true"`. - Below a divider, one 「高级」 / "Advanced" button (`aria-expanded`, `aria-controls` → the region) over a region holding the 高级 groups (`studio-menu-advanced-group-GROUP`). The region stays in the DOM with `hidden` when closed. - Closed by default; a click writes `studio_menu_advanced=true|false` (path `/`, 7 days, the menu collapse cookie's lifetime), apart from `studio_menu_state`. - Open by itself while the current entry is a 高级 one (a bookmark to the hook list, the default sharing overview), without writing the cookie; the author can still close it there. - A search lists the matches of both tiers flat, under their group labels, with no fold. - `~org` and `~all` draw no fold: their entries are listed flat, in the table's order, under the same muted labels. ⌘K: no change to the palette model. It reads `buildStudioMenu`'s output, so it lists the same entries in the new order and ignores the fold; on a package it now also shows the AI group, because its 常用 agent type is always listed (`StudioPaletteGroups.surfaceScope-36900.test.tsx` updated on purpose). `studioMenuPlacement.ts`: #37232's L1 N1 carried. The `## Pins` block names the three pins (the registry, the ruled order, ADR-0084), and "the menu applies that rule when it reads this list" is now true and says where (`buildStudioMenu`). i18n: two keys added in `studio/{en,zh}.ts` — `engine.studio.menu.advanced` (Advanced / 高级) and `engine.studio.menu.emptyType`. None removed; `engine.studio.menu.typeCount` is now unread (see Acceptance notes). No route, address, entry key or entry test id changes. ## Tests - `studioMenuModel.test.ts` - **`:64` rewritten on purpose**: "a package draws all six groups, an empty one included" → "a package draws a group only where it holds an entry" (with no type served, only the non-type entries' groups). - New: table order with an unplaced type and the non-type entries last; tier stamping (rows, unplaced → advanced); the four non-type entries are 高级; `studioMenuTiers` (a group in a tier only where it has an entry of that tier; 平台 only in the fold); addresses and keys unchanged; `STUDIO_MENU_ALWAYS_TYPES` = the 常用 rows and the directory rule lists them on a package that holds none; empty = settled ∧ no item (not before settled, never on 高级, never off a package); the cookie reader. - The `~org`/`~all` case now expects the table's order (permission before position). - `StudioMenu.test.tsx`: group labels muted with no count / link; muted item count; tier-labelled groups; empty 常用 type dimmed, numberless (no "0" either), a link; not empty before the sweep answers or when it failed; a new package lists every 常用 type; the fold (closed by default, `aria-expanded` / `aria-controls`, the cookie written on click and read on remount, open by itself on a bookmark to 钩子 with no cookie written, closable there, a 常用 page leaves it closed, search ignores it); focus order toggle → search → 常用 entries → 高级 button → its entries; `~org` / `~all` flat with no fold and, for #37211, no count above Organization flows. - `StudioPaletteGroups.surfaceScope-36900.test.tsx`, `StudioDesignSurface.notFound-26708.test.tsx`: expectations moved on purpose (the AI group in ⌘K; the 常用 groups and the fold on a listed package). - `ui/e2e/studio-left-menu-36899.spec.ts` (Chromium, real Tailwind): the six-groups case now reads the 常用 groups; a new case lays out the fold closed, opened by a click, its cookie written and kept across a reload. <details><summary>Local runs (head <code>ff794532</code>; the readings below name the tree each was taken on)</summary> - `ui`: `vitest run packages/app-shell/src/views/studio-design/ packages/app-shell/src/views/metadata-admin/` at `ba3afa16` less one fix: **Test Files 1 failed | 1078 passed (1079)**, Tests 1 failed | 10757 passed | 1 skipped. The one failure was `StudioDesignSurface.notFound-26708.test.tsx` "CONTROL — a listed package renders its builder" (it expected all six groups drawn on a package); fixed in `ba3afa16`, re-run green: 2 files, 18 passed. - Menu, palette and surface files at `b5b0f6ad` + the fixture fix: **Test Files 6 passed (6), Tests 97 passed (97)**. - `pnpm --filter @object-ui/app-shell type-check` (both `tsc` programs, the test one included): exit 0 at `ff794532`'s bytes. The first run, before `ff794532`, was red on the search fixture missing `tier` (TS2345 x4) — the reason for that commit. - `ui/e2e/studio-left-menu-36899.spec.ts`, Chromium, with the Console web server switched off (the spec bundles and serves its own page): **4 passed**. - `pnpm --dir ui exec vitest run scripts/`: Test Files 172 passed | 2 skipped, Tests 5130 passed | 2 skipped. - `eslint` on the 11 changed ui files: exit 0. - Derived gate families (`dispatch-gates.mjs --commands`): 38 derived, 38 run, every one exit 0; `--ran` reconciliation: "38 run, 0 NOT-MEASURED (a DERIVED zero)". Before every push: `check:test-source-alias` exit 0, `ui check:i18n-keys` exit 0, `overlap-check.mjs` "VERDICT clean exit 0" (against `origin/main` and #37315, which shares the two studio i18n files and merges cleanly). </details> <details><summary>Ablations: 17 of 17 red, each restored to the HEAD blob</summary> Committed implementation first (`b5b0f6ad`); each row mutated one anchor through `scripts/ablation-replace.mjs` (anchor hit 1 → 0, blob moved, restored blob equal to HEAD, `git diff HEAD` empty) and ran `studioMenuModel.test.ts` + `StudioMenu.test.tsx` (45 tests; all green unmutated). The test files are resolved from `ui/` source by vitest, so there is no `dist/` leg. | # | Mutation | Result | |---|---|---| | A1 | no sort by the placement table | 4 failed | | A2 | every type stamped 常用 | 8 failed | | A3 | organization flows stamped 常用 | 4 failed | | A4 | always-listed = the old object · flow · permission | 8 failed | | A5 | empty without `settled` | 3 failed | | A6 | a failed sweep counts as answered | 1 failed | | A7 | a group drawn in a tier with no entry of it | 2 failed | | A8 | group label not muted | 3 failed | | A9 | an empty 常用 type still shows its number | 1 failed | | A10 | an empty 常用 type not dimmed | 1 failed | | A11 | fold open by default | 4 failed | | A12 | a click writes no cookie | 2 failed | | A13 | no self-open on a 高级 page | 2 failed | | A14 | the self-open writes the cookie | 1 failed | | A15 | the search honours the fold | 2 failed | | A16 | a fold on `~org` / `~all` | 2 failed | | A17 | no `aria-controls` | 1 failed | A first pass of this table is not counted: three rows (A6, A12, A14) were refused by `ablation-replace.mjs` before running (the replacement was a substring of the anchor), and A9 stayed green — no test had an empty 常用 type with a served count of 0. That pin was added (`b5b0f6ad`, "a sweep that counts 0 of it: still no number, never 0") and the whole table re-run. </details> ## Acceptance notes - `engine.studio.menu.typeCount` ("{count} types") has no reader after this change; `check:i18n-dead-keys` reports it as a candidate. It ships in the released `@object-ui/i18n` catalogue, and this card's rule is additive-only, so it stays. - "Empty" uses `countsAnswered` (settled and the sweep did not fail) rather than the bare `settled`: on a failed sweep `settled` is true with no counts, which would have dimmed every 常用 type. - `studio-menu-group-GROUP` now names the 常用 (or flat) instance of a group; the fold's instance is `studio-menu-advanced-group-GROUP`. - Follow-up decision cards F1–F3 from proposal §3.10 are the seat's to file when this lands (card Notes). ## Verification **Browser walk-through on a live showcase stack** — measured, not described. Own ports, torn down after: backend `examples/app-showcase` `objectstack dev --seed-admin --fresh -p 38417` (built tree at `b5b0f6ad`, `pnpm build` 121/121), Console from `ui/` source (`ui/apps/console`, `vite --port 5197 --strictPort`, `DEV_PROXY_TARGET` the backend). Driven with Playwright/Chromium at 1280 px, signed in as the seeded admin; the menu was read from the DOM after the reads settled, and screenshots were checked. 1. **Package scope, 高级 closed** — `/studio/com.example.showcase/metadata/object?package=com.example.showcase`, fresh browser. Fold: a `BUTTON` "Advanced", `aria-expanded=false`, `aria-controls` resolves to the region. Drawn: Data — Object 24 (current) · UI — Application 1, Page 29, Dashboard 3, Report 4 · Automation — Flow 33 · Access — Permission Set 9 · AI — AI Agent, AI Tool, AI Skill (dimmed, no number: the package holds none). Every group label muted, no group count anywhere (0 `studio-menu-group-count-*` nodes). The 高级 groups were in the DOM and not visible. 2. **Package scope, 高级 open** — one click: `aria-expanded=true`, cookie `studio_menu_advanced=true`, `studio_menu_state` not written. The fold shows Data — Hook 8, Mapping 1 · UI — View 36, Action 73, Dataset 4 · Automation — Job 1, Organization flows · Platform — Doc 8, Book 1, Email template 1, API 3, Datasource 1, Diagnostics · Access — Position 10, Sharing rule 2, Capability 2, Default sharing, Positions and permissions · AI — AI context 2. A reload kept it open. Closed again and searched "hook": the hook entry listed under Data, no fold drawn. 3. **A bookmark to 钩子** — a second fresh browser straight to `/studio/com.example.showcase/metadata/hook?package=com.example.showcase`: the fold open, Hook 8 marked current, and no `studio_menu_advanced` cookie in the jar. 4. **A new empty package** — `POST /api/v1/packages` (201, `com.walk.empty…`), then its object list: all ten 常用 entries listed and dimmed with no number (Object, Application, Page, Dashboard, Report, Flow, Permission Set, AI Agent, AI Tool, AI Skill); the fold closed, holding only Organization flows, Diagnostics, Default sharing, Positions and permissions. 5. **`~org`** — `/studio/~org/metadata/flow?source=runtime`: no fold; Automation — Organization flows (current), with no number above it (#37211); Access — Permission Set 19, Position 17, Sharing rule 3, Capability 13, Positions and permissions, in the table's order. `~all` reads the same, the catalog entry current. **Two-minute check:** open any package in Studio. Expect the ten Common entries, then a closed "Advanced" row; click it, reload, and it stays open. > PM note (zone a4-S): #37211 now carries a claim (7172656271) naming this branch, so `Fixes #37211` closes it at merge. That was the dev's open question 1, ruled A. --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYniqTW93usTV1hShjE)_ <!-- signed: repo:objectstack#4 · os-justin · session_01QSeKYkkwuF6UuFtu85Yd5H --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f339060 commit 8316d3d

12 files changed

Lines changed: 769 additions & 133 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(studio): the left menu shows the 常用 Common types first and folds everything else under one 「高级」 Advanced section
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
Studio's left menu on a package now lists the ten Common types first, in building order: Objects · Apps, Pages, Dashboards, Reports · Flows · Permission sets · Agents, Tools, Skills. Every other type, and the four entries that are not a type (Organization flows, Diagnostics, Default sharing, Positions and permissions), sit under one **Advanced** (高级) button below a divider, still under their group names.
12+
13+
- The Advanced section is closed by default. Opening or closing it is remembered per browser in the `studio_menu_advanced` cookie, apart from the menu's own collapse cookie.
14+
- Opening a page that is one of its entries (a bookmark to the hooks list, the default sharing overview) shows the section open, with that entry marked current; this does not change the remembered state.
15+
- The menu search lists matches from both tiers, whether the section is open or not.
16+
- Group names are small muted headings with no number. The muted number beside an entry is its item count.
17+
- A Common type the package holds nothing of is listed anyway, dimmed and with no number, and still opens its list, so a new package shows where to make its first app, page, dashboard or report. Before the item counts have loaded, no type is dimmed.
18+
- The organization's flows (`~org`) and the cross-package catalog (`~all`) have no Advanced section: their entries are listed flat, in the same order.
19+
20+
No address changes: every entry opens the same page as before, bookmarks keep working, and the ⌘K palette lists the same entries in the new order. Two new strings: "Advanced" (高级) and the dimmed entry's tooltip.

‎ui/e2e/studio-left-menu-36899.spec.ts‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { uiRoot } from '../scripts/ui-root.mjs';
1818
* full width, still collapsed after a reload (Studio's own cookie, on a real
1919
* http origin), and a drawer over the page at phone width.
2020
*
21+
* objectstack#37201 — the 「高级」 fold laid out: closed by default with its
22+
* groups out of sight, opened by a click, and still open after a reload under
23+
* its own cookie (`studio_menu_advanced`), the collapse cookie untouched.
24+
*
2125
* REAL: `StudioMenuProvider`, `StudioMenuTrigger`, `StudioMenu` and everything
2226
* they import (the sidebar primitive, the menu model, the i18n), bundled by
2327
* Vite from source, and the real Tailwind theme compiled for the classes on
@@ -65,7 +69,7 @@ const ENTRIES = [
6569
];
6670
export const useMetadataClient = () => ({});
6771
export const useMetadataTypes = () => ({ loading: false, error: null, entries: ENTRIES });
68-
export const useGlobalDiagnostics = () => ({ countsByType: { object: 12 }, packagesByType: {}, reload: () => {} });
72+
export const useGlobalDiagnostics = () => ({ loading: false, error: null, countsByType: { object: 12 }, packagesByType: {}, reload: () => {} });
6973
`;
7074
},
7175
};
@@ -175,8 +179,11 @@ test.beforeAll(async ({ browser }) => {
175179
)).forEach((c) => c && seen.add(c));
176180
await open(page, 1280);
177181
await collect();
182+
await page.getByTestId('studio-menu-advanced-toggle').click();
183+
await collect();
178184
await page.getByTestId('studio-menu-toggle').click();
179185
await collect();
186+
await page.context().clearCookies();
180187
await open(page, 390);
181188
await page.getByTestId('studio-menu-toggle').click();
182189
await page.waitForSelector('[role="dialog"]');
@@ -186,7 +193,7 @@ test.beforeAll(async ({ browser }) => {
186193
});
187194

188195
test.describe('Studio left menu (objectstack#36899)', () => {
189-
test('wide: docked at the left, six groups, the content beside it', async ({ page }, testInfo) => {
196+
test('wide: docked at the left, the 常用 groups shown, the content beside it', async ({ page }, testInfo) => {
190197
await open(page, 1280);
191198
const panel = await rect(page, PANEL);
192199
const content = await rect(page, '#content');
@@ -195,12 +202,43 @@ test.describe('Studio left menu (objectstack#36899)', () => {
195202
expect(panel.width).toBeGreaterThanOrEqual(255);
196203
expect(panel.width).toBeLessThanOrEqual(256);
197204
expect(content.left).toBeGreaterThanOrEqual(panel.right - 1);
198-
for (const g of ['data', 'ui', 'automation', 'system', 'security', 'ai']) {
205+
// objectstack#37201 — the served 常用 types' groups; 平台 Platform holds only 高级 entries.
206+
for (const g of ['data', 'automation', 'security']) {
199207
await expect(page.getByTestId(`studio-menu-group-${g}`)).toBeVisible();
200208
}
209+
await expect(page.getByTestId('studio-menu-group-system')).toHaveCount(0);
201210
await testInfo.attach('wide', { body: await page.screenshot(), contentType: 'image/png' });
202211
});
203212

213+
test('the 高级 fold: closed, then opened by a click, and a reload keeps it open (objectstack#37201)', async ({ page }, testInfo) => {
214+
await open(page, 1280);
215+
const fold = page.getByTestId('studio-menu-advanced-toggle');
216+
await expect(fold).toBeVisible();
217+
await expect(fold).toHaveAttribute('aria-expanded', 'false');
218+
await expect(page.getByTestId('studio-menu-advanced-group-system')).toBeHidden();
219+
await expect(page.getByTestId('studio-menu-entry-diagnostics')).toBeHidden();
220+
await testInfo.attach('advanced-closed', { body: await page.screenshot(), contentType: 'image/png' });
221+
222+
await fold.click();
223+
await expect(fold).toHaveAttribute('aria-expanded', 'true');
224+
for (const g of ['automation', 'system', 'security']) {
225+
await expect(page.getByTestId(`studio-menu-advanced-group-${g}`)).toBeVisible();
226+
}
227+
await expect(page.getByTestId('studio-menu-entry-diagnostics')).toBeVisible();
228+
// Below the 常用 entries, inside the docked panel.
229+
const below = await page.getByTestId('studio-menu-entry-diagnostics').evaluate((el) => el.getBoundingClientRect().top);
230+
const above = await page.getByTestId('studio-menu-entry-type:permission').evaluate((el) => el.getBoundingClientRect().top);
231+
expect(below).toBeGreaterThan(above);
232+
const cookies = await page.context().cookies(ORIGIN);
233+
expect(cookies.find((c) => c.name === 'studio_menu_advanced')?.value).toBe('true');
234+
expect(cookies.find((c) => c.name === 'studio_menu_state')).toBeUndefined();
235+
await testInfo.attach('advanced-open', { body: await page.screenshot(), contentType: 'image/png' });
236+
237+
await page.reload();
238+
await page.waitForSelector('[data-testid="studio-menu-advanced-toggle"]');
239+
await expect(page.getByTestId('studio-menu-advanced-toggle')).toHaveAttribute('aria-expanded', 'true');
240+
});
241+
204242
test('collapsed: off the canvas, the content takes the full width, and a reload keeps it', async ({ page }, testInfo) => {
205243
await open(page, 1280);
206244
await page.getByTestId('studio-menu-toggle').click();

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.notFound-26708.test.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,14 @@ describe('Studio: a package id no package has renders "package not found" (objec
226226
renderAt(`/studio/${PACKAGE_ID}/data`);
227227
await listAnswered(fetchMock);
228228
expect(screen.queryByTestId('studio-package-not-found')).toBeNull();
229-
// objectstack#36899 — the left menu, its six groups drawn.
230-
for (const group of ['data', 'ui', 'automation', 'system', 'security', 'ai']) {
229+
// objectstack#36899 — the left menu drawn. objectstack#37201 — the 常用 groups of the served
230+
// types (object, flow, permission), and the 「高级」 fold holding the four entries that are not a type.
231+
for (const group of ['data', 'automation', 'security']) {
231232
expect(within(menu()).getByTestId(`studio-menu-group-${group}`)).toBeInTheDocument();
232233
}
234+
for (const group of ['automation', 'system', 'security']) {
235+
expect(within(menu()).getByTestId(`studio-menu-advanced-group-${group}`)).toBeInTheDocument();
236+
}
233237
});
234238

235239
it('CONTROL — a kernel package the Studio landing hides is installed, never "not found"', async () => {

0 commit comments

Comments
 (0)