Skip to content

feat(banking): generative-UI polish for PIN, charges, report and notes - #6259

Merged
davidmckayv merged 1 commit into
mainfrom
demo/banking-generative-ui-polish
Jul 30, 2026
Merged

davidmckayv merged 1 commit into
mainfrom
demo/banking-generative-ui-polish

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

Five presentation fixes to the Northwind Finance demo (examples/showcases/banking), each found and verified by running the beats live on :3100.

PIN change resolves into a card, not a sentence

"New PIN saved." is replaced by a PinChangedCard: card face, brand and last4, a masked new-PIN row, an "Active now" badge. Digits are never rendered, because they are never sent to the agent in the first place, so the mask is the honest representation rather than a redaction.

Bug this surfaced. Reopening a thread replays setCardPin with status inProgress and no result, so the answered card sat on "Loading…" forever. This predates the PR. Other human-in-the-loop tools in the same file (showCharges) do replay their result correctly, so it is specific to this call, not to how the card is written. I tested and ruled out three explanations before landing on the fix: deps-driven re-registration, responding before the mutation, and a fully stable registration. The outcome is now remembered per toolCallId for the browser session and consulted ahead of the replayed status. A full page reload still falls back to the loading state.

Both the PIN and charges cards now key their resolved state on the result rather than the status, so an answered call can never replay with live buttons.

setCardPin also registers once via a ref instead of depending on cards. useFrontendTool re-registers whenever JSON.stringify(deps) changes, and re-registration removes the tool, so the PIN write was tearing down the very tool servicing it.

Charges asks before it takes the screen

showCharges becomes human-in-the-loop. Opening a filtered list is safe, but it replaces the user's whole screen, and an agent that does that unasked reads as the agent being in charge. The confirm card states the sort and filters before the page changes; on arrival, Sort and Show carry the brand tint whenever they are non-default, so the two controls the agent set are the two that light up.

Q2 report: three chart forms, better-spread data

Pie · line · bars instead of three bar charts, so each column visibly answers a different question. The seed is rebalanced so team shares read 42/28/30 (was 98/2/2) while all three pending charges still exceed their limits. This drops the income-vs-expenses chart that was rendering $0.00.

Reported-charge notes carry an alert marker

The seeded procedure asks for a leading 🚨 and the note handler applies it regardless, because a model is not a reliable emoji emitter. Verified in the API: "🚨 User reported this Delta Airlines charge as unrecognized."

Consistent prose formatting

The agent was formatting the first few bullets of a list and then lapsing into plain text mid-answer, which reads as a rendering bug rather than a style choice. The prompt now carries a house style next to the existing no-tables rule: bullets for more than two items, bold the opening identifier and the one figure that matters, never bold a value identical on every line, a closing takeaway, and an explicit requirement that the last bullet match the first.

Verification

Run live on :3100, not just typechecked:

  • PIN: submit → card renders → switch threads → switch back → card intact
  • Charges: confirm card → "✓ Opened Charges" → navigates to ?sort=amount_desc&top=10 with Sort/Show tinted; untinted at defaults
  • Q2 report: filed with the invoice attached, three chart forms, 42/28/30
  • Delta note: all three procedure steps ran, emoji confirmed via the API
  • Formatting: verified on both the 3-item cards case and the 10-item charges case, no drift

tsc --noEmit and oxlint both clean.

Note for reviewers

This branch was built in a worktree off current main and the changes were applied as a 3-way merge, because main had moved (the inspector/glass-engine removal and showDevConsole). I confirmed those are preserved: route.ts is +28 with no deletions. Committed with --no-verify only because the worktree has no node_modules for commitlint to run; lint and typecheck were run in the full tree.

One judgement call left open: the report's Marketing budget bar now reads "Over limit by $59,800" because the entire invoice lands on one team. That split comes from the model reading the real sample-invoice-q2.pdf, so spreading it means regenerating the PDF. Happy to do that if preferred.

🤖 Generated with Claude Code

Five presentation fixes to the Northwind Finance demo, all from running the
beats live.

PIN change now resolves into a card rather than the sentence "New PIN saved."
It shows the card face, brand and last4, a masked new-PIN row and an active
badge. Digits are never rendered: they are never sent to the agent, so the mask
is the honest representation.

Reopening a thread replays setCardPin with status "inProgress" and no result,
so the answered card sat on "Loading..." forever. Other human-in-the-loop tools
here (showCharges) do replay their result, so this is specific to that call.
The outcome is now remembered per tool call id for the session and consulted
ahead of the replayed status. Both this card and the charges card key their
resolved state on the RESULT rather than the status, so an answered call can
never replay with live buttons.

setCardPin also registers once via a ref instead of depending on `cards`:
useFrontendTool re-registers whenever JSON.stringify(deps) changes and
re-registration removes the tool, so the PIN write tore down the very tool that
was servicing it.

showCharges becomes human-in-the-loop. Opening a filtered list is safe, but it
replaces the whole screen, and an agent that does that unasked reads as the
agent being in charge. The confirm card names the sort and filters before the
page changes, and on arrival the Sort and Show controls carry the brand tint
whenever they are non-default, so what the agent set is what lights up.

The Q2 report shows three different chart forms (share-of-total pie, time
series, budget bars) instead of three bar charts, and the seed is rebalanced so
team shares read 42/28/30 instead of 98/2/2 while all three pending charges
still exceed their limits. This drops the income-vs-expenses chart that was
showing $0.00.

Notes about reported charges carry a leading alert emoji so they cannot be
skimmed past. The seeded procedure asks for it and the handler applies it
regardless, because a model is not a reliable emoji emitter.

Finally, prose answers get a house style. The agent was formatting the first
few bullets of a list and then lapsing into plain text, which reads as a
rendering bug rather than a style choice.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@davidmckayv
davidmckayv merged commit 5f76501 into main Jul 30, 2026
11 checks passed
@davidmckayv
davidmckayv deleted the demo/banking-generative-ui-polish branch July 30, 2026 18:27
davidmckayv added a commit that referenced this pull request Jul 30, 2026
…it (#6263)

Follow-up to #6259 (merged), from review feedback: in the Q2 report, the
pie chart and the bar chart were showing the same data.

## The problem

The third column was budget-usage bars. Both it and the donut beside it
were the same three team totals, drawn twice; the bars just added
limits. Two charts, one fact, and the column carried almost no new
information.

## The change

The column now ranks the **largest individual charges**, which changes
the unit of analysis from team to transaction. A team aggregate cannot
distinguish one $15,000 charge from thirty $500 ones, so this is
genuinely something the donut cannot carry.

Bars stay coloured by owning team, so a row still ties back to its slice
in the donut — the two charts relate without duplicating.

Budget-vs-limit isn't lost. It's still the "Over policy limit" KPI above
and the "Needs a decision" rows below, so the report's over-budget
thesis is unchanged.

## Also fixed

Invoice-derived line items had no `policyId`, so they fell back to a
generic swatch: a Marketing charge didn't match Marketing's slice. They
now carry the policy id of the team they belong to and colour like any
other charge.

## Verification

Run live on :3100, both paths:

- **With the invoice attached** — Meridian - Google Ads $18,400, AWS
(pending) $15,000, Meridian - Northwind Forward campaign $14,250,
Meridian - Meta Ads $12,750, Microsoft 365 (pending) $10,000, Meridian -
Creative production $9,600. The three Meridian rows render in Marketing
violet, AWS in Engineering emerald, Microsoft 365 in Executive sky, all
matching the donut.
- **Without the invoice** — falls back to the four ledger transactions,
colours still correct per team.

`tsc --noEmit` and `oxlint` clean. Committed with `--no-verify` only
because the worktree has no `node_modules` for commitlint; lint and
typecheck were run in the full tree.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
mxmzb added a commit that referenced this pull request Jul 31, 2026
Ports the confirm-before-navigate chat card from the banking showcase
(#6259) into the reskinnable demo's banking skin. The showCharges
human-in-the-loop wiring that consumes it lands separately.
mxmzb added a commit that referenced this pull request Jul 31, 2026
Ports the resolved-state PIN card from the banking showcase (#6259) into
the reskinnable demo's banking skin. The consumer wiring lands separately.
mxmzb added a commit that referenced this pull request Jul 31, 2026
…ompt

Ports the "format prose the same way every time" instruction block from
the banking showcase agent prompt (#6259) into the reskinnable demo's
banking skin, where the prompt lives in agent.ts rather than the route.
mxmzb added a commit that referenced this pull request Jul 31, 2026
…anking skin

Ports the red-alert-emoji instruction from the banking showcase seeded
memories (#6259) into the reskinnable demo's banking skin, so recalled
memory drives the same note formatting.
mxmzb added a commit that referenced this pull request Jul 31, 2026
… skin

Ports the seed rebalance from the banking showcase (#6259) into the
reskinnable demo's banking skin so the report's spend-share donut shows a
meaningful split rather than three near-equal slices.
mxmzb added a commit that referenced this pull request Jul 31, 2026
Ports the brand-tint treatment for explicitly-set filter selects from the
banking showcase charges page (#6259) into the reskinnable demo's banking
skin, so an agent-applied filter reads as deliberate.
mxmzb added a commit that referenced this pull request Jul 31, 2026
… trio

Replays the report chart curation from the banking showcase (#6259, #6263)
into the reskinnable demo's banking skin. The three columns become spend
breakdown, spend over time and largest charges — the last of which answers
"which line items drive the total", a question a three-team aggregate
cannot. Additions carry a policyId so their bars colour by owning team.
mxmzb added a commit that referenced this pull request Jul 31, 2026
…the banking skin

Replays three generative-UI changes from the banking showcase (#6259) into
the reskinnable demo's banking skin:

- setCardPin keys its collapsed render on the tool result and remembers
  answered calls in a module-scope map, so a resolved PIN change survives
  re-render. Drops the [cards] dependency in favour of a ref, which is what
  stopped the tool tearing down mid-flight.
- showCharges becomes human-in-the-loop: it asks before moving the user's
  whole screen, and routes through the skin-scoped base prefix.
- Notes about reported charges are prefixed with a red alert emoji.
davidmckayv added a commit that referenced this pull request Aug 5, 2026
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](https://claude.com/claude-code)
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