Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(updates): continue active threads across server restarts #9167

Mergedmaria-rcksmerged 8 commits intomain fromrefs/pull/9167/headmerged by maria-rcks View on GitHub

maria-rckscommented

Note

Written by gpt-5.6-sol on behalf of Maria

When enabled, an update resumes active threads without a prompt when the provider supports it → otherwise T3 sends "Continue where you left off."

Verified with 290 focused tests, targeted web/contracts/server typechecks, and the real local desktop-managed settings flow.

beforeafter
general settings beforegeneral settings after

Built with gpt-5.6-sol in T3 Code through the Codex harness.


Note

Medium Risk Touches self-update handoff timing, post-restart session reconciliation, and sendTurn validation; incorrect marker or continuation logic could resume the wrong turn or leave sessions stuck.

Overview Adds an opt-in path to resume in-flight provider work after a self-update restart, instead of always treating restarted sessions as orphaned.

Server: When the client sends continueRunningThreads, withRunningThreadContinuation marks running, resumable threads in the session directory before handoff (at installing for boot-service, at desktop commit for desktop-managed). Markers are cleared on real failures but kept once the launcher/desktop handoff is accepted. After restart, reconcileProviderSessions resumes marked threads via sendTurn—promptless for adapters with promptlessTurnContinuation (Codex), otherwise a fixed “Continue where you left off.” prompt. Environment descriptors advertise serverUpdateThreadContinuation alongside progress-capable self-update paths.

Client: New Continue threads after server updates setting (default off). Update buttons pass continueRunningThreads only when the server capability and that preference are both enabled.

Contracts: Optional continuation on provider turns, continueRunningThreads on self-update input, and the new environment capability flag.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1e64c5abe6f05f9512cd1a438dec8284d87f0f7e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add active thread continuation across server self-update restarts

  • Before a self-update, the server marks eligible running provider sessions with a continuation marker containing their active turn; after restart, reconcileProviderSessions in serverRuntimeStartup.ts resumes marked sessions with provider-specific input and clears the marker on success.
  • The withRunningThreadContinuation wrapper in selfUpdate.ts prepares markers at the appropriate handoff stage (installing for web mode, commit for desktop mode), retains them across interrupt-only termination after handoff acceptance, and clears them on other failures.
  • A new client setting continueThreadsAfterServerUpdate (default false) in settings.ts gates whether update requests include the continueRunningThreads flag; the server advertises support via the serverUpdateThreadContinuation environment capability.
  • ProviderService.sendTurn in ProviderService.ts accepts empty continuation turns only for adapters with the promptlessTurnContinuation capability (currently Codex); Claude and others receive the fallback continuation prompt.
  • Risk: reconcileProviderSessions now treats previously-orphaned running sessions as continuable instead of settling them as errors; archived, deleted, or unresumable sessions are still settled as errors. Partial marker-write failures trigger cleanup of already-written markers before re-failing.
Macroscope summarized 1e64c5a.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. apps/server/src/serverRuntimeStartup.ts line 390Resolvedby maria-rcks
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/70d7017917ec6c3c9c68a1dfefc297880fe0ff5c/apps/server/src/provider/Layers/ProviderService.ts#L780

      A continuation: true request with no prompt or attachments reports ProviderValidationError but leaves an inactive thread running after recovery, including its MCP credential, when the provider does not support promptless continuation. Because allowRecovery: true runs recoverSessionForThread before this capability check, validate the adapter capability before recovery and only recover supported requests.

      ✅ Resolved in 657bce11fee3ca861840857d4347079f7ab1f9f2

    4. apps/server/src/serverRuntimeStartup.ts line 474Resolvedby maria-rcks
      apps/server/src/serverRuntimeStartup.ts line 368OutdatedResolvedby maria-rcks
      apps/server/src/cloud/selfUpdate.ts line 111OutdatedResolvedby maria-rcks
      apps/server/src/serverRuntimeStartup.ts line 463Resolvedby maria-rcks
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR introduces a cross-cutting production workflow that persists active-session state, changes self-update handoffs, and automatically resumes provider work after restart across server, provider, protocol, WebSocket, and client layers. It also adds a new product preference with a defined default, so the scope and default behavior warrant human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Note

      Written by gpt-5.6-sol on behalf of Maria

      fixed in 657bce11f. promptless capability validation now happens before recovery, with coverage proving an unsupported stopped session is not restarted.

    7. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e87c98fced43a061437ce5a3e4b8fb4b503e28a4. Configure [here](https://www.cursor.com/dashboard/bugbot).
      apps/server/src/serverRuntimeStartup.ts line 556OutdatedResolvedby maria-rcks
      apps/server/src/cloud/selfUpdate.ts line 156Resolvedby maria-rcks
    8. maria-rcks merged this5b7d72a

    9. maria-rcks closed this

Sign in to join this conversation.