Repository navigation
fix(banking): collapse HITL approval buttons on the tool result - #6401
Merged
Merged
Conversation
Approve/Deny buttons could reappear on a card the user had already answered. The clearest case is the teach arc: after "Open policy exception" is approved and the chain moves on, that first card came back showing live buttons while the later cards read "Response submitted." "Response submitted." was purely local useState, so nothing tied it to the tool call. Any remount lost it, and the earliest card in a multi-step chain has its subtree replaced when the run syncs. Clicking the resurrected buttons would fire a duplicate write against an already-settled call. ApprovalButtons now takes a `resolved` prop carrying the durable signal from the tool call itself, OR-ed with the local state: local collapses the buttons immediately on click, `resolved` survives remounts and thread reloads. This is the same result-over-status rule already applied to the PIN and charges cards. Wires the 3 call sites that had no guard. The 3 that already collapse on `result` are unchanged — there TypeScript correctly rejects the status comparison as unreachable. 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 17:19
guidovizoso
approved these changes
Aug 5, 2026
davidmckayv
added a commit
that referenced
this pull request
Aug 5, 2026
…ult (#6404) 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 `ApprovalButtons` collapsed only on local `responded` state, 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 `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: ```tsx resolved={status === "complete" || !!result} ``` 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 — passing `resolved` there is both redundant and a type error, since `status` is narrowed to `ToolCallStatus.Executing`. That is why banking also has exactly three call sites. ## Verification - Before: second card had live Approve/Deny. After: it reads *"Response submitted."* - `pnpm lint` → exit 0 - `pnpm build` (the type-check gate) → exit 0 Note: the duplicate card still renders — that comes from a separate pre-existing `Encountered two children with the same key` warning 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](https://claude.com/claude-code)
pull Bot
pushed a commit
to rsoorajs/CopilotKit
that referenced
this pull request
Aug 5, 2026
Ports the banking demo's CopilotKit#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]>
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.
Approve/Deny buttons could reappear on a card the user had already answered.
The clearest case is the teach arc: after "Open policy exception" is approved and the chain moves on, that first card comes back showing live buttons, while the two later cards correctly read "Response submitted."
Root cause
"Response submitted."was purely localuseState. Nothing tied it to the tool call, so any remount lost it — and the earliest card in a multi-step chain has its subtree replaced when the run syncs. That's why card 1 regresses and cards 2 and 3 don't.The visual glitch is the mild part. The buttons are live: clicking them again fires a duplicate write against an already-settled call.
Fix
ApprovalButtonstakes aresolvedprop carrying the durable signal from the tool call itself, OR-ed with local state:resolvedsurvives remounts and thread reloadsSame result-over-status rule already applied to the PIN and charges cards in #6259.
Scope
Wires the 3 call sites that had no guard. The 3 that already collapse on
resultare unchanged — there TypeScript correctly rejectsstatus === "complete"as unreachable, which is a useful signal that the guard is already in place.The identical bug existed in
CopilotKit/fdereskinnable-demo, where 10 of 13 call sites were unguarded. Fixed there separately (58d400bon that repo's main).Verification
tsc --noEmitandoxlintclean.Not yet exercised in a browser: reproducing it means running the teach arc through to the AWS climax. The change is mechanical and type-checked, but flagging that the runtime behaviour is reasoned rather than observed, since on this demo green checks have not always meant the surface is right.
🤖 Generated with Claude Code