Repository navigation
fix(terminal): agent pane auto-launch lost under fish + Starship (STA-3417) - #12840
Conversation
|
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:
📝 WalkthroughWalkthroughFish now supports PTY startup barriers and shell-ready markers. Marker-enabled launches use login mode, a fish initialization command, and 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
|
Electron QA passed on the exact PR worktree.
|
1774adf to
9c59d34
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/shell-templates.ts (1)
163-169: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce duplicated Fish readiness comments.
Keep the rationale in
src/main/shell-templates.tsas one concise comment. Remove the repeated rationale from the launch branches.
src/main/shell-templates.ts#L163-L169: replace the seven-line comment with one concise statement of thefish_promptreadiness requirement.src/main/providers/local-pty-shell-ready.ts#L401-L403: remove the duplicated launch rationale.src/main/daemon/shell-ready.ts#L354-L356: reduce the barrier rationale to one concise statement.src/main/daemon/shell-ready.ts#L419-L421: remove the duplicated launch rationale.As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3ec4e17f-02c8-4927-a500-a050a09af81c
📒 Files selected for processing (5)
src/main/daemon/shell-ready.test.tssrc/main/daemon/shell-ready.tssrc/main/providers/local-pty-shell-ready.test.tssrc/main/providers/local-pty-shell-ready.tssrc/main/shell-templates.ts
9c59d34 to
a4d6a2c
Compare
|
@coderabbitai Both findings addressed in a4d6a2c. Duplicate query replies — confirmed and fixed as suggested. It was worse than an occasional double-send: any query sitting wholly inside the carry window was re-answered on the next chunk. Verified the boundary logic against three cases:
The third case is the telling one — the old code emitted a spurious third reply. A stray Comment duplication — agreed, the rationale was repeated at four sites. Consolidated to one statement in Suites re-run 5× consecutively: 97/97, no flakes. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Tip For best results, initiate chat on the files or code changes.
🐇 ✅ ✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
a4d6a2c to
c8c5d1b
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
c8c5d1b to
1df555e
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 11b29978-a640-4c4d-937e-e4b2d2655e74
📒 Files selected for processing (7)
.github/workflows/pr.ymlconfig/scripts/pr-workflow-parallelism.test.mjssrc/main/daemon/shell-ready.test.tssrc/main/daemon/shell-ready.tssrc/main/providers/local-pty-shell-ready.test.tssrc/main/providers/local-pty-shell-ready.tssrc/main/shell-templates.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- .github/workflows/pr.yml
- src/main/providers/local-pty-shell-ready.ts
- src/main/shell-templates.ts
- src/main/daemon/shell-ready.ts
- src/main/daemon/shell-ready.test.ts
- src/main/providers/local-pty-shell-ready.test.ts
Fish never emitted the OSC 777 shell-ready marker, so agent launch commands were written into the PTY while fish/Starship were still initializing: the daemon path wrote them synchronously at session create and the local path blind-wrote ~30ms after the first output byte. The command was echoed by the kernel but never executed. - shell-templates: shared fish --init-command that emits the marker once on the first fish_prompt event (the earliest point fish's own reader owns the PTY, mirroring zsh's zle-line-init marker) - daemon shell-ready: fish joins the startup barrier so the launch command queues until the marker (timeout fallback unchanged) - local-pty-shell-ready: fish launch config gains the marker wrapper - codex-startup-delivery/tui-agent-startup: omp/pi/opencode plans now request shell-ready delivery (codex parity) so the SSH renderer path also waits for the prompt; plain payload-free codex stays on the markerless fast path
1df555e to
47f3256
Compare
|
@coderabbitai Both addressed in 47f3256. Exact package tokens + whole-workflow lane check — agreed on both counts. Mutation-tested both invariants:
Context for why this guard matters more than it looks: the real-shell tests skip themselves when the binary is absent, so a dropped package doesn't fail the lane — it silently empties it. That is exactly how the fish coverage was passing CI while never running. |
|
Tip For best results, initiate chat on the files or code changes.
The mutation results show that both invariants fail as intended. The explicit The missing-binary skip behavior is important. The workflow contract test now protects against silent loss of fish test coverage. 🐇 ✅ ✏️ Learnings added
You are interacting with an AI system. |
The barrier queues all inbound input until the ready marker, including the renderer's DA1 reply. A shell that withholds its first prompt until DA1 is answered — fish waits 10s — therefore never emits the marker that would release the reply it is waiting for. Measured: 10.37s to launch an agent, versus 0.35s once the reply lands. Answer DA1 from the daemon while the barrier holds, writing straight to the subprocess so the reply bypasses the queue, and consume the query so the renderer's xterm cannot also reply. Released on ready, timeout, or dispose, handing DA1 back to the renderer for steady state. Consolidates the identical DA1 handler the ConPTY override already used.
4d2849a to
37937db
Compare
|
Electron QA result: fish 4.8.1 with a 200 ms prompt-init delay; OMP UI rendered 3.206 s after pane creation (3.787 s after selecting launch). This did not reproduce the ~10 s DA1 stall or its fish error, and the renderer console showed 0 errors, but the measured result is above the requested well-under-2-second target. |
Electron QA — PASS (STA-3417 fish agent auto-launch + DA1)Commit: Setup (isolated; no user config mutated)
Action
Result — PASS
ScreenshotsCleanupIsolated Electron process tree, temp user-data, temp fish XDG config, and playwright session torn down after this report. |
…r is late stablyai#12840 put a marker-gated barrier in front of the startup command so it is not written into a shell that has not started reading its PTY yet. The barrier gives up after SHELL_READY_TIMEOUT_MS and then writes the command anyway, which is the same blind write, fifteen seconds later. When it is swallowed the caller gets a session that looks healthy and never ran anything. The startup command now takes its own path. `Session.writeStartupCommand` holds it out of the pre-ready queue, so the deadline still releases queued keystrokes — the pane has to stay typeable — while the command keeps waiting for the marker for SHELL_READY_LATE_MARKER_GRACE_MS longer. A marker that arrives late still proves the shell is reading, so the command is delivered then, exactly once, through the existing post-ready flush gate. The marker scanner stays armed past the deadline for the same reason, which also stops a late marker from reaching the pane as raw OSC bytes. Two outcomes are not proof of delivery, and both now say so in the daemon log: the grace deadline expiring, which still writes the command but without evidence, and the session ending while the command is still held, which never writes it at all. `shellState` stays `timed_out` in the first case and the Manage Sessions list reports it rather than showing the session as running. Shortening the barrier is how a caller opts out of marker-gated delivery, so a session with an explicit shellReadyTimeoutMs — Codex — gets no grace window.
…-3417) (stablyai#12840) * fix(terminal): extend the shell-ready startup barrier to fish (STA-3417) Fish never emitted the OSC 777 shell-ready marker, so agent launch commands were written into the PTY while fish/Starship were still initializing: the daemon path wrote them synchronously at session create and the local path blind-wrote ~30ms after the first output byte. The command was echoed by the kernel but never executed. - shell-templates: shared fish --init-command that emits the marker once on the first fish_prompt event (the earliest point fish's own reader owns the PTY, mirroring zsh's zle-line-init marker) - daemon shell-ready: fish joins the startup barrier so the launch command queues until the marker (timeout fallback unchanged) - local-pty-shell-ready: fish launch config gains the marker wrapper - codex-startup-delivery/tui-agent-startup: omp/pi/opencode plans now request shell-ready delivery (codex parity) so the SSH renderer path also waits for the prompt; plain payload-free codex stays on the markerless fast path * fix(terminal): answer DA1 past the shell-ready barrier The barrier queues all inbound input until the ready marker, including the renderer's DA1 reply. A shell that withholds its first prompt until DA1 is answered — fish waits 10s — therefore never emits the marker that would release the reply it is waiting for. Measured: 10.37s to launch an agent, versus 0.35s once the reply lands. Answer DA1 from the daemon while the barrier holds, writing straight to the subprocess so the reply bypasses the queue, and consume the query so the renderer's xterm cannot also reply. Released on ready, timeout, or dispose, handing DA1 back to the renderer for steady state. Consolidates the identical DA1 handler the ConPTY override already used. * fix(terminal): prevent duplicate startup DA1 replies





Summary
Fixes STA-3417: opening an agent pane under a fish shell with a slow prompt integration (Starship) rendered the launch command text in the terminal but never executed it — the pane sat at the prompt with no agent running.
Root cause: fish had no shell-ready barrier. Orca's OSC 777
orca-shell-readymarker wrappers existed only for zsh/bash, sosupportsPtyStartupBarrier/supportsReadyMarkerwere false for fish and:terminal-host-session-create.ts—Session.writeonly queues in'pending'state, and fish sessions were'unsupported'), i.e. at t≈0 while fish was still initializing;writeStartupCommandWhenShellReady), the same race.Fix (mirrors the existing zsh/bash design):
shell-templates.ts: shared fish--init-commandthat emits the marker exactly once on the firstfish_promptevent — the earliest point fish's own reader owns the PTY, mirroring zsh'szle-line-initmarker. Usesbuiltin printfso a user-definedprintffunction cannot silently swallow the marker and send every launch to the timeout fallback.daemon/shell-ready.ts: fish branch in the launch config + fish added toshellPathSupportsPtyStartupBarrier, so daemon sessions queue the startup command until the marker (existing 15 s timeout fallback unchanged; plain payload-free Codex keeps its deliberate markerless 300 ms fast path).providers/local-pty-shell-ready.ts: same fish branch for the local/non-daemon path (1.5 s timeout fallback unchanged). Attribution-only (no-marker) fish spawns stay unwrapped.This is the smallest of the three shell integrations: fish's event system needs no wrapper directory, no rc-file re-sourcing, and no recursion guard — 5 lines of generated fish versus zsh's generated
ZDOTDIRwrapper dir andzle-line-initwidget chaining.Scope note: this PR originally also extended
startupCommandDelivery: 'shell-ready'to omp/pi/opencode. That change is agent-scoped and only affects the SSH renderer/relay path, so it neither fixes nor depends on the fish barrier. It has been split out to #12963.Reproduction & evidence
Deterministic repro on fish 4.8.1. Bare
pty.fork()+fish -l, command written immediately after fork, with every startup capability query answered (Primary DA, OSC 11, kitty keyboard, XTGETTCAP, CPR):The identical write gated on the
fish_promptmarker executes intact at every length tested, including 1560 bytes. Reproduced consistently across ~6 runs, with both a DA-only and a full responder.Two supporting measurements:
fish could not read response to Primary Device Attribute query after waiting for 10 seconds). With DA answered, the marker lands in ~20 ms. xterm.js implementssendDeviceAttributesPrimary, so attached panes reach the marker promptly.New tests that fail before the fix and pass after:
daemon/shell-ready.test.ts: fish joins the startup barrier; fish launch config wraps with thefish_promptmarker init and usesbuiltin printf; attribution-only fish stays unwrapped; plus a live-fish (itWithFish, skipped when fish is absent) test that spawns real fish via node-pty behind a Starship-shaped slow config, asserts the marker fires exactly once, and asserts a post-marker command executes.providers/local-pty-shell-ready.test.ts: same launch-config assertions for the local path.The live-fish test includes a minimal xterm.js-shaped query responder. Without it the test does not exercise the barrier at all — it races fish's 10 s DA timeout and fish swallows the post-marker command as a query reply.
Screenshots
No visual change. Electron QA evidence is in the PR comment below (OMP auto-launching through a delayed fish prompt).
Testing
pnpm lint— oxlint + oxfmt clean on all changed filespnpm typecheck— all three projects (node, cli, web) cleanpnpm test—daemon/shell-ready+providers/local-pty-shell-ready: 97 passed, including the live-fish test. Re-ran the live test 5× consecutively with no flakes; suite wall time dropped from 10.5 s to 3.0 s once the test stopped waiting out fish's DA timeout.pnpm build— not run locally; no dependency, bundler, or asset changesAI Review Report
supportsPtyStartupBarrierreturns false on win32 before any shell-name check, the local wrapper block sits insideprocess.platform !== 'win32', and the daemon POSIX branch is separate from the Windows fallback chain. No shortcuts, labels, or path handling touched; args are passed as an argv array, so no shell quoting is involved andpath.joinusage is unchanged.-lis not a behaviour change:['-l']is already the POSIX default for every shell on all three transports (local-pty-provider.ts,daemon/pty-subprocess.ts,relay/pty-shell-launch.ts), and the zsh wrapper passes it too. Wrapped fish keeps the args it already had.shellArgsis Orca-owned and was already exactly['-l'], so the wrapper replaces a constant, not user input.-C/--init-commandhas existed since fish 2.3 (2016) andfunction --on-eventsince 2.x, so nothing here depends on a recent fish. Verified on 4.8.1.shellPathSupportsPtyStartupBarrierrecheck interminal-host-session-create.ts; ifconfig.fishnever reaches a prompt, the daemon 15 s / local 1.5 s timeouts flush the queued command as before.Security Audit
--init-commandis a static template with no user input interpolated; the only variable is the marker constant, an Orca-owned literal. It is passed as a discrete argv element topty.spawn, so there is no shell-quoting or injection surface.scanForShellReadyimplementation unchanged.ORCA_SHELL_READY_MARKERis the same env toggle zsh/bash already use. No new dependencies.Notes
relay/pty-shell-launch.tswraps only bash and zsh). Those launches are unchanged by this PR; full remote marker support is a follow-up.fish_promptevent fires before fish emits?2004h, not after — the submission is nonetheless delivered correctly because the tty input buffer holds the bytes until fish's reader drains them with modes armed, which was verified against real fish.session.ts— the renderer's xterm is the authoritative responder). A fish session created before a renderer attaches therefore waits out fish's full 10 s DA timeout, andSession.writequeues all input during that window, not just the startup command. Worth exercising a hidden/background fish pane before merge; if it bites,installConptyPrimaryDeviceAttributesOverrideinheadless-emulator.tsis existing precedent for answering DA1 in a scoped window.itWithZsh/itWithBashpattern), so it does not run on CI runners without fish.Closes #12551.
Closes STA-3417.