Skip to content

fix(agents): include OMP terminals in cold session restoration - #8991

Merged
OrcaWin merged 5 commits into
stablyai:mainfrom
xianjianlf2:fix/omp-cold-session-restoration-8962
Jul 24, 2026
Merged

OrcaWin merged 5 commits into
stablyai:mainfrom
xianjianlf2:fix/omp-cold-session-restoration-8962

Conversation

@xianjianlf2

Copy link
Copy Markdown
Contributor

OMP terminals report status through Orca's managed Pi-compatible extension, but Orca never recorded OMP's provider session ID. On a cold terminal restore (the prior PTY can't be reattached), Claude/Codex relaunch via --resume <id> while OMP had no sleeping-session record and fell back to an unresumed terminal (#8962).

This feeds the missing source fact into the existing sleeping-session/cold-restore pipeline rather than adding an OMP-specific path:

  • The generated Pi/OMP status handler now attaches session_id from the extension context (ctx.sessionManager.getSessionId()) to every posted snapshot — it must ride every event because the transport keeps only the latest pending post and a session can switch within a process.
  • omp is added to RESUMABLE_TUI_AGENTS; extractAgentProviderSession parses its session_id; getAgentResumeArgv returns ['omp', '--resume', <id>] (matching omp -r/--resume).

Warm daemon reattachment is unaffected — cold-restore consumption of the record is unchanged, so it still can't launch a duplicate agent (#5232/#5240 invariant).

Tests: OMP round-trips through extract/resume-argv; the generated hook payload includes session_id from the extension context (and omits it when absent).

Closes #8962

X: @mark86202384100

@coderabbitai

coderabbitai Bot commented Jul 16, 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

OMP Pi status hooks now receive context and include session_id in lifecycle status payloads when available. Pi and OMP session metadata handling is covered by expanded tests. Shared agent-session handling recognizes OMP as resumable, extracts its session metadata, and generates omp --resume arguments. Mobile AI Vault resume launches normalize OMP transcript paths and preserve them through startup-plan and command generation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is relevant, but it does not follow the required template and is missing explicit Summary, Screenshots, AI Review Report, Security Audit, and Notes sections. Rewrite it using the repository template and add the missing sections, including screenshots or 'No visual change', testing checklist, AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding OMP terminals to cold session restoration.
Linked Issues check ✅ Passed The changes address #8962 by recording OMP session IDs, making OMP resumable, and generating omp --resume as required.
Out of Scope Changes check ✅ Passed No clear out-of-scope code is evident; the mobile and resume-path changes support the same OMP cold-restore pipeline.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 16, 2026 17:17
@xianjianlf2
xianjianlf2 force-pushed the fix/omp-cold-session-restoration-8962 branch from dfe9ebb to 5bf8c0a Compare July 17, 2026 02:30
OMP terminals report status through the managed Pi-compatible extension,
but Orca never recorded OMP's provider session id, so a cold terminal
restore (when the prior PTY cannot be reattached) could not build an
`omp --resume <id>` startup command and fell back to an unresumed
terminal — unlike Claude/Codex/Pi.

Feed the existing sleeping-session/cold-restore pipeline the missing
source fact instead of adding an OMP-specific path, reusing the session
metadata transport that stablyai#8876 introduced for Pi resume:

- For kind 'omp', refresh the shared `sessionMetadata` from the handler
  ctx (`ctx.sessionManager.getSessionId()`) on every event, and spread it
  into every posted payload. Unlike Pi (which resumes by transcript file
  and gates its metadata on that file existing), OMP resumes by id alone,
  so the latest handler-captured id rides every post as-is. Refreshing on
  every event matters because the transport keeps only the latest pending
  post and a session can switch within a process. Pi's generated source
  is byte-for-byte unchanged.
- Add `omp` to `RESUMABLE_TUI_AGENTS`, parse its `session_id` in
  `extractAgentProviderSession`, and return `['omp', '--resume', <id>]`
  from `getAgentResumeArgv`.

Warm daemon reattachment is unaffected: cold-restore consumption of the
sleeping record is unchanged, so it still cannot launch a duplicate
agent (stablyai#5232/stablyai#5240 invariant).

Closes stablyai#8962
@xianjianlf2
xianjianlf2 force-pushed the fix/omp-cold-session-restoration-8962 branch from 5bf8c0a to 3f12cfa Compare July 18, 2026 03:21
@xianjianlf2

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (cb9c42d) to adapt to the new session-metadata transport introduced by #8876: OMP now reuses the shared sessionMetadata/updateSessionMetadata mechanism (refreshed per event from ctx) instead of the previous per-handler injection. Since OMP resumes by id (omp --resume <id>) rather than by transcript file, no session-file persistence gate is applied — Pi's generated extension source is byte-for-byte unchanged. 482 tests across the touched suites pass; oxlint/tsc clean.

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7fba9a29-30b0-4ab0-8730-03a87c25b7ac

📥 Commits

Reviewing files that changed from the base of the PR and between 5bf8c0aee4149e4d6685f0c93f249c92d5306750 and 3f12cfa.

📒 Files selected for processing (3)
  • src/main/pi/agent-status-extension-source.test.ts
  • src/main/pi/agent-status-extension-source.ts
  • src/main/pi/agent-status-handler-source.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/pi/agent-status-extension-source.test.ts

@xianjianlf2

Copy link
Copy Markdown
Contributor Author

Addressed this in 98da1532e by decoupling session_id and session_file assignment in the generated extension source.

What changed:

  • sessionMetadata is initialized first.
  • session_id is added when a non-empty session id exists.
  • session_file is added independently when a non-empty session file exists.
  • Added regression coverage for Pi preserving a session file even when the session id is unavailable.

Local checks:

  • pre-commit oxlint / oxlint --config config/oxlint-react-doctor.json / oxfmt --write
  • pnpm exec vitest run --config config/vitest.config.ts src/main/pi/agent-status-extension-source.test.ts (30 tests passed)

@revofusion

Copy link
Copy Markdown

Bumping @Jinwoo-H

@OrcaWin OrcaWin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the OMP cold-restore paths, custom session stores, WSL/SSH handling, persistence, mobile launch, and mixed-version fallback. Local validation and Electron reproduction passed; awaiting CI before merge.

@OrcaWin
OrcaWin merged commit e3adb20 into stablyai:main Jul 24, 2026
5 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…yai#8991)

Preserve OMP session identity and exact resume paths across cold restoration, AI Vault, mobile, WSL/SSH, and host-authority routes. Add mixed-version fallback and completed-session recovery coverage.
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]: OMP terminals are excluded from cold session restoration

4 participants