Skip to content

refactor(studio): move the workspace's verdict state onto VerdictLedger - #2323

Merged
kantord merged 1 commit into
studio-followups/12-move-messagefrom
studio-followups/13-verdict-ledger
Oct 15, 2026
Merged

kantord merged 1 commit into
studio-followups/12-move-messagefrom
studio-followups/13-verdict-ledger

Conversation

@kantord

@kantord kantord commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

The workspace now reads one VerdictLedger, like the side panel, instead of four Sets and two epochs. Escape and the verdict buttons read the same predicate, so they cannot disagree.

Part of #2303 ("Tiny follow-up fixes"); it does not close it. This is PR 13 of 14 in a stack of draft PRs, reviewed and merged in order.

What changed

  • The four Sets, two epochs and the separate ordinary and plan predicates are removed; one approvalDisabled, approvalUncertain and retainUncertainApprovals read the ledger. controlPending is reset in the session-switch effect.
  • settledAskKey(runId, askId) in chat-state.ts, used at the 5 workspace sites and 2 reducer sites (the remaining \u0000 keys are authorization keys and are left alone).
  • The stale "workspace still holds four Sets" comment in verdict-ledger.ts is updated.

Behavior changes

Documented parity fixes with the side panel: (1) a plan verdict blocked by an in-flight or uncertain verdict, or by identity, returns silently instead of showing the "stale" error; (2) setControlPending(false) after a verdict is guarded by "session still viewed"; (3) the workspace records acknowledge() in the ledger (bookkeeping, no test can observe it). Two edges become stricter: a stream retract or approval event now resets the ledger for the whole ask (also dropping an in-flight phase, as in the side panel), and the plan card's disabled state includes the identity checks (its buttons were already hidden in that case).

Verification

Biome, typecheck, the full Studio test suite and pnpm generated:check pass on this branch, run on the assembled stack. The full Playwright suite passes on the stack tip (122 passed, 30 skipped, 0 failed, including chat-approval against a real mecated build). Two new tests fail on the pre-change workspace: a racing plan double-click on workspace and side panel sends one POST and shows no "stale" text; a session switch with held verdicts enables the new session's asks, and the old verdict settling does not release the new session's pending state. The cross-session scenario is covered by happy-dom only; the Playwright spec does not switch sessions mid-verdict.

Not included

Removing settledAskKeys from the workspace: stream settle events reset the ledger to idle, so without it a replayed permission.ask would bring back a ghost card. The shared hook (next PR).

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

@kantord
kantord added this pull request to stack #2325 October 14, 2026 13:27
@kantord kantord mentioned this pull request Oct 14, 2026
41 tasks done
@kantord
kantord marked this pull request as ready for review October 15, 2026 08:41

@peppescg peppescg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Daniel. One ledger per surface means the Escape and button predicates can't disagree, and the two new tests fail on the old workspace as described.

Nit:

  • apps/web/src/features/chat/chat-workspace.tsx:2446: stopRun's finally still clears controlPending without checking the session, so a cancel started in session A that settles after a switch can release B's pending state mid-verdict, the same case your new test guards for verdicts. Capturing target.sessionId and guarding with if (viewedSessionId.current === target.sessionId) would close it. Fine as a follow-up.

@kantord
kantord force-pushed the studio-followups/13-verdict-ledger branch 6 times, most recently from 924b44b to 89541d6 Compare October 15, 2026 13:00
@kantord
kantord force-pushed the studio-followups/13-verdict-ledger branch from 89541d6 to dde4722 Compare October 15, 2026 13:26
The workspace kept four Sets and two epochs for ordinary and plan verdicts;
it now reads one VerdictLedger like the side panel, with one approvalDisabled
and approvalUncertain shared by the buttons, the detail panel, and Escape.

Parity with the panel: a plan verdict blocked by an in-flight or uncertain
verdict returns silently instead of calling the ask stale; a verdict only
clears controlPending when its session is still viewed, and a session switch
resets it. Adds settledAskKey(runId, askId) for the run/ask settled keys.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@kantord
kantord force-pushed the studio-followups/13-verdict-ledger branch from dde4722 to 9b788aa Compare October 15, 2026 14:01
@kantord
kantord merged commit d58c180 into main Oct 15, 2026
31 checks passed
@kantord
kantord deleted the studio-followups/13-verdict-ledger branch October 15, 2026 14:07
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
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