Skip to content

Commit 8361dfc

Browse files
feat(app-shell): the design layout menu adds the app's AI inquiry page, and 「Set as home」 moves it first (#37934)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D3PqTGGb1rgoRqKj4rT4Xjk)_ Fixes #37832 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:应用管理员在「设计布局」里添加菜单项时,多了一种「AI 问询」;填好欢迎标题、副标题、输入框提示和推荐问题即可放进菜单,菜单项的「⋮」里还能再改文案、点「设为首页」把它挪到菜单第一位。 - 为什么做:属于「AI 问询首页」专区,让搭应用的人不进 Studio、不写元数据就能把问询页放进应用并设成首页。 - 出错会怎样:最坏是管理员加了问询页却没成为首页,或文案没生效;保存前能看到菜单,保存后可在设计布局里再移除或挪位,直接撤回。 - 要你做什么:无。 ## What changes `ui/packages/app-shell/src/layout/` (the design mode's menu editor): - **Picker kind 「AI inquiry」.** `MENU_TARGET_KINDS` gains `aiChat`. Like 「Link」 it lists nothing: a small form takes the entry's name (default "Ask AI") and the page's copy, heading / subtitle / question-box hint / suggested questions (one per line). The entry written is `{ id, type: 'component', label, icon: 'sparkles', componentRef: 'ai:chat', params? }` (`entryFor`'s new `aiChat` branch), the shape ui ADR-0057 Amendment A4 decided. - **Singleton.** `aiChatOffered(menu, served, stored)` hides the kind while the staged menu holds an `ai:chat` entry at any depth, or the stored menu holds one the reader was not shown (the save keeps that one). Removing the shown one in the mode offers the kind again. Until the stored menu is read the kind is not offered. This is the picker's agreement with the spec's `checkAppSingleAiChatEntry`. - **Form = schema.** `aiChatParamsOf(form)` trims each field, leaves an empty one out (the page then draws its default), takes the non-empty lines as suggestions, and judges the result with `AiChatNavParamsSchema.safeParse`. A refusal is said under its field and the form cannot be sent. Every field empty writes no `params`. - **The entry's 「⋮」.** 「Edit inquiry page」 opens the same form over the stored copy (`aiChatFormOf`, which fills only from a record the schema takes). 「Set as home」 is `asHome`: `moveEntry(menu, id, null, 0)`, the first place of the top level, and nothing else. No `landing` is written. - **Save.** Unchanged: `saveAppMenu` writes the app's own package when writable, else its `.custom` pair, and publishes. - `ui/packages/i18n`: twelve new `designMode.menu.*` strings (one under `kind`) in the eleven locales that carry this block. ## Tests `ui/packages/app-shell/src/layout/__tests__/designModeMenuAiChat-37832.test.ts`, one `describe` per acceptance line: - the entry `entryFor('aiChat', …)` adds is one `AppSchema` takes; - singleton: offered on an app with none; not offered with one at the top level, nested in a group, or stored but not shown; offered again after the shown one is removed; and the spec refuses the second entry the picker would have added (`navigation.2`); - the form refuses each bound `AiChatNavParamsSchema` refuses (heading 61, subtitle 201, hint 101, five suggestions, a 101-character suggestion), and the schema refuses the same copy; it takes copy at each bound; all empty writes no `params`; - 「Set as home」 moves the entry out of its group to the top level's first place, and the save writes the new order with no `landing` key; - an installed app: the entry is saved into `com.acme.crm.custom`, published there, with no audience keys, and the saved document passes `AppSchema`. The rendered pins are in the shared harness `DesignModeMenu-36363.test.tsx` (ruling record 6583487846): one new top-level `describe` there. Existing cases are not edited. It pins that the picker offers 「AI inquiry」 on an app with no `ai:chat` entry, adds one through the form and then leaves the kind out; that it leaves the kind out when one is nested in a group; that the entry's 「⋮」 shows 「Edit inquiry page」 and 「Set as home」 while another entry's shows neither; and that 「Set as home」 moves the entry out of its group to the first place and the save writes no `landing`. Ablations of the singleton rule and of the picker filter: see Verification. ## Acceptance notes - 「Set as home」 only reorders, so on an app that declares `landing` it does not change where those audiences land: a declared `landing` outranks position (ADR-0057 A4 "Home"). The action's copy does not say so; this is kept as a note and the behaviour is unchanged. - The editor mounts only for an app without `areas` (`UnifiedSidebar`), so `aiChatOffered` reads `navigation`. The spec's rule also counts `areas[].navigation`. ## Verification Two-minute check: run `pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/designModeMenuAiChat-37832.test.ts`. Expect every test to pass. Or, in the console, open 「Design layout」 on an app with no AI inquiry page and click 「Add menu item」. The kinds list 「AI inquiry」. Add one and the kind is gone from the next picker. Read first, ordered by risk: 1. `designModeMenuModel.ts`: `aiChatOffered` (the stored-but-not-shown branch). 2. `DesignModeMenu.tsx`: `AiChatCopyForm` (validation and the disabled submit). 3. `designModeMenuModel.ts`: `aiChatParamsOf` (the trimming and empty-field rules). Readings at head `2943fb41` (objectstack-ai/objectstack, merge base `ff63b02b4`), for the harness pins this head adds; the readings for `0d1358c7` follow. <details><summary>Harness pins, ablation and type-check (head 2943fb4)</summary> - `pnpm --dir ui exec vitest run --maxWorkers=2` over `DesignModeMenu-36363.test.tsx` and `designModeMenuAiChat-37832.test.ts`: Test Files 2 passed (2), Tests 79 passed (79); lock VERDICT command-exit 0. - Ablation of the picker filter: the `MENU_TARGET_KINDS` filter on `aiChatOffered` was removed on disk and the committed tree restored afterwards. The harness went red: Tests 2 failed, 60 passed ("offers 「AI inquiry」 while the menu holds no `ai:chat` entry, and leaves it out once one is added" and "leaves 「AI inquiry」 out when the app already holds one, nested in a group"). After the restore: green, as above. - `pnpm --filter @object-ui/app-shell run type-check` (both programs): VERDICT command-exit 0. - Gates derived for this head's path (`dispatch-gates --commands` given the harness file): 27 commands. All 26 `node`/`pnpm check:*` commands exited 0, and `pnpm --dir ui exec vitest run scripts/` gave Test Files 172 passed, 2 skipped (VERDICT command-exit 0). `pnpm --dir ui run check:new-line-citations`: 0 new citations. </details> <details><summary>Tests and type-check (app-shell, i18n), head 0d1358c</summary> - `pnpm --dir ui exec vitest run --maxWorkers=2` over the new file and the six existing design-mode menu files: Test Files 7 passed (7), Tests 187 passed (187); lock VERDICT command-exit 0. - `pnpm --filter @object-ui/app-shell run type-check`: VERDICT command-exit 0. - `pnpm --dir ui exec vitest run packages/i18n/` and `pnpm --filter @object-ui/i18n run type-check`: Test Files 107 passed (107), Tests 1867 passed, 13 skipped; VERDICT command-exit 0. The first run was red on `zh-hant-generated.test.ts` (zh-Hant is generated from zh-Hans); `gen:zh-hant` regenerated it, commit `0d1358c7`. - Ablation of the singleton rule: deleting the staged-menu line in `aiChatOffered` turned the new file red (Tests 2 failed, 15 passed). After the restore: green. </details> <details><summary>Gate families, head 0d1358c</summary> - 40 derived `node`/`pnpm check:*` commands each exited 0. `pnpm --dir ui exec vitest run scripts/`: Test Files 172 passed, 2 skipped. - `dispatch-gates --ran`: 41 derived, 41 run, 0 NOT-MEASURED, 0 UNRUN. - Type-check lanes, artifact rosters and repo-wide scans are CI's. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cwGVgec21LwQTtRY85 <!-- signed: repo:objectstack#1 · os-elon-musk · session_016WV4cwGVgec21LwQTtRY85 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5b32625 commit 8361dfc

16 files changed

Lines changed: 820 additions & 12 deletions

File tree

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(app-shell): 「Design layout」's menu adds the app's AI inquiry page, and 「Set as home」 makes it the app's home
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The design mode's menu picker gains 「AI inquiry」, which adds the app's AI inquiry page: a `type: 'component'` navigation entry whose `componentRef` is `ai:chat`. Like 「Link」 it lists nothing. A small form takes the entry's name and the page's copy (heading, subtitle, question-box hint, and up to four suggested questions, one per line); a field left empty keeps the page's default text. The form refuses, under the field, what `AiChatNavParamsSchema` refuses, and cannot be sent until it is mended. An app carries at most one such entry, so the kind is not offered once the app has one, nested in a group included, or when its stored menu holds one the reader is not shown.
12+
13+
That entry's 「⋮」 menu gains 「Edit inquiry page」, which edits the same copy again, and 「Set as home」, which moves the entry to the first place of the top level. The home follows the app's existing landing rule: a declared `landing` comes first; with none, from 768 px up the first entry shown lands; below 768 px the app root is the app's menu, where the entry becomes its first row. So the move is the whole edit: no `landing` is written, and an app that declares `landing` keeps landing where it declares.
14+
15+
The entry is saved like every other menu edit: into the app's own package when it is writable, else into its customization package, and published at once. Who sees it is set in Studio, as for every entry. `@object-ui/i18n` carries the new strings in all eleven locales.
16+
17+
Nothing to migrate.

0 commit comments

Comments
 (0)