Skip to content

fix(app-shell): a menu reordered in design mode is saved in the order the sidebar draws it - #36622

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-36591-design-menu-order
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-36591-design-menu-order

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #36591
Clause-②: no
Metadata-protocol: none

维护者速读

  • 管理员在运行界面的设计模式里调整菜单顺序(上移、下移、移到分组、在前后加一项、添加菜单项、拖动)并保存后,侧栏现在按设计模式里显示的顺序排列;以前在 AI 搭建、菜单项带排序号的应用里,保存成功却毫无变化,再进设计模式看到的顺序也和侧栏相反。
  • 属于「运行界面的设计模式」专题,替用 AI 搭建应用、要在应用里直接调菜单的管理员解决「改了不生效、也不报错」的问题。
  • 出错时,带排序号的应用保存菜单后侧栏顺序会和设计模式不一致;只影响菜单顺序,不丢菜单项,可以在设计模式里再调一次保存,或撤回本次合并恢复旧行为。
  • 无。

What changes

The sidebar sorts each level of an app's navigation by order (byNavOrder in @object-ui/layout: lower first, an absent order as 0, ties in array order). Design mode listed and saved the array as authored, so in an app whose entries carry order a move was saved and published and changed nothing on screen.

Route taken (the claim's Route, the card's first option): rewrite order on save, never drop it.

  • Display — design mode seeds its menu with every level put in the sidebar's order (inShownOrder in designModeMenuModel.ts, which sorts each level through inMenuOrder, the app-shell statement of the sidebar's rule; no new comparator). The menu reads the same in and out of the mode.
  • Save — saveAppMenu puts the stored menu in that same shown order before the edits are replayed on it (rebaseMenuEdits), then rewrites order on the result (withOrderRewritten): each level in which any entry carries order has every entry numbered 0, 1, … in the order design mode showed; group entries and each group's children are numbered per level. A level where no entry carries order is saved by array order and gains no key (HotCRM-shaped apps are unchanged).
  • Why 0..n-1: it is the smallest rule that makes byNavOrder draw exactly the array order (no ties are possible inside a renumbered level), it covers the mixed level the card names, and it is idempotent: a second save of the same menu writes the same numbers. Dropping order was rejected because it deletes authored keys from AI-built apps.
  • Why the stored menu is sorted first: the edits are replayed by place ("after the entry before it"), and the stored array of an order-carrying app is not in shown order. Without the sort an entry added at the end of [X(2), Y(1), Z(0)] lands after X in the array and is numbered between X and Y. A stored entry the reader was never shown (pruned) keeps its shown place among the rest.
  • rebaseMenuEdits and order: the editor never writes order, so the served and edited copies of an entry always agree on it and it is never a patch key; the stored value travels with the entry and is then rewritten. Nothing is treated as a conflict and nothing is dropped. Pinned by "a move up is written as order; a rename beside it writes its label, and order is never read as an edit".

Why #36363's tests did not catch it

Every fixture in the three #36363 test files authored its menu without order (HotCRM-shaped), where array order is the sidebar order. The save pins read the written navigation's array positions (navigation[1].children.map((c) => c.id)), and nothing drew the saved menu through the sidebar's renderer. Its acceptance line "上移并保存:顺序变了;刷新后还在" was therefore true of every fixture and false of the AI-built app the coordinator saved. The new pins draw what the save wrote through the real NavigationRenderer and compare it with what design mode showed, over menus that carry order.

Tests

Read first (by risk):

  1. ui/packages/app-shell/src/layout/designModeMenuSave.ts — the two lines around rebaseMenuEdits: the sort before the replay and the rewrite after the payload.
  2. ui/packages/app-shell/src/layout/designModeMenuModel.ts — inShownOrder and withOrderRewritten.
  3. ui/packages/app-shell/src/layout/DesignModeMenu.tsx — the served seed.

New pins, each a top-level describe in the existing shared harness of its subject (no new test files):

  • DesignModeMenu-36363.test.tsx · "the design-mode menu in the sidebar order (objectstack#36591)" — real DesignModeMenu + mode save, the sidebar read from a rendered NavigationRenderer (no sort written in the test): ordered app reads the same in design mode and in the sidebar; Move up on Contacts then Save → sidebar reads Contacts, Customers, …, and the saved app re-opens design mode in that order; Add an item after + Move to group → the sidebar places both where design mode showed them; CONTROL: an app with no order saves a move by array order and gains no order key; a mixed level reads as design mode after one save.
  • designModeMenuSave-36363.test.ts · "the save writes the order the editor showed as order (objectstack#36591)" — added at the end, move up with a rename beside it, a pruned entry, and the no-order control.
  • designModeMenuModel-36363.test.ts · "a level in the sidebar order, and that order written back as order (objectstack#36591)".
Runs (head f4425f4)
  • pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/layout/ → Test Files 155 passed (155), Tests 1247 passed (1247); lock VERDICT command-exit 0.
  • The three touched files alone → Test Files 3 passed (3), Tests 75 passed (75).
  • pnpm --filter @object-ui/app-shell type-check (both tsconfig.json and tsconfig.test.json) → lock VERDICT command-exit 0, after rebuilding the dependency closure the origin/main merge moved (a first run against the pre-merge dist reported RecordDetailView.tsx TS2322 from main's merged change; gone after the rebuild).
Ablation — the order rewrite removed

node scripts/ablation-replace.mjs --file ui/packages/app-shell/src/layout/designModeMenuSave.ts --anchor 'const nextNav = withOrderRewritten(navPayloadOf(rebased as unknown[]) as Menu);' --replacement 'const nextNav = navPayloadOf(rebased as unknown[]) as Menu; void withOrderRewritten;' over the three files:

  • ok mutation landed: anchor 1 -> 0, blob b319aa8229c4 -> fd40d9929ee0
  • Test Files 2 failed | 1 passed (3), Tests 6 failed | 69 passed (75) — red: the three order save pins, and in the render harness Move up, Add after + Move to group, and the mixed level. The two CONTROL pins (no order) and the display pin stay green, as they should.
  • ok restored: blob == HEAD (b319aa8229c4) and git diff HEAD is empty.

Acceptance notes

  • Renumbering rewrites authored values. Saving a menu whose level carries order writes consecutive numbers on every entry of that level (an authored 10, 20, 30 becomes 0, 1, 2), even when the save only renamed an entry. The order drawn is unchanged; the values are not preserved.
  • Another package's entries (navigationContributions) keep their own order. They are not in the stored menu, so they are not renumbered. One that carries no order keeps its place (it sorts as 0 right after the app's first entry, as design mode now shows it); one that carries its own order can sit in a different place relative to the renumbered entries than design mode showed. No live app was found with such a contribution; noted, not filed.
  • Two save rules for one key. Studio's nav canvas (AppNavCanvas moveItem) writes order on the moved entry only; design mode now renumbers the level. Both draw the order their editor showed; they differ in how many keys a save writes. Observation only.
  • Browser check: NOT MEASURED, reason: the worktree has no built runtime or Console (packages/console/dist absent), and a full build plus a seeded backend on this shared 4-core box was not taken on for this card; the sidebar half is measured instead by rendering the real NavigationRenderer over the written navigation.
  • Overlap: node scripts/pm/overlap-check.mjs exits 1 against feat(console): create a dashboard from the design mode's Add menu item #36606 (shares DesignModeMenu.tsx, designModeMenuSave.ts, conflicts in DesignModeMenu-36363.test.tsx); the seat sequenced this card first and feat(console): create a dashboard from the design mode's Add menu item #36606 rebases on it.

Verification

Two minutes: pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/DesignModeMenu-36363.test.tsx -t "sidebar order" — expect 5 passed, among them "「Move up」 on Contacts, saved: the sidebar reads Contacts, Customers, …".

Local gates: node scripts/pm/dispatch-gates.mjs --commands derived 38 commands for this diff; all 38 ran with exit 0 and --ran reconciles "38 run, 0 NOT-MEASURED". The ui/scripts vitest family was run with --maxWorkers=2 added (dispatch order). Families CI runs are read from this PR's check-runs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm

… differs from another only in case

`layout/DesignModeMenu.tsx` and `layout/designModeMenu.ts` were one module
name on a case-insensitive file system: the sidebar's lazy
`import('./DesignModeMenu.js')` resolved to the helper module there, the
app-shell build failed with TS1149 and design mode white-screened. The
helpers move to `designModeMenuModel.ts` (git mv), their test to
`designModeMenuModel-36363.test.ts`, and the three importers follow.

Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm
Co-authored-by: Claude <noreply@anthropic.com>
…asing' into claude/issue-36591-design-menu-order
…r alone would misplace them

Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm
Co-authored-by: Claude <noreply@anthropic.com>
…sign-menu-order

# Conflicts:
#	ui/packages/app-shell/src/layout/__tests__/designModeMenuSave-36363.test.ts
#	ui/packages/app-shell/src/layout/designModeMenuSave.ts
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 23, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Flake reading — PR #36622 @ f4425f4 · 2026-11-23T04:25Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Second red — PR #36622 @ f4425f4 · 2026-11-23T04:42Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

席位核对

ACCEPT — PR #36622 @ 78acf16 (head of record, full sha on the PR; main merged by the relay's update-branch onto f4425f4 after #36619's fix PR #36636 merged) · card #36591 · L1 first read by area s2-B (area order rule 9) · 2026-11-23T06:41Z · no contract review owed (Clause-②: no: no new export, no new key)

  • Shape: open, draft, base main; first line Fixes #36591, Clause-②: no, Metadata-protocol: none; no closing keyword near another card (l1-face.mjs --pr 36622 CLEAN).
  • Premise: held (claim 7090287287). The sidebar sorts each navigation level by order (byNavOrder); design mode listed and saved array order, so in an app whose entries carry order a saved move changed nothing on screen.
  • Scope: 7 files, 337+/6-: designModeMenuModel.ts (inShownOrder through the existing inMenuOrder; withOrderRewritten), designModeMenuSave.ts (sort the stored menu before rebaseMenuEdits, rewrite order after), DesignModeMenu.tsx (seed in shown order), three existing test files, one changeset. Not governed. The update-branch delta leaves the PR's own diff byte-identical (same 7 files, same stat).
  • Diff read: the route is the claim's (rewrite order, never drop it): a level where any entry carries order gets every entry numbered 0..n-1 in shown order, groups and their children per level; a level with no order is saved by array order and gains no key. order is never a patch key in the rebase, so nothing is read as a conflict or dropped.
  • Changeset read against the diff: matches; patch per Metadata-protocol: none.
  • Tests and gates: new pins in the three 设计模式(二)菜单编辑:添加已有的菜单项,上移下移、移到分组、移除、改名和图标 #36363 harnesses, the sidebar read from a rendered NavigationRenderer (move up, add after + move to group, mixed level, two no-order controls). Ablation (rewrite removed): 6 red, both controls and the display pin green; restore blob equal to HEAD. 38 of 38 derived gate families run, 0 NOT-MEASURED. Browser: NOT MEASURED (reason in the PR body; the sidebar half is measured through the real renderer). CI at 78acf16: 39 success, 13 skipped, 0 failing (the earlier head f4425f4 was red twice only on Test flake: DataPillar.panelHold-27629 'leaving the Actions tab keeps the hold' sometimes sees a save of the unparsable predicate (fails 1 in ~5–8 runs on main) #36619, readings 7091578823 and 7091810932; fixed by PR fix(studio): Save waits for the CEL verdict to reach the page before it reads the hold #36636).
  • Accepted deviations: renumbering rewrites authored values on any save of an order-carrying level (10, 20, 30 → 0, 1, 2); the drawn order is unchanged. Accepted as the card's chosen route.
  • Out of scope: navigationContributions from other packages keep their own order and are not renumbered (no live app found with one); Studio's AppNavCanvas writes order on the moved entry only. Both Acceptance notes, not filed.
  • Landing: non-governed, ≤3000 lines; K = 1 (<15) at this head ⇒ area lands it in this stroke; s2-C feat(console): create a dashboard from the design mode's Add menu item #36606 rebases on it after the merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 23, 2026 06:42
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 93d8921 Nov 23, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36591-design-menu-order branch November 23, 2026 07:02
247257110 pushed a commit to 247257110/objectstack that referenced this pull request Nov 23, 2026
objectstack-ai#36606)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi93yJM5eSHAibimwWb6xCgvP)_
Part of objectstack-ai#36364
Clause-②: yes (widening) — new `@object-ui/i18n` keys
(`designMode.menu.*` for the new picker row and name step,
`dashboard.noCards.*`), in all 11 locales; no spec, schema or public
export change
Metadata-protocol: none

repo:objectstack#2 · os-steve · session_01ADHkmPiTdmLxHXBjakSvJy

## 维护者速读

- 用户能看到什么变化:管理员在设计模式里「添加菜单项 →
仪表盘」,第一行是「新建仪表盘…」,填名称确定后,新仪表盘出现在占好的菜单位置,其他改动一起保存,然后直接进入它的编辑状态;没有卡片的仪表盘会显示「还没有卡片」。
- 为什么做:设计模式专题的第三张卡,让管理员不用进 Studio 就能在应用里新建仪表盘并挂到菜单上。
- 出错会怎样:菜单保存失败时,刚建的仪表盘会被删掉,设计模式保持打开并说明原因;中途取消什么都不写;可以直接撤回本次合并。
- 要你做什么:不用做什么。新建报表这一半席位已定(报表必须先选数据集和指标,改为从报表搭建页新建),等 objectstack-ai#36374 合并后另做。

## What changes

- The design-mode picker's Dashboards list starts with 「New dashboard…」
(`DesignModeMenu.tsx`). It asks for a name only. 「Cancel」 (or closing
the dialog) writes nothing and drops the held place.
- 「Create」 runs, in order (`designModeMenuCreate.ts`): every check of
the menu save first (`prepareAppMenuSave`, split out of `saveAppMenu`
unchanged in behaviour); the dashboard created empty (`{ name, label,
widgets: [] }`) and published in the menu's own package (the app's
package when listed writable, else its `.custom` pair via the ensure
door; ADR-0146 D2, objectstack-ai#35624 ruling C) through the existing confirmed-save
door `saveDashboardInPlace`; then the menu written and published with
the new entry in the held place and every other staged menu edit
(`writeAppMenu`). Where the menu cannot be saved, nothing is created: no
package-less fallback.
- A refused menu removes the dashboard again (the item DELETE with
`?package=`, measured on a live server: `Deleted dashboard ... it no
longer exists`). If that removal is refused too, the error says the
dashboard was left.
- The design mode gains `saveWith(key, change)` (`designMode.tsx`):
commit everything staged with one change in its key's place, never
staging it on its own, so a failed create leaves no half-written entry
staged for a later Save.
- The machine name is generated from the name (Chinese through pinyin),
and checked free on the server (`GET /meta/dashboard/:name`) so a create
never publishes over an existing dashboard.
- On success the mode is left and the page navigates to the dashboard
with a one-time navigation-state landing (`designModeArrival.ts`);
`DashboardView.tsx` opens its objectstack-ai#36372 edit state on that landing once the
Edit button is offered, and clears it.
- A dashboard with no cards now draws 「No cards yet」 instead of a blank
canvas (view mode only).
- **Not in this PR: 「New report…」.** The spec refuses a report without
`dataset` + `values`, and the server's draft save refuses it too
(`INVALID_METADATA`, measured), so a name-only report cannot be created.
The seat's premise correction on the card (comment 7090058961) settles
it: 「New report…」 opens the report builder (objectstack-ai#36374) in a create mode and
writes the report and its menu entry once a dataset and a measure are
picked; that half follows after objectstack-ai#36374 merges.

Branch name: this card thread's container pushes only to
`claude/project-thread-un7cwb`, so the `claude/issue-36364-*` spelling
the Duplicate Fix Guard looks for is not available; the card is objectstack-ai#36364
(claim comment 7088329990).

Overlap: touches `DashboardView.tsx`, which draft PR objectstack-ai#36461 also
touches; `overlap-check` reads both merging cleanly. This PR lands after
objectstack-ai#36461 per the claim.

## Tests

<details><summary>Unit and component tests (head 313b6bf)</summary>

Run from the repo root under `os-verify-lock`; vitest root `ui/`.

- Head `313b6bf8` merges `origin/main`, bringing objectstack-ai#36604 (the
`designModeMenu.ts` rename to `designModeMenuModel.ts`), objectstack-ai#36622
(objectstack-ai#36591's menu `order` rule) and objectstack-ai#36461. The one conflict, in
`DesignModeMenu-36363.test.tsx`, was resolved by keeping both sides:
this card's `server` mock, its reset and its describe, next to objectstack-ai#36591's
`servedNav` and its describe. Two imports were moved to the renamed
module (`designModeMenuCreate.ts` and its test); no file names the old
module any more. objectstack-ai#36591's `inShownOrder` / `withOrderRewritten`
auto-merged into `prepareAppMenuSave`, so the create path applies the
same rule. It is pinned by a new test: the new entry, held between two
entries of an `order`-carrying level, is saved as `[customer 0,
nav_item_1 1, contact 2, opportunity 3]`.
- At `313b6bf8`, after rebuilding the app-shell dependency closure
(`VERDICT command-exit 0`): `pnpm --dir ui exec vitest run
--maxWorkers=2 packages/app-shell/src/layout/ packages/i18n/` plus the 9
`packages/app-shell/src/views/DashboardView*.test.tsx` files gives `Test
Files 271 passed (271)`, `Tests 3301 passed | 13 skipped (3314)`,
`VERDICT command-exit 0`. This covers the 4 card files and every
layout/i18n/DashboardView test the merge touched.
- At `313b6bf8`: `designModeMenuCreate-36364.test.ts` alone gives `Tests
14 passed (14)`.
- At `313b6bf8`: `pnpm --dir ui --filter @object-ui/app-shell --filter
@object-ui/i18n run type-check` (both `tsc --noEmit` and
`tsconfig.test.json`) gives `VERDICT command-exit 0`, 0 `error TS`.
- Earlier, at `ab2257f4`: the i18n run plus the 4 card files gave 110
files and 2050 tests passing. At `0647077c`, a narrowed app-shell + i18n
run found 3 failures caused by this change: zh-Hant was not regenerated,
and the de quote count was 125 against 126. Both were fixed. The full
app-shell suite is left to CI's `Test` shards.
- New and extended pins:
- `designModeMenuCreate-36364.test.ts`: 14 tests (13, plus the `order`
pin).
- `DesignModeMenu-36363.test.tsx`: 4 tests (the create row, Cancel
writes nothing, the create-and-land flow, a refused menu).
  - `designMode-36362.test.tsx`: 3 tests for `saveWith`.
- `DashboardView.inPageEdit-36372.test.tsx`: 3 landing tests and 2
empty-state tests.

</details>

<details><summary>Ablations (one-shot, not kept)</summary>

- Removal of the created dashboard on a refused menu deleted
(`ablation-replace`, anchor 1 to 0, restored blob equals HEAD): 3 tests
red (`a refused menu removes the dashboard it was made for…`, `…cannot
be removed says the dashboard was left`, `a refused menu removes the new
dashboard; the mode, the held place and the other staged edits stay`).
- The dashboard created before the menu-save checks: 8 of 13 red in
`designModeMenuCreate-36364.test.ts`, every "nothing is created" case
among them. A first attempt of this leg was refused by the tool (the
replacement contained its own anchor) and ran no tests; the second
attempt is the reading above.

</details>

## Acceptance notes

- The card's first acceptance line names the group 「数据洞察」; the CRM
example's group is 「数据分析」, used for the screenshots.
- 「Members see an empty state」 was checked as the admin in view mode;
the empty-state branch has no role gate. A non-admin session was NOT
MEASURED.
- Test pins went into the existing harness files for the design mode,
the menu editor and the dashboard in-page edit (AGENTS.md: a new pin for
a component with a shared harness goes into that file), plus one new
file for the new module, `designModeMenuCreate-36364.test.ts`.

## Verification

Screenshots (live CRM example on a `--fresh` backend, console dev
server, zh-CN, deviceScaleFactor 2) are stored with the seat
(`objectstack-seat2/36364-shots/`): design mode; picker 「仪表盘」 with
「新建仪表盘…」 first; the name step; the new 「回款分析」 in its edit state, in the
held place under 数据分析; Cancel leaving nothing; the new dashboard in view
mode (「还没有卡片」); Studio 「界面」 listing the same 回款分析 in the app's
navigation. After the run: the dashboard is the only item of
`com.example.crm.custom`, the app's stored menu holds `nav_item_1:
hui_kuan_fenxi` under `group_analytics`, no draft is pending, and the
cancelled name has no item (404).

Read first: `ui/packages/app-shell/src/layout/designModeMenuCreate.ts`
(the order and the removal), `designMode.tsx` (`saveWith`'s drop rule
after a commit), `DashboardView.tsx` (the landing effect).

Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/designModeMenuCreate-36364.test.ts`
shows 14 passing.

<details><summary>Derived gates (head ab2257f)</summary>

- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 41 commands from the tree at commit
ab2257f. Each was run with stdin from /dev/null, and its exit code was
captured before any pipe. The two heavy commands ran under
`os-verify-lock`: `pnpm --dir ui exec vitest run scripts/` and `pnpm
check:type-check-debt`.
- All 41 exited 0. The reconciliation with `--ran` reads: `Run
reconciliation — 41 derived, 41 run, 0 NOT-MEASURED, 0 UNRUN.`
- The record is stored with the seat
(`objectstack-seat2/36364-gates-ran.txt`).
- Before the PR was opened, `overlap-check` gave `VERDICT clean exit 0`
against origin/main and the open PR heads.
- At `313b6bf8`, `dispatch-gates --commands` derives the same 41
commands as at `ab2257f4`. The merge brought no new gate family for the
touched paths, so the run above was not repeated. At push,
`overlap-check` against origin/main is clean; it conflicts with open PR
objectstack-ai#36629 on the serial de quote-count pin, and whichever lands second
rebumps it.
- CI families (lint farm, `Test` shards, `Test Core`) are left to this
PR's check-runs; none was rerun locally.

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmPiTdmLxHXBjakSvJy)_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmPiTdmLxHXBjakSvJy -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants