Skip to content

fix(terminal): OMP's prompt-bubble markers no longer end the agent's turn, so the phone's chat finds the session (#10923) - #30273

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-10923-chat-session
Oct 18, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-10923-chat-session

Conversation

@nwparker

@nwparker nwparker commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​214 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​214
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21

ELI5

Some agent CLIs draw invisible "this is a prompt" markers around the messages you type. OMP draws a "command started" marker and, right after it, a "command finished" marker at the end of every message bubble. Orca uses the same kind of marker from your shell to learn that a program has exited. It mistook OMP's marker for the shell saying "OMP exited", so in the middle of every turn it threw away what it knew about the running agent, including which conversation it is in. The phone's chat view needs exactly that to find the transcript, so it went blank.

What Changed

Before: in a terminal running OMP, sending a message (from the phone or the desktop) made Orca drop the pane's agent status mid-turn. On a headless orca serve host the phone's session.tabs.list never carried agentStatus.providerSession for the OMP tab, so native chat had no transcript to read. The optimistic bubble showed, then the chat went back to empty, which is the OMP report in #10923. The agent's later hooks for that turn were also refused, because the pane had been retired.

After: OMP's bubble markers are ignored. The pane keeps its status and session through the turn, the phone's tab list carries the OMP session, and nativeChat.readSession returns the conversation. When OMP really exits, the shell's own marker still ends the command as before.

Mechanism: createOsc133CommandFinishedScanner (src/shared/terminal-osc133-command-finished.ts) is the one scanner every consumer uses: main's per-PTY tracker, the daemon's background fact relay, and the renderer. The scanner now remembers which OSC 133 marks arrived back to back, with no other output between them. A D;0 that comes straight after B then C is an app closing its own zone, so it no longer counts as command-finished. Every other C and D behaves exactly as before.

Root cause: OMP 18 ends each user bubble with 133;B 133;C 133;D;0 (oh-my-pi packages/tui/src/chat/user-message.ts, OSC133_ZONE_CLOSE). Orca read that D as command-finished. That fact calls retirePtyAgentLaunchAuthority, which calls retirePaneAuthority on the hook server and deletes the pane's status row (terminal-title-tracker.ts and terminal-transient-facts.ts).

Wire compatibility: no wire change. The host stops deleting a row it used to delete, so older phones get the existing optional providerSession field they already read.

Why

The rule has to be narrow, because the shell itself can print C and then D;0 back to back. A silent command such as cd does that, and synthetic tests do too. Those finish events nudge things like the git status refresh and agent identity cleanup, so they have to keep firing.

What tells them apart is the B (end of the prompt). A shell prints its C after the command line the user typed, so a B is never directly before it. OMP prints B C D;0 together in a single write.

The rule needs no timers and no held state, so it also survives the daemon handing scanning over when a pane is hidden or shown. An earlier version of this PR waited for the shell's next prompt mark instead, and the Codex review found it lost a silent command's finish across that handoff.

Alternatives considered:

  • Tracking C/D nesting depth: the daemon creates a fresh scanner each time a pane goes to the background, so the depth would be wrong in exactly the headless case.
  • Special-casing OMP by agent type: the scanner runs below agent identity, and any app that closes its own zone this way has the same problem.

Linked Issue

Part of #10923 (the OMP reproduction). The other reproductions are covered in Notes.

Visual Proof

N/A. This is host-side status data with no UI change. The phone draws the same chat view once the session arrives.

Testing

Reproduced on fresh origin/main first, then verified with the fix, all locally on macOS with isolated HOME and profile, background launch and no windows:

  • Real OMP 18.10.3, live: an isolated headless orca serve with real omp in its PTY and a local fake OpenAI-compatible model. A scripted phone client typed a prompt, then polled session.tabs.list and called nativeChat.readSession.
    • On main, the OMP hooks reached the hook server, which accepted all four with 204. Temporary tracing showed retirePaneAuthority (from emitDaemonPtyTransientFact → command-finished) deleting the row mid-turn, so the tab never got providerSession.
    • With the fix, the tab carries the OMP session, it holds across polls and a second turn, and readSession returns the user and assistant messages.
  • Captured transcript: src/main/runtime/__fixtures__/omp-user-bubble-osc133-zone.txt, recorded with config/scripts/capture-agent-pty-transcript.mjs (the scrub check came back clean).
  • src/shared/terminal-osc133-self-closed-zone.test.ts (fails on main):
    • The OMP transcript, fed in chunks of 1, 3, 7 and 64 bytes and whole, reports no finish.
    • A zone close split across chunks is dropped.
    • These still finish: a silent shell command (C D;0), a command typed after the prompt's B, and a failed command.
    • A reset forgets the zone end.
  • src/main/runtime/omp-user-bubble-launch-authority.test.ts: a launched OMP pane keeps its hook authority through the real transcript and loses it when the shell reports the exit. This fails on main.
  • All 46 unit test files that feed OSC 133 bytes pass unchanged.
  • The src/shared, src/main/runtime, src/main/daemon and src/renderer/src/components/terminal-pane folders pass single-worker, apart from local failures that also fail on origin/main without this change:
    • two daemon shell-ready files that spawn real zsh/bash
    • three tests in orca-runtime.test.ts and orca-runtime-structured-agent-session-create-intent.test.ts
  • The full static-analysis job steps pass locally.

Not run: Windows and Linux, and the desktop renderer path (that path uses the same scanner, so it is covered only by the unit tests).

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Other #10923 reproductions, checked on current main:

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…nt's turn (#10923)

OMP ends every user bubble with OSC 133 B C D;0 to close its own prompt zone.
Orca read that D as the shell's command finishing, retired the pane's hook
authority mid-turn and deleted its status row, so the phone's chat view lost the
provider session it reads the transcript by. A D;0 directly after B C is now an
app's zone close, not a command exit.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 029e48fa-2e58-4f67-9e28-4215e2202378
📥 Commits

Reviewing files that changed from the base of the PR and between 9bd47de and 0139810.

📒 Files selected for processing: 5
  • src/main/runtime/__fixtures__/omp-user-bubble-osc133-zone.meta.json
  • src/main/runtime/__fixtures__/omp-user-bubble-osc133-zone.txt
  • src/main/runtime/omp-user-bubble-launch-authority.test.ts
  • src/shared/terminal-osc133-command-finished.ts
  • src/shared/terminal-osc133-self-closed-zone.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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