Skip to content

Commit c355f85

Browse files
feat(studio): one table holds the menu's type order and its 常用 / 高级 tier (#37232)
Fixes #37200 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:这次只新增一张「菜单排序与常用 / 高级分层」的表,左侧菜单暂时还不读它,界面与之前完全一样。 - 属于 Studio 改版(左侧菜单分「常用 / 高级」两层)这个大任务,是菜单真正改动前的第二步。 - 出错只会让测试变红,不会影响任何用户;这次改动可以直接撤回。 - 无。 ## What changes - New `ui/packages/app-shell/src/views/studio-design/studioMenuPlacement.ts`: `STUDIO_MENU_PLACEMENT`, one ordered list of `{ type, tier }`, 32 rows (every listable type of the 33 the registry holds on `origin/main`; `field` is hidden by the directory). - 常用 (common), in the ruled order: object · app, page, dashboard, report · flow · permission · agent, tool, skill. - 高级 (advanced), every other type, in the proposal's order: picklist, hook, mapping, object_extension, seed · view, action, dataset · job · doc, book, email_template, translation, api, datasource, external_catalog · position, assignment_rule, sharing_rule, queue, capability · ai_context. - Order and tier only; a type's group stays its served `domain`. Not wired into anything (the menu card wires it). - New `studioMenuPlacement.test.ts`, three holds: - registry: every type `DEFAULT_METADATA_TYPE_REGISTRY` registers and the directory lists has exactly one row, and every row names a registered, listed type; - ruling: the common and advanced rows, in order, as literals; - ADR-0084 (merged with the type table's Order and Tier columns): tier per type both ways, each ADR row's group equal to the served domain, and the order inside each group equal to the Order column. A failure names the type or the group. - `.changeset/37200-studio-menu-placement.md` (`@object-ui/app-shell` patch). ## Tests Final head `5568fa63a1`. - `vitest run packages/app-shell/src/views/studio-design/studioMenuPlacement.test.ts`: 1 file, 12 tests passed. - `@object-ui/app-shell` `type-check` (both tsc programs): exit 0, 0 errors (after `pnpm --filter '@object-ui/app-shell^...' build`). The first run caught a real typing error in the test (a `Set` of the registry's literal type union), fixed in `2eae5a0f90`. - Ablations, each through `scripts/ablation-replace.mjs` on a committed head, each restored and proven by the HEAD blob hash and an empty `git diff HEAD`: <details><summary>Ablation readings</summary> | Mutation | File | Result | |---|---|---| | remove the `hook` row | placement | 3 red: exactly-one-row, same-set, advanced order | | swap `app` and `page` | placement | 1 red: common order | | add a row `not_a_registered_type` | placement | 3 red: row-names-a-registered-type, same-set, advanced order | | remove the `ai_context` row | placement | 3 red: exactly-one-row, same-set, advanced order | | `job` retiered to common | placement | 4 red, including `job: ADR-0084 row: expected 'advanced' to be 'common'` | | ADR row `picklist` retiered to 常用 | ADR-0084 | 1 red: `picklist: ADR-0084 row: expected 'common' to be 'advanced'` | | ADR row `app` Order 1 to 9 | ADR-0084 | 1 red: `group ui` order | The first try at the unknown-type mutation was a no-op (its anchor survived inside the replacement, and the tool refused it with "the anchor count moved 1 -> 1"); it was re-run with an anchor that disappears. The ADR mutations were transient and restored; this PR does not edit the ADR. </details> ## Acceptance notes - The card names `studioAddressTable.test.ts` as the pattern; no file has that name. The address table is pinned in `studioAddress.test.ts` ("the mapping table agrees with the code"), which is the model used. - `ai_context` was registered on `main` after the ruling (33 types). It takes an advanced row, last in ai, matching ADR-0084's table; its tier is an open question for the maintainer, and a ruling the other way is a one-row edit plus the ADR row. - ADR-0146 still reads "32 at `origin/main` `151e8123`" for the registered-type count. That sentence lives only in the ADR, which this PR does not touch; it is reported to the seat as a follow-up. Nothing in this PR relies on the count 32. ## Verification Read first: `studioMenuPlacement.ts` (the rows themselves), then the ADR block of `studioMenuPlacement.test.ts` (the table-row regex is the risk: a reformatted ADR table makes the row-count test go red, never silently pass). Two-minute check: `cd ui && pnpm exec vitest run packages/app-shell/src/views/studio-design/studioMenuPlacement.test.ts` with `@objectstack/spec` built; expect 12 passed. Change any tier in the file and expect a red that names the type. <details><summary>Gates (local, head 5568fa6)</summary> - `dispatch-gates.mjs --commands` derived 38 families; all 38 run, each exit 0 (`--ran` reconciliation: 38 run, 0 NOT-MEASURED, a derived zero), including `pnpm check:test-source-alias`, `pnpm check:cross-package-test-inputs` and `pnpm --dir ui exec vitest run scripts/`. - `overlap-check.mjs --branch=HEAD`: merges cleanly with `origin/main`, VERDICT clean exit 0. - Repo-wide scans and the rest of the farm are CI's. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent bd98dd1 commit c355f85

3 files changed

Lines changed: 241 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
chore(studio): one table holds the order and the 常用 / 高级 tier of every type Studio's left menu lists
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`studioMenuPlacement.ts` adds `STUDIO_MENU_PLACEMENT`, one ordered list of `{ type, tier }` rows. The common rows are object, app, page, dashboard, report, flow, permission, agent, tool and skill, in that order; every other type the directory lists is advanced, picklist, email template and `ai_context` included. The table holds order and tier only: a type's group stays its served registry `domain`. A test holds the list against `DEFAULT_METADATA_TYPE_REGISTRY`, so a newly registered type fails until it has a row, and against the Order and Tier columns of ADR-0084's type-to-group table, so the record and the code cannot drift apart. Nothing reads the table yet, and the menu draws exactly what it drew before.
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#37200 — Studio's menu placement table agrees with the registry
5+
* and with the ruled order (ruling on #37192).
6+
*
7+
* Three holds:
8+
* - against `DEFAULT_METADATA_TYPE_REGISTRY`: every type the directory can
9+
* list has exactly one row, and every row names a registered, listable
10+
* type — so a newly registered type fails here until it is placed;
11+
* - against the ruling: the rows, in order, with their tiers. The expected
12+
* values are literals, so a reordered or re-tiered row fails here, not in
13+
* the menu;
14+
* - against ADR-0084's type-to-group table: its Order and Tier columns
15+
* equal this list, group by group, so the record and the code cannot drift
16+
* apart; a drift either way names the type.
17+
*/
18+
19+
import { describe, expect, it } from 'vitest';
20+
import { readFileSync } from 'node:fs';
21+
import { dirname, resolve } from 'node:path';
22+
import { fileURLToPath } from 'node:url';
23+
import { DEFAULT_METADATA_TYPE_REGISTRY } from '@objectstack/spec/kernel';
24+
import { HIDDEN_DIRECTORY_TYPES } from '../metadata-admin/directoryScope.js';
25+
import { STUDIO_MENU_PLACEMENT } from './studioMenuPlacement.js';
26+
27+
/** The types a package's directory can list: every registered type it does not hide. */
28+
const LISTABLE_TYPES = DEFAULT_METADATA_TYPE_REGISTRY.map((entry) => entry.type).filter(
29+
(type) => !HIDDEN_DIRECTORY_TYPES.has(type),
30+
);
31+
32+
describe('the menu placement table agrees with the registry (objectstack#37200)', () => {
33+
it('every type the directory can list has exactly one row', () => {
34+
for (const type of LISTABLE_TYPES) {
35+
expect(STUDIO_MENU_PLACEMENT.filter((row) => row.type === type).length, type).toBe(1);
36+
}
37+
});
38+
39+
it('every row names a registered type the directory lists', () => {
40+
const registered = new Set<string>(DEFAULT_METADATA_TYPE_REGISTRY.map((entry) => entry.type));
41+
for (const row of STUDIO_MENU_PLACEMENT) {
42+
expect(registered.has(row.type), row.type).toBe(true);
43+
expect(HIDDEN_DIRECTORY_TYPES.has(row.type), row.type).toBe(false);
44+
}
45+
});
46+
47+
it('the rows and the listable types are the same set', () => {
48+
expect(STUDIO_MENU_PLACEMENT.map((row) => row.type).sort()).toEqual([...LISTABLE_TYPES].sort());
49+
});
50+
});
51+
52+
describe('the menu placement table holds the ruled order and tiers (objectstack#37200)', () => {
53+
it('常用: object · app, page, dashboard, report · flow · permission · agent, tool, skill, in that order', () => {
54+
expect(STUDIO_MENU_PLACEMENT.filter((row) => row.tier === 'common').map((row) => row.type)).toEqual([
55+
'object',
56+
'app', 'page', 'dashboard', 'report',
57+
'flow',
58+
'permission',
59+
'agent', 'tool', 'skill',
60+
]);
61+
});
62+
63+
it("高级: every other type, in the proposal's order", () => {
64+
expect(STUDIO_MENU_PLACEMENT.filter((row) => row.tier === 'advanced').map((row) => row.type)).toEqual([
65+
'picklist', 'hook', 'mapping', 'object_extension', 'seed',
66+
'view', 'action', 'dataset',
67+
'job',
68+
'doc', 'book', 'email_template', 'translation', 'api', 'datasource', 'external_catalog',
69+
'position', 'assignment_rule', 'sharing_rule', 'queue', 'capability',
70+
'ai_context',
71+
]);
72+
});
73+
74+
it('the common rows come first, and every row carries one of the two tiers', () => {
75+
const tiers = STUDIO_MENU_PLACEMENT.map((row) => row.tier);
76+
expect(new Set(tiers)).toEqual(new Set(['common', 'advanced']));
77+
expect(tiers.indexOf('advanced')).toBe(tiers.lastIndexOf('common') + 1);
78+
});
79+
80+
it('picklist and email template are advanced, as ruled', () => {
81+
expect(STUDIO_MENU_PLACEMENT.find((row) => row.type === 'picklist')?.tier).toBe('advanced');
82+
expect(STUDIO_MENU_PLACEMENT.find((row) => row.type === 'email_template')?.tier).toBe('advanced');
83+
});
84+
85+
it('each row holds a type and a tier, and nothing else (the group stays the served domain)', () => {
86+
for (const row of STUDIO_MENU_PLACEMENT) {
87+
expect(Object.keys(row).sort(), row.type).toEqual(['tier', 'type']);
88+
}
89+
});
90+
});
91+
92+
const HERE = dirname(fileURLToPath(import.meta.url));
93+
const ADR_0084 = resolve(HERE, '../../../../../../docs/adr/0084-application-builder-information-architecture.md');
94+
95+
/** One row of ADR-0084's type-to-group table: `| Group | domain | Order | Registered type | Tier |`. */
96+
interface AdrRow {
97+
readonly domain: string;
98+
readonly order: number;
99+
readonly type: string;
100+
readonly tier: 'common' | 'advanced';
101+
}
102+
103+
const ADR_ROW = /^\| \*\*[^|]+\*\* \| `([a-z_]+)` \| (\d+) \| `([a-z_]+)`[^|]* \| (常用|高级) \|$/;
104+
105+
function adrRows(): AdrRow[] {
106+
return readFileSync(ADR_0084, 'utf8')
107+
.split('\n')
108+
.map((line) => ADR_ROW.exec(line.trim()))
109+
.filter((m): m is RegExpExecArray => m !== null)
110+
.map((m): AdrRow => ({ domain: m[1], order: Number(m[2]), type: m[3], tier: m[4] === '常用' ? 'common' : 'advanced' }));
111+
}
112+
113+
/** Each type's served registry `domain`. */
114+
const DOMAIN_OF = new Map<string, string>(DEFAULT_METADATA_TYPE_REGISTRY.map((entry) => [entry.type, entry.domain]));
115+
116+
describe("the menu placement table equals ADR-0084's Order and Tier columns (objectstack#37200)", () => {
117+
const rows = adrRows();
118+
119+
it('the ADR table is read: one row per listable type', () => {
120+
expect(rows.length).toBe(LISTABLE_TYPES.length);
121+
});
122+
123+
it('every type has the same tier in the ADR and in the list', () => {
124+
for (const row of STUDIO_MENU_PLACEMENT) {
125+
expect(rows.find((r) => r.type === row.type)?.tier, `${row.type}: ADR-0084 row`).toBe(row.tier);
126+
}
127+
for (const r of rows) {
128+
expect(STUDIO_MENU_PLACEMENT.find((row) => row.type === r.type)?.tier, `${r.type}: placement row`).toBe(r.tier);
129+
}
130+
});
131+
132+
it("every ADR row's group is the type's served domain", () => {
133+
for (const r of rows) expect(DOMAIN_OF.get(r.type), r.type).toBe(r.domain);
134+
});
135+
136+
it("inside each group, the list's order is the ADR's Order column", () => {
137+
for (const domain of new Set(rows.map((r) => r.domain))) {
138+
const adr = rows.filter((r) => r.domain === domain).sort((a, b) => a.order - b.order).map((r) => r.type);
139+
const list = STUDIO_MENU_PLACEMENT.filter((row) => DOMAIN_OF.get(row.type) === domain).map((row) => row.type);
140+
expect(list, `group ${domain}`).toEqual(adr);
141+
}
142+
});
143+
});
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* Where each metadata type sits in Studio's left menu: its order and its tier
5+
* (objectstack ADR-0084; epic #36890, ruling on #37192).
6+
*
7+
* One ordered list of `{ type, tier }`. It holds order and tier ONLY: a type's
8+
* group stays its served registry `domain`, so this table can never disagree
9+
* with the registry about a group.
10+
*
11+
* ## Tiers
12+
*
13+
* - `common` (常用): always listed on a package, in this order — object ·
14+
* app, page, dashboard, report · flow · permission · agent, tool, skill.
15+
* The AI group is drawn last of the visible groups, above the fold.
16+
* - `advanced` (高级): every other type the directory lists, in one collapsed
17+
* fold under the common groups, still under its own group label. That
18+
* includes picklist (选项列表) and email template.
19+
*
20+
* A type with no row here is drawn in `advanced`, at the end of its group. It
21+
* is never invisible; the menu applies that rule when it reads this list.
22+
*
23+
* ## Order
24+
*
25+
* A consumer sorts the entries of one group, within one tier, by the row's
26+
* index in {@link STUDIO_MENU_PLACEMENT}. The common rows come first, in the
27+
* ruled order; the advanced rows follow in the proposal's order, group by
28+
* group.
29+
*
30+
* ## Pins
31+
*
32+
* `studioMenuPlacement.test.ts` holds this list against
33+
* `DEFAULT_METADATA_TYPE_REGISTRY`: every type the directory can list has
34+
* exactly one row, and every row names a registered type. Nothing reads the
35+
* list yet; the menu reads it once `buildStudioMenu` orders by it.
36+
*/
37+
38+
/** A type's tier in Studio's left menu. */
39+
export type StudioMenuTier = 'common' | 'advanced';
40+
41+
/** One row: a metadata type and its tier. Its position in the list is its order. */
42+
export interface StudioMenuPlacementRow {
43+
readonly type: string;
44+
readonly tier: StudioMenuTier;
45+
}
46+
47+
/** Every listable metadata type, in menu order, with its tier. */
48+
export const STUDIO_MENU_PLACEMENT: readonly StudioMenuPlacementRow[] = Object.freeze([
49+
// 常用 — in the ruled order.
50+
{ type: 'object', tier: 'common' },
51+
{ type: 'app', tier: 'common' },
52+
{ type: 'page', tier: 'common' },
53+
{ type: 'dashboard', tier: 'common' },
54+
{ type: 'report', tier: 'common' },
55+
{ type: 'flow', tier: 'common' },
56+
{ type: 'permission', tier: 'common' },
57+
{ type: 'agent', tier: 'common' },
58+
{ type: 'tool', tier: 'common' },
59+
{ type: 'skill', tier: 'common' },
60+
// 高级 — data
61+
{ type: 'picklist', tier: 'advanced' },
62+
{ type: 'hook', tier: 'advanced' },
63+
{ type: 'mapping', tier: 'advanced' },
64+
{ type: 'object_extension', tier: 'advanced' },
65+
{ type: 'seed', tier: 'advanced' },
66+
// 高级 — ui
67+
{ type: 'view', tier: 'advanced' },
68+
{ type: 'action', tier: 'advanced' },
69+
{ type: 'dataset', tier: 'advanced' },
70+
// 高级 — automation
71+
{ type: 'job', tier: 'advanced' },
72+
// 高级 — system (平台)
73+
{ type: 'doc', tier: 'advanced' },
74+
{ type: 'book', tier: 'advanced' },
75+
{ type: 'email_template', tier: 'advanced' },
76+
{ type: 'translation', tier: 'advanced' },
77+
{ type: 'api', tier: 'advanced' },
78+
{ type: 'datasource', tier: 'advanced' },
79+
{ type: 'external_catalog', tier: 'advanced' },
80+
// 高级 — security (访问)
81+
{ type: 'position', tier: 'advanced' },
82+
{ type: 'assignment_rule', tier: 'advanced' },
83+
{ type: 'sharing_rule', tier: 'advanced' },
84+
{ type: 'queue', tier: 'advanced' },
85+
{ type: 'capability', tier: 'advanced' },
86+
// 高级 — ai
87+
{ type: 'ai_context', tier: 'advanced' },
88+
] as const satisfies readonly StudioMenuPlacementRow[]);

0 commit comments

Comments
 (0)