Repository navigation
fix(terminal): prove an idle Git Bash prompt through its bin launcher - #22752
Conversation
Git for Windows' bin\bash.exe is a launcher that runs usr\bin\bash.exe as a child and waits, so an idle Git Bash pane's job always holds two pids and the Windows shell proof never confirmed it. Accept exactly the launcher plus its direct bash.exe child, checked against the identity process table.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Launcher predicate —
isGitForWindowsBashLauncherPath(git-bash.ts) matches Git for Windows'bin\bash.exeand excludesusr\bin\bash.exe, with unit coverage for both the launcher and the MSYS binary. - Shell-alone proof —
isWindowsShellAloneInJob(agent-foreground-process.ts) keeps the one-process path unchanged and adds exactly one accepted shape: the spawned path is the launcher, the job holds two processes, and the second is a directbash.exechild of the launcher. Any other shape, an unreadable table, or a missing row fails closed. The table is only consulted in that one shape. - Local provider wiring —
ptyShellPathrecords the post-fallback spawned path inactivateLocalPtySessionand the confirm path now uses it instead of the basename, so the launcher is distinguishable; it is cleared alongsideptyShellNameinclearPtyState. The daemon path already passed the full path. - Tests — new unit suite for the accepted/refuted job shapes and the "never reads the table for other shells" contract, a predicate test in
git-bash.test.ts, a local-provider contract test pinning the full path, and a Windows-only integration test against the real launcher added to the Windows CI list.
I verified pnpm tc:node is clean and the four touched non-Windows suites pass locally (85 tests); the Windows integration suite is skipped here but is wired into the Windows job. The existing powershell.exe, null-job, and rejecting-reader tests still pass because size 2 + a non-launcher path falls through to false.
ℹ️ The process-table caller inventory omits the new reader
The "Which callers need which" table in docs/reference/windows-process-enumeration.md is the doc's inventory of who reads the process table and on which flag set, but it does not list the identity read this PR adds in agent-foreground-process.ts. Non-blocking, but the table is otherwise exhaustive and future maintainers use it to reason about the identity/detailed split.
Technical details
# Add agent-foreground-process.ts to the caller table
## Affected sites
- `docs/reference/windows-process-enumeration.md:167-185` — "Which callers need which" table
does not include the new `readWindowsProcessIdentityTableFresh` caller.
## Required outcome
- The table lists `agent-foreground-process.ts` as an identity-flag reader
(`pid` / `ppid` / `name`, fresh), with a one-line note that it is only reached for an
accepted Git Bash launcher shape.
## Open questions for the human
- Optional; the table is an inventory rather than a contract, so this can be deferred.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change records each local PTY’s spawned shell path and passes it to foreground confirmation. Windows job validation now accepts a shell-only job or a Git for Windows Bash launcher with its verified Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The Git Bash idle-prompt change is mergeable on the supplied evidence; its Windows test has the required launcher on the configured runner. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new Git Bash check enables cleanup at an idle prompt, but it can also mistake a running nested Bash process for an idle shell. The identified effect is limited to terminal state in the affected pane; no privilege or cross-user exposure is established. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, rationale, testing, platform impact, and checklist. However, the required Linked Issue is explicitly marked as "None," and the required issue reference is missing. ✨ Finishing Touches 💡 1📝 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8986afb7-5659-45bc-8534-c5316f7b2e25
📒 Files selected for processing (10)
.github/workflows/pr.ymlsrc/main/git-bash.test.tssrc/main/git-bash.tssrc/main/providers/agent-foreground-process-git-bash-launcher.test.tssrc/main/providers/agent-foreground-process-git-bash.win32.test.tssrc/main/providers/agent-foreground-process.tssrc/main/providers/local-pty-child-process-verdict.test.tssrc/main/providers/local-pty-foreground-inspection.tssrc/main/providers/local-pty-provider-state.tssrc/main/providers/local-pty-session-activation.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Orca launches Git Bash as bin\bash.exe -c "chcp.com ...; exec \"$BASH\" ... -i", and each MSYS exec leaves its pre-exec process alive as a stub, so an idle pane's job is launcher -> stub -> interactive bash. Accept any job that is one parent-to-child chain rooted at the launcher whose every later member is bash.exe, instead of a fixed two-process shape.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (ff1da52), the author found the real idle shape is three processes, not two, and reworked the proof:
- Chain-based shell proof —
isWindowsShellAloneInJobmoved into a dedicatedwindows-shell-alone-in-job.tsand now accepts one unbranched parent-to-child chain rooted at the launcher, every later member namedbash.exe, instead of a fixed two-process shape. It adds astartedBeforepid-reuse guard; branches, non-bash links, missing rows, and non-launcher shells still fail closed. The identity table is read only for a launcher pane whose job holds more than one process. - Unit suite rewrite — covers
launcher → exec stub → bash, the bare hand-off, nested/forked bash leaves, branches and orphans, missing/older/reused rows, and the "table never read for other shells" contract. - Windows integration test rewrite — now drives Orca's real launch plan (
createPtyShellLaunchPlan+spawnNativeDaemonPty) for both the login shell and the Codex--rcfilewrapper, asserting the idle three-process job and then refutingsleep 60andsleep 60 &.
I verified pnpm run typecheck:node is clean and the touched non-Windows suites pass (41 tests across the launcher unit, git-bash, and local verdict suites; 66 across the surrounding shell-proof suites). The Windows suite is skipped here but is wired into the Windows job.
The accepted residual — a foreground bash running only builtins reads as an idle prompt — is documented in the function's doc-comment and blessed in the test, so it is a stated trade-off rather than a defect.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (32eaa9e), the only new commit registers the Git Bash shell-proof test in the second of the two Windows lane lists:
- Windows scope registration — added
src/main/providers/agent-foreground-process-git-bash.win32.test.tstoWINDOWS_PACKAGE_TESTSinconfig/scripts/pr-code-change-scope.mjs:270, mirroring its existing entry in the.github/workflows/pr.ymlWindows lane (pr.yml:988). This closes the classifier half of the dual-registration contract enforced byconfig/scripts/win32-test-lane-registration.test.mjs—WINDOWS_PACKAGE_TESTSdecides whether thepackage_windowsjob runs for a diff, and the file was previously in the lane argv only. Ordering is immaterial (Array.includes), and both lists keep the entry afterwindows-msys-job.win32.test.ts.
The substantive chain proof (windows-shell-alone-in-job.ts) and its unit/integration coverage were reviewed and cleared in the prior run; no production code paths changed here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
A spawned shell path with a space (/Users/John Doe/bin/zsh) was split as a command line, so the POSIX proof compared against "john" and never confirmed. Local panes now keep only the spawned shell path and derive the name from it; the Git Bash chain walk drops guards the member check already covers.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (69d807bd0), the head 2cd1fdec4c fixes a real space-in-path bug and consolidates the shell state:
- Spawned shell read as a path — the POSIX branch of
confirmShellForegroundProcessnow basenamesspawnedShellProcesswithsplit(/[\\/]/).pop()instead ofexecutableBasename, which parsed it as a command line and truncated/Users/John Doe/bin/zshtojohn. This is the fix for CodeRabbit's login-wrapper concern and covers both the local (ptyShellPath) and daemon (args.shellPath) callers, both of which pass an unquoted path.executableBasenameremains in use for the process-tablerow.commandvalues, so it is not dead. - One shell map — the independent
ptyShellNamemap is removed;ptyShellPath(plan.shellPath) is now the single source of truth andgetPtyShellName(id)derives the basename viagetSpawnedShellName. All readers (local-pty-foreground-inspection.ts,local-pty-session-operations.ts) and the clear path are updated; no staleptyShellNamereference remains. - Launcher predicate rewritten —
isGitForWindowsBashLauncherPathis now a direct regex equivalent to the oldisGitForWindowsBashPath && !endsWith('\usr\bin\bash.exe'), decoupling it from the broader predicate. startedBeforerefactor — takes numeric start times from astartMsByPidmap built from the member rows; behavior is unchanged because every parent pid is a member.- Regression test —
agent-foreground-process-shell-path.test.tsdrives the real POSIX confirmation with a space-bearing path; it fails before the fix.
Verified pnpm tc:node clean, oxlint clean on the changed source files, and 96 tests across the seven touched suites pass. The Windows integration suite is skipped on this host but is wired into both Windows lane lists.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Before Orca cleans up after a full-screen program that crashed, it checks that nothing but the shell is running in the pane. For Git Bash on Windows that check always said "something else is running", so the cleanup never happened. Now the check knows what an idle Git Bash pane looks like.
What Changed
Before: in a Git Bash pane on Windows, if a program turned on mouse reporting and exited without turning it off (for example
printf '\033[?1003h\033[?1006h', or a TUI that crashed), mouse reporting stayed on at the next prompt. Moving the mouse printed escape codes into the prompt. PowerShell and cmd panes were already cleaned up.After: Git Bash panes get the same cleanup as PowerShell and cmd.
Mechanism: On Windows, Orca decides "only the shell is running" by reading the pane's job object (the set of processes Orca started for that pane). The rule was "the job holds exactly one process: the shell". An idle Git Bash pane never has just one process. Orca starts
C:\Program Files\Git\bin\bash.exe -c "chcp.com 65001 ...; exec \"$BASH\" ... -i", and two things add processes:bin\bash.exeis a small launcher. It starts..\usr\bin\bash.exeas a child and waits for it.execdoesn't replace the process. The process that ranexecstays alive as a stub and waits for the new one.So a real idle pane is three processes in a line: launcher →
bash -c "chcp ...; exec"stub → interactive bash. That was measured in a real Orca pane.The new rule is one check, not a list of allowed sizes. The pane counts as "only the shell" when the job is the shell alone, or when the shell is Git for Windows'
bin\bash.exelauncher and every other process in the job forms one straight parent-to-child chain below it, each one abash.exe. The last bash in the chain is the interactive shell.vim,sleep, an agent) adds a process that isn'tbash.exeat the end, so the check fails.windows-process-table). That is the cheaper of the two table reads, though it still opens one limited query handle per process to get start times. It reads it only for the Git Bash launcher, and only when the job has more than one process.The local (non-daemon) provider used to keep only the shell's file name (
bash.exe), which can't tell the launcher apart fromusr\bin\bash.exe. It now keeps the full spawned path instead and works out the file name from it when needed. The check reads that path as a path, so a shell path with a space in it (/Users/John Doe/bin/zsh) still matches on macOS and Linux. The daemon path already passed the full path.Known gap, accepted: a foreground bash that runs only builtins also ends the chain with
bash.exe, so it counts as a prompt. Examples: a nested interactivebash, a subshell loop, or a fork caught in the instant before it becomes the real command. For a nestedbashthat answer is correct, since it is a shell at a prompt. In the other cases the worst outcome is resetting leftover mouse and keyboard modes early, and the program that starts next sets its own modes afterwards.Why
Other options I considered:
usr\bin\bash.exedirectly, without the launcher. This removes the extra process, but the launcher does more than wait. Measured on Windows: through the launcher,MSYSTEM=MINGW64,PLINK_PROTOCOL=ssh, and/mingw64/bincomes first onPATH. Launched directly, all three are missing. Orca would have to copy the launcher's environment setup and keep it matching future Git for Windows releases, and every Git Bash user's shell environment would change. That is a lot of risk to fix a detection rule.execstub. The count depends on how manyexecs the startup command does, so a fixed count is fragile. The chain rule describes why the processes exist and holds for any number of stubs.bash.exe, not just the launcher. Ausr\bin\bash.exethat the user started directly with a forked subshell has the same shape, and nothing Orca launched explains it. So the rule applies only to the launcher.Linked Issue
None. Found while investigating the terminal shell-recovery cleanup (the scroll-freeze work). Measured in a real Orca Git Bash pane on Windows: the idle job holds [launcher,
bash -c "chcp ...; exec"stub, interactive bash].Visual Proof
N/A. The change is in a process check with no UI. The Windows test below exercises the real launcher.
Testing
Unit tests (
agent-foreground-process-git-bash-launcher.test.ts, fake job and process table) cover:bash, and a fork caught before its exec.usr\bin\bash.exeand PowerShell never read the table.git-bash.test.ts: the launcher-path check.local-pty-child-process-verdict.test.ts: the local provider passes the full spawned path.Windows-only test
agent-foreground-process-git-bash.win32.test.ts, on the Windows CI list. It builds the pane with Orca's own daemon launch code (createDaemonPtyEnvironment,createPtyShellLaunchPlanwithshellOverride: 'git-bash',spawnNativeDaemonPty) and checks it through the daemon'sconfirmPtyShellForeground. It runs twice: once with the plain--loginstartup, and once with Orca's--rcfilewrapper (Codex preflight set). At the idle prompt the job has 3 processes and the check passes.sleep 60fails it, Ctrl-C passes it again, andsleep 60 &fails it. Passed on a real Windows 11 machine with Git for Windows, along withwindows-msys-job.win32.test.ts.pnpm tc:nodepasses, oxlint is clean, andcheck:code-quality:changedpasses.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
/bin/zsh.judgeCachedAgentJobEvidence, "the shell is alone, so retire the cached agent") has the same one-process assumption. For Git Bash it falls through to the regular process scan, so it's slower but still correct.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)