Repository navigation
fix(server): resolve the login-shell env only for launchers that opt in - #714
Merged
Merged
Conversation
added 4 commits
October 12, 2026 19:09
Rinat S (rsolmano)
requested review from
Olga Lavrichenko (OLavrik),
Rustam Sadykov (SBOne-Kenobi) and
danyaberezun
as code owners
October 12, 2026 17:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #689,
bootHost()always imports the user's login-shell environment (provider API keys included), skipping it only whenTERMis set.bun testdropsTERM=dumb, which is what agent shells and turbo provide. Sosrc/host/boot.test.tscopied the developer's real login env into the sharedbun testprocess, and later faux-model suites resolved a real provider instead of the faux one. On a machine withANTHROPIC_API_KEYin~/.zshrc,chatResources.test.tsthen talks to real Anthropic: its scripted tool calls never happen, tests time out one after another, and the server suite hangs indefinitely at about 150% CPU while spending real tokens.Impact today: every
bun run teststarted from a ThinkRail agent hung until the 30-minute bash timeout. Because the tool's timeout doesn't kill turbo's child process groups, the hungbun testprocesses then stayed running for hours and slowed every other workspace (load average ~77; e2e took over an hour; pre-commit typecheck timed out).Bisected: at
57a1361a(the parent of #689)boot.test.tsleaves the env alone; atea08fbdc(#689) theboot.test.ts+chatResources.test.tspair imports the key and hangs.Approach
Make the login-shell resolution opt-in instead of something tests must opt out of.
BootHostOptions.resolveShellEnvdefaults to off; the three real launchers (dev.ts, the CLI bootstrap, the desktop host generator) passtrue, so shipped behavior is unchanged. Any embedder or test that does not pass the flag keeps the environment it was given.Trade-off: the flag gates the whole
resolveShellEnv()(PATH, locale andSSH_AUTH_SOCKrepairs too), so a future launcher that forgets it loses all of them. That is the safer failure mode than leaking credentials into test processes.Changes
packages/server/src/host/boot.ts: newresolveShellEnv?: booleanboot option;resolveShellEnv()runs only when it is set.packages/server/src/dev.ts,apps/cli/src/bootstrap.ts,apps/desktop/preBuild.ts: opt in.packages/server/src/host/boot.test.ts: deterministic regression test using a fake login shell that exports a canary variable. The canary must stay absent without the flag and be imported with it. The test fails with the guard reverted. Skipped on win32, whereresolveShellEnvdoes nothing.packages/server/SPEC.md,packages/server/src/host/SPEC.md(with the post-mortem),apps/cli/SPEC.mdandapps/desktop/SPEC.mddescribe the opt-in.Not in this PR (follow-ups):
bun testfrom an agent shell still inherits the key the app itself imported. A test preload that strips ambient provider credentials would close that.boot.test.ts, the detached-Agent tests inchatResources.test.tsfail. It does not hang and predates feat: upgrade pi to 1.1.0, gate session reloads and teardown, import the login env #689.Screenshots
Not applicable — no frontend changes.
Related issues
Regression from #689.
Checklist
bun run lint,bun run typecheck,bun run test(lint and typecheck re-run green after the rebase onto9d6ad0b2.bun run test: server 1464 pass and 4 fail, finishing in 2m36s instead of hanging. The 4 failures arechangesCRLF/final-newline tests that also fail onmainwithout this change. All other tasks are green.)bun run e2e: all 8 shards passed in 268s, run before rebasing over the web-only feat(web): calm the topbar location bar #712)SPEC.md/ top-level specs updated to reflect any boundary, contract, or behavior changeAlso run:
bun run check:deps,check:boundaries,check:seamsandcheck:spec-surfaceare green.bun test src/host/boot.test.tsgives 16 pass.env -u ANTHROPIC_API_KEY bun test src/host/boot.test.ts src/agent/chatResources.test.tsnow finishes in 50s; before the fix it hung.