← Back to Pull requests

fix(launch): the first seat on a new tmux server gets the scoped environment too #2047

Closed
unknown closed this pull request without merging on Oct 25, 2026 18:52 UTC
View on GitHub
unknown unknown commented on Oct 25, 2026 18:01 UTC
Author

What a user gets

The first seat launched on a new tmux server now gets the same scoped environment as every later seat. It no longer gets the daemon's whole environment.

Before, the scoped launch read the default shell, default-command and update-environment from the running tmux server. When rig up launched a rig while no tmux server was running yet, those reads failed. The launch then fell back to the previous behaviour, "Scoped tmux environment unavailable; retaining the previous environment for this launch". So that first seat inherited everything the daemon carries, such as ANTHROPIC_BASE_URL, OPENAI_BASE_URL and CLAUDE_CODE_USE_BEDROCK, while later seats didn't.

Now, when those options can't be read, the empty tmux server is started first, the same way a first start of one seat already does, and the options are read again. A server started this way loads the person's tmux config, so their default shell and update-environment apply to the first seat too.

The seat-environment integration test was asserting the old inherited environment, which #1573 removed on purpose. On Linux it failed. On macOS, where CI runs it, it passed without checking anything, because there's no /proc. It now asserts today's behaviour:

  • a seat gets the selected configuration (CLAUDE_CONFIG_DIR, CODEX_HOME, the daemon's PATH, HOME, OPENRIG_HOME);

  • it gets nothing else the daemon or tmux server carries;

  • the parent session's identity stays out.
  • It runs on Linux only, and is skipped on macOS rather than passing there.

    Reported by @AdamWhitehurst in #2041 (items 3 and 4). Refs #2041.

    How you verified it

  • On Linux (Ubuntu 26.04, tmux 3.6, Node 22), a fresh clone of main at a16735a9, npm ci, daemon and CLI built.

  • - main with the old test: the "existing server" case fails. A seat doesn't get ANTHROPIC_BASE_URL, OPENAI_BASE_URL or CLAUDE_CODE_USE_BEDROCK, and its PATH is the daemon's, so the old expectations no longer hold. The "daemon" case passes.
    - main with the updated test: the "existing server" case passes. The "daemon" case fails: the only seat, the first on the new server, has ANTHROPIC_BASE_URL, CLAUDE_CODE_USE_BEDROCK and OPENAI_BASE_URL. That's the reported fallback, through rig up.
    - With this change (daemon rebuilt): both integration cases pass.
  • A new case in tmux-agent-environment.test.ts (real tmux on a private socket, so it runs on macOS too).

  • - The setup: no server is running; the person's ~/.tmux.conf sets the default shell and an observing default-command; a daemon-only variable is set.
    - With this change, the first seat sees the selected value and not the daemon-only one, and no fallback warning is logged.
    - With main's tmux.ts it sees the daemon-only value and not the selected one. That's on Linux and macOS.
  • macOS: tsc --noEmit passes. 559 tests pass across 15 tmux, launch, first-start, restore and teardown test files, with the integration file reported as skipped (2 tests). Single worker.

  • Not run here: the full npm test and npm run lint, which are left to CI.
  • Anything you were unsure about

  • Starting the server inside the scoped launch adds no tmux calls when a server is already running. It only starts one where new-session would otherwise have started it with the daemon's environment.

  • CI runs the daemon tests on macOS only, so the integration test is skipped there. The new adapter test covers the first-seat behaviour on both platforms, but a Linux job would be what runs the integration test in CI.
  • One concern per PR; no version bump; no CHANGELOG.md edit

  • Tests added or updated where the change is testable

  • I listed the checks I ran, their results, and any checks I could not run
  • 🤖 Generated with Claude Code

    Diff: 485 lines (+363 / -122) across 6 files Reviewer: openrig-review Review duration: 50m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 485 lines diff across 6 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.370
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #2047"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.3% (MEDIUM) · Higher = larger blast radius
    52.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.7% · Safe to merge
    20.7%