Skip to content

Fix inherited PTY setup launch state - #16909

Closed
brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/main-red-e2e-wslenv-r1
Closed

brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/main-red-e2e-wslenv-r1

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​138 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​106
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31 $\color{#cf222e}{\Huge{\mathbf{−}}}$​39 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8

ELI5

Some Orca terminals are "gated": the workspace has a setup script, so instead of starting the agent immediately, Orca gives that terminal two private environment variables that mean "wait for setup to finish, then run this agent command." Environment variables are inherited by every program a process starts — and that is the bug. If you launched Orca itself from inside one of those gated terminals (for example, typing orca in that pane's shell), the new Orca process inherited the "you are launching an agent" markers and passed them on to every terminal it opened. Every plain terminal then looked like it was launching an agent.

Two things you could actually notice:

  1. Git stopped asking for credentials. Orca deliberately disables interactive Git credential prompts in unattended agent terminals (GIT_TERMINAL_PROMPT=0, blanked GIT_ASKPASS/SSH_ASKPASS, GCM_INTERACTIVE=never, credential.interactive=false) so an agent can never hang on an invisible "Username:" prompt. With the inherited markers, that guard fired in ordinary user terminals too: a git clone/fetch/push over HTTPS that needed to ask for credentials failed immediately with fatal: could not read Username … terminal prompts disabled instead of prompting. Cached credentials kept working (the credential helper is preserved), so it presented as intermittent auth failure rather than an obvious config problem.
  2. OMP status entries disappeared (the originally reported symptom): the terminal "already" seemed to be launching an agent, so the derived OMP status setup was suppressed.

When you'd hit it

  • A pane is setup-gated: the workspace has a setup command, so the agent pane's shell carries ORCA_SEQUENCED_STARTUP_COMMAND (plus ORCA_SEQUENCED_STARTUP_SCRIPT on POSIX) for its whole lifetime.
  • From that shell you start an Orca process — the desktop app or CLI locally, or an Orca relay server on an SSH host. That process's process.env now carries the sequencing variables.
  • Every terminal that instance spawns then inherits them: local spawns build on process.env (buildPtyHostEnv), the persistent daemon inherits by fork, and the SSH relay's buildSpawnEnv spreads the relay server's process.env. resolveSetupAgentSequenceLaunchCommand turns the inherited startup command into that terminal's launch-command hint, so applyTerminalGitCredentialPromptGuard and the OMP-shadow logic both treat the plain terminal as an agent launch.

Before this PR, the local and daemon boundaries already scrubbed the four pane-identity keys (ORCA_PANE_KEY, ORCA_TAB_ID, ORCA_WORKTREE_ID, ORCA_AGENT_LAUNCH_TOKEN) — but not the two sequencing keys, and the SSH relay boundary scrubbed none of the six.

What Changed

  • Treat pane identity, launch tokens, and setup-sequencing variables as child-PTY-scoped environment.
  • Apply the ownership rule at local, persistent-daemon, and SSH relay spawn boundaries.
  • Preserve values explicitly supplied for the child PTY.
  • Add regression coverage for local, daemon, WSL, relay fresh-spawn, and relay revive paths.
  • Concretely: one shared scrubber (removeUnspecifiedPtyChildScopedEnv) removes all six keys above at every spawn boundary unless the caller explicitly supplied them for that child. The relay previously had no scrub of any of these keys; it now scrubs all six at fresh spawn and at revive.

Why

The WSLENV test exposed a production environment ownership bug, not an order-dependent assertion. The 16-to-8 shard change made the test visible in a different batch, but the failure also reproduced isolated because the parent Orca process carries setup-sequencing variables.

The blast radius is wider than the OMP status symptom: the same inherited state made applyTerminalGitCredentialPromptGuard treat ordinary user terminals as agent launches, forcing GIT_TERMINAL_PROMPT=0 (overriding both an explicit =1 and Git's prompt-by-default) along with the askpass/GCM guards — a user-visible behavior change in terminals where people run Git by hand, not an internal detail. An independent review reproduced this from its own gated pane: with the inherited environment present, pre-PR code fails 7 existing tests in isolation, including the relay assertion that an ordinary user terminal's GIT_TERMINAL_PROMPT is left unchanged.

The E2E native build blocker is already resolved on main by 9e0704b9d46209885e95f1a24292a486b041dc73; this PR does not duplicate that fix.

Linked Issue

N/A — current-main CI health blocker.

Visual Proof

N/A — no visible UI or interaction surface changes; this changes PTY child environment construction.

Testing

  • Automated tests added/updated
  • Focused local/daemon/WSL/relay suite — 106 passed
  • Exact PR shard --shard=1/8 — 847 files passed, 6 skipped; 7,644 tests passed, 26 skipped
  • pnpm tc:node
  • Three changed-file oxlint lenses
  • E2E workflow contract — 34 passed
  • Linux x64 Node 24 Docker target coverage and native-runtime E2E build validation

Review

Independent same-model adversarial review found the missing relay parity path; it was fixed and the updated diff was re-reviewed clean. Performance is bounded to six key checks per PTY spawn with no polling, fanout, retained state, or output-path work. A second independent adversarial review at head f875c0ff72ba reproduced the bug from its own gated review pane and confirmed the wider user-facing blast radius described above.

Agent skill upstream boundary

  • Not applicable

Notes

No persisted state, IPC/RPC wire contract, mobile surface, renderer UI, or user-owned data changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Visual proof is N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform and SSH/remote impact considered
  • Focused tests, typecheck, code-quality checks, and exact CI shard pass; CI will cover the remaining matrix

@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c26cd41-8807-47cb-9182-fe3f3d871a11

📥 Commits

Reviewing files that changed from the base of the PR and between 65dd06a and 02cacf6.

📒 Files selected for processing (10)
  • src/main/daemon/pty-subprocess-env-inheritance.test.ts
  • src/main/daemon/pty-subprocess/spawn-environment.ts
  • src/main/ipc/pty-serializer-settlement-mapping.test.ts
  • src/main/providers/local-pty-launch-helpers.ts
  • src/main/providers/local-pty-provider-spawn-env.test.ts
  • src/main/providers/local-pty-provider.ts
  • src/relay/pty-handler-revive.test.ts
  • src/relay/pty-handler-spawn-environment.test.ts
  • src/relay/pty-handler.ts
  • src/shared/pty-child-scoped-env.ts
💤 Files with no reviewable changes (1)
  • src/main/providers/local-pty-launch-helpers.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

A shared removeUnspecifiedPtyChildScopedEnv helper now removes inherited pane, worktree, launch-token, and sequenced-startup variables unless explicitly supplied. Daemon, local provider, and relay PTY spawn paths use the helper. Tests cover inherited-variable removal, explicit child-variable preservation, relay revive behavior, and credential-prompt state evaluation. WSL coverage also verifies that sequenced-startup variables are not forwarded.

Merge Risk: 🔵 Low · up to 02cac

The change prevents setup and agent-launch state from leaking into ordinary terminals, restoring expected Git credential prompting and status behavior across local, daemon, and relay sessions. The PR is mergeable with owner awareness that local environment augmentation should not accidentally reintroduce the protected variables before spawning a terminal.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed and covers the required change, rationale, testing, visual proof, review, and checklist sections. The required Linked Issue section is marked N/A even though the template r… Provide a valid linked issue reference, or obtain and document an explicit repository-approved exception for omitting one.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: preventing inherited PTY setup-launch state.
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.
Full details: Description check

Explanation

The description is detailed and covers the required change, rationale, testing, visual proof, review, and checklist sections. The required Linked Issue section is marked N/A even though the template requires an issue link.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Status: ready for CI at exact SHA 9cdb21005315e3cadcaf05f66a43a1f5bc22aa86.

  • Reproduced the WSLENV assertion isolated and in exact shard 1/8 on untouched main; it was caused by inherited parent setup-sequencing state, not test order.
  • Failing-first coverage proved local, daemon, WSL, relay fresh-spawn, and relay revive inherited child-scoped state before the fix.
  • Focused suite: 106 passed; exact shard rerun: 7,644 passed / 26 skipped; pnpm tc:node and changed-file quality lenses pass.
  • The separate E2E native build blocker is already resolved on main by 9e0704b9d46209885e95f1a24292a486b041dc73; its workflow contract test passes here.
  • Remote branch tip verified with git ls-remote at the SHA above.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/main-red-e2e-wslenv-r1 branch from 9cdb210 to f875c0f Compare August 28, 2026 01:10
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up at exact SHA f875c0ff72baf08334713877ea82599d6c9277df (rebased onto origin/main @ bdabb09a07af4eca7d50314e9dcbe25e77017fa6).

1. The daemon-launch-paths.ts "deletion" was incidental, not load-bearing — and is now gone. The previous head 9cdb21005315 branched from 39ac32f279f9, which predates #16777 ("Extract daemon launch path helpers"); the branch's single commit never touched daemon-launch-paths.ts or daemon-init.ts, so the apparent −93/+113 was a stale-base artifact, not a revert authored by this PR. After the rebase, src/main/daemon/daemon-launch-paths.ts is byte-identical to origin/main (blob 9f01d2770e99), daemon-init.ts has zero diff vs origin/main, and nothing #16777 introduced is modified by this PR. The OMP/child-scoped-env fix never needed to touch that module.

2. Correction: this PR did not unblock #16336. I previously reported #16336 as "confirmed unblocked" by this fix. That was wrong. #16336's only red check was the e2e app build (plain-node-entry-guard / missing pty.node), which is inherited base staleness fixed on main by 9e0704b9d46209885e95f1a24292a486b041dc73; it was never red on the WSLENV assertion, and I cannot show a red-to-green transition attributable to this PR for it or any other open PR. As far as I can determine, no open PR is currently red on the WSLENV assertion. The fix stands on its reproduction: the assertion failure was reproduced on untouched main isolated, file-wide, and in exact shard 1/8 (1 failed / 7,643 passed), and the failing-first coverage in this PR proved the inherited child-scoped state at the local, daemon, WSL, relay fresh-spawn, and relay revive sites.

3. Rebase + post-rebase verification. The PR was DIRTY against main; it is now CLEAN/MERGEABLE. The one conflict was with #16778 ("Extract local PTY launch helpers"): main moved removeUnspecifiedPaneIdentityEnv into local-pty-launch-helpers.ts while this branch supersedes it with the strict-superset removeUnspecifiedPtyChildScopedEnv (same four pane-identity keys plus the two setup-sequencing launch keys). Resolution adopts main's split and removes the now-dead narrow helper from local-pty-launch-helpers.ts, leaving exactly one live scrubber running at all three spawn sites. Post-rebase, the tree diff vs origin/main for the #16777/#16778/#16779 extraction files is empty except that intentional helper removal — none of main's behavior is lost.

Post-rebase verification at f875c0ff72baf08334713877ea82599d6c9277df:

  • CI: settled with 0 failures (all non-path-filtered checks pass).
  • pnpm tc: pass.
  • Focused suites (5 files): 106 passed.
  • Changed-code quality gate: 0 findings across the 9 changed files (base bdabb09a07af).
  • Exact CI shard 1/8 (same excludes as pr.yml): 7,644 passed / 26 skipped, exit 0 — matching the pre-rebase run. (A first local attempt hit 8 unrelated renderer/persistence 30s-timeout flakes under machine load; all pass in isolation and the full-shard rerun is green.)
  • Remote tip verified with git ls-remote: f875c0ff72baf08334713877ea82599d6c9277df.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Independent adversarial review — f875c0ff72baf08334713877ea82599d6c9277df

Reviewed with no reliance on the author's report. Verdict: merge-ready (PASS). No P0/P1 findings; non-blocking notes below.

1. Superset claim — verified beyond key sets, at the invocation points

Old scrubber (4 keys) vs new (PTY_CHILD_SCOPED_ENV_KEYS, 6 keys): same Object.hasOwn(explicitEnv, key) guard, keys are a strict superset. Parent commit had exactly two call sites; head has the same two, replaced in place, plus one net-new relay site:

  • Local — local-pty-provider.ts:617: same line as the old call; runs after the process.env+args.env merge and before buildPtyHostEnv, so the host-env assembly (host-env/assembly.ts:49, which derives launchCommandHint and the shouldPrepareOmpShadow = piAgentKind === 'omp' || !hasLaunchCommand decision) sees post-scrub env. Nothing between scrub and spawn reintroduces the keys except explicit caller env, which is the intended channel.
  • Daemon — spawn-environment.ts:133: same position as the old call; rescrubDaemonPtyEnvironment/finalizeDaemonPtyEnvironment (envToDelete/TERM/PATH/conda only) cannot reintroduce the six keys.
  • Relay — pty-handler.ts:658 in buildSpawnEnv, which is shared by spawn() and revive(). Scrub runs before the env augmenters; both registered augmenters (hook coords, plugin overlay dirs) inject none of the six keys, and shellLaunch.env cannot either. resolveSetupAgentSequenceLaunchCommand(spawnEnv, command) at pty-handler.ts:1620 and the plugin augmenter's OMP decision both read post-scrub env. Revive re-injects pane identity from the serialized entry as explicit env, which the hasOwn guard preserves.

Note (broader than the PR's framing): the relay previously had no pane-identity scrub at all — this PR newly scrubs all six keys at relay fresh-spawn and revive, not just the two sequencing keys. Verified safe: clients always deliver pane identity explicitly in the spawn request, and revive rebuilds it from the serialized entry. It is the right parity move, but it is extra behavior the "strict superset" claim undersells.

2. Extra scrubbing as a behavior change — consumer sweep for the two sequencing keys

Every reader of ORCA_SEQUENCED_STARTUP_COMMAND / ORCA_SEQUENCED_STARTUP_SCRIPT (no shell/CLI/mobile readers exist; grep for both literals and both constants):

Consumer Channel Inheritance-dependent?
Gated pane's bash -lc 'eval "$ORCA_SEQUENCED_STARTUP_SCRIPT"' explicit startupEnv No — explicit, preserved by hasOwn
host-env/assembly.ts:49 launch-hint + OMP-shadow decision assembled child env Inherited presence was the bug
relay/pty-handler.ts:1620 launch-hint + credential-guard + shell-ready delivery assembled child env Inherited presence was the bug
Relay plugin augmenter OMP materialization assembled child env Inherited presence was the bug
codex-resume.ts stripSequencedStartupResumeArgv env under assembly; rewrites the key only if present No
wsl-orca-env.ts WSLENV /u passthrough names keys; inert when absent No — explicit values still cross into the guest
orca-runtime.ts:29133 (agent-teams sequenced launch) producer, sets explicitly No

No consumer depended on inheriting the keys; the extra scrubbing is exactly the intended semantics. ORCA_TERMINAL_HANDLE is deliberately absent from the list — it has its own trust-gated reconciliation (local-configure.ts:84: untrusted inherited handles are deleted and replaced by a pre-allocated one).

3. Failing-first + ablation (all runs local, this head)

PR tests against parent production code (bdabb09a07af): 6 failed / 100 passed — all five claimed sites red (local, daemon, WSL managed terminal, relay fresh-spawn, relay revive). Head: 106/106 green.

Per-hunk ablation (revert one production hunk, keep PR tests):

Ablated hunk Result
daemon spawn-environment.ts 1 failed — daemon inheritance test
local-pty-provider.ts (+helpers) 2 failed — local spawn + WSL managed-terminal tests
relay pty-handler.ts 3 failed — relay fresh-spawn, relay revive, plus the pre-existing "leaves an ordinary Windows SSH user terminal unchanged" test

Every hunk is load-bearing; no dead production code.

4. Independent confirmation this is a production environment-ownership bug

My review terminal is itself a setup-gated Orca agent pane, so the test process inherits both sequencing vars — the exact production condition. Under parent code, the pre-existing relay test "leaves an ordinary Windows SSH user terminal unchanged" fails in isolation in this environment (GIT_TERMINAL_PROMPT expected '1', got '0'): the inherited command resolves as a launch hint and applyTerminalGitCredentialPromptGuard treats an ordinary user terminal as agent-launched. So the bug's blast radius was wider than the suppressed OMP status entry — it also disabled interactive git credential prompts in plain terminals spawned by an Orca that was launched from a gated pane. Under head, the same environment is fully green (126/126 across the six related files, and 6 existing overlay tests that fail on parent under pollution pass on head). This confirms deterministic environment ownership, not test-order flakiness.

5. WSL correctness

The diff builds no wsl.exe argv (WSL appears only in test assertions). The managed-WSL spawn path is untouched and already routes through the --exec builder; the guard suite passes on head. Nothing new parses WSL stdout, so login-shell fencing is not applicable; the interactive terminal is the documented do-not-fence case. The scrub runs on the Windows-side env before wsl.exe spawns, so the untouched WSLENV /u passthrough carries explicitly-set sequencing keys into the guest and is inert for the now-absent inherited ones — which is the fix.

6. Relay/SSH wire compatibility

No RPC param, serialized-state, or stream-frame changes; no new opcodes, so no capability negotiation needed. What the host publishes does change: a new relay scrubs the six keys from child env unless the client set them explicitly. Old client + new relay is safe — old clients already deliver pane identity and gated-launch env explicitly, and relay-inherited values were never a deliberate delivery channel (the relay daemon's env comes from sshd/nohup). New client + old relay simply keeps the bug until the host updates; no hazard.

7. Flake spot-check

GitHub Actions has zero reruns on this branch — every run is attempt 1, all green at both commits — so the recorded green CI was not masked by retries; the reported 8-flake rerun was a local run. I replicated CI's exact shard 1/8 invocation locally on head (in the polluted gated-pane environment): 7,642 passed / 0 failed (846 files; author reported 846+1/7,642+2, within environment-conditional drift). Exit code 1 came solely from one vitest worker-fork pool error ("Worker exited unexpectedly") with no failing test — a local-load harness artifact, not a PR effect. Nothing suggests this PR causes flakes.

8. Performance

By-hand analysis (the perf skill is disable-model-invocation here): the scrub is a six-key Object.hasOwn loop per PTY spawn/revive — user-interaction-rate, not hot-path. No new allocations of consequence, timers, listeners, retained state, or polling. Negligible.

9. Superseding bar

This is close to what I would write from scratch: one shared scrubber in src/shared (importable by relay and main), keys as constants owned by their defining module, one invocation per spawn boundary, explicit-env passthrough. Two things a from-scratch design might do differently, both non-blocking:

  • P2: PTY_CHILD_SCOPED_ENV_KEYS is an enumerated list; the next pane-scoped ORCA_* var must be remembered manually, and nothing ratchets new per-pane env keys into it. A prefix-based default-deny with an explicit child-passthrough allowlist would fail closed, but it would touch many legitimate passthrough keys and is a materially bigger change than this fix warrants.
  • Nit: the save/restore block in pty-serializer-settlement-mapping.test.ts hand-rolls per-key restore where the loop pattern used in the relay tests would be tighter. Cosmetic.

Checklist coverage

Crash/cast/growth: no new casts, no unbounded structures. Security/supply chain: no dependency, network, or exec-surface changes. Backcompat/data loss: no persisted state or migrations; no mobile-facing surface touched. Code organization: pty-child-scoped-env.ts is a concrete domain name in the right layer. Counsel validation not triggered: verdict is PASS with no P0/P1 candidates.

…ch state

The spawn-env scrub only fixes the reported bug if it runs before
buildSpawnEnv's consumers read the env. Moving it after the credential-guard
read left every existing test green on a clean environment while ordinary
user terminals silently lost Git credential prompts again.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/main-red-e2e-wslenv-r1 branch from f875c0f to 02cacf6 Compare August 28, 2026 10:05
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review round 1 — verdict: PATCH (not superseded), one test added

Rebased onto current origin/main (65dd06a870) and re-verified; the rebase changed nothing (diff byte-identical to the pre-rebase diff). Head is now 02cacf64e0.

The bug is real, and reproduces from a setup-gated pane

Pure origin/main, no test changes, run from a pane that carries the sequencing markers — 2 pre-existing tests fail:

FAIL src/relay/pty-handler-spawn-environment.test.ts > leaves an ordinary Windows SSH user terminal unchanged
  AssertionError: expected '0' to be '1'          <- GIT_TERMINAL_PROMPT forced off in a USER terminal
FAIL src/main/ipc/pty-serializer-settlement-mapping.test.ts > forwards the trusted Orca terminal handle into managed WSL terminals

Those same 5 files are green at head (106 passed). This is independent confirmation of the PR's premise, not a re-run of its own assertions.

Can launch state still cross a PTY boundary? No — via inheritance or replay.

I traced all four lifecycle transitions rather than assuming spawn parity:

Transition Path Verdict
Fresh spawn local / daemon / relay buildSpawnEnv scrubbed; explicit child values preserved. Tested at all 3
PTY replacement codex-detached-pane-restart.ts:215 env rebuilt via buildPaneIdentityEnv for the NEW pane; carries no sequencing keys
Reattach pty.attach no process spawned, no env constructed — N/A by construction
Cold restore cold-restore-resume-startup.ts:87 / relay pty.revive startup rebuilt from the resumable provider session with a freshly minted launch token; relay revivedEnv is an explicit allow-list and SerializedPtyEntry has no env field

The scrub is also correctly ordered before its consumers at every boundary — it runs ahead of resolveSetupAgentSequenceLaunchCommand (relay pty-handler.ts:655 before :1620; local local-pty-provider.ts:617 before buildPtyHostEnv assembly.ts:49). Env augmenters run after the scrub and none of them return any of the six keys.

Also confirmed: the 6-key set is a strict superset of the old 4-key PANE_IDENTITY_ENV_KEYS at the current head, and there are no orphaned references to the deleted removeUnspecifiedPaneIdentityEnv anywhere in src/, mobile/, or scripts/.

Ablation table — every production hunk is pinned

Hunk Ablation Result
local-pty-provider.ts scrub call removed 2 failed
spawn-environment.ts scrub call removed 1 failed
pty-handler.ts scrub call removed 3 failed
key list: ORCA_SEQUENCED_STARTUP_COMMAND dropped 6 failed
key list: ORCA_SEQUENCED_STARTUP_SCRIPT dropped 5 failed
key list: 4 pane-identity keys dropped 4 failed
Object.hasOwn(explicitEnv, …) preserve arm always-delete 7 failed
local-pty-launch-helpers.ts dead-code removal — structurally unpinnable (pure removal, zero remaining refs)

One gap found and closed

The scrub-before-read ordering was not pinned by any test. I moved the relay scrub to after the credential-guard read and, on a clean CI-like environment, the entire suite stayed green — including the PR's own new test, which only checks that the keys are absent from the final spawn env. A future refactor could have reintroduced the exact user-visible bug undetected.

Added leaves an ordinary user terminal unguarded when the relay itself was launched from a gated agent pane to pty-handler-spawn-environment.test.ts. It asserts the symptom (GIT_TERMINAL_PROMPT stays 1, gitCredentialPromptGuarded is false) rather than the mechanism, and it fails in a clean environment both pre-fix and under the ordering ablation.

Live end-to-end validation, and one thing this PR does NOT fix

I launched an isolated dev build from a setup-gated pane (own CDP port, own renderer port, own user-data profile) so the app genuinely inherited the markers, and spawned a plain terminal through the real PTY IPC:

RESULT seq_cmd=EMPTY seq_script=EMPTY          <- fix confirmed end-to-end
PROBE  gtp=[0] gcm=[never] askpass_set=SET cfgcount=[2]
       k0=[credential.interactive] v0=[false] k1=[credential.guiPrompt] v1=[false]

The sequencing markers are correctly gone. But GIT_TERMINAL_PROMPT=0 is still set in that ordinary terminal — byte-identical to the launching pane's own values, GIT_CONFIG_COUNT included, and with the markers already scrubbed the guard cannot have fired. That is pure inheritance of the guard's own env, a second and independent path to this PR's stated symptom #1 ("Git stopped asking for credentials").

Root cause is the early return in applyTerminalGitCredentialPromptGuard (src/shared/terminal-git-credential-guard.ts:28-30): the not-guarded case returns false without removing inherited guard env, so a normal user terminal keeps whatever prompts-disabled state it inherited. Same fall-through-toward-the-destructive-branch shape as #16900 / #16908 / #16926.

Deliberately not fixed here — different mechanism, different fix site, its own test surface. Worth a follow-up. It does mean the PR body's symptom-1 claim should be read as "removes one of two causes": a user who launches Orca from a gated pane still gets prompt-less Git in every terminal.

Gates

tsconfig.node.json / tsconfig.tc.cli.json / tsconfig.tc.web.json all exit 0. oxlint clean on every changed file across all three lenses (default + unused-disable-directives, --type-aware, react-doctor) — gate proven live by injecting a violation and seeing it caught. git diff --check clean. Formatted with npx oxfmt --write on the changed file only. Parent suites green: 426 files / 4,556 tests across src/relay, src/main/providers, src/main/daemon, src/main/ipc/pty.

Not verified

Windows and WSL legs were not executed on real hosts — reasoned about only (wsl-orca-env.ts adds a WSLENV entry only when the variable is present, so a scrubbed key is not forwarded). Dev-mode CDP is blind to packaged-build regressions. No SSH relay was exercised against a real remote host; relay coverage is unit-level plus the revive path.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing: replaced by #43153, which moves Setup-gated launches off inherited environment variables.

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