Repository navigation
Commit 4af32b9
feat(app-shell): Ask AI opens a new conversation after the user's own close, and the drawer header names the conversation (#37970)
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoK5FfvaJPRjBoGxoAHny6iN)_
Fixes #37860
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:所有用户点「问
AI」时,如果上次是自己关掉的助手(或这个标签页第一次打开),就开一个新会话,旧会话留在历史里;手机上点答案里的链接被自动收起、或有待确认的写入时,仍回到原会话。抽屉顶部改为会话标题、+、历史图标、⋯、×。
- 为什么做:「问 AI」入口改造专题的第四张卡,解决从别的记录再问时落进上一个旧会话、问题被混在一起的问题。
-
出错会怎样:最坏是本该续上的会话开成了新会话(或反过来),用户可从历史里点回原会话,不丢数据;没发消息前不会产生空会话。直接撤回这次改动即恢复原样。
- 要你做什么:无。
## What changes
Implements every row of ui ADR-0057 Amendment A5's open-type table (as
merged, `bc173343`). Where the card's text and A5 differ, A5 wins (claim
7218853868).
1. **Who closed the drawer is recorded.** `useConsoleChatDock` writes
one per-tab record at each close (sessionStorage, module copy when
storage throws): `by: user` for ×, the entry or the keyboard toggle
again, and dismissing the phone sheet; `by: console` for the phone
sheet's PUSH/POP collapse (objectstack#37556) and the A4 ask-page
collapse; plus the conversation the body showed then
(`onShownConversationChange`, reported by `ChatDockConversation`).
2. **An opening from the entry** (`openEntry` on the dock handle; the
top bar's 「Ask AI」 toggle, the keyboard toggle, Home's 「Ask AI」 through
`useAskAiEntry`, and the record pane's button) reads that record through
the pure `entryOpening`:
- row 1 / row 4: after the user's close, or with no record (first
opening in the tab) → a new conversation, target `{ agent?, fresh: true
}`, which reaches `useChatConversation` as `forceNew` only (never
`resumeMode: 'fresh'`), so no row exists until the first send;
- row 2: after the console's close → the same conversation;
- row 3: a write awaiting this user's approval in the conversation shown
at the close → that conversation (read off the assistant bus with
`isApprovalPendingIn`);
- row 8: a build thread (a target naming `build` or a package, or
`app.defaultAgent: 'build'` with no target agent) → as before;
- rows 5, 6, 7, 9 are untouched: `open(target)`, a reload, the bus's
`requestAssistantOpen`, filling the window.
An entry that names an agent (Home's `ask`) keeps the closed thread only
when it is that agent's.
3. **Write approvals reach the bus** (A5's "Not recorded yet" bullet).
`ChatPane` counts the tool calls the framework parked as pending actions
(`approval-requested` with a `pendingActionId`) that have no decision,
or a failed one, in the chat (`countWritesAwaitingApproval`), and
publishes the count per conversation with `publishPlanApprovalPending`.
The reading outlives the pane, as the bus intends.
4. **The header row**, the same in the rail, the full window and the
phone sheet: the conversation's label on the left as its history row
reads it (server title, else the latest user message:
`useConversationLabel`, the list's own `normalize` on the detail read;
the first message stands in until the server answers), "New
conversation" (`console.ai.newConversation`, the history list's own
fallback) before the first send, nothing while an existing label is
read. Right: + (the body's new-conversation action), the history as an
icon button with `aria-pressed` and both names (rail and sheet only; the
full window keeps the column), ⋯ unchanged, × (the sheet keeps its own ✕
last). No ☆ (C8).
5. **C3's hand-over items.** The record pane's and the record drawer
stack's `record-pane-open-assistant` button reads 「Ask AI」
(`home.askAI`) with the chat-bubble icon and opens as the entry does.
The drawer is no longer titled "AI Assistant"; the objectstack#34827 pin
now pins the new rule.
No new i18n key: the title and + reuse `console.ai.newConversation`, the
history button keeps `console.ai.dock.history` / `backToChat`.
## Tests
- `useConsoleChatDock.phoneCollapseOnNavigate-37556.test.tsx`, new
top-level describe (the hook's shared harness): A5 rows 1 (first
opening; ×; entry and keyboard closes; sheet dismissal), 2, 3 (and its
control: another conversation, another user), 5, 6 (reload is no
opening; the record survives a reload), 7, 8 (defaultAgent build; a
build target with a package), Home's 「Ask AI」 after a build thread, and
with the drawer open. The stand-ins now report the shown conversation
and offer × and dismissal.
- `ChatDock.test.tsx`, new describe: the header row in rail / full /
sheet, the label, "New conversation", nothing while pending, the history
icon's pressed state and names, + calling the body's action and closing
the history.
- `ChatDock.titleMatchesTopBar-34827.test.tsx` rewritten to "drawer
title = the conversation's label, 「新对话」 / "New conversation" before the
first send", real packs, every built-in pack.
- `writeApprovalPending-37860.test.tsx`: real hydration of stored rows
and the real `useHitlInChat` decisions → pending, cleared by an
approval, kept by a failed one; control with no parked write.
- `AiChatPage.toolLabelsLocale-11667.test.tsx`, new describe: the real
`ChatPane` publishes the pending write for its conversation and clears
it after the user's reject.
- `recordDrawerAssistant-36998.test.tsx`,
`ObjectDataPage.openRule-35875.test.tsx`: the pane button's name is 「Ask
AI」 and its click is an entry opening.
Ablation (on disk, restored from the commit): every entry opening forced
to `same` → 7 of 30 cases in the hook harness red (all row-1 cases, the
row-3 control, row 6, Home's entry). `ChatPane` publishing `pending:
false` → the pane pin red (1 of 3).
<details><summary>Readings</summary>
- Related suite at `db93e901` + tests (every ui test file naming
ChatDock, useConsoleChatDock, AssistantTopBarButton,
ChatPane/AiChatPage, Console/Home layout, HomePage, the conversation
list or sidebar, recordDrawerStack, ObjectDataPage, assistantBus,
chatDockControl, DocsPortalShell): 327 files / 3893 tests passed.
- After the last source change (`5d407804`): every ui test file naming
ChatDock or useConsoleChatDock, 28 files / 305 tests passed.
- `pnpm --filter @object-ui/app-shell run type-check` (src and
`tsconfig.test.json`): exit 0, after building the dependency closure.
- eslint on the changed files: 0 errors; no new warning on the changed
lines.
- `overlap-check.mjs` before the first push: clean against main, #37924
(shares `ChatDockConversation.tsx`) and #37940 (shares
`useConversationList.ts`).
</details>
## Acceptance notes
- **zh title wording.** C3's note said 「新会话」; A5 says the header reads
the history row's label and "New conversation" before the first send.
The history list's own fallback is `console.ai.newConversation`, which
reads 「新对话」 in zh-Hans, so the header reads 「新对话」. No pack changed.
- **The amber marker now also lights for a pending write.** Write
approvals reach the bus that the entry's marker (and Studio's 「N 项待确认」
count) read. Its description, `console.ai.dock.planAwaitingApproval`,
now reads "An action is waiting for your approval" (「有一项操作等待确认」) in all
eleven packs, with the key unchanged. That was L1-c's R1 (7220360349),
fixed at `12ae1bed`.
- **The record pane's button stays an icon** in the pane's top bar (the
bar's own button shape), named 「Ask AI」 with the chat-bubble icon, not
the outlined text button of the page header.
- **Home's 「Ask AI」 with the drawer already open** is no opening; it
opens on the `ask` agent as before.
- **Label read.** The header reads the shown conversation's detail once
per open and after each send (the same refresh cadence as the history
list). That is a second read of a conversation the body already
hydrates.
- **Reload limits.** The approval reading lives in the page's memory
(A5: "in the page's memory only"); after a reload, row 3 holds again
once the chat is next mounted on that conversation.
- **File surface.** Three files outside the claim's first glob, added to
the claim by the seat (7218893089): `views/ObjectDataPage.tsx`,
`views/recordDrawerStack.tsx`, `console/ai/ChatPane.tsx`. Plus
`assistant/writeApprovalPending.ts` (new, inside the glob).
- Ships in the same release as C5 (objectstack#37861), per the card.
## Verification
Read first, by risk:
1. `ui/packages/app-shell/src/layout/useConsoleChatDock.tsx`:
`entryOpening`, `openEntry`, `closeBy` and which close paths call it.
2. `ui/packages/app-shell/src/layout/ChatDockConversation.tsx`: the
shown-conversation report and the header actions.
3. `ui/packages/app-shell/src/console/ai/ChatPane.tsx`: the bus publish
effect.
Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/useConsoleChatDock.phoneCollapseOnNavigate-37556.test.tsx`.
Expected: 30 passed. In the Console: open 「问 AI」, send a message, close
with ×, click 「问 AI」 again: the header reads 「新对话」 and the old thread is
in history.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibzv3KSUSav5J2uw97s)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ecd10e9 commit 4af32b9
33 files changed
Lines changed: 1098 additions & 168 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- assistant
- __tests__
- console/ai
- __tests__
- hooks
- layout
- __tests__
- views
- __tests__
- i18n/src/locales
| 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 | + | |
| 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 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
252 | 264 | | |
253 | 265 | | |
254 | 266 | | |
| |||
| 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 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
422 | 425 | | |
423 | 426 | | |
424 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
425 | 445 | | |
426 | 446 | | |
427 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
72 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
0 commit comments