Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(connections): manage environment availability #5598

ClosedDominicVonk(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/5598/headopened View on GitHub

Saved environments could be removed or retried, but users could not explicitly disable them, re-enable them from an error state, or safely edit their details across desktop and mobile. The composer status also reported a disabled environment without offering a recovery action.

This change makes environment availability a durable, user-controlled property and keeps the behavior consistent across surfaces:

  • persists enabled/disabled state in the existing connection catalog;
  • starts supervisors with the persisted intent and updates persistence before runtime state, without unreachable startup retry machinery;
  • lets web/desktop and mobile enable, disable, retry, edit, and remove environments;
  • opens saved-environment editing in a dialog;
  • preserves disabled state while editing and serializes edits with re-pairing so stale edits cannot overwrite fresh credentials;
  • retains a healthy runtime for label-only/no-op edits and reconnects only when the endpoint changes;
  • restores a persisted registration if a temporary platform registration disappears;
  • keeps successful mobile switch requests optimistic until the catalog confirms them, while failed requests roll back immediately;
  • shows an explicit Retry action for enabled cloud environments in an error state;
  • allows the red composer connection status to enable a disabled environment;
  • includes the reverse operations and current state everywhere the controls are shown.

The implementation uses the existing per-environment registry lease and atomic catalog updates. It does not add a second reconciliation lifecycle or a new dependency.

These PRs all target main and can be merged in any order:

Verification

  • focused behavior suite: vp test run apps/mobile/src/features/connection/environmentSections.test.ts apps/mobile/src/features/home/workspace-connection-status.test.ts apps/mobile/src/features/showcase/showcaseEnvironmentRows.test.ts apps/mobile/src/features/threads/threadEnvironmentActivation.test.ts apps/mobile/src/state/workspaceModel.test.ts apps/web/src/connection/storage.test.ts packages/client-runtime/src/connection/onboarding.test.ts packages/client-runtime/src/connection/registry.test.ts packages/client-runtime/src/platform/storageDocument.test.ts
    • 10 files passed
    • 67 tests passed
  • typechecks:
    • vp run --filter @t3tools/client-runtime typecheck — passed
    • vp run --filter @t3tools/web typecheck — passed
    • vp run --filter @t3tools/mobile typecheck — passed
    • vp run --filter @t3tools/desktop typecheck — passed
    • only inherited Effect suggestions were reported
  • targeted vp lint over all 40 changed files
    • passed
  • fallow audit --base upstream/main
    • completed; 79 inherited findings were excluded and the latest race fix introduced no new blocker
  • desktop integrated pass:
    • paired two disposable local environments through the real Add environment flow
    • disabled an environment, edited its label, and confirmed it remained disabled
    • reopened the dialog and confirmed the Enabled switch remained unchecked
  • iPhone 6.9-inch showcase capture:
    • built and captured with stable Xcode 26.6 (Build 17F113), not Xcode beta
    • both images validated at 1320 × 2868, 24-bit RGB

Screenshots

DarkLight
Environment management in dark modeEnvironment management in light mode

The screenshots show an enabled environment with a connection error and explicit Retry action, plus an available disabled environment with its activation switch.

Desktop screenshots

BeforeDisabled environment
Desktop connections before environment managementDesktop disabled environment with Edit, Remove, and Enable actions

Edit dialog

Desktop edit environment dialog preserving the disabled state

The before image shows the original connect/disconnect-only row. The after images show explicit Edit, Remove, and Enable actions, plus the edit dialog retaining the disabled state after a label update.

Built and reviewed with GPT-5 Codex via Codex CLI.

Fork validation PR


Note

Medium Risk Changes core connection registry lifecycle, catalog schema, and registration APIs used by all clients; behavior is heavily tested but mistakes could affect when supervisors connect or how edits interact with re-pairing.

Overview Environments can stay registered but disconnected. Availability is stored in the connection catalog as disabledEnvironmentIds, wired through a new ConnectionActivationStore on mobile, web, and desktop. Registration now passes an explicit { enabled } flag so migrations and new connections default to enabled.

The registry honors that intent at startup and via setEnabled, so disabling tears down the supervisor without removing credentials or cache until the user removes the environment. updateRegistration (used for bearer edits) keeps disabled state, avoids reconnecting on label-only changes, reconnects when endpoints change, and serializes against re-pairing so stale credential edits cannot win.

Mobile and web replace “toggle = connect/disconnect” with activation switches (optimistic pending state on mobile), Retry for enabled cloud errors, edit flows that preserve disabled state, and thread composer actions that enable a disabled environment before retrying. Web adds an Edit dialog with label/URL updates and an enabled switch on saved backends.

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

Note

Add environment enable/disable support to connection management across web and mobile

  • Introduces a persistent enabled flag for registered environments, stored in the connection catalog's new disabledEnvironmentIds field and exposed via a new ConnectionActivationStore service.
  • Adds setEnabled and updateRegistration methods to EnvironmentRegistry, which persist activation state and immediately connect or disconnect the environment's supervisor.
  • Surfaces enable/disable controls in the web ConnectionsSettings and mobile ConnectionEnvironmentRow/CloudEnvironmentRows UIs, with optimistic toggle state managed by the new EnvironmentActivationSwitch component.
  • On mobile, disabled environments show a 'Disabled' status, hide connection errors, and offer an explicit 'Enable' button; the thread screen routes activation actions through a new threadEnvironmentActivationAction helper.
  • Risk: existing connection catalog documents without disabledEnvironmentIds default to an empty list, and all callers of ConnectionRegistrationStore.register must now pass an options: { enabled: boolean } argument.
Macroscope summarized 5e9126e.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 0e7b63bd-2d4d-484d-a078-94de13fc3259

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Reviewed the new ConnectionActivationStore service, Connectivity.followNetworkStatus, and the registry/supervisor/discovery call sites against the Effect service conventions.

      The service definition itself follows the conventions (inline interface in Context.Service, canonical module placement in platform/persistence.ts, Foo["Service"] references, namespace subpath imports, environment acquisition via yield* Persistence.ConnectionActivationStore in registry.make).

      One convention issue: the activation writes reuse the unrelated "register-connection" operation discriminator, so the persisted operation context — and the message surfaced to the UI — does not identify the failure that actually occurred. Details inline.

      Posted via Macroscope — Effect Service Conventions
    4. The activation-store follow-up mixed up the ConnectionPersistenceError.operation labels in apps/mobile/src/connection/storage.ts: the registration/target store now reports activation operations and the new activation store reports target/registration operations. The web store (apps/web/src/connection/storage.ts) maps the same operations correctly, so the mobile mapping looks like an accidental swap. Since operation is the stable, serializable context callers and messages rely on, each failure should carry the operation that actually ran.

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

      Approvability

      Verdict: Needs human review

      This PR introduces a new feature allowing users to enable/disable environments without removing them. It adds new UI components, persistence fields, and changes connection lifecycle behavior across multiple layers, warranting human review for the new capability.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/d9aacda9d49c937127dde16be4f25bd3f8c994c9/apps/mobile/src/features/connection/CloudEnvironmentRows.tsx#L263

      Disabling an enabled cloud environment via the switch removes its registration instead of setting enabled to false. The switch in ConnectedCloudEnvironmentRow passes enabled=false to onValueChange, which calls props.onDisconnect(), and CloudEnvironmentRowsContent wires that to controller.removeEnvironment. So toggling off deletes the environment's device registration rather than disabling it, causing the row to disappear and requiring rediscovery/re-registration to restore — which is impossible while signed out or offline. The onValueChange handler should call props.onSetEnvironmentEnabled(environment.environmentId, false) (or a dedicated onDisable callback) instead of props.onDisconnect() when enabled is false.

      ✅ Resolved in 5c216ddfac1740b2443bc1a25e636831fdcefe1b

    7. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/5c216ddfac1740b2443bc1a25e636831fdcefe1b/apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx#L71

      When an environment is disabled after a failed connection, the status label shows Disabled in the error color with the old trace ID appended, and the status dot can still display a failed/retrying state. The row computes hasConnectionFailure and statusTraceId directly from connectionError/connectionErrorTraceId and passes connectionState to ConnectionStatusDot without checking enabled, so stale connection state leaks through alongside the Disabled label. Consider gating those derived values on environment.enabled so a disabled environment presents a clean disabled state.

      ✅ Resolved in fe43036bba8da6658421b8538642bd62bca79b2e

    8. One convention issue found: newly added tagged-failure recovery in packages/client-runtime/src/connection/onboarding.ts uses Effect.catchTag instead of Effect.catchTags. The previously flagged ConnectionPersistenceError operation labels in apps/mobile/src/connection/storage.ts now match the failing calls.

      Posted via Macroscope — Effect Service Conventions
    9. Effect service conventions review: the previously flagged catchTag/persistence-operation labelling issues are resolved. One remaining observation in packages/client-runtime/src/connection/layer.ts.

      Posted via Macroscope — Effect Service Conventions
    10. 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).

      Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0761c9138fa7e17794e192f9f32932ffcdcb8f6e. Configure [here](https://www.cursor.com/dashboard/bugbot).
    11. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together.

      This branch adds availability flags, catalog migration, onboarding controls, and connection behavior across desktop, mobile, web, contracts, and server. It creates a new environment state without a clear rule for how disabled, offline, deleted, and remote environments differ.

      If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed.

Sign in to join this conversation.