Skip to content

fix(plugin-chatbot): a reloaded answer draws a redrawn chart once, keeping the last visualize_data result per chartId - #34840

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34716-chart-dedupe-reload
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-34716-chart-dedupe-reload

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread
Fixes #34716

Clause-②: no
Metadata-protocol: none

repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa

维护者速读

  • 改了什么:聊天历史读取(extractCharts 的 visualize_data 结果路径)在同一条消息里按结果信封顶层的 chartId 合并:同一 chartId 只画一张图,用最后一次结果的图,放在第一次出现的位置。
  • 为什么改:模型在一次回答里重画图表时,实时对话只剩一张;刷新页面从历史重载后,被替换的那张又回来,用户看到两张图。
  • 风险与回滚:低。没有 chartId 的结果(旧历史、其它生产者)逐字节照旧;从不跨消息合并;data-chart 部件路径(实时流)不变。回滚 = revert 本 PR。
  • 先看:ui/packages/plugin-chatbot/src/toolResultParsers.ts(extractCharts 中 resultIndexByChartId 一段,chartFromToolResult 改为同时返回 chartId);ui/packages/plugin-chatbot/src/__tests__/mapMessages.chartIdDedupe-34716.test.ts。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/mapMessages.chartIdDedupe-34716.test.ts,预期 7 passed。
  • 需要你做的:无,席位落地。

What changes

  • chartFromToolResult now returns the chart together with the envelope's top-level chartId (only a non-empty string counts as an id).
  • extractCharts, on the results path only: within ONE message, a result whose chartId was already seen replaces that earlier chart in place (last descriptor, first result's textOffset). A result without a chartId is pushed exactly as before. The map is local to one call, so nothing is merged across messages. The data-chart part branch is unchanged (still preferred whenever the message has one).
  • Changeset: @object-ui/plugin-chatbot patch.

Tests

New file mapMessages.chartIdDedupe-34716.test.ts (7 tests), per the card's Acceptance:

  • same chartId twice in one message: one chart, last descriptor, first offset;
  • different chartIds: two charts at their own offsets;
  • a redraw keeps the first chart's position among other charts;
  • CONTROL: results without chartId (same descriptor twice) give two charts at their own offsets, as today;
  • same chartId in two messages: one chart in each;
  • legacy string content (unanchored): the redraw collapses, no offset;
  • data-chart parts present: parts win, every part kept, results ignored.

Acceptance notes

  • The card's premise was re-measured on base c513d62a before coding: extractCharts pushed every visualize_data hit into fromResults, and no chartId reader existed under ui/packages/plugin-chatbot/src (grep -rn chartId returned nothing).
  • If the LAST result for a chartId is unrenderable (no series), it is skipped by the existing descriptor narrowing and the earlier chart stays. Noted, not pinned.

Verification

All readings at head 59e6bcaa, in worktree objectstack-issue-34716.

Package tests and typecheck
  • pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-chatbot/ under the verify lock: Test Files 102 passed (102), Tests 1035 passed (1035), VERDICT command-exit 0.
  • pnpm --filter @object-ui/plugin-chatbot run type-check (tsc --noEmit && tsc -p tsconfig.test.json; the test project includes src/**/*.test.ts): VERDICT command-exit 0.
Ablation (one, the collapse lookup)

node scripts/ablation-replace.mjs replaced the resultIndexByChartId.get(chartId) lookup with a constant undefined (anchor 1 to 0, blob a5f650e0 to 8eb18380). The suite imports ../mapMessages from source, so no build sits between the edit and the run. Result: 3 failed, 4 passed. The three same-chartId tests went red; CONTROL, different ids, two messages and the data-chart path stayed green. Restore: blob back to a5f650e0, which equals HEAD, and git diff HEAD is empty.

Derived gate families (dispatch-gates --commands, 38)

All 38 derived commands ran locally with exit 0, including pnpm --dir ui exec vitest run scripts/ (171 files passed, 2 skipped). dispatch-gates --ran reconciliation: 38 derived, 38 run, 0 NOT-MEASURED (a derived zero: every entry carries an exit code). check:new-line-citations: 0 new citations. After the last commit (it changed only the test file), check:nul-bytes, check:cross-package-test-inputs and check:test-source-alias were re-run: exit 0. The type-check lanes and repo-wide families belong to CI.


Generated by Claude Code

Within one message, visualize_data results sharing a top-level chartId
collapse to one chart: the last descriptor at the first result's text
offset. Results without a chartId are read as before; nothing is merged
across messages; the data-chart part path is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa

L1 review (L1-d) · 2026-11-17T13:25Z

L1: ACCEPT
Head-sha: 59e6bcaa0017a5269027563eefbe072f4d489635

Read at that head: the file list (3 paths), the full diff, the PR body, card #34716 with its triage comment 6943297547, claim 6947876307 and os-dev-report 6948830939, and the 52 check-runs on 59e6bcaa.

Checklist

  • Shape: draft, base main, Fixes #34716 near the top. The card's three Work items and four Acceptance items are all delivered, so a closing keyword is right. No other open card number sits beside a keyword.
  • Scope vs claim: toolResultParsers.ts (extractCharts results path, chartFromToolResult), a new card-named test under ui/packages/plugin-chatbot/src/__tests__/, and one root changeset. All three match the claim's file surface. No unrelated file.
  • Changeset: @object-ui/plugin-chatbot is published (no private in its package.json) and is the only package whose src/** moved. The patch entry names it. Sentences checked against the diff: "live stream replaces the chart in place" (card fact: same-id data-chart parts fold in the SDK reducer; the data-chart branch is untouched); "reads the chartId … at the top level of its envelope, beside chart" (envelope?.chartId, non-empty strings only); "last result's chart, at the place … where the first one sat" (fromResults[redrawn] = { ...chart, textOffset: first.textOffset }); "without a chartId … read exactly as before" (same push path); "never merged across messages" (the map is local to one extractCharts call); "data-chart parts … unchanged" (fromParts wins exactly as before). All true. chartsFromParts is the mapMessages re-export, and uiMessageToChatMessage reaches extractCharts at mapMessages.ts:1660.
  • Clause-② / Metadata-protocol: no / none, same in the claim, the body and the changeset. extractCharts keeps its exported signature. chartFromToolResult, whose return type changed, is module-private. Neither line touches a contract face.
  • Governed: check-governed-merges.mjs --pr 34840 gives 0 of 3 paths and 212 changed lines, so not Tier H.
  • Tests: 7 tests, one per Acceptance item, plus the position-among-others case, the string-content case and the data-chart-wins case. The CONTROL case (no chartId, same descriptor twice → two charts at their own offsets) pins the "byte for byte as today" item. The body records an ablation of the resultIndexByChartId lookup: 3 red, 4 green, the expected split. Local package run: 102 files / 1035 tests, plus type-check, both with a real command and exit code.
  • CI at this head: Lint & Repo Gates, TypeScript Type Check, Test UI (all 16 shards), Type Check UI, Build & E2E UI, Live E2E UI, Check Changeset and the Governed Surface Queue Guard all success. The rest are skipped by path filter. Nothing red or pending.

Must-fix

None.

Should-fix

None.

Notes

  • N1, the shared-harness question (AGENTS.md line 146, ruling record 6583487846): I agree with the area's reading A. That rule covers a component that already has a shared harness file, meaning set-up the new pin would otherwise pay again. mapMessages is a pure function. mapMessages.persistedChart-25908.test.ts pins one card and builds no harness, and the package's __tests__/ already holds about ten mapMessages.<topic>-<card>.test.ts files. A new card-named file is within the rule.
  • N2, no live reading: the only chartId producer is cloud PR docs(protocol): http-protocol 的 API Discovery 拆成两段式 —— REST 形状与 dispatcher 形状分开 (#4817) #4826. There is no non-test chartId writer under packages/ or ui/packages on main, so an open-source boot cannot replay a redraw. The card's Acceptance is test-only, and the reload half of cloud#4824 item 1 is verified on the cloud side.
  • N3: the body's edge note (a last result with no series is dropped by the existing narrowing, so the earlier chart stays) is accurate and harmless. No pin is owed.

Landing: not governed, all checks green. Area o3-H lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa

Landing (area o3-H) · 2026-11-17T13:25Z

Reading Value
L1 ACCEPT (L1-d, comment 6949352639) on head 59e6bcaa0017a5269027563eefbe072f4d489635, no must-fix, no should-fix
CI on that head 39 success, 13 skipped (path filter), 0 failed or pending; mergeable_state: clean
check-governed-merges.mjs --pr 34840 NOT governed, 0 of 3 paths; 212 changed lines ≤ 3000
K (c513d62a..origin/main, first-parent) 13 (< 15)

State change: ready + auto-merge enabled; Fixes #34716 closes the card on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 13:26
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 7752cac Nov 17, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34716-chart-dedupe-reload branch November 17, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chatbot: a reloaded answer draws a redrawn chart twice, because the history reader keeps every visualize_data result instead of the last per chartId

2 participants