Repository navigation
feat(threads): settle working threads once idle on V2 - #15648
Draft
piotrnowakowski wants to merge 8 commits into
Draft
piotrnowakowski wants to merge 8 commits into
piotrnowakowski wants to merge 8 commits into
Conversation
Idle Settle settles again when only a dev server is left running; a thread is filed only while a run is live or background work will wake the agent. Dropping a queued delivery that never started no longer returns a filed thread to Active. The intent token, persistent-monitor and PR-watch holds, and per-item sweep triggers are gone; a filed thread keeps its place on the shelf when it settles. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…hread-v2 # Conflicts: # apps/server/src/mcp/toolkits/thread/tools.ts
unmanbearpig
added a commit
to unmanbearpig/t3code-unmbp
that referenced
this pull request
Oct 5, 2026
Port the deferred settlement feature from pingdotgg#15648 at 5751538 onto the fork. Manual settlement records durable intent while work continues; the server fulfills it when idle, independently of automatic settlement settings and PR discovery. Keep relay activity visible while background work remains, update runtime coverage for active and held runs, and verify that explicit settlement skips branch PR lookup. Preserve the fork's MCP tool scope and keybindings. Validation: 616 focused tests; server, shared, contracts, client-runtime, web, and mobile typechecks; scoped lint and export checks compared with baseline. No new lint or export findings. Browser/device checks not run. Co-authored-by: piotrnowakowski <61783713+piotrnowakowski@users.noreply.github.com>
…hread-v2 Keeps both sides in Orchestrator.ts: archive and settle clear the settle-when-idle intent and end pull request watches. Updates SettleWhenIdle.test.ts for main's renamed SQL client, persistence and replay harness modules. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A pull request watch now counts as background work (pingdotgg#16204), but Settle stops watches (pingdotgg#16095), so a filed thread no longer waits on one until the PR closes. A held queue only resumes when the user resumes it: a held user message still blocks Settle, and a filed thread does not wait on held automatic runs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A filed thread with a pull request watch settles once its run ends and the watch stops. A held automatic run does not keep a filed thread and is cancelled when it settles. A held user message blocks Settle on a working thread instead of filing it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…hread-v2 Settling now runs cleanUpSettledThread (idle terminals and the project's settle action); the settle-when-idle-set case stays beside it, so a filed thread runs that cleanup when it really settles. The settled composer banner became a status line after the last message on main; a filed thread shows "Settles when its work finishes" there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Settling a working thread fails, including when an agent calls
t3_thread_organizewithaction: "settle"on its own thread as its final step. The turn is still running during that call. Users need to file the thread immediately while allowing its work to finish.Change
Rebuilds #14495 on orchestrator V2. Settle on a working thread records a durable, one-shot
settleWhenIdleAtintent instead of emittingthread.settledor stopping its provider session. Settle on an idle thread stays the command it is today.main.thread.settle, and its provider cleanup, once the orchestrator confirms that work finished. The thread keeps its place on the settled shelf. Startup recovery and retry work even with automatic settlement disabled or keep-active set.completed.main, instead of filing the thread with the message hidden on the shelf. Held automatic runs are cancelled when the thread settles.main's settle cleanup (idle terminals and the project's settle action) runs then, after the agent's work has finished.Scope and approval
Addresses #13630 and its accepted scope. Replaces the V1 implementation in #14495 following the request to rebuild on V2, and covers the agent self-settle report.
The contract, server, shared client state, web/mobile UI, and notification changes implement this one lifecycle behavior. No new menu entry or automatic-settlement setting is introduced.
Two details differ from the triage text:
mainalready settles past both. Work that will wake the agent does hold it.completedfor every settled thread, not only filed ones. Without that, the real settle at the end would still announce the completion that the intent is meant to keep quiet.Verification
Tested locally on Windows 11 at
8a0df2f6d, which mergesmainat611132c17.runtimeLayerand themainsuites around settling, pull request sync, and pull request watches. New cases cover a filed thread with a pull request watch settling and ending the watch, a held automatic run not holding a filed thread, and a held user message blocking Settle on a working thread. The earlier cases still cover filing without stopping the session, settling at the filed time, dev servers, subagent and monitor work, failed and interrupted runs, recovery with automatic settlement disabled, optimistic filing, mobile, and notification suppression.main'srejects settling a thread while a run is activetest now expects the thread to be filed, which is the behavior this PR adds.pnpm exec vp run --filter @t3tools/web build) and server bundle (pnpm exec vp run --filter t3 build:bundle) passed.mainatd8d037eae(attachments, ACP teardown on Windows, mobile branch checkout), none in code this PR touches.Test command
Visual evidence
Web client on Windows 11, against isolated dev servers (
vp run devin each worktree) with real Codex turns that runStart-Sleepin a scratch Git project. Re-recorded after mergingmain. All files are in this gist.mainat611132c178a0df2f6dSettle while working, 2x speed. Full-speed MP4.
Agent settles its own thread, 2x speed. Full-speed MP4. The agent called
t3-code.t3_thread_organizewith{"action":"settle"}during its own turn. The thread was filed while the turn ended and settled once it completed. This is the case from the agent self-settle report.Filed thread with a pull request watch, 2x speed. Full-speed MP4. The agent watched this PR with
watch_pull_request, then ranStart-Sleep. Settle filed the thread while it worked. When the turn ended, the watch did not hold it: the thread settled and the watch stopped, with the PR still linked.In an earlier take the watch woke the agent once before the turn ended. The filed thread waited for that queued continuation, then settled and stopped the watch.
Server events for the recorded threads
Not checked: native iOS or Android, and the Electron desktop shell, which wraps the same web UI.
Agents: GPT-6 using the Codex harness for the initial implementation; Claude Opus 5.5 using the Claude Code harness for the review fixes, the merge of current
main, and visual evidence.🤖 Generated with Claude Code