Repository navigation
fix(reskinnable-demo): collapse HITL approval buttons on the tool result - #6404
Merged
Merged
Conversation
Ports the banking demo's #6401 fix, which was never carried over to this app. ApprovalButtons collapsed only on local `responded` state, which dies with the component. These cards do get remounted when the run syncs, which resurrected live Approve/Deny buttons on an action the user had already taken; clicking them again fires a duplicate write against an already-settled call. Adds a durable `resolved` prop, OR-ed with the local state so a click still collapses without waiting for the round trip. It is passed from the tool call itself at the three HITL renders that do not already early-return on status "complete". The other three (offerWorkflowRecording, awaitDashboardDemonstration, saveLearnedWorkflow) render their own terminal card when complete, so they never reach the buttons and need nothing — which is why banking also has exactly three call sites. Verified against the banking skin in the browser: before, approving a policy exception left a second card carrying live Approve/Deny; after, that card reads "Response submitted." `pnpm lint` and `pnpm build` both exit 0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
davidmckayv
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
August 5, 2026 18:39
mxmzb
approved these changes
Aug 5, 2026
davidmckayv
added a commit
that referenced
this pull request
Aug 5, 2026
…#6407) Follow-up to #6404. That PR stopped the *duplicate write* from a resurrected approval card; this one removes the duplicate card itself. ## Symptom Approving a HITL card in the banking skin left a **second, blank copy** of the same card in the transcript — "Open policy exception" with no transaction id and no code — plus a React warning: ``` Encountered two children with the same key, call_QHa801k5PL32WtPKsPItO1pI ``` ## Root cause `@ag-ui/client`'s `TOOL_CALL_START` handler appends to the parent assistant message's `toolCalls` with no check for an existing entry with that id: ```js message.toolCalls ??= []; message.toolCalls.push({ id, type: "function", function: { name, arguments: "" } }); ``` So when a start event is applied twice — which the HITL flow triggers when the run syncs after `respond()` — the message carries the same call twice. The second copy has **empty `arguments`**, because a start event carries none; the args arrive afterwards as `TOOL_CALL_ARGS` deltas addressed to the first copy. That empty copy is what rendered as the blank card, and `CopilotChatToolCallsView` uses the call id as its render key, hence the warning. Evidence gathered while diagnosing: - Instrumented the message view: the offending assistant message ends up with `toolCalls: ["call_X","call_X"]`, and the React warning fires on the same id in the same tick. - Queried a local Intelligence stack: the server emits **exactly one** `TOOL_CALL_START` for that id (one `START`, one `END`, one `RESULT`). So this is client-side state, not a stream defect. - React StrictMode is **not** involved — the demo sets `reactStrictMode: false`. ## Fix Extends the existing `deduplicateMessages()` — which already collapses duplicate *message* ids arriving from streaming re-delivery — to also collapse duplicate *call* ids within a message, preferring whichever copy actually carries arguments. Applied outside the merge branch too, because the duplicate also lands on a message that was never itself duplicated (observed `rawMsgs=5 dedupMsgs=5` with the duplicate still present). Returns the original array untouched when there is nothing to collapse, so memoized consumers don't re-render needlessly. ## Scope / known limitation This fixes what renders. The underlying agent state still holds the duplicate entry, so a fully correct fix also wants an idempotency guard in the AG-UI start handler (upstream). Filed separately — flagging here so the remaining gap is explicit rather than implied-fixed. The precise reason a single start event gets applied twice is also still open; the fix is deliberately robust to re-application whatever the trigger. ## Verification - 5 regression tests added, **verified red before green** (neutered the fix → 3 failed with "Expected 1, Received 2"; restored → pass). - Full `@copilotkit/react-core` suite: **1480 passed / 123 files**. - `test`, `publint`, `attw` green for react-core and its dependents. - In-browser against a live Intelligence stack: before, approving left a blank second card + 3 key warnings; after, **one card and zero warnings**. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the banking demo's #6401 fix, which was never carried over to
reskinnable-demo. Found while bringing the demo up against a local Intelligence stack.The bug
ApprovalButtonscollapsed only on localrespondedstate, which dies with the component. These cards do get remounted when the run syncs, which resurrects live Approve/Deny buttons on an action the user already took — a second click fires a duplicate write against an already-settled call.Reproduced in the banking skin: clicking the "Approve the $15,000 AWS charge" pill and approving the policy exception left a second card carrying live Approve/Deny buttons (with empty args).
The fix
Adds a durable
resolvedprop, OR-ed with the local state so a click still collapses without waiting for the round trip. It is passed from the tool call itself:Applied at the three HITL renders that don't already early-return on
status === "complete"(openPolicyException,finalizePolicyException,approveTransaction).The other three (
offerWorkflowRecording,awaitDashboardDemonstration,saveLearnedWorkflow) render their own terminal card when complete, so they never reach the buttons — passingresolvedthere is both redundant and a type error, sincestatusis narrowed toToolCallStatus.Executing. That is why banking also has exactly three call sites.Verification
pnpm lint→ exit 0pnpm build(the type-check gate) → exit 0Note: the duplicate card still renders — that comes from a separate pre-existing
Encountered two children with the same keywarning also present in banking, and is out of scope here. This PR removes the duplicate-write hazard, which is what #6401 addressed.🤖 Generated with Claude Code