Repository navigation
Commit 211c1aa
fix(plugin-chatbot): the record-write card header badge follows the decision the card body shows (#39303)
Fixes #39265
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:在 AI
助手的写入确认卡上点了确认之后,卡片标题旁的状态标签改为跟着卡片内容走:提交中显示「正在写入」,写好后显示「已写入」,取消后显示「已取消」,不再一直停在「等待确认」。
- 为什么做:替点确认的人解决同一张卡上标题说「等待确认」、内容却说「已写入」的矛盾。
- 出错会怎样:只影响确认卡标题上的状态文字,写入的数据和按钮都不变;有问题可以直接撤回这次改动。
- 要你做什么:无。
## What changes
- `ui/packages/plugin-chatbot/src/chat/toolRecordWrite.ts`: new
`recordWriteOutcomeOf(decision)` reads the host's decision for the tool
call (`toolDecisions[toolCallId]`, the one source the card body already
used) and names what the card says about it: `submitting`, `written`,
`cancelled`, `held`, `expired` or `error`. With no decision it is
absent.
- `ui/packages/plugin-chatbot/src/chat/toolDetail.tsx`: the record-write
card reads that one outcome twice.
- The body's decision line now branches on it, with the same words as
before.
- The header badge also reads it. Each outcome maps to the AI-SDK badge
state whose icon fits and to the label the body uses for it. In flight
reads `recordWriteSubmittingLabel`, written reads
`recordWriteWrittenLabel`, and cancelled reads
`recordWriteCancelledLabel`. Held reads the inbox's held word, expired
reads the expired word, and a refused write reads the existing `Error`
badge word, with the server's reason in the body.
- With no decision, the badge still follows the tool part's state
("Awaiting approval").
- Before this change the badge read only the tool part's state. A
Confirm or Cancel on the card calls the pending-action door and never
changes that state, so the badge kept reading "Awaiting approval" until
a reload.
- No new strings. No change to `ChatbotEnhanced.tsx`, the vendored
`elements/tool.tsx` or any locale pack.
- Changeset `.changeset/39265-write-card-badge.md`: a `patch` for
`@object-ui/plugin-chatbot`.
Read first, by risk:
1. `chat/toolDetail.tsx`, the `recordWriteBadge` table and the
`ToolHeader` props. These choose the icon state and label per outcome.
2. `chat/toolRecordWrite.ts`, `recordWriteOutcomeOf`. Its branch order
is the body's old order: error, held, expired, pending, then success
split by `decision.decision`.
3. The new `describe` at the end of
`ChatbotEnhanced.recordWriteCard-3565.test.tsx`.
## Tests
The pins are a new top-level `describe` in the existing harness file
`ChatbotEnhanced.recordWriteCard-3565.test.tsx`. Each test re-renders
one card through the decision states with `rerender`, with no remount
and no reload:
- create and update (`it.each`): the badge reads "Awaiting approval",
then the submitting label while the Confirm is in flight, then "Written"
after a successful Confirm. At each step the badge reads the same word
as the body.
- Cancel: the badge reads the submitting label, then "Cancelled", never
"Written".
- held, expired and refused: the badge reads the held word, then the
expired word, then "Error". It never reads "Written" or "Awaiting
approval".
<details><summary>Runs on fa63a25 (the final commit)</summary>
```text
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.recordWriteCard-3565.test.tsx packages/plugin-chatbot/src/__tests__/recordWrite-3565.test.ts
Test Files 2 passed (2) Tests 53 passed (53) VERDICT command-exit 0
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-chatbot/
Test Files 89 passed (89) Tests 882 passed (882) VERDICT command-exit 0
pnpm --filter @object-ui/plugin-chatbot type-check (tsc --noEmit && tsc -p tsconfig.test.json)
VERDICT command-exit 0; tsconfig.test.json --listFiles counts the three edited files (3)
```
</details>
<details><summary>Ablation and restore</summary>
`node scripts/ablation-replace.mjs` replaced the line that selects the
badge from the outcome with a constant `undefined`. The body still read
the outcome. The anchor went from 1 to 0, and the blob changed from
09c401c to 8169fe87afbe.
```text
× create: awaiting, then in flight, then written after 确认
× update: awaiting, then in flight, then written after 确认
× after 取消 the badge reads cancelled, as the body does
× a held, lapsed or refused decision reads on the badge as it does in the body, never as written
Tests 4 failed | 25 passed (29)
Expected element to have text content: 正在写入… Received: Create recordAwaiting approval
```
The mutated tree reproduces the reported defect: the header reads
"Awaiting approval" while the body reads the decision. The restore leg
matched the blob against HEAD (09c401c == 09c401c), and `git
diff HEAD` is empty.
</details>
## Acceptance notes
- The generic approval cards (the plain Approve or Deny strip, the
sample-data cleanup card and the package-removal card) also draw their
header badge from the tool part's state. They show the decision only in
their own decision line. This PR does not change them, because the card
scopes the fix to the record-write card. This is an inference from
reading the code and was not measured in a browser. It is not filed.
- The badge for a refused write reads the existing `Error` word, not the
server's sentence. The body carries the sentence.
## Verification
Local gate subset on `fa63a255d5`. The derivation is `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`, computed against the merge base `c7478b37b`
with the 4 changed paths. Each exit code was captured before any pipe.
<details><summary>38 derived commands plus `check:changeset-fixed`:
every one exit 0</summary>
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm check:changeset-fixed :: exit 0
```
</details>
`node scripts/pm/dispatch-gates.mjs --ran` printed:
```text
Run reconciliation — 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero — all 38 recorded an exit code and none of them is 3).
```
`check:changeset-fixed` was run as well, because its roster lives in
`.changeset/`; `--ran` lists it as outside the derivation. Type-check
lanes, the whole-tree families and the repo-wide lint are left to CI and
are not repeated here. Before opening, `origin/main` was 3 commits ahead
of the base, and none of them touch `ui/packages/plugin-chatbot`, so the
branch was not merged; CI runs on the merge ref.
Two-minute check: run `pnpm --dir ui exec vitest run
packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.recordWriteCard-3565.test.tsx`
from the repository root. Expect 29 passed, including the four tests
under "the record-write card header badge follows the decision".
---
_Generated by [Claude
Code](https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 14680d0 commit 211c1aa
4 files changed
Lines changed: 155 additions & 9 deletions
File tree
- .changeset
- ui/packages/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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
192 | 208 | | |
193 | 209 | | |
194 | 210 | | |
| |||
237 | 253 | | |
238 | 254 | | |
239 | 255 | | |
240 | | - | |
| 256 | + | |
241 | 257 | | |
242 | | - | |
| 258 | + | |
243 | 259 | | |
244 | 260 | | |
245 | 261 | | |
| |||
526 | 542 | | |
527 | 543 | | |
528 | 544 | | |
529 | | - | |
| 545 | + | |
530 | 546 | | |
531 | 547 | | |
532 | 548 | | |
| |||
541 | 557 | | |
542 | 558 | | |
543 | 559 | | |
544 | | - | |
| 560 | + | |
545 | 561 | | |
546 | 562 | | |
547 | 563 | | |
548 | 564 | | |
549 | | - | |
| 565 | + | |
550 | 566 | | |
551 | 567 | | |
552 | 568 | | |
553 | 569 | | |
554 | | - | |
| 570 | + | |
555 | 571 | | |
556 | 572 | | |
557 | 573 | | |
558 | 574 | | |
559 | | - | |
| 575 | + | |
560 | 576 | | |
561 | 577 | | |
562 | 578 | | |
563 | 579 | | |
564 | | - | |
| 580 | + | |
565 | 581 | | |
566 | 582 | | |
567 | 583 | | |
568 | 584 | | |
569 | 585 | | |
570 | 586 | | |
571 | | - | |
| 587 | + | |
572 | 588 | | |
573 | 589 | | |
574 | 590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 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 | + | |
14 | 47 | | |
15 | 48 | | |
16 | 49 | | |
| |||
0 commit comments