Skip to content

fix(banking): collapse HITL approval buttons on the tool result - #6401

Merged
davidmckayv merged 1 commit into
mainfrom
demo/banking-hitl-resolved
Aug 5, 2026
Merged

davidmckayv merged 1 commit into
mainfrom
demo/banking-hitl-resolved

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

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 local useState. 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

ApprovalButtons takes a resolved prop carrying the durable signal from the tool call itself, OR-ed with local state:

  • local state collapses the buttons instantly on click, without waiting for the round trip
  • resolved survives remounts and thread reloads

Same 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 result are unchanged — there TypeScript correctly rejects status === "complete" as unreachable, which is a useful signal that the guard is already in place.

The identical bug existed in CopilotKit/fde reskinnable-demo, where 10 of 13 call sites were unguarded. Fixed there separately (58d400b on that repo's main).

Verification

tsc --noEmit and oxlint clean.

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

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
davidmckayv merged commit d4bb539 into main Aug 5, 2026
11 checks passed
@davidmckayv
davidmckayv deleted the demo/banking-hitl-resolved branch August 5, 2026 17:27
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants