Repository navigation
Commit e4a02be
feat(console): read the in-app pending_confirmation answer beside the stored pending_approval one (#38446)
Fixes #38322
Part of: #33806 (step 2 of 4, UI and SDK; step 1 merged as PR #38273)
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:用户无感。控制台聊天里待确认操作的审批卡片,今后服务端换成新的答复写法后照样出现;按旧写法保存的历史对话也照样出现,批准、拒绝都能用。
-
为什么做:这是「把应用内助手的待确认操作并入统一确认服务」四步中的第二步(界面与客户端),必须在第三步改服务端答复之前落地,否则新提案在聊天里看不到审批卡片。
- 出错会怎样:最坏情况是聊天里某条待确认操作不显示审批按钮,用户可改到 AI 审批收件箱处理;本改动只动控制台识别逻辑,可整体撤回。
- 要你做什么:无
## What changes
Step 1 (PR #38273) moved the in-app pending answer from `{ status:
'pending_approval', pendingActionId }` to `{ status:
'pending_confirmation', pendingId }` (`ActionConfirmationPending`,
`packages/spec/src/contracts/ai-service.ts`), and its contract text ("A
stored `pending_approval` answer") says a stored old answer is read by
the SAME recogniser, taking `pendingActionId` as the `pendingId`, with
no second reader. Ruling A on #33806 says the same.
- `ui/packages/plugin-chatbot/src/toolResultParsers.ts`:
`detectPendingApproval` is that one recogniser. It reads
`pending_confirmation` + `pendingId` and `pending_approval` +
`pendingActionId`. Each status pairs with its own id key only: a crossed
pair (`pending_confirmation` + `pendingActionId`, or `pending_approval`
+ `pendingId`) is not read, so no lenient dialect gets in. The id still
comes back as `pendingActionId`, the name
`ChatToolInvocation.pendingActionId` and the approve/reject routes
already use. Signature and return type are unchanged. An orphaned
docblock that named only the old literal is gone.
- Every reader already goes through it: `mapMessages.ts` (the live and
stored-history mapper, plus the record-write, sample-data-cleanup and
package-removal card detectors), app-shell `useChatConversation.ts`
(`toUIMessages` approval promotion), and `aiChatHydration.ts`.
`useHitlInChat.ts` and `useObjectChat.ts` read only the lifted
`tool.pendingActionId`. No reader of either literal is left outside the
recogniser (`git grep` over `ui/` for both literals, outside tests and
CHANGELOGs, finds only the recogniser, the docblocks and the cache
writer below).
- Docblocks that named only the old literal now name both:
`chat/types.ts`, `useHitlInChat.ts`, `useObjectChat.ts`,
`mapMessages.ts`, and `useChatConversation.ts` (the cache writer).
- SDK half of the card: nothing to move. `packages/client/src/index.ts`
(`ai.pendingActions.*`) and
`ui/packages/plugin-chatbot/src/usePendingActions.ts` call the REST
routes `/ai/pending-actions/*`. They name none of the four retired
`IAIService` members (`proposePendingAction`, `approvePendingAction`,
`rejectPendingAction`, `listPendingActions`), so `git grep` over
`packages/client`, `packages/client-react` and `ui/` (CHANGELOGs
excluded) finds 0 hits. The routes belong to step 3, so both files are
untouched.
- No runtime, route or spec change, and no export added or removed.
## Tests
- `ui/packages/plugin-chatbot/src/__tests__/mapMessages.test.ts`: a new
top-level `describe`, "detectPendingApproval reads the current and the
stored pending answer". It covers the new shape (bare, text-wrapped,
JSON string), the old shape (bare, text-wrapped), crossed pairs and
malformed ids refused, a live `pending_confirmation` result lifted to
`approval-requested` + id, the record-write card drawn from a
`pending_confirmation` envelope, and a conversation stored with the old
answer re-drawing its approval card. A lit control checks that an
ordinary result draws no card.
-
`ui/packages/app-shell/src/hooks/__tests__/useChatConversation.test.tsx`:
two new driven round trips that end in the REST call Approve makes. One
restores a cached entry from the stored `pending_approval` envelope
alone (part-key fallback removed, so the recogniser is what is proven).
The other takes a live `pending_confirmation` answer through the cache
to Approve.
## Acceptance notes
- The chat's local cache writer (`pendingApprovalToCachedResult`) still
mints `{ status: 'pending_approval', pendingActionId }`. This PR first
switched it to the current answer, but
`AiChatPage.runtimeMessageSeam.test.tsx` under
`app-shell/src/console/ai/__tests__` pins that exact shape, and that
file is outside this card's claimed file surface, so the writer change
was reverted. The recogniser reads both, so a cached entry restores
either way. Moving the writer to the current answer is a one-line change
plus that one assertion. Carrier: #38448.
- `detectPendingApproval` is a public export of
`@object-ui/plugin-chatbot` (and `/core`). Its signature is unchanged,
and it now also recognises the `pending_confirmation` answer. It refused
that input before, so this PR declares `Clause-②: yes (widening)` (seat
routing on the dev's question; the claim said `no`). The bump stays
`patch`: the level follows `Metadata-protocol`, which is `none`. The
declaration owes a TIER_DEFAULT review of record.
## Verification
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-chatbot/src/__tests__/mapMessages.test.ts`. Expect every
test to pass, including the 7 under "detectPendingApproval reads the
current and the stored pending answer".
Read first (by risk):
1. `ui/packages/plugin-chatbot/src/toolResultParsers.ts`, the
`detectPendingApproval` / `pendingAnswerIdKey` hunk: the strict
literal-to-id-key pairing.
2.
`ui/packages/app-shell/src/hooks/__tests__/useChatConversation.test.tsx`:
the two new round trips.
3. `ui/packages/plugin-chatbot/src/__tests__/mapMessages.test.ts`: the
new `describe`.
All readings below are at head `e5da5265` unless a line says otherwise.
<details><summary>Tests (local, under the shared verify lock)</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2
packages/plugin-chatbot/` + all 14 `*ratchet*` tests under
`packages/app-shell/src` + `packages/app-shell/src/console/*.test.tsx` +
`packages/app-shell/src/console/ai/` + `packages/app-shell/src/hooks/` +
`packages/app-shell/src/assistant/`: Test Files 238 passed (238), Tests
2086 passed (2086), VERDICT command-exit 0.
- `pnpm --filter @object-ui/plugin-chatbot type-check`: exit 0.
`--listFiles` shows `tsconfig.test.json` compiles
`src/__tests__/mapMessages.test.ts`.
- `pnpm --filter @object-ui/app-shell type-check` (after building the
`@object-ui/app-shell^...` closure, 72/72 tasks): VERDICT command-exit
0.
- eslint over the 8 changed `ui/` files: 0 errors (13 warnings, all on
lines this PR does not touch).
- Narrowing, declared: the full app-shell suite (about 2,459 files) was
not run locally. CI `Test UI` runs it.
</details>
<details><summary>Ablation (on-disk mutation via
scripts/ablation-replace.mjs, restored to the HEAD blob each
time)</summary>
The vitest config aliases the packages under test to `src`, so no `dist`
was involved.
- Removed the `pending_confirmation` arm (`toolResultParsers.ts` blob
9e4f150 to 9ba227b6). 4 red: the three new-shape pins in
`mapMessages.test.ts` and the new-answer cache round trip. Restored:
blob equals HEAD, `git diff HEAD` empty.
- Removed the `pending_approval` arm (blob 9e4f150 to 89c4cedb). 6 red:
the old-shape pin, the stored-conversation re-draw, the new
stored-envelope-only cache restore, and three existing cache round trips
that read the stored literal. Restored: blob equals HEAD, `git diff
HEAD` empty.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` derived 38 families
for this diff. All 38 ran locally, each exit 0 (`pnpm --dir ui exec
vitest run scripts/`: 172 files passed, 2 skipped). `--ran`
reconciliation: "38 derived famil(ies) accounted for — 38 run, 0
NOT-MEASURED (a DERIVED zero)".
- `node scripts/pm/overlap-check.mjs`: "VERDICT clean exit 0". It merges
cleanly with `origin/main` and shares a file with no open PR.
- Families CI runs (repo-wide lint, the full UI test shards, typecheck
lanes): read from this PR's check-runs, not re-run locally.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(`packages/spec` is not touched.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran. eslint on the changed files shows 0 errors;
repo-wide `pnpm lint` is left to CI.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: not applicable.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English, apart from the
maintainer quick-read section the fleet contract asks for in Chinese.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5nvFivDeQyYgTFkZhi)_
<!-- signed: repo:objectstack#5 · os-project-manager ·
session_01FEkQ5nvFivDeQyYgTFkZhi -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3b77188 commit e4a02be
9 files changed
Lines changed: 286 additions & 31 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/hooks
- __tests__
- plugin-chatbot/src
- __tests__
- chat
| 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 | |
|---|---|---|---|
| |||
1457 | 1457 | | |
1458 | 1458 | | |
1459 | 1459 | | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
1460 | 1519 | | |
1461 | 1520 | | |
1462 | 1521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 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 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | | - | |
144 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
309 | 310 | | |
310 | 311 | | |
311 | 312 | | |
312 | | - | |
313 | | - | |
314 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
315 | 318 | | |
316 | 319 | | |
317 | 320 | | |
| |||
357 | 360 | | |
358 | 361 | | |
359 | 362 | | |
360 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
361 | 366 | | |
362 | 367 | | |
363 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | 58 | | |
67 | 59 | | |
68 | 60 | | |
| |||
111 | 103 | | |
112 | 104 | | |
113 | 105 | | |
114 | | - | |
115 | | - | |
116 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
117 | 128 | | |
118 | 129 | | |
119 | 130 | | |
| |||
126 | 137 | | |
127 | 138 | | |
128 | 139 | | |
129 | | - | |
130 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
131 | 144 | | |
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
135 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
136 | 159 | | |
137 | 160 | | |
138 | 161 | | |
| |||
0 commit comments