Skip to content

fix(server): settling a thread no longer closes its agent or drops pending work - #3

Merged
greaber merged 2 commits into
grant/mainfrom
grant/settle
Nov 12, 2026
Merged

greaber merged 2 commits into
grant/mainfrom
grant/settle

Conversation

@greaber

@greaber greaber commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Settling a thread (by hand or automatically) detached the agent's provider session without checking for a running turn, cancelled queued notification and delegated-completion runs and pending questions, and ended PR watches. In production, auto-settle fired the instant a background task finished, while Claude Code was starting the turn that delivers the task's notification; settle closed the session mid-turn and the thread stalled silently for hours.

Settling is now a sidebar status:

  • No session detach, no cancelled queued runs or questions, PR watches kept. Archive and delete are unchanged.
  • Settle scripts and stopOnSettle terminals still run, but only when the thread is still settled and idle (rechecked before running). Other idle shells are no longer closed on settle; they are closed when storage cleanup removes the worktree.
  • Automatic work on a settled thread runs and unsettles it: usage-limit resume (server, web banner, mobile card), PR-watch wakes, queued automatic runs, restart continuation. Storage cleanup holds a settled thread's worktree for a pending resume.
  • Auto-settle is off by default (sidebarAutoSettleOnMerge false, sidebarAutoSettleAfterDays null), also for users who never changed the setting. A closed PR now obeys the same setting as merge ("Auto-settle when a pull request merges or closes", web and mobile).
  • User docs updated (thread-sidebar, source-control, project-settings, updating).
Check SHA Result
vp test run src/orchestration-v2/runtimeLayer.test.ts 1382ccf 130 pass
vp test run ThreadSettlementService, control-reads, UsageLimitRecoveryWorker, terminal/Manager, GuestShare, ThreadManagementService 1382ccf 171 pass
vp test run ThreadSettlementService, RestartContinuation, ProjectSetupScriptRunner, terminal/Manager 331ecb6 168 pass
vp test run src/storageCleanup.test.ts 331ecb6 184 pass
web UsageLimitRecoveryBanner.test.tsx; web settings search/useSettings; mobile settings 331ecb6 / 1382ccf pass
vp run check:changed 331ecb6 format, lint, knip, typecheck pass; tests fail only in ProjectionStore "fixed SQL turn-item window" (local Node 24 node:sqlite lacks StatementSync.stat, fails without this change) and load-sensitive ssh "concurrent launches"

Claude Opus 5.5 via Claude Code (T3 Code).

greaber and others added 2 commits November 11, 2026 12:56
…nding work

Settling detached the thread's provider sessions, cancelled queued
notification and delegated-completion runs, cancelled pending questions,
ended pull request watches, and closed idle terminals. Auto-settle could
fire at the moment a background task finished, when Claude Code had just
started a turn to deliver the task notification but T3 had no run for it
yet; the detach closed the query, killed that turn, and the thread then
stalled silently.

Settling is now only a sidebar status change:

- manual and automatic settle no longer detach provider sessions, cancel
  queued automatic runs or pending runtime requests, or end PR watches;
  archive keeps its existing cleanup
- settle runs the project's settle scripts and stops terminals marked
  stopOnSettle, but no longer closes other idle terminals
- usage-limit auto-resume, PR-watch wakes and subagent limit recovery
  proceed on settled threads
- starting a queued run on a settled thread unsettles it, so a running
  thread never sits under Settled (dispatched messages already did)
- auto-settle is off by default (on merge: false, after days: null), and
  a closed pull request settles only when the merge setting is on; the
  setting is relabelled "merges or closes" on web and mobile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and recovery

Settling became display-only, but several places still treated a settled
thread as finished work:

- storage cleanup no longer holds a usage-limited thread's worktree when
  the thread was settled, so it could delete a checkout a pending
  auto-resume needs; settled threads are now held like any other
- storage cleanup counted every live shell in a worktree as blocking, so
  now that settling keeps idle shells open a settled worktree could never
  be cleaned; only terminals running a command (or still starting) block,
  and idle-prompt shells there are closed just before the worktree is
  removed (closeIdle now reports whether everything closed)
- the restart continuation skipped settled threads; it now continues them
- the web limit banner and mobile limit card hid the resume-at-reset
  action on settled threads; they now offer it
- settle scripts and stopOnSettle terminals could run while an agent was
  starting a turn as the thread settled (a background task's result); they
  now run only when the thread is still settled and has no active, queued
  or background work

User docs explain that settle actions run only on an idle settled thread,
that idle shells are closed on worktree removal, that restarts resume
settled threads, and that auto-settle is now off by default even for
settings that were never changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 11, 2026
@greaber
greaber merged commit 9e8710e into grant/main Nov 12, 2026
9 of 20 checks passed
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