Skip to content

fix(desktop): use consistent env for persistent terminal sessions - #778

Closed
Kitenite wants to merge 3 commits into
mainfrom
env-var-testing
Closed

Kitenite wants to merge 3 commits into
mainfrom
env-var-testing

Conversation

@Kitenite

@Kitenite Kitenite commented Jan 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Persistent terminal mode was merging daemon's process.env with the filtered env from buildTerminalEnv()
  • This caused inconsistent behavior vs non-persistent mode which uses only the filtered env
  • The daemon's process.env could be stale or contain unexpected values, leading to unpredictable terminal environments
  • Now both modes use only the filtered env from buildTerminalEnv(), ensuring consistent behavior

Test plan

  • Enable terminal persistence in settings
  • Kill existing daemon: pkill -f "terminal-host.js"
  • Open a new terminal in Superset
  • Verify terminal environment matches non-persistent mode behavior
  • Run bun dev inside a Superset terminal to verify env vars work correctly

Note

Ensures persistent terminal sessions use the same environment as non-persistent mode.

  • In session.ts spawn(), build processEnv solely from the provided filtered env and set TERM to xterm-256color
  • Stop merging in the daemon's process.env, preventing stale or unexpected variables

Written by Cursor Bugbot for commit 6d1c275. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Refactor
    • Optimized terminal session environment variable handling in the desktop application, simplifying internal environment construction while maintaining existing behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

The daemon-based terminal manager was merging the daemon's process.env
with the filtered environment from buildTerminalEnv(). This caused
inconsistent behavior between persistent and non-persistent modes:

- Non-persistent: uses only the filtered env from buildTerminalEnv()
- Persistent: merged daemon's process.env + filtered env

The daemon's process.env could be stale (from when daemon was first
spawned) or contain different values than expected, leading to
unpredictable terminal environments.

Now both modes use only the filtered env from buildTerminalEnv(),
ensuring consistent and predictable behavior.
@coderabbitai

coderabbitai Bot commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Simplified subprocess environment variable handling in terminal session creation by replacing manual filtering and merging logic with direct object spreading, reducing code complexity while maintaining equivalent functionality across the process environment setup.

Changes

Cohort / File(s) Summary
Terminal Session Environment Setup
apps/desktop/src/main/terminal-host/session.ts
Refactored environment variable construction for subprocess spawning: replaced explicit filtering of process.env (excluding ELECTRON_RUN_AS_NODE and undefined values) with simplified object spread syntax (...env). The actual spawn call retains full process.env with ELECTRON_RUN_AS_NODE set via spawn options.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through variables with glee,
Spreading objects left and right with such ease,
No filtering fuss, just ...env so clean,
The simplest solution the coder has seen! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: using consistent environment variables for persistent terminal sessions across both modes.
Description check ✅ Passed The PR description covers the summary of changes, related context about the inconsistency, and includes a detailed test plan with specific steps to verify the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@cursor

cursor Bot commented Jan 16, 2026

Copy link
Copy Markdown

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on February 14.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@Kitenite Kitenite closed this Jan 16, 2026
@github-actions

github-actions Bot commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

@Kitenite Kitenite reopened this Jan 16, 2026
@Kitenite Kitenite closed this Jan 17, 2026
@Kitenite
Kitenite deleted the env-var-testing branch January 17, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant