Skip to content

fix(terminal): agent pane auto-launch lost under fish + Starship (STA-3417) - #12840

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/sta-3417-fish-agent-autolaunch
Aug 9, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/sta-3417-fish-agent-autolaunch

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

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-ready marker wrappers existed only for zsh/bash, so supportsPtyStartupBarrier / supportsReadyMarker were false for fish and:

  • the daemon path (production panes) wrote the launch command into PTY stdin synchronously at session create (terminal-host-session-create.ts — Session.write only queues in 'pending' state, and fish sessions were 'unsupported'), i.e. at t≈0 while fish was still initializing;
  • the local path resolved the ready barrier immediately and blind-wrote ~30–200 ms after the first output byte (writeStartupCommandWhenShellReady), the same race.

Fix (mirrors the existing zsh/bash design):

  • shell-templates.ts: shared fish --init-command that emits the marker exactly once on the first fish_prompt event — the earliest point fish's own reader owns the PTY, mirroring zsh's zle-line-init marker. Uses builtin printf so a user-defined printf function 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 to shellPathSupportsPtyStartupBarrier, 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 ZDOTDIR wrapper dir and zle-line-init widget 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):

FULL responder, t=0 write, ~ 260 bytes -> executed = False
FULL responder, t=0 write, ~1560 bytes -> executed = False

The identical write gated on the fish_prompt marker 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 4.x holds its first prompt until a Primary DA reply arrives, giving up only after a 10 s timeout (and printing 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 implements sendDeviceAttributesPrimary, so attached panes reach the marker promptly.
  • Fish re-emits capability queries around every prompt and consumes stdin until each reply lands, so a command written into an unanswered terminal is absorbed as a query response.

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 the fish_prompt marker init and uses builtin 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 files
  • pnpm typecheck — all three projects (node, cli, web) clean
  • pnpm 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 changes
  • Added or updated high-quality tests that would catch regressions

AI Review Report

  • Cross-platform (macOS/Linux/Windows): the fish branches are only reachable on POSIX paths — supportsPtyStartupBarrier returns false on win32 before any shell-name check, the local wrapper block sits inside process.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 and path.join usage is unchanged.
  • -l is 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.
  • User shell args: there is no user-configurable POSIX shell-args setting; shellArgs is Orca-owned and was already exactly ['-l'], so the wrapper replaces a constant, not user input.
  • fish version floor: -C / --init-command has existed since fish 2.3 (2016) and function --on-event since 2.x, so nothing here depends on a recent fish. Verified on 4.8.1.
  • Regression risk: plain payload-free Codex startup keeps the markerless fast path (its existing test still passes); attribution-only fish spawns stay unwrapped so interactive fish terminals behave exactly as before; a fish→bash fallback shell drops the stale barrier via the existing shellPathSupportsPtyStartupBarrier recheck in terminal-host-session-create.ts; if config.fish never reaches a prompt, the daemon 15 s / local 1.5 s timeouts flush the queued command as before.
  • Folder workspaces: unaffected — the change is at the shell-spawn layer, independent of worktree vs folder context.

Security Audit

  • Command execution: the fish --init-command is 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 to pty.spawn, so there is no shell-quoting or injection surface.
  • Input handling: the change delays writing an already-authorized startup command; it introduces no new parsing of untrusted data. The marker scanner reuses the existing scanForShellReady implementation unchanged.
  • Path handling / secrets / auth / IPC: no file paths, credentials, or IPC message shapes added; ORCA_SHELL_READY_MARKER is the same env toggle zsh/bash already use. No new dependencies.
  • No follow-up security work needed.

Notes

  • Split: the omp/pi/opencode SSH delivery change moved to fix(terminal): wait for shell-ready before every SSH startup command #12963. Disjoint file sets; either can merge first.
  • Fish over direct SSH remotes still has no remote-side fish wrapper (relay/pty-shell-launch.ts wraps only bash and zsh). Those launches are unchanged by this PR; full remote marker support is a follow-up.
  • Fish sessions now also get bracketed-paste-wrapped multiline startup submissions on the daemon path. Note the ordering: the fish_prompt event 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.
  • The marker is emitted as OSC 777, matching the existing zsh/bash wrappers. OSC 777 is also the rxvt-unicode notification namespace; migrating the whole barrier to standard OSC 133;A would avoid collisions when a session is rendered by a non-Orca terminal. Pre-existing, not changed here.
  • Known gap, not addressed: the daemon emulator is architecturally forbidden from answering terminal queries (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, and Session.write queues all input during that window, not just the startup command. Worth exercising a hidden/background fish pane before merge; if it bites, installConptyPrimaryDeviceAttributesOverride in headless-emulator.ts is existing precedent for answering DA1 in a scoped window.
  • The live fish test is skipped automatically where fish is not installed (mirrors the existing itWithZsh / itWithBash pattern), so it does not run on CI runners without fish.

Closes #12551.
Closes STA-3417.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Fish now supports PTY startup barriers and shell-ready markers. Marker-enabled launches use login mode, a fish initialization command, and ORCA_SHELL_READY_MARKER. The initialization command emits one marker at the first prompt and removes its hook. Attribution-only launches remain unwrapped. Tests cover launch configuration, terminal capability queries, marker ordering, and post-marker command execution.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The fish shell-ready barrier is addressed, but the linked issue also requires agent-specific delivery fixes for omp, pi, and opencode. Include the agent-specific startup delivery changes in this PR, or link the completed follow-up and update the issue scope explicitly.
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. 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 fish and Starship auto-launch fix.
Description check ✅ Passed The description includes all required sections, test results, limitations, AI review, security audit, and platform notes.
Out of Scope Changes check ✅ Passed The workflow, implementation, and test changes support fish shell-ready behavior and its regression coverage.
✨ 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

Electron QA passed on the exact PR worktree.

  • Launched the isolated dev app and verified the automation-visible identity was brennanb2025/sta-3417-fish-agent-autolaunch.
  • Used fish 4.8.1 with a deliberately delayed, Starship-shaped prompt initialization, then launched OMP from New tab → OMP.
  • Process evidence showed fish running with the -C shell-ready marker registration and omp as its foreground child; the tab reached OMP ready and rendered the full OMP UI.
  • Renderer console had no errors.

STA-3417: OMP auto-launched successfully through delayed fish prompt

@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-3417-fish-agent-autolaunch branch from 1774adf to 9c59d34 Compare August 7, 2026 01:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/shell-templates.ts (1)

163-169: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce duplicated Fish readiness comments.

Keep the rationale in src/main/shell-templates.ts as 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 the fish_prompt readiness 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

📥 Commits

Reviewing files that changed from the base of the PR and between 87d1d1a and 9c59d34.

📒 Files selected for processing (5)
  • src/main/daemon/shell-ready.test.ts
  • src/main/daemon/shell-ready.ts
  • src/main/providers/local-pty-shell-ready.test.ts
  • src/main/providers/local-pty-shell-ready.ts
  • src/main/shell-templates.ts

Comment thread src/main/daemon/shell-ready.test.ts Resolved
@brennanb2025

Copy link
Copy Markdown
Contributor Author

@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:

case before after expected
query tail-aligned to chunk end 2 replies 1 1
query split across the boundary 1 1 1
two genuinely distinct queries 3 2 2

The third case is the telling one — the old code emitted a spurious third reply. A stray \x1b[?6c reaching fish's stdin at the prompt would land as typed input and could corrupt the startup command line, so this was a latent flake rather than a cosmetic issue.

Comment duplication — agreed, the rationale was repeated at four sites. Consolidated to one statement in shell-templates.ts where the mechanism lives; the three launch branches are now one line each pointing at their mirror.

Suites re-run 5× consecutively: 97/97, no flakes.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@brennanb2025 Confirmed. The duplicate-query fix prevents repeated terminal replies from entering fish stdin. The tests cover the critical chunk-boundary cases. The rationale consolidation also removes the repeated comments.

🐇 ✅


✏️ Learnings added
Learnt from: brennanb2025
URL: https://github.com/stablyai/orca/pull/12840

Timestamp: 2026-08-07T07:19:20.772Z
Learning: In the fish shell-ready terminal-query parser, bytes retained in the carry window must not cause a terminal capability query to be answered again when that complete query appears entirely in the next received chunk. Duplicate replies, such as `\x1b[?6c`, can reach fish stdin at the prompt and corrupt the startup command line. Preserve one reply for tail-aligned queries, split queries, and each genuinely distinct query.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-3417-fish-agent-autolaunch branch from a4d6a2c to c8c5d1b Compare August 7, 2026 07:39
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-3417-fish-agent-autolaunch branch from c8c5d1b to 1df555e Compare August 7, 2026 07:46
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between f057cbc and 1df555e.

📒 Files selected for processing (7)
  • .github/workflows/pr.yml
  • config/scripts/pr-workflow-parallelism.test.mjs
  • src/main/daemon/shell-ready.test.ts
  • src/main/daemon/shell-ready.ts
  • src/main/providers/local-pty-shell-ready.test.ts
  • src/main/providers/local-pty-shell-ready.ts
  • src/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
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-3417-fish-agent-autolaunch branch from 1df555e to 47f3256 Compare August 7, 2026 18:03
@brennanb2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai Both addressed in 47f3256.

Exact package tokens + whole-workflow lane check — agreed on both counts. includes('fish') would have matched a comment or a longer package name, and scoping the negative check to workflow.jobs.test left every other job free to install shells. Now parses the apt-get install line into package tokens and asserts jobsInstallingPackages equals exactly ['shell_contracts'].

Mutation-tested both invariants:

mutation result
drop fish from the install line fails (1/11)
add a shell install to the general shard lane fails (1/11)
unmodified passes 11/11

toBeDefined() on the located steps — added. Worth noting these were already load-bearing: shellInstall.with[...] and shellStep.run would throw a TypeError if either lookup missed, so the test did fail. The explicit assertions just make the failure message say which step vanished instead of Cannot read properties of undefined.

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.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@brennanb2025 Confirmed. The exact-token check prevents false matches. The whole-workflow assertion prevents shell installation from moving to another lane.

The mutation results show that both invariants fail as intended. The explicit toBeDefined() assertions also provide clear failure output.

The missing-binary skip behavior is important. The workflow contract test now protects against silent loss of fish test coverage.

🐇 ✅


✏️ Learnings added
Learnt from: brennanb2025
URL: https://github.com/stablyai/orca/pull/12840

Timestamp: 2026-08-07T18:04:03.728Z
Learning: In `.github/workflows/pr.yml`, real-shell contract tests can skip when the required shell binary is unavailable. The workflow contract test must verify that the dedicated `shell_contracts` job installs the required shell packages and that no other job installs them. It should parse `apt-get install` package tokens exactly rather than use substring matching, because a missing package can otherwise silently remove CI coverage.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-3417-fish-agent-autolaunch branch from 4d2849a to 37937db Compare August 7, 2026 18:56
@brennanb2025

Copy link
Copy Markdown
Contributor Author

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.

Timed fish OMP launch

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA — PASS (STA-3417 fish agent auto-launch + DA1)

Commit: dd3b219ad25264bb6e8de0f0177324f52f81f700
Identity: window.api.app.getIdentity() → Orca: brennanb2025/sta-3417-fish-agent-autolaunch (devLabel sta-3417-fish-agent-autolaunch, worktree root matches this PR branch)

Setup (isolated; no user config mutated)

  • Unique ORCA_DEV_USER_DATA_PATH + CDP 9333 + renderer 5175
  • App SHELL=/opt/homebrew/bin/fish
  • Temp XDG_CONFIG_HOME/fish/config.fish only (Starship-shaped: sleep 0.25 + QA-fish> prompt) — not user ~/.config/fish

Action

  1. Activated worktree → blank fish tab showed QA-fish> (fg=fish)
  2. New tab → OMP (visible UI) under delayed fish prompt
  3. Second OMP launch + tab switch + third OMP after close attempt (reopen / multi-startup path for duplicate-DA1 regression at HEAD)

Result — PASS

Check Evidence
Agent auto-launches Tab title OMP ready, fg process omp, buffer shows OMP TUI (omp v17.0.5, Welcome back) — not unexecuted omp text at fish prompt
Fish delayed prompt Blank tab buffer ends with QA-fish>
Duplicate DA1 / stray input No ?1;2c / DA1 reply text in any buffer; no fish Primary DA timeout message; 3 OMP panes all fg=omp with TUI
Console/logs No relevant terminal/shell-ready errors. Daemon: clean session-created for each pane. Benign: React Grab outdated, Tooltip controlled/uncontrolled, xterm task-queue deadline, FileListingCancelledError on explorer

Screenshots

01 OMP auto-launch
02 two OMP tabs
03 relaunched OMP

Cleanup

Isolated Electron process tree, temp user-data, temp fish XDG config, and playwright session torn down after this report.

@brennanb2025
brennanb2025 merged commit 6858e07 into main Aug 9, 2026
50 checks passed
JustShinobi pushed a commit to JustShinobi/orca that referenced this pull request Aug 10, 2026
…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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…-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
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.

[Bug]: Agent pane auto-launch broken for omp/pi/opencode in fish + Starship

1 participant