Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(connections): balance new threads across connected machines #9895

Mergedmaria-rcksmerged 12 commits intomain fromrefs/pull/9895/headmerged by maria-rcks View on GitHub

maria-rckscommented

When enabled in Connections, new threads in shared projects choose a connected machine using whole-host CPU and available memory, with per-machine choices (Prefer, Normal, Less often, or Manual only) in Connections. The composer calls this Auto balance and gives it a scales icon, without appending a machine name. Automatic routing is opt-in and defaults off in web/desktop, supports any number of machines, and keeps the selected machine stable; choosing a machine, branch, or worktree manually pins the draft. Existing threads and the native mobile app keep their current routing.

Auto balance defaults off for new settings and older settings that omit the field; saved choices are preserved. The opt-in revision passes scoped lint and 119 existing-file settings tests across contracts, web hydration, and desktop persistence. CI and both independent source reviews pass on 61423c5e1; no conflicts or unresolved review threads remain. Fresh visual evidence for the preference dropdowns remains blocked by preview capture failures; earlier interaction and persistence checks passed. Native macOS/Windows resource sampling remains unverified.

Before the name/icon refinement:

composer before the standalone auto balance name

After:

auto balance with a scales icon and no machine suffix

auto balance in the narrow dark composer

auto balance in the narrow light composer

Implemented with gpt-5.6-sol in Codex.


Note

Medium Risk Changes default draft routing for multi-machine projects (load balancing defaults on) and adds host resource RPC sampling; wrong eligibility or stale metrics could send work to a busy machine or block send until override.

Overview Adds automatic load balancing for new draft threads in multi-environment shared projects. Web/desktop clients can enable it under Settings → Connections, set per-machine preference weights (0 = manual only), and pick Auto balance in the composer to re-check resources or override with a specific machine.

The server exposes server.getHostResources, sampling whole-host CPU (200ms delta) and platform-specific available memory with a 5s shared cache. The client scores eligible connected machines (provider-ready, positive weight, not saturated) via chooseLoadBalancedEnvironment, then pins the draft’s loadBalancedEnvironmentId until the user chooses a machine, branch, or worktree manually. Send is blocked until settings hydrate and balancing finishes; attachments require staying on the current machine for auto routing.

Draft persistence gains environmentSelection (auto | manual) and clears balanced routing on project remaps. Existing threads and mobile stay on manual environment selection.

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

Note

Add automatic load balancing for new threads across connected machines

  • Adds a HostResources service that samples host CPU and memory capacity and exposes it over websocket RPC (serverGetHostResources).
  • Adds client settings for loadBalancingEnabled and per-environment loadBalancingWeights, configurable in the Connections settings UI.
  • Draft composers use the useLoadBalancedEnvironment hook and chooseLoadBalancedEnvironment selector to persist an automatic environment choice based on resource capacity and configured weights.
  • Risk: manual environment or branch changes mark the draft selection as manual in composerDraftStore.ts; project remapping clears the persisted load-balanced environment identifier.
Macroscope summarized 61423c5.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. apps/web/src/components/ChatView.tsx line 3279Resolvedby maria-rcks
    3. Stale Bugbot comment from a previous run.

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds a cross-cutting load-balancing workflow with new host telemetry, authenticated RPCs, persisted routing state, settings, and composer send-path behavior. The feature is opt-in, but its implementation is substantial and touches sensitive authorization code, so the changes warrant focused human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Cursor Bugbot has reviewed your changes using default 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 d3eb4c31bfd8eaec618bc1f0a6a92c1815fdbea5. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. maria-rcks merged this420fd76

    7. maria-rcks closed this

Sign in to join this conversation.