Repository navigation
fix(agent-resume): resume OMP sessions after worktree sleep - #16276
CodeHourra wants to merge 1 commit into
Conversation
OMP 的 session_start 现在会带上 session_file,休眠唤醒时把 --resume 打进已恢复的 shell,并从 AI Vault 历史恢复时保留原会话标题。
📝 WalkthroughWalkthroughThe change extends Pi-compatible provider-session handling to OMP. OMP session metadata now includes transcript paths across hooks, status events, persistence, hydration, and resume argument generation. Reattached worktree-sleep sessions keep their PTYs and receive resume commands after restore. AI Vault launches now pass session metadata, configure agent-specific startup behavior, claim automatic resumes, and seed tab titles. Tests cover these flows for OMP, Codex, Claude, Gemini, Pi, and Prime Agent. Merge Risk: 🟡 Moderate · up to Restoring conversations through the web runtime can lose the saved conversation title, causing an inconsistent restored-session experience. The PR should address this bounded correctness issue before merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/lib/launch-ai-vault-session.ts (1)
41-43: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense the rationale comments.
Use one concise line for each comment.
src/renderer/src/lib/launch-ai-vault-session.ts#L41-L43: reduce the title-persistence rationale to one line.src/renderer/src/lib/launch-ai-vault-session.test.ts#L175-L176: reduce the test rationale to one line.As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 15dae804-f06e-4efe-bdf9-d9bd4faf1755
📒 Files selected for processing (25)
src/main/agent-hooks/server-last-status-hydrate-validation.test.tssrc/main/agent-hooks/server.tssrc/main/pi/agent-status-extension-source.test.tssrc/main/pi/agent-status-extension-source.tssrc/main/pi/agent-status-handler-source.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.tssrc/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsxsrc/renderer/src/components/terminal-pane/pty-connection-cold-restore-resume-command.test.tssrc/renderer/src/components/terminal-pane/pty-connection/apply-reattach-payload.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-attach.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-reattach-connect.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-payload-context.test.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-payload-context.tssrc/renderer/src/components/terminal-pane/pty-connection/reattach-result-handler.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/lib/launch-ai-vault-session.test.tssrc/renderer/src/lib/launch-ai-vault-session.tssrc/renderer/src/lib/sleeping-agent-pane-ownership.tssrc/renderer/src/store/slices/agent-status-provider-session.test.tssrc/renderer/src/store/slices/agent-status.tssrc/shared/agent-hook-listener-pi-compatible.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-session-resume.test.tssrc/shared/agent-session-resume.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| title?: string | ||
| sessionId?: string |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve titles for web-runtime resumes.
title and sessionId are ignored when isWebRuntimeSessionActive(...) is true. createWebRuntimeSessionTerminal receives neither field, and this branch returns before seedAiVaultResumeTabTitle. A resumed web-runtime tab therefore loses its restored title. Pass title metadata through the web-runtime creation path and add web-runtime coverage.
|
The bounded recorded-transcript-path resume proposal is carried forward in #20634, with credit to @CodeHourra and the original Git author stevelliu. Final review identified producer dependencies #20611 → #20615 → #20634, so the replacement is not merged yet. Your broader sleep/replay/title changes are not adopted wholesale; this PR remains open until the replacement is actually merged. |
Based on the resume-locator proposal in #16276 by @CodeHourra. Retains UUID-based ownership and existing reattach behavior.
|
Superseded by #20634 (OMP transcript-path resume), which contains the current implementation and verification on . Closing this stale duplicate so review stays on the maintained PR. |
|
Superseded by #20634. |
ELI5
Sleeping a worktree used to bring Claude back with
--resume. OMP (and other Pi-compatible TUI agents) woke into a blank shell instead. After this change, Orca types--resumeinto the restored shell, using the on-disksession_filethe agent reported. Restoring from AI Vault also keeps the previous conversation title.What Changed
session_fileastranscriptPath, keepproviderSessionacrossdone → working, and preferompResumeFilePath/transcriptPath/ id when building--resume.session_starthooks so the sleeping record has a resume locator.createOrAttach(sessionId)drops argv, so we no longer send resume argv onconnect({ sessionId })and we never inject when a live snapshot/replay is still on screen.aiVaultTitlefor Claude/Codex and pinscustomTitlefor other agents so a later OSC title cannot overwrite the conversation name.Why
Worktree sleep/wake reattaches an existing PTY session id. The daemon drops spawn argv on that path, so Claude only resumed because a later path typed
--resumeinto the shell. OMP never capturedsession_fileand skippedsession_start, so that inject had nothing to type.Linked Issue
No existing issue.
Visual Proof
N/A — restore injects a
--resumeline into an existing terminal; there is no new UI chrome.--resume <session_file>into the restored shell; AI Vault history keeps the original titleTesting
Covered in unit tests:
--resumeprefersompResumeFilePath, thentranscriptPath, then idsession_startis processed (Pi-compatible)done → workingfor Pi-compatible agentsproviderSessionOnlyconnect({ sessionId })pnpm exec vitest run --config config/vitest.config.ts \ src/shared/agent-session-resume.test.ts \ src/shared/agent-hook-listener-pi-compatible.test.ts \ src/main/pi/agent-status-extension-source.test.ts \ src/renderer/src/store/slices/agent-status-provider-session.test.ts \ src/renderer/src/lib/launch-ai-vault-session.test.ts \ src/renderer/src/components/terminal-pane/pty-connection-cold-restore-resume-command.test.ts \ src/main/agent-hooks/server-last-status-hydrate-validation.test.ts \ src/renderer/src/components/terminal-pane/pty-connection/reattach-payload-context.test.ts8 files, 136 tests passed.
AI Disclosure
Cursor Grok authored the implementation, tests, and this PR description.
Review
transcriptPath/ompResumeFilePathremain optional fields.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Summary
session_fileand--resumeafter worktree sleep instead of waking into a blank shell.Test plan
--resumeand continues the same conversation--resumeinto a still-running TUIMade with Cursor