Skip to content

feat(tui): inherit terminal environment per session - #42957

Merged
thdxr merged 5 commits into
v2from
session-environment
Aug 17, 2026
Merged

thdxr merged 5 commits into
v2from
session-environment

Conversation

@thdxr

@thdxr thdxr commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • capture the launching terminal environment when the TUI starts, excluding server authentication variables
  • keep a process-local environment snapshot per session and use it for local shell execution
  • refresh existing sessions on route activation and initialize new sessions before their first submission
  • expose and generate the session.environment API

Testing

  • bun test test/session-environment.test.ts test/session-remove.test.ts test/session-create.test.ts test/tool-shell.test.ts (packages/core)
  • bun test test/env.test.ts test/server-connection.test.ts (packages/cli)
  • bun typecheck (packages/protocol)
  • bun typecheck (packages/client)
  • bun typecheck (packages/cli)

Notes

  • The repository-wide pre-push typecheck is currently blocked by existing DOM Headers/Request/Response errors under core dependents and ended with a Bun SIGSEGV. No errors referenced files changed by this PR.
  • live API smoke test: start dev server, set session environment, run session shell, verify attached value

@thdxr
thdxr enabled auto-merge (squash) August 17, 2026 20:08
@thdxr
thdxr merged commit 42fc297 into v2 Aug 17, 2026
8 checks passed
@thdxr
thdxr deleted the session-environment branch August 17, 2026 20:18
shuv1337 added a commit to shuv1337/shuvcode that referenced this pull request Aug 17, 2026
Superseded by anomalyco#42957 (42fc297): per-session in-memory environment inheritance via SessionEnvironment and Env.session().

Upstream forwards the entire client process.env (minus OPENCODE_PASSWORD/OPENCODE_SERVER_PASSWORD) into an in-memory SessionEnvironment map rather than an allowlist with PATH/hijack-var rejection. Env is not durable across server restarts and has no per-message semantics; Shell.create merges the session map when a local sessionID is present, so direct ! session.shell paths share the same inheritance. Trade-offs vs the retired plan: broader privacy surface, no restart survival, no forbidden-key backstop — acceptable given upstream shipped the core shared-service need.
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
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