Skip to content

Apply queued checkout switches on idle and announce them at pick time - #135

Merged
badcuban merged 2 commits into
mainfrom
feature/checkout-switch-feedback
Aug 10, 2026
Merged

Apply queued checkout switches on idle and announce them at pick time#135
badcuban merged 2 commits into
mainfrom
feature/checkout-switch-feedback

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

Why

When a thread's session was busy (running turn, or a subagent working in a worktree), picking a different checkout only queued the switch, and the queue drained on the next user message. Until then every surface stayed pointed at the old checkout, and the only signal was the small chip next to the composer. In practice this read as "it did not let me switch".

What

Server: apply the queued switch as soon as it is safe, not on the next message. ProviderCommandReactor now listens for thread.meta-updated (checkout picked while idle) and thread.session-set (turn finishing, background tasks settling). When the session is idle with no active turn and no pending background tasks, and its checkout differs from the thread's target, the session is cycled into the target via the existing resume-carrying restart path. Threads without a live runtime keep lazy semantics. The guard validates against the freshly projected thread and the projected session.checkoutCwd (rewritten on every bind), so it cannot loop or fight a turn dispatch: the per-thread sequential worker already serializes both.

Web: say the queueing out loud. A new shared queuedCheckoutSwitchToast helper (built on resolvePendingCheckoutSwitch) raises an info toast when a pick leaves the live session behind: one wording when a background task defers the switch, another when only the running turn does. Wired into both the composer branch picker and the source control panel branch menu. No toast when the session is idle, since the switch now applies right away. Chip copy updated to match the new behavior ("moves as soon as the current turn ends" instead of "your next message starts it").

Tests

  • ProviderCommandReactor.test.ts: two new tests — queued switch applies on background-task settle without a new message, and immediately on an idle pick; existing deferral tests still pass unchanged.
  • BranchToolbar.logic.test.ts: coverage for the toast helper (deferred, mid-turn, idle → null, no-op pick → null).
  • Full gates: fmt, lint, typecheck, server suite (one pre-existing NodePTY Windows-shell failure also red on main), web unit + browser suites all green.

A checkout switch used to wait for the user's next message, and while a
subagent ran in the target worktree the only signal was a small chip by the
composer. Two changes:

- The reactor now applies a queued switch as soon as the session is safe to
  move: idle status, no active turn, no pending background tasks. Triggered
  from thread.meta-updated (pick while idle) and thread.session-set
  (background tasks settling, turn finishing), so the source control panel
  and diff surfaces follow without needing a new message.
- Picking a branch that queues a switch behind a busy session now raises an
  info toast from both the composer branch picker and the source control
  panel, saying where the agent still is and when it will move.
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
threadlines Skipped Skipped Aug 10, 2026 7:23am

Request Review

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Aug 10, 2026
@badcuban
badcuban merged commit f3571b0 into main Aug 10, 2026
15 checks passed
@badcuban
badcuban deleted the feature/checkout-switch-feedback branch August 10, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant