Repository navigation
Commit 83a79e6
fix(app-shell, plugin-chatbot): the AI panel in an app has one title row, and its composer reads cleanly (#35573)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg6v19uPsX6gX42G8tGcvvzb)_
Refs #35445
Fixes #35426
repo:objectstack#5 · os-bill · session_01Utp6CbSphdunq2aJq7ktuY
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户看到的变化:应用里的 AI
助手面板标题栏只剩一行「历史」「···」「×」,用量、分享、铺满、构建诊断收进「···」,只有能搭建的人看得到构建诊断;输入框上沿显示「正在看」,模型选择收起时不显示倍率,「+」读作「添加附件」,回答表格的复制、下载按钮用当前语言。
- 为什么:您看了面板说「很混乱」并按效果图立卡;右上角改成与抽屉一致的「×」是另一张已同意的卡。
-
如果判断错:只影响面板上按钮的位置和名称,不动数据和接口;最坏是某个按钮要多点一下才找到。去掉「构建」字样和「切换应用」要等云端的问数改动,本次没做。
- 需要您做的:一件待定,模型列表里的倍率是否也去掉(以前定过「选择时要看清倍数」),席位另卡请您裁决。
## What changes
**Drawer title bar (item 2 of #35445, and #35426).** The console AI
drawer's header is one row: History, a 「···」 menu, and Close.
- The 「···」 menu holds the AI usage reading, Share, Expand / Restore
side panel, and the Build Doctor. The usage reading reuses the
indicator's hook and words. While the pool is low, the menu also offers
the indicator's upgrade or top-up entry, and the trigger carries a
marker so the warning shows with the menu closed.
- The Build Doctor is listed only for a user who may build. The body now
reads it as the agent's `debug` capability AND `useCanAuthorMetadata()`,
the same reading that decides who gets the build composer. Before this
change, a business user whose app defaults to the build agent, or who
opened a build target, saw it.
- Close is the drawer 「×」, named 「关闭」 / Close, in both the rail and the
full window. Behaviour is unchanged: collapse, with the thread kept for
the next open.
- Share and the Build Doctor are no longer drawn in the pane row under
the title. `ChatDockConversation` reports what the menu needs
(`onActionsChange`: the conversation id, and whether the doctor is
offered). The share dialog and the doctor's drawer stay in the body,
opened through controlled props, the same way the history already is.
`ChatPane` gains `actionsInHost` for this. The full-page chat and the
Studio copilot do not pass it, so they are unchanged.
- The phone sheet gets the same menu, without Expand.
- Left exactly as it is, per the ruling zone: the pane row's 「构建」 agent
label and the app chip (「切换应用」). That is item 1, which ships with or
after cloud#4894.
**Answer tables (item 3).** The renderer is streamdown, wrapped by
`MessageResponse` in
`ui/packages/plugin-chatbot/src/elements/message.tsx`. Its copy and
download tools are icon buttons whose `title` is both tooltip and
accessible name. They now take their names from the locale packs
(`chatbot.answer.copyTable` / `downloadTable` and the five format
variants) instead of streamdown's English defaults.
**「正在看」 chip (item 4).** The chip is now the input frame's top row
(`PromptInputHeader`, `order-first`), inside the frame. Before this
change it sat above the frame.
**Composer (item 5).**
- The closed model picker shows the model's label alone, with no
provider and no `×N`. It is capped and truncated, with the full label on
its `title`.
- The key hint is `whitespace-nowrap` and `shrink-0`. The tools row is
`min-w-0`, so the picker gives way instead of the hint wrapping.
- The 「+」 attachment button and its menu item are named 「添加附件」 / Add
attachment (`chatbot.composer.addAttachment`).
New locale keys, all 11 packs: `console.ai.dock.close`,
`console.ai.dock.more`, `chatbot.composer.addAttachment`, and seven
`chatbot.answer.*Table*` keys.
## Tests
- `layout/__tests__/ChatDock.test.tsx`, new describe
(objectstack#35445):
- the rail header's controls are exactly History / More actions / Close;
- filled, they are More actions / Close;
- no usage, share, fill or doctor control outside the menu;
- Close is the lucide `x`;
- the menu lists Share / Expand / Build Doctor plus the usage block, and
opens the body's dialogs;
- the doctor is absent when the body withholds it;
- the low-pool marker shows, with a CONTROL where it does not;
- the phone sheet's menu.
- The two existing expand/restore cases now go through the menu.
- `layout/__tests__/ChatDock.appBinding-10926.test.tsx` (real body and
real `ChatPane`), new describe:
- the pane row keeps the app chip and draws no Share or doctor;
- a builder's Share and doctor are disabled until the first send creates
the thread, then enabled;
- a non-builder on a build thread gets no doctor, with a CONTROL for a
builder on the same target.
- `plugin-chatbot` pins:
- `ChatbotEnhanced.surfaceContextTitle-8219.test.tsx`: the chip is
inside the input frame, first, before the textarea, and not in the
message log.
- `ChatbotEnhanced.modelPicker-11865.test.tsx`: the 「+」 and its item are
named Add attachment; the hint is nowrap and shrink-0; the picker
truncates.
- `chatAnswerLayout-13032.test.tsx`: zh tool names are 复制表格 / 下载表格 with
no English left, an en CONTROL, and the table box is `overflow-x-auto`
inside `min-w-0` answer columns.
- Old pins updated: `ChatbotEnhanced.modelCostMultiplier-33660`,
inverted to "the trigger draws no multiplier and names the model alone".
`ChatbotEnhanced.modelPicker-11865` trigger text is now the label
without the provider. `AiChatPage.modelCostMultiplier-33660` reads the
switch off the trigger's name instead of its `×N`. The list-row `×N`
pins in both 33660 files are unchanged.
<details><summary>Suites and typecheck</summary>
Pre-merge, at `1aeec5a214` (then only a changeset commit before the
merge): `pnpm --dir ui exec vitest run --maxWorkers=2
packages/plugin-chatbot/ packages/i18n/ packages/app-shell/` gave `Test
Files 2540 passed | 1 skipped (2541)`, `Tests 24884 passed | 22 skipped
(24906)`, and the lock's `VERDICT command-exit 0`.
Post-merge, on the final head: the `type-check` of
`@object-ui/plugin-chatbot`, `@object-ui/i18n` and
`@object-ui/app-shell`, plus the scoped re-run (plugin-chatbot, i18n,
and app-shell's `layout/`, `console/ai/` and `views/studio-design/`).
The readings are below in Verification.
</details>
<details><summary>Ablations (each mutation proven on disk by
`scripts/ablation-replace.mjs`, then restored to the HEAD blob with an
empty `git diff HEAD`)</summary>
- Header pin: drop `actionsInHost={actionsInHost}` from the body.
Result: ✗ "the pane row under the title keeps the app chip and draws no
Share or Build Doctor of its own" (1 failed / 22).
- Header pin: Close becomes `full ? X : History`. Result: ✗ "the rail
draws History, 「···」 and Close, and nothing else; Close is the drawer
「×」…" (1 failed / 17).
- Build-permission gate: `&& canAuthorMetadata` becomes `&&
(canAuthorMetadata || true)`. Result: ✗ "a user who may not build never
sees the Build Doctor, even on a build thread" (1 failed / 23).
- Table pin: drop `...tableToolLabels,`. Result: ✗ "in Chinese the copy
and download tools are named 复制表格 / 下载表格, never in English" (1 failed /
36).
- The first attempt at three of these was refused by the tool: an empty
or too-common replacement means the count does not rise. Nothing ran
then. They were re-run with `--delete` and a distinctive replacement,
and the results are the ones listed above.
</details>
## Acceptance notes
**Findings on the older preview that no longer hold on `origin/main`.**
I re-read `origin/main` and measured with a scratch Vite page that
mounts the real `ChatDockPanel` and `ChatbotEnhanced` at 1167×762 with a
410 px drawer. The page was not committed.
- The answer table is not wider than the panel. Its wrapper spans x
784–1141 inside the drawer's 757–1167, and the table box scrolls inside
(`clientWidth` 337, `scrollWidth` 655, `overflow-x: auto`). The
coordinator's "x=1190" is the scrolled-off content of that box. The
English tool names did hold, and are fixed here.
- The 「正在看」 chip was already in flow above the input on `origin/main`,
not floating over the last line. It now sits inside the input's frame,
as figure 27 draws it.
- The two-line key hint and the unnamed 「+」 held, and are fixed.
**Held for a ruling (not done in this PR).**
1. *List rows keep `×N`.* The card asks the model list to replace `×N`
with a cost word. The multiplier display was set by a maintainer
condition for opening the paid model picker on production, quoted on
#33660 (triage comment 6889924748) from cloud#4536: 「只要选择时能够看清楚倍数」.
Figure 27, which the maintainer filed with 「立卡」, annotates only the
closed picker (「只显示档位名,不显示倍率」) and says nothing about the open list. I
found no ruling that lifts the condition for the moment of choice, so
this PR removes `×N` from the closed trigger only. The open list keeps
it, and so does the ×20 confirmation.
2. *The tier name alone (「快速」).* `AiModelsResponseSchema` gives a model
`id`, `label`, `default` and `costMultiplier`, and no tier. The label is
cloud-written: a tier word, " · ", then the vendor model name. Showing
「快速」 would need either a new spec key that cloud fills (a contract
change) or parsing the label at its first " · " (a consumer-side parse
that AGENTS.md's contract-first rule forbids). The trigger shows the
label, truncated, with the full text on its title.
**Other notes.**
- `console.ai.dock.collapse` is no longer read by the drawer. It is left
in the packs because this PR's file surface is new keys only, and
`check-i18n-dead-keys` is report-only.
- The usage reading in the menu shows status and percent. The popover's
reset countdown is not carried over; the standalone `AiUsageIndicator`,
still used by the Studio copilot, keeps it.
**Item 1 feasibility (asked on the card, read-only).** A sentence can be
re-sent into the target app's thread with existing code; no new
mechanism is needed:
- `ChatDockControl.open(target, handoff)` (`layout/chatDockControl.tsx`)
with `{ agent: 'build', packageId: X }` and `{ handoffPrompt }` holds
the handoff in memory (`useConsoleChatDock`).
- `dockTargetFollowsApp` (`layout/chatDockTarget.ts`) shows that target
in app X.
- `ChatDockConversation` seeds the prompt into `pendingFirstMessageRef`
stamped `targetAgentRoute: 'build'`.
- `useDeferredFirstSend` (`console/ai/AiChatPage.tsx`) sends it once the
pane's conversation id lands.
The limits: the handoff is in memory only (never URL or storage,
objectui#12493), so it survives in-app navigation but not a reload. It
targets the build agent, and the page still has to be navigated into X
by the caller. Prefill-only would need new code:
`useComposerDraftHandoff` carries an unsent draft only between panes of
the same host and endpoint.
## Verification
Final head `1b6dbff1bd` (`origin/main` `eed422ea24` merged). These are
the local readings on it; CI owns the full farm.
<details><summary>Typecheck and scoped tests on the final head</summary>
- `type-check` ran for `@object-ui/plugin-chatbot`, `@object-ui/i18n`
and `@object-ui/app-shell` (both tsconfigs), chained with `&&` ahead of
the run below.
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-chatbot/
packages/i18n/ packages/app-shell/src/layout/
packages/app-shell/src/console/ai/
packages/app-shell/src/views/studio-design/` gave `Test Files 754 passed
(754)`, `Tests 7203 passed | 13 skipped (7216)`, and the lock's `VERDICT
command-exit 0`.
- After the merge, the whole of app-shell was not re-run. The incoming
app-shell commits touch only record-detail, inbox-feed and
studio-landing views, none of the drawer or chat files. The pre-merge
full three-package run is above.
</details>
<details><summary>Derived gate families</summary>
`node scripts/pm/dispatch-gates.mjs --commands` named 40 families. All
were run locally, each `:: exit 0`. `--ran` reconciliation: `40 derived,
40 run, 0 NOT-MEASURED, 0 UNRUN` (a DERIVED zero). The 40 include `pnpm
--dir ui exec vitest run scripts/` (`Test Files 171 passed | 2
skipped`), `check:nul-bytes`, `check:published-files` and
`check:type-check-coverage`/`-debt`.
Also run under `ui/`, each exit 0: `check-i18n-call-site-keys.mjs`
(every call-site key resolves against the en pack, inline defaults
match), `check-new-cross-file-line-citations.mjs` (0 new), and
`check-i18n-en-drift.mjs` (no en value changed).
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbSphdunq2aJq7ktuY -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent bf69cb4 commit 83a79e6
25 files changed
Lines changed: 732 additions & 75 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- console/ai
- __tests__
- layout
- __tests__
- i18n/src/locales
- plugin-chatbot/src
- __tests__
- elements
| 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 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1791 | 1791 | | |
1792 | 1792 | | |
1793 | 1793 | | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
1794 | 1801 | | |
1795 | 1802 | | |
1796 | 1803 | | |
| |||
1821 | 1828 | | |
1822 | 1829 | | |
1823 | 1830 | | |
| 1831 | + | |
1824 | 1832 | | |
1825 | 1833 | | |
1826 | 1834 | | |
| |||
2860 | 2868 | | |
2861 | 2869 | | |
2862 | 2870 | | |
| 2871 | + | |
2863 | 2872 | | |
2864 | 2873 | | |
2865 | 2874 | | |
| |||
2888 | 2897 | | |
2889 | 2898 | | |
2890 | 2899 | | |
| 2900 | + | |
2891 | 2901 | | |
2892 | 2902 | | |
2893 | 2903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
207 | | - | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| |||
0 commit comments