Skip to content

Commit 83a79e6

Browse files
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
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/plugin-chatbot': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
fix(app-shell, plugin-chatbot): the AI panel in an app has one title row, and its composer reads cleanly
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
The console's AI drawer title bar is one row: History, a 「···」 menu and a 「×」 Close. The menu holds the AI usage reading (with its upgrade or top-up entry when the pool runs low), Share, Expand / Restore side panel, and the Build Doctor. The Build Doctor is listed only for a user who may build (`manage_metadata`, the reading that already decides who gets the build composer). While the usage pool is running low or full, the 「···」 trigger carries a marker. The close button is the drawer 「×」, named Close, in both the side panel and the full window; closing still keeps the conversation for the next open. The phone sheet gets the same menu, without Expand.
13+
14+
The pane row under the title keeps the agent label and the app chip, but no longer draws Share or the Build Doctor in the drawer. `ChatPane` gains `actionsInHost` for a host that offers them itself. The full-page chat and the Studio copilot are unchanged.
15+
16+
In the composer:
17+
18+
- the 「正在看」 chip sits on the input's top edge, inside its frame;
19+
- the closed model picker shows the model's label alone, truncated, with the full label on its title (no provider, no `×N`). The list rows keep both;
20+
- the 「↵ 发送 · Shift+↵ 换行」 hint stays on one line;
21+
- the 「+」 attachment button and its menu item are named "Add attachment" (「添加附件」).
22+
23+
An answer table's copy and download tools are named in the reader's language (「复制表格」, 「下载表格」 and their format variants) instead of streamdown's English defaults.
24+
25+
New locale keys, in every pack: `console.ai.dock.close`, `console.ai.dock.more`, `chatbot.composer.addAttachment`, `chatbot.answer.copyTable`, `copyTableAsMarkdown`, `copyTableAsCsv`, `copyTableAsTsv`, `downloadTable`, `downloadTableAsCsv`, `downloadTableAsMarkdown`. The drawer no longer reads `console.ai.dock.collapse`.

‎ui/packages/app-shell/src/console/ai/AiChatPage.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,13 @@ interface ChatPaneProps {
17911791
* @default false
17921792
*/
17931793
hideHeader?: boolean;
1794+
/**
1795+
* objectstack#35445 — the host offers Share and the Build Doctor in its own
1796+
* title bar (the console drawer's 「···」 menu), so the pane's header row
1797+
* draws neither. The rest of the row (the agent switcher, the app chip) stays.
1798+
* @default false
1799+
*/
1800+
actionsInHost?: boolean;
17941801
}
17951802

17961803
export function ChatPane({
@@ -1821,6 +1828,7 @@ export function ChatPane({
18211828
onDebug,
18221829
showDebug,
18231830
hideHeader = false,
1831+
actionsInHost = false,
18241832
}: ChatPaneProps) {
18251833
const { t, language } = useObjectTranslation();
18261834
const navigate = useNavigate();
@@ -2860,6 +2868,7 @@ export function ChatPane({
28602868
</DropdownMenu>
28612869
) : null}
28622870
</div>
2871+
{actionsInHost ? null : (
28632872
<div className="flex shrink-0 items-center gap-1">
28642873
{showDebug && onDebug ? (
28652874
<Button
@@ -2888,6 +2897,7 @@ export function ChatPane({
28882897
<Share2 className="h-3.5 w-3.5" />
28892898
</Button>
28902899
</div>
2900+
)}
28912901
{agentsError ? (
28922902
<span
28932903
className="basis-full text-[10px] text-amber-700 dark:text-amber-400"

‎ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.modelCostMultiplier-33660.test.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,21 @@ describe.each([
191191
fireEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }));
192192
await waitFor(() => expect(screen.queryByRole('alertdialog')).toBeNull());
193193
trigger = await picker();
194-
expect(trigger.textContent).toMatch(/^Fast/);
194+
expect(trigger.textContent).toBe('Fast');
195195

196196
fireEvent.click((await open(trigger))[2]);
197197
dialog = await screen.findByRole('alertdialog');
198198
fireEvent.click(within(dialog).getByRole('button', { name: 'Switch model' }));
199199
await waitFor(() => expect(screen.queryByRole('alertdialog')).toBeNull());
200-
await waitFor(() => expect(multiplierOf(screen.getByRole('combobox', { name: 'Model' }))).toBe('×20'));
200+
// objectstack#35445 — the closed trigger names the model alone, so the switch reads off its name.
201+
await waitFor(() => expect(screen.getByRole('combobox', { name: 'Model' }).textContent).toBe('Expert'));
201202
});
202203

203204
it('CONTROL: a ×5 pick applies at once, with no dialog', async () => {
204205
mount();
205206
fireEvent.click((await open(await picker()))[1]);
206207
expect(screen.queryByRole('alertdialog')).toBeNull();
207-
await waitFor(() => expect(multiplierOf(screen.getByRole('combobox', { name: 'Model' }))).toBe('×5'));
208+
await waitFor(() => expect(screen.getByRole('combobox', { name: 'Model' }).textContent).toBe('Advanced'));
208209
});
209210

210211
it('the allowance note shows with usage served', async () => {

0 commit comments

Comments
 (0)