Repository navigation
fix(daemon): resolve Unix shell fallback before node-pty spawn - #8306
Conversation
… shell The adapter computes shellReadySupported from the preferred shell before spawn. When the daemon falls back (e.g. to /bin/sh), the session would queue startup commands for the full 15s ready-marker timeout and wrap multiline prompts in bracketed-paste markers the fallback shell cannot parse. Expose the spawned shell on SubprocessHandle and downgrade the barrier and paste wrapping in TerminalHost when the actual shell cannot emit the marker. Also apply the Unix shell fallback after the relay env scrub so a scrubbed SHELL cannot drop the corrected value, and cover the resolve- before-launch-config ordering, the no-shell throw, and candidate dedup with tests. Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughUnix shell paths are now resolved to executable fallback shells before PTY creation. The resolved path is propagated through subprocess handles and used to determine shell-ready barriers and bracketed-paste behavior. Shell-specific startup handling distinguishes Bash and Zsh from fallback shells such as 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/daemon/shell-ready.ts (1)
351-354: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a brief comment explaining the zsh/bash-only allowlist.
shellPathSupportsPtyStartupBarrierhardcodes support to onlyzsh/bash, which now gates both pre-spawnshellReadySupportedcomputation and post-spawn reconciliation against the actual fallback shell. The reason (only these shells get the Orca shell-ready wrapper injection, e.g.ZDOTDIR) isn't obvious from this snippet — a one-line comment would help future readers avoid assumingsh/dash/fishsupport was simply forgotten.As per coding guidelines, "When code is driven by a design document or non-obvious constraint, add a brief one- or two-line comment explaining why it behaves that way, without restating the implementation."📝 Suggested comment addition
+// Why zsh/bash only: these are the only shells the daemon injects the +// shell-ready wrapper (ZDOTDIR/marker) into; other shells never emit it. export function shellPathSupportsPtyStartupBarrier(shellPath: string): boolean { const shellName = pathWin32.basename(basename(shellPath)).toLowerCase() return shellName === 'zsh' || shellName === 'bash' }Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e68fa8c7-9525-4208-89e9-2619d84d08ee
📒 Files selected for processing (8)
src/main/daemon/pty-subprocess.test.tssrc/main/daemon/pty-subprocess.tssrc/main/daemon/session.tssrc/main/daemon/shell-ready.tssrc/main/daemon/terminal-host.test.tssrc/main/daemon/terminal-host.tssrc/main/providers/local-pty-utils.test.tssrc/main/providers/local-pty-utils.ts
…yai#8306) * fix: resolve daemon shell before spawning * fix(daemon): reconcile shell-ready barrier with the resolved fallback shell The adapter computes shellReadySupported from the preferred shell before spawn. When the daemon falls back (e.g. to /bin/sh), the session would queue startup commands for the full 15s ready-marker timeout and wrap multiline prompts in bracketed-paste markers the fallback shell cannot parse. Expose the spawned shell on SubprocessHandle and downgrade the barrier and paste wrapping in TerminalHost when the actual shell cannot emit the marker. Also apply the Unix shell fallback after the relay env scrub so a scrubbed SHELL cannot drop the corrected value, and cover the resolve- before-launch-config ordering, the no-shell throw, and candidate dedup with tests. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Vitus Apollo <[email protected]> Co-authored-by: Orca <[email protected]>
Summary
On Linux, a failed
execinside node-pty's forked child does not throw — the child just dies, leaving a silently dead daemon terminal when the preferred shell (e.g./bin/zshdefault on hosts without zsh) is missing. This also hits SSH relay hosts, which run the same daemon spawn path.resolveUnixShellPath): validate the preferred shell pre-fork and fall back through/bin/zsh→/bin/bash→/bin/sh, matchingspawnShellWithFallback's local-provider chain. If nothing is executable, throw a clear error before node-pty forks (surfaced via the daemon RPC error path instead of a dead shell). Non-absolute shells are left untouched so execvp can resolve them against PATH/cwd.env.SHELLand the shell-ready launch config are derived from the resolved shell, matching LocalPtyProvider.shellReadySupportedfrom the preferred shell before spawn. A fallback shell without the ready marker (e.g./bin/sh) would otherwise queue startup commands until the shell-ready timeout and bracketed-paste-wrap them for a line editor without paste mode. The subprocess handle now reports the shell that actually spawned, andTerminalHostdrops the stale flag when that shell can't emit the marker.Testing
pnpm vitest run src/main/daemon src/main/providers(1223 passed)pnpm typecheck,pnpm exec oxlinton touched files/bin/sh, barrier kept for bash).Made with Orca 🐋