Repository navigation
Commit ab91323
feat(studio): a dashboard list's New opens the app's design mode on its dashboards (#37368)
Fixes #36907
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 管理员在 Studio
的仪表盘列表点「新建」,会直接打开对应应用,「设计布局」已开、「添加菜单项」停在仪表盘一栏;建好的仪表盘挂在菜单上并进入编辑,点 × 回到
Studio 列表;手机宽度不出现「新建」,包里没有可打开的应用时也不出现,并写明原因。
- 属于「Studio 重构」专题,落实你定的「新建跳到设计模式加菜单」,让新仪表盘不会游离在所有菜单之外。
- 出错时管理员在 Studio 里可能新建不了仪表盘,或进不了设计模式;已有仪表盘、报表和菜单不受影响,纯前端改动,可直接撤回。
- 无
## What changes
The Studio dashboard list's New now uses design mode's existing 「Add
menu item → New dashboard…」 flow (#36364), the maintainer's
「新建跳到设计模式加菜单」 (dashboard half). The report half (decision 13) is
unchanged.
**The arrival (`layout/designModeArrival.ts`,
`layout/useDesignModeArrival.ts`).** A second navigation-state arrival,
`designModeAddDashboard`, sits beside `designModeNewDashboard` and
carries the Studio list it came from. `ConsoleLayout` reads it once per
history entry through `useDesignModeArrival`. It first replaces the
entry without the arrival, so a reload or Back enters nothing. Then it
asks the mode to `enterOpening({ column: 'dashboard', studioReturn })`.
- ⛔ No URL enters design mode. The arrival rides navigation state only;
the landing address carries no `?studio=` and no mode.
- `enterOpening` is `enter` plus a one-shot "opening" held in the mode
store. Where `enter` refuses (an editor holds the mode out, PR #36848),
nothing is held and the mode's own `designMode.editorOpen` toast says
why. On a phone the arrival is cleared and nothing more happens.
- The held-out count moved from state to a ref. An editor that opens in
the same commit the arrival lands in is then still judged (pinned;
ablation A5c below). `enter()` keeps its zero-argument contract: a click
event is never an opening.
**`DesignModeMenu`** takes the opening once (`useDesignModeOpening`). It
opens the picker on 「Dashboards」 for an entry at the end of the top
level, as that level's 「Add menu item」 would. A dashboard created from
that picker navigates with `withStudioReturn(href, studioReturn)`, so
the dashboard page's existing × goes back to the Studio list
(`?studio=`). Closing that picker drops the return, and later adds are
plain.
**Studio (`StudioAreaAppOpen.tsx`, `studioAppEdit.ts`,
`StudioMetadataArea.tsx`).** `StudioAreaAppTarget` gains `{ kind:
'new-dashboard' }`. `AreaCreate` sends `dashboard/new` through it, under
the same condition the report leg uses (`!readOnly || pairCreate`). It
replaces the Studio address with `/apps/SEGMENT` (`appHomePath`) and the
arrival.
- The app comes from decision 6 via `studioAppCreateSegment`.
- The `.custom` pair leg from #37348 applies: a pair with no app of its
own reads its base's apps. That reading is factored into
`readStudioTargetApps`, which the item leg now shares too.
- With no app, or on a phone, the fallback is the area's own create, as
for a report.
**The list (`ResourceListPage.tsx`).** `useStudioDashboardNew` gates the
area's dashboard 新建 by the same reads. It never shows at phone width,
and it is not drawn while the apps are being read. With no target app
the header shows no 新建 and shows a `role="note"` reason instead
(`engine.list.dashboardNewNoApp`); the empty state says the same.
**Riders from seat 4's L1 on PR #37348.**
- N1: the `StudioAreaAppOpen-36906` test header now says a pair row
opens in the base's app.
- N2: this changeset carries a note on the #37237 entry: rule 1's menu
leg (the remembered app counts when its menu opens the item) applies on
the pair leg too.
Additive en and zh keys: `engine.list.dashboardNewNoApp` and
`engine.list.dashboardNewWiderScreen` (the phone empty state, from the
L1 S1 round) in the `studio` namespace (it is en/zh only). No server,
spec or route change.
## Read first
1. `ui/packages/app-shell/src/layout/useDesignModeArrival.ts`: the
consume-then-enter order. Risk: it navigates (replace) in the same
commit `AppRootLanding`'s redirect may navigate. Child effects run
first, so the landing redirect re-applies on the next render; see
Acceptance notes.
2. `ui/packages/app-shell/src/layout/designMode.tsx`: `enterWith` /
`enterOpening` / `takeOpening`, and `heldOut` moving to a ref.
3.
`ui/packages/app-shell/src/views/studio-design/StudioAreaAppOpen.tsx`:
the `new-dashboard` leg and `useStudioDashboardNew`.
## Tests
Pins, each with an ablation that turned it red (and restored
hash-verified through `scripts/ablation-replace.mjs`). Every file below
imports the subject from source, so no build or dist preflight applies:
| Pin | File (new top-level describe) | Ablation → red |
|:--|:--|:--|
| Studio 新建 lands in the target app, design mode open, dashboard column
open | `StudioAreaAppOpen-36906` (`dashboard list's New…`),
`DesignModeMenu-36363` (`the arrival…`) | A6 `AreaCreate` dashboard
branch off → 5 red; A1 `enterOpening` call removed → 6 red; A2 picker
kind `null` → 2 red |
| A created dashboard is in the menu and opens for editing, × back to
the list | `DesignModeMenu-36363` | A3 `withStudioReturn` dropped → 1
red |
| CONTROL: the report 新建 is unchanged | existing 36906 report-New tests
and pair report-New control; list control `CONTROL — the report list` |
(control: green under every ablation) |
| No 新建 at phone width | `ResourceListPage.pairCreate-36897` (`dashboard
list's 「新建」…`) | A8 phone read as false → 1 red |
| No 新建 without a target app, reason shown | same | A9 gate ignores
`no-app` → 3 red; A10 reason not drawn → 2 red |
| A refused `enter()` does nothing | `DesignModeMenu-36363` | A5 hold
ignored → 2 red; A5c render-time snapshot of the hold → the same-commit
pin red, the prior-editor pin green |
| The pair leg | `StudioAreaAppOpen-36906`,
`ResourceListPage.pairCreate-36897` | A7 pair leg off (Studio) → 2 red;
A7b (list) → 1 red |
| The arrival is consumed (reload / Back enter nothing) |
`DesignModeMenu-36363` | A4 replace removed → 4 red |
Moved by this change, and re-pinned rather than deleted:
- 36906's "a dashboard New is not this card" half is now the new
describe.
- 36906's "a dashboard made by the area's create … Back lands on the
list" runs at phone width, the one place the area's own dashboard create
is still reached from a list.
<details><summary>Local runs on the final head 6fbbdd9 (rebased on
d5ae7a4)</summary>
- `cd ui && npx vitest run --maxWorkers=2` over the 4 pinned files
(`DesignModeMenu-36363`, `designMode-36362`, `StudioAreaAppOpen-36906`,
`ResourceListPage.pairCreate-36897`) gave `Test Files 4 passed (4) ·
Tests 114 passed (114)` before the L1 S1 round. At the final head
`cc7bb340`, with the S1 and N2 pins added, the seat's L1 run over the
same files gives 119/119 passed.
- `pnpm --filter @object-ui/app-shell type-check` (both `tsconfig.json`
and `tsconfig.test.json`) gives lock `VERDICT command-exit 0`.
- The 156 app-shell/i18n test files that name a touched surface
(ResourceListPage, designMode, DesignModeMenu, StudioAreaAppOpen,
StudioMetadataArea, ConsoleLayout, studioAppEdit) were run on the
pre-rebase head `b0fc2e64`, giving `Test Files 156 passed (156) · Tests
1743 passed (1743)`. The rebase brought in one commit, #37347, which
touches none of this PR's files. The full app-shell suite (2,431 files)
is left to CI's `Test UI` (a declared narrowing).
- Gates derived by `node scripts/pm/dispatch-gates.mjs --commands`: all
38 commands exit 0, run on `b0fc2e64`.
- Pre-push gates on `6fbbdd9b`: `pnpm check:test-source-alias` exit 0,
`pnpm --dir ui check:i18n-keys` exit 0, `node
scripts/pm/overlap-check.mjs` gives `VERDICT clean exit 0`. It reports
one open PR, #37362, that shares the studio en/zh namespace files and
merges cleanly.
- In-flight branches, by `git merge-tree`:
- `claude/issue-37139-studio-package-menu` merges clean.
- `claude/issue-36909-studio-pillar-dead-code` merges clean. It shares
`StudioMetadataArea.tsx` with this PR, in different hunks.
</details>
<details><summary>Ablations (each through scripts/ablation-replace.mjs,
restored, git diff HEAD empty)</summary>
- A1: drop the `enterOpening` call in `useDesignModeArrival` →
`DesignModeMenu-36363`: 6 failed | 50 passed.
- A2: `setPickerKind(null)` → 2 failed.
- A3: navigate without `withStudioReturn` → 1 failed.
- A4: drop the consuming `navigate(..., { replace: true })` → 4 failed.
- A5: `if (false)` in place of the held-out check → 2 failed.
- A5b: a held-out getter that always reads 0 → 2 failed.
- A5c: judge the hold at render time (`heldOutAtRender`) → only "the
same refusal when the editor opens in the very commit the arrival lands
in" fails among this card's pins. The prior-editor pin stays green.
- A6: `AreaCreate`'s dashboard branch never taken →
`StudioAreaAppOpen-36906`: 5 failed | 22 passed.
- A7: pair leg off in `readNewDashboardSegment` → 2 failed. A7b (list) →
`ResourceListPage.pairCreate-36897`: 1 failed.
- A8: `useStudioDashboardNew` reads no phone → 1 failed.
- A9: `canCreate` ignores `dashboardNew` → 3 failed.
- A10: reason note not drawn → 2 failed.
</details>
## Acceptance notes
- **Double replace at the app root.** `useDesignModeArrival` replaces
the history entry it read, in the same commit `AppRootLanding` may
redirect to the app's landing. Child effects run first, so the landing
redirect re-applies on the next render. In the browser, the showcase
landed on its first page (`/page/showcase_capability_map`) with the mode
on and `history.state.usr === null`. A self-built app whose menu holds
only links stays on `/apps/ID`, with the same result.
- **An app whose menu is split into `areas`** keeps its plain menu under
design mode, because `UnifiedSidebar` draws the editor only when
`areas.length === 0`. That predates this PR. There the arrival enters
the mode but no picker opens. No example app uses `areas`. See the
report's open question.
- **The arrival does not repeat the 「Design layout」 door's own gate**
(`useStudioEntryGate` and the customization wall). The Studio list's 新建
is already gated by `canCreate` (`walled`, `pairCreate`), and the server
judges every write again.
- **The held-out count moved from state to a ref** (`designMode.tsx`).
Nothing rendered from it; `enter` is the only reader. The existing 36692
pins pass unchanged.
- **The pair leg is applied to the dashboard New only.** A pair's report
New still falls back to the area's own create, pinned as CONTROL per the
dispatch's "report 新建 unchanged". Whether it should gain the leg is in
the report's open questions.
- While the package's apps are being read, the list draws no 新建, so a
no-app package never flashes one.
## Verification
- Browser walk on the showcase stack: `pnpm dev -- --fresh -p 38461`
(seeded admin), and the Console from `ui/` sources via `pnpm --filter
@object-ui/console dev` on :5180 pointed at it. Driven with Playwright
from a scratch script, not committed.
- **Showcase** (`com.example.showcase`, a read-only code package; the
HotCRM shape): Studio › dashboard list › 新建 lands on
`/apps/com.example.showcase/page/showcase_capability_map` with the
Design layout bar and the 「Add menu item」 picker on Dashboards (「New
dashboard…」 first). The history entry's state was cleared.
- Create lands on
`/apps/com.example.showcase/dashboard/walk_showcase?studio=/studio/com.example.showcase/metadata/dashboard?package=com.example.showcase`
in its edit state, with the × drawn. The entry is in the menu, and the
dashboard was saved to `com.example.showcase.custom`.
- A reload of that page shows no design bar. × returns to the Studio
list.
- **Self-built** (`com.walk.selfbuilt`, created through `POST
/api/v1/packages` with one app `walk_app`): 新建 lands on
`/apps/com.walk.selfbuilt` with the bar and picker. Create opens
`/apps/com.walk.selfbuilt/dashboard/walk_selfbuilt?studio=…`, and the
dashboard was saved to `com.walk.selfbuilt`. × returns to the list.
- **No app** (`com.walk.noapp`): no 新建, and the note reads "A new
dashboard is made in an app's design mode, so that it hangs in a menu.
This package has no app to make it in."
- **Phone** (390 px): no 新建 and no note.
- Two-minute check: in Studio, open any package's Dashboards list and
press 新建. Expect the app with the purple Design layout bar and the 「Add
menu item」 dialog already on Dashboards.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYoLfUxK6MRhuSp7nAt)_
<!-- signed: repo:objectstack#4 · os-justin ·
session_01QSeKYkkwuF6UuFtu85Yd5H -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent db46566 commit ab91323
15 files changed
Lines changed: 966 additions & 91 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- layout
- __tests__
- views
- metadata-admin
- studio-design
- i18n/src/namespaces/studio
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
237 | 242 | | |
238 | 243 | | |
239 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| |||
144 | 151 | | |
145 | 152 | | |
146 | 153 | | |
147 | | - | |
| 154 | + | |
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
| |||
181 | 188 | | |
182 | 189 | | |
183 | 190 | | |
| 191 | + | |
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
| |||
452 | 460 | | |
453 | 461 | | |
454 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
455 | 485 | | |
456 | 486 | | |
457 | 487 | | |
458 | | - | |
| 488 | + | |
459 | 489 | | |
460 | 490 | | |
461 | 491 | | |
| |||
498 | 528 | | |
499 | 529 | | |
500 | 530 | | |
501 | | - | |
502 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
503 | 534 | | |
504 | 535 | | |
505 | 536 | | |
| |||
622 | 653 | | |
623 | 654 | | |
624 | 655 | | |
625 | | - | |
| 656 | + | |
| 657 | + | |
626 | 658 | | |
627 | 659 | | |
628 | 660 | | |
| |||
915 | 947 | | |
916 | 948 | | |
917 | 949 | | |
| 950 | + | |
918 | 951 | | |
919 | 952 | | |
920 | 953 | | |
921 | 954 | | |
922 | 955 | | |
923 | 956 | | |
924 | 957 | | |
| 958 | + | |
| 959 | + | |
925 | 960 | | |
926 | 961 | | |
927 | 962 | | |
| |||
930 | 965 | | |
931 | 966 | | |
932 | 967 | | |
933 | | - | |
| 968 | + | |
934 | 969 | | |
935 | 970 | | |
936 | 971 | | |
| |||
0 commit comments