Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(web): automatically update idle servers #7503

Closedt3-code-bot[bot](GitHub profile, opens in a new tab)wants to merge 9 commits intomain fromfeat/automatic-server-updatesopened View on GitHub

what changed

  • adds an opt-in automatic server update setting per environment, off by default
  • waits for a live shell snapshot and for every active turn, provider startup, and background task to finish
  • rechecks the server's authoritative activity snapshot after download and before activation
  • blocks new agent commands between the final idle check and service-launcher handoff
  • suppresses repeat attempts for a failed target until an explicit manual retry
  • upgrades background-service servers only when the connected client is newer, so it never downgrades
  • reuses the existing verified download, restart, rollback, and reconnect pipeline
  • shows waiting, downloading, restarting, and failed states in chat and connections
  • adds an enable auto-updates action for every currently connected environment
  • documents the automatic update behavior and background-service requirement

related to #5513.

screenshots

before, light

connections before automatic updates in light mode

after, light

connections with automatic updates in light mode

before, dark

connections before automatic updates in dark mode

after, dark

connections with automatic updates in dark mode

how to test

  1. run a client newer than a connected background-service server.
  2. open settings → connections and turn on automatic server updates for that environment.
  3. keep an agent turn or background task active and confirm the update waits.
  4. let the environment become idle and confirm it updates, restarts, and reconnects.
  5. confirm a newer server is never offered the older client version.

verification

  • vp test run packages/shared/src/semver.test.ts apps/server/src/cloud/selfUpdate.test.ts packages/contracts/src/settings.test.ts packages/client-runtime/src/state/server.test.ts apps/web/src/components/ServerUpdateAction.test.tsx apps/server/src/bin.test.ts (100 passing)
  • full repository suite: 8,288 passed and 7 skipped; one unrelated provider-registry timing test failed once and passed immediately in isolation, while the 2 unchanged root-runner failures reproduce for the node test file and wasm?inline fixture
  • targeted lint on all changed typescript files
  • targeted typecheck for contracts, shared, client runtime, server, and web
  • production web build
  • real web app rendered and inspected in light and dark mode

request provenance

  • requested by: @maria-rcks

Note

Medium Risk Changes the self-update and orchestration admission paths on the server (including rejecting new agent work during automatic activation), but behavior is heavily covered by new tests and scoped to opt-in automatic updates on background-service environments.

Overview Adds an opt-in per-environment automaticallyUpdateWhenIdle setting (default off) so launcher-managed servers can align with a newer connected client without a manual Update server click.

The client waits for a live shell snapshot and no active sessions, turns, or background work, then calls self-update with automatic: true. A root AutomaticServerUpdateCoordinator drives that flow and syncs a new pending update state (synchronizing vs active-work) into chat and Connections.

The server extends self-update for automatic mode: rejects non-upgrades and repeated automatic retries after a failed target until manual retry; runs an idle re-check on the authoritative shell snapshot after download and before launcher handoff; defers with ServerAutomaticUpdateDeferredError if work appeared during download; and withCommandAdmission blocks new orchestration dispatches (HTTP and WS) once automatic handoff is accepted. Manual updates are unchanged.

Connections adds per-environment and bulk Enable auto-updates controls (boot-service only). User docs describe the behavior. Semver parsing now ignores build metadata for comparisons used in version gating.

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

Note

Add automatic idle-aware server updates with per-environment opt-in controls

  • Introduces an opt-in automaticallyUpdateWhenIdle setting per environment; when enabled, the server automatically updates to the client version once no active work (running sessions, turns, or background liveness) is detected.
  • Adds automaticServerUpdateDecision logic in the client runtime that gates updates on semver comparison, shell status, and thread activity, producing ineligible, pending (with reason synchronizing or active-work), or ready outcomes.
  • The server's ServerSelfUpdate service gains idle-check enforcement, downgrade rejection, deferred-update error propagation, and a withCommandAdmission gate that blocks orchestration dispatch when an automatic handoff is pending.
  • A new AutomaticServerUpdateCoordinator component mounts in the authenticated root and drives update requests per environment; ConnectionsSettings gains a bulk "Enable auto-updates" button and per-environment toggle.
  • Chat and settings UIs surface a new pending update state with contextual banners and progress messages, and the update RPC error schemas are extended to carry ServerAutomaticUpdateDeferredError.
  • Fixes normalizeSemverVersion to strip build metadata (e.g. 1.2.3+build.7) before semver comparison.
  • Risk: orchestration dispatch over HTTP and WS now fails with an admission error while an automatic update handoff is pending, which is a new failure mode for connected clients.
Macroscope summarized a0f0b72.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Reviewed the changed Effect service code (apps/server/src/cloud/selfUpdate.ts, apps/server/src/orchestration/http.ts, apps/server/src/ws.ts, and the touched packages/* modules) against the service conventions. Two findings, both in apps/server.

      Posted via Macroscope — Effect Service Conventions
    3. UI consistency review of the changed web surfaces found three issues, all on lines this PR adds: the new pending update state is presented as live progress in the composer banner (losing dismissal and the manual Update action), the new header action duplicates a large class-string override of Button's geometry and base colors instead of reusing/extending a named variant, and the compact auto-update toggle renders capability copy for environments that are not connected.

      Posted via Macroscope — UI Consistency
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire12.6 KiB12.6 KiB+16 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire6.3 KiB6.3 KiB−1 B (−0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.3 KiB6.3 KiB+17 B (+0.3%)7.8 KiB✅
      CodexLive turn WebSocket decoded51.8 KiB51.8 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages16160 (0.0%)21✅
      ClaudeTotal thread wire12.6 KiB12.6 KiB+1 B (+0.0%)15.1 KiB✅
      ClaudeThread snapshot wire6.3 KiB6.3 KiB−4 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.3 KiB6.3 KiB+5 B (+0.1%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded52.7 KiB52.7 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages16160 (0.0%)21✅

      Baseline: 2aa5f09 · PR result: a0f0b72 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 99.9 KiB
      • Claude decoded thread snapshot: 100.6 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    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 new automatic server update feature with command admission control, idle-checking logic, and new UI surfaces — substantial new runtime behavior requiring human review. A Medium-severity finding about retry logic after deferred updates also warrants attention.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. UI consistency review found one interaction regression and two consistency issues in the new automatic-update surfaces. Earlier findings on the header button styling and the disconnected-row toggle look addressed.

      Posted via Macroscope — UI Consistency
      @@ -3048,4 +3173,5 @@
      30483173 control={
      30493174 primaryVersionMismatch &&
      30503175 primaryEnvironmentId !== null &&
      3051- primaryServerUpdateState.status !== "running" ? (
      3176+ (primaryServerUpdateState.status === "idle" ||
      3177+ primaryServerUpdateState.status === "failed") ? (
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Narrowing this to idle/failed hides the manual Update control while an automatic update is pending, but the conversation notice keeps it (ChatView.tsx only suppresses actions for updateInProgress), so the same state offers an escape hatch in one surface and not the other. SavedBackendListRow (line 1556) has the same narrowing. Consider keeping the manual action available during pending here too, so both surfaces agree on what a waiting automatic update lets the user do.

      Posted via Macroscope — UI Consistency
    7. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      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 4eac7f4f26e04cc2af962ed506f3c5d4d212322b. Configure [here](https://www.cursor.com/dashboard/bugbot).
    8. One convention violation found in the changed Effect service code: Effect.catchTag in the orchestration dispatch handler. Inline comment below.

      Posted via Macroscope — Effect Service Conventions
    9. UI consistency review of the automatic-server-update surfaces. The earlier compact-switch labelling, ghost-muted header action, and disconnected-row gating are all addressed; two smaller call-site inconsistencies remain in ConnectionsSettings.tsx.

      Posted via Macroscope — UI Consistency
    10. One finding: the new retryWhenIdle flag on ServerSelfUpdateError is a control-flow discriminator rather than a diagnostic field, which the error conventions ask to model as a distinct tagged error class.

      Posted via Macroscope — Effect Service Conventions
    11. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High cloud/selfUpdate.ts:168

      A manual retry interrupted while clearing lastFailedTarget leaves inFlight permanently true, so every subsequent update is rejected as already in progress until the server restarts. This yield* Ref.set(...) runs after the claim but before operation installs its Effect.onError cleanup; move it inside the protected operation or bracket the inFlight claim.

      ✅ Resolved in c7e37ceffdaeeb570ac53d7b525674a3c9fc3627

    12. One convention finding on the new command-admission wiring in apps/server/src/ws.ts. The rest of the change (the ServerSelfUpdateIdleCheck service dependency, ServerAutomaticUpdateDeferredError as its own tagged error, Effect.catchTags in orchestration/http.ts and in the progress stream) matches the service conventions.

      Posted via Macroscope — Effect Service Conventions
    13. fixed in c7e37ceff. clearing the failed target now happens inside the protected operation, and a regression test interrupts a manual retry and verifies automatic suppression plus later manual retry still work.

    14. One finding: the automatic-update coordinator publishes the new pending update state for environments that are not connected, which makes two surfaces claim an automatic update is waiting on an offline server and breaks ChatView's version-skew banner fold. Details inline.

      Posted via Macroscope — UI Consistency
    15. @@ -0,0 +70,21 @@
      70+ return;
      71+ }
      72+
      73+ if (decisionStatus !== "ready" || fromVersion === null || targetVersion === null) {
      74+ return;
      75+ }
      76+
      77+ const targetKey = `${fromVersion}->${targetVersion}`;
      78+ if (updateState.status === "running") {
      79+ attemptedTargetRef.current = targetKey;
      80+ return;
      81+ }
      82+ if (
      83+ updateState.status === "failed" &&
      84+ updateState.fromVersion === fromVersion &&
      85+ updateState.targetVersion === targetVersion
      86+ ) {
      87+ attemptedTargetRef.current = targetKey;
      88+ return;
      89+ }
      90+ if (attemptedTargetRef.current === targetKey) {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium components/AutomaticServerUpdateCoordinator.tsx:90

      A ServerAutomaticUpdateDeferredError leaves the environment permanently unable to retry while decisionStatus remains ready: updateServer resets updateState to idle, but attemptedTargetRef still equals targetKey, so the next effect run returns at line 90. Clear or otherwise invalidate this key when the update is deferred so a later eligible attempt can proceed.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/components/AutomaticServerUpdateCoordinator.tsx around line 90:
      
      A `ServerAutomaticUpdateDeferredError` leaves the environment permanently unable to retry while `decisionStatus` remains `ready`: `updateServer` resets `updateState` to `idle`, but `attemptedTargetRef` still equals `targetKey`, so the next effect run returns at line 90. Clear or otherwise invalidate this key when the update is deferred so a later eligible attempt can proceed.
    16. Note

      This comment is posted by Julius' dot

      Closing under the verification requirement. The screenshots show disabled controls on a server without background-service support. They don't demonstrate the new automatic-update flow, and no recording is supplied. Add a short recording on a supported environment showing the update wait for active work, then restart and reconnect when idle, with the observed result. Then request reconsideration.

    17. juliusmarminge closed this

Sign in to join this conversation.