Skip to content

refactor(studio): share one plan verdict flow via usePlanVerdictControl - #2324

Merged
kantord merged 1 commit into
studio-followups/13-verdict-ledgerfrom
studio-followups/14-plan-verdict-hook
Oct 15, 2026
Merged

kantord merged 1 commit into
studio-followups/13-verdict-ledgerfrom
studio-followups/14-plan-verdict-hook

Conversation

@kantord

@kantord kantord commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

One plan verdict flow for the workspace and the side panel, so planUnavailableReason and the blocking rule are the same on both surfaces (Escape parity).

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

What changed

  • New use-plan-verdict-control.ts owns the follow abort, reattachRef, continuationActive, planUnavailableReason, respondToPlan, reset and abort. Each surface passes only onStarted plus retract, onUncertain, setControlPending, setError and setNotice.
  • The error strings that were duplicated verbatim are constants in plan-continuation.ts.
  • Beyond the plan: a controlPending input (the old blocking rule included it), onUncertain, endContinuation(), sessionId in the onStarted payload, and an optional follow seam (vi.mock is banned by a lint rule). The watch effects stay where they are and read plan.reattachRef.

Behavior changes

The side panel now clears its error when a plan verdict starts (the workspace already did).

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). Eight renderHook tests; seven mutations of the hook were each caught by a test (the setError(undefined) mutation initially was not, so an assertion was added). Existing behavior-sensitive tests (approval-interactions, plan-review) pass unchanged.

Not included

The watch effects and ordinary verdicts, which are not shared between the surfaces.

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 changed the title refactor(studio): share one plan verdict flow between the workspace and side panel refactor(studio): share one plan verdict flow via usePlanVerdictControl Oct 14, 2026
@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. The shared hook keeps both surfaces' guard and success ordering intact, and the renderHook tests exercise the flow through the fetch boundary rather than snapshotting.

Nit:

  • apps/web/src/features/chat/use-plan-verdict-control.ts:43: onStarted receives resumeFrom, but neither surface reads it; the cursor already travels through reattachRef. Consider dropping it from the payload, along with the export on PlanReattach (line 22), which is only used inside the hook.

@kantord
kantord force-pushed the studio-followups/14-plan-verdict-hook branch 6 times, most recently from 2ce9f39 to 70efc91 Compare October 15, 2026 13:00
@kantord
kantord force-pushed the studio-followups/14-plan-verdict-hook branch from 70efc91 to 3ba0c1c Compare October 15, 2026 13:26
…nd side panel

usePlanVerdictControl owns the plan verdict POST, the continuation follow,
the reattach handed to each surface's watch effect, planUnavailableReason,
and the shared messages (now constants in plan-continuation.ts). Each surface
supplies only its ledger, active target, and what to do when execution starts.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@kantord
kantord force-pushed the studio-followups/14-plan-verdict-hook branch from 3ba0c1c to 17a4f1c Compare October 15, 2026 14:01
@kantord
kantord merged commit 550c67f into main Oct 15, 2026
31 checks passed
@kantord
kantord deleted the studio-followups/14-plan-verdict-hook 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