Skip to content

fix(server): terminals no longer inherit the launching tmux session - #13359

Open
UzEE wants to merge 1 commit into
pingdotgg:mainfrom
UzEE:uzee/strip-multiplexer-terminal-env
Open

UzEE wants to merge 1 commit into
pingdotgg:mainfrom
UzEE:uzee/strip-multiplexer-terminal-env

Conversation

@UzEE

@UzEE UzEE commented Sep 24, 2026 •

Copy link
Copy Markdown

What Changed

Integrated terminals no longer inherit TMUX, TMUX_PANE, STY, WINDOW, ZELLIJ, ZELLIJ_SESSION_NAME, or ZELLIJ_PANE_ID from the server process. The change adds these names to TERMINAL_ENV_BLOCKLIST in apps/server/src/terminal/Manager.ts, the same list that already drops ELECTRON_RUN_AS_NODE (#1162).

The blocklist only filters the inherited server env. A per-terminal or provider env can still set any of these variables. One test in Manager.test.ts covers both cases.

Why

If you start the server from a tmux pane with t3 serve, npx t3, or vp run dev, every integrated terminal gets that pane's TMUX and TMUX_PANE. Shells in the terminal then act as if they run inside tmux, even though their pty belongs to T3 Code:

  • Clipboard helpers that check $TMUX run tmux load-buffer -w -. The copy goes to the tmux session that launched the server, not to the T3 Code terminal.
  • tmux split-window, tmux display, and anything that reads TMUX_PANE act on that unrelated pane.

GNU screen (STY, WINDOW) and Zellij (ZELLIJ*) have the same problem. I only drop the variables Zellij sets for a session, so user settings like ZELLIJ_CONFIG_DIR still pass through.

The background service (t3 service install) is not affected. systemd and launchd start it with a clean env.

I checked it by hand. I ran vp run dev from a tmux pane, opened an integrated terminal, and ran echo "TMUX=$TMUX PANE=$TMUX_PANE TP=$TERM_PROGRAM". It printed TMUX= PANE= TP=tmux. TERM_PROGRAM=tmux still comes through because this PR leaves it alone. #9954 sets TERM_PROGRAM for T3 Code terminals, which would fix that part.

This does not make copying from the terminal work. That needs OSC 52 support (#8361).

Tests: vp test run src/terminal/Manager.test.ts (83 passed), server typecheck, and lint on the changed files.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (no UI changes)
  • I included a video for animation/interaction changes (none)

Model: Claude Opus 5.5. Harness: Claude Code in T3 Code.

Summary by CodeRabbit

  • Bug Fixes
    • Terminal sessions no longer inherit multiplexer environment variables from the pane that launched the server, including variables for tmux, screen, and Zellij. This keeps terminal environment details separate from the launching pane.
    • Environment values provided directly when opening a terminal are still preserved, including an explicitly supplied TMUX_PANE value.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 24, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This changes the default environment of integrated terminals by stripping multiplexer context from inherited server variables, affecting all relevant terminal sessions rather than an opt-in path. The implementation is small and tested, but the default behavior change warrants human review.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: bdf0d88f-028a-4437-a04c-49d0fb3e88f8

📥 Commits

Reviewing files that changed from the base of the PR and between 54fce3db31f62feb8c8965142d197e021e9599c2 and 7866600.

📒 Files selected for processing (1)
  • apps/server/src/terminal/Manager.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The terminal spawn environment now excludes multiplexer variables inherited from the launching pane. A test checks that these variables are filtered and that an explicitly supplied TMUX_PANE value remains.

Changes

Terminal environment filtering

Layer / File(s) Summary
Filter inherited multiplexer variables
apps/server/src/terminal/Manager.ts, apps/server/src/terminal/Manager.test.ts
The blocklist excludes multiplexer variables from the inherited environment. A test checks that an explicit TMUX_PANE value is retained.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 78666

Terminal spawns no longer inherit the launching multiplexer’s variables, while explicitly supplied terminal values remain available. No material merge-blocking risk is evident.

Architecture Summary

Architecture risk: 🔵 Low · up to 78666

The change affects 1 system.

Changed systems: apps/server

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/server (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/terminal/Manager.ts: TERMINAL_ENV_BLOCKLIST is expanded from PORT, ELECTRON_RENDERER_PORT, and ELECTRON_RUN_AS_NODE to additionally block the multiplexer pane variables TMUX, TMUX_PANE, STY, WINDOW, ZELLIJ, ZELLIJ_SESSION_NAME, and ZELLIJ_PANE_ID; a comment explains the multiplexer pane variables were inherited from the launching pane, not the PTY. When any of these variables are present in the base environment, shouldExcludeTerminalEnvKey now filters them out of the terminal spawn environment instead of passing them through.
  • observed — Modified behavior in apps/server/src/terminal/Manager.test.ts: Adds a test asserting that inherited multiplexer session variables are absent from a terminal’s spawn environment, while an explicitly supplied TMUX_PANE on another terminal is preserved.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing terminals from inheriting the launching tmux session.
Description check ✅ Passed The description includes the required What Changed, Why, UI Changes, and Checklist sections. It explains the affected variables, behavior, rationale, testing, and that no UI changes apply.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

When the server runs inside tmux, screen, or Zellij, integrated terminals
inherited TMUX, TMUX_PANE, STY, WINDOW, and ZELLIJ* from it. Tools then
acted on the pane that launched the server, e.g. clipboard helpers wrote
to that tmux buffer instead of the T3 Code terminal. Drop these from the
inherited env; explicit terminal env can still set them.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@UzEE
UzEE force-pushed the uzee/strip-multiplexer-terminal-env branch from 54fce3d to 7866600 Compare September 26, 2026 05:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant