orca icon indicating copy to clipboard operation
orca copied to clipboard

[Bug]: OMP terminals are excluded from cold session restoration

Open revofusion opened this issue 4 months ago • 3 comments

Operating system

macOS

Orca version

1.4.124

Details

OMP terminals report status through Orca's managed Pi-compatible extension, but Orca never records OMP's provider session ID. When a restart or crash requires a cold terminal restore (the prior PTY cannot be reattached), Claude is relaunched with claude --resume <session-id>, while OMP cannot enter the same restoration path and falls back to an unresumed terminal.

omp v17.0.1 --help confirms the supported interface is:

-r, --resume=<value>  Resume a session (by ID prefix, path, or picker if omitted)

Reproduction

  1. Open an Orca terminal and launch omp.
  2. Send at least one prompt so OMP creates a persisted session.
  3. Restart Orca in a way that forces cold restoration, such as terminating the PTY daemon with the app rather than allowing warm daemon reattachment.
  4. Reopen the workspace and restored terminal.

Expected: Orca starts omp --resume <session-id> in the existing pane and shows the session-restored banner, matching Claude/Codex behavior.

Actual: no OMP sleeping-session record exists, so pty-connection.ts has no provider session from which to build a cold-resume startup command.

Code path and root cause

The general restoration pipeline is already present:

  1. agent-hook-listener.ts calls extractAgentProviderSession(...) and attaches the result to the agent status row.
  2. agent-status.ts only creates a SleepingAgentSessionRecord when the agent is resumable, has providerSession, and getAgentResumeArgv(...) succeeds.
  3. pty-connection.ts consumes that record only on cold restore and builds the replacement startup command. This preserves the #5232/#5240 invariant: warm reattachment must not launch a duplicate agent tab/session.

OMP is blocked at every input to that pipeline in agent-session-resume.ts:

export const RESUMABLE_TUI_AGENTS = [
  'claude',
  'codex',
  // ...
  'devin'
] as const

omp is absent from RESUMABLE_TUI_AGENTS; extractAgentProviderSession explicitly returns null for it; and getAgentResumeArgv has no OMP case.

The missing source fact is visible in the generated managed extension. agent-status-extension-source.ts posts the supplied extra object unchanged:

payload: { hook_event_name: hookEventName, ...extra }

agent-status-handler-source.ts registers handlers without the extension context and only posts prompt/tool/message fields:

pi.on('before_agent_start', (event) => {
  post('before_agent_start', { prompt: event.prompt ?? '' })
})

OMP's extension API already exposes the authoritative ID as ctx.sessionManager.getSessionId(). The CLI accepts that ID through omp --resume <id>, so Orca does not need to infer a session from paths, titles, or process state.

Possible fix

  1. In agent-status-handler-source.ts, accept the second ctx argument for each status handler and attach session_id: ctx.sessionManager.getSessionId() to every posted snapshot. Attach it to every event rather than only the first because the transport intentionally keeps only the latest pending post, and sessions can switch within a process.
  2. In agent-session-resume.ts:
    • add 'omp' to RESUMABLE_TUI_AGENTS;
    • parse OMP's session_id into { key: 'session_id', id };
    • return ['omp', '--resume', id] from getAgentResumeArgv.
  3. Keep pi unsupported unless its CLI resume contract is independently verified; this issue only needs the explicit OMP contract.
  4. Add focused coverage:
    • the generated OMP hook payload includes session_id from the extension context;
    • extractAgentProviderSession('omp', ...) and getAgentResumeArgv('omp', ...) round-trip the ID;
    • quit/live capture persists an OMP sleeping record and cold restore launches omp --resume <id> in the same pane;
    • warm daemon reattachment still does not launch a duplicate OMP process.

This should reuse the existing sleeping-session schema and cold-restore flow rather than adding an OMP-specific restoration path.

revofusion avatar Jul 16 '26 05:07 revofusion

🤖 Agent handoff — reproduction kit

Status: REPRODUCED · GitHub label has_repro
Writeup (branch): docs/bug-reproductions/8962.md
Branch with tests + docs: nwparker/bug-repro-handoffs

Summary

OMP posts agent-status hooks through the managed Pi-compatible extension, but Orca never records an OMP provider session ID. Cold restore therefore cannot build omp --resume <id> and falls back to an unresumed shell. Claude/Codex/etc. already go through the sleeping-session + cold-resume path.

Automated re-run

git fetch origin nwparker/bug-repro-handoffs
git checkout nwparker/bug-repro-handoffs
# or: git worktree add /tmp/orca-repro-8962 origin/nwparker/bug-repro-handoffs

# See writeup on branch: docs/bug-reproductions/8962.md

Code / evidence files

  • (no automated test file yet — use writeup steps)

How another agent should use this

  1. Check out nwparker/bug-repro-handoffs (or cherry-pick the repro-* test for this issue).
  2. Run the command(s) above — green documents the bug (or cannot_repro proves current tree does not show it).
  3. Implement the fix on a new branch from main; keep/adapt the repro test as a regression test that should flip behavior or stay as a guard.
  4. Open a PR with: Description, Evidence, ELI5, User-regression-tradeoffs.

Posted by bug-repro orchestration so work is not trapped in a local worktree only.

nwparker avatar Jul 16 '26 18:07 nwparker

Independent cross-platform confirmation on Windows 11 with a WSL2 / Ubuntu 24.04 project runtime, using Orca v1.4.146 and OMP v17.0.5.

The two restart paths behave differently:

  • When Orca restarts itself during an application update, the previously open OMP session is restored and remains attached.
  • When Orca is fully closed and then launched again, the same pane returns only as a plain terminal; OMP is not relaunched or resumed.

This is a useful differential reproduction of warm PTY reattachment versus cold restoration and matches the root cause described here. Please include this Windows/WSL scenario in validation for #8991: a full quit and relaunch should restore the pane by running omp --resume <session-id>, while an update-time warm reattachment must continue to avoid launching a duplicate process.

euclodius avatar Jul 19 '26 13:07 euclodius

will be in next release, usually within 24 hours

OrcaWin avatar Jul 24 '26 02:07 OrcaWin