Skip to content

fix(agent-resume): restore Cursor conversations after restart - #18927

Closed
edenaion wants to merge 1 commit into
stablyai:mainfrom
edenaion:fix/cursor-conversation-recovery
Closed

edenaion wants to merge 1 commit into
stablyai:mainfrom
edenaion:fix/cursor-conversation-recovery

Conversation

@edenaion

@edenaion edenaion commented Sep 5, 2026

Copy link
Copy Markdown

Cursor tabs currently lose automatic conversation recovery after the terminal process is gone because Cursor is excluded from the resumable-agent list and its hook conversation ID is discarded.

Capture Cursor's stable conversation_id, persist it through the existing recovery path, and resume with cursor-agent --resume <id>. Use the same identity for session history and advertise a Cursor-specific runtime capability so older remote hosts keep the existing fallback. Completed conversations retain their recovery checkpoint.

Validation: 86 focused tests passed; Node, CLI, and web type checks passed; formatting and changed-file lint passed. The Electron force-exit/restart suite passed for both Cursor and the existing Codex case. These cases verify persistence and resume dispatch with a deterministic replacement command. A separate disposable real Cursor conversation resumed through the compiled command and retained its previous context across CLI processes. Local EZ-Verify push-tier verification passed.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 47f73eee-80a7-4955-b4a5-86e2da82e0bc

📥 Commits

Reviewing files that changed from the base of the PR and between c58d7a0 and 905085f.

📒 Files selected for processing (10)
  • src/renderer/src/lib/ai-vault-resume-command.resumable-agent.test.ts
  • src/renderer/src/lib/ai-vault-resume-command.test.ts
  • src/renderer/src/lib/ai-vault-resume-command.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.test.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.ts
  • src/renderer/src/store/slices/agent-status-quit-capture-resumable-agents.test.ts
  • src/shared/agent-session-resume.test.ts
  • src/shared/agent-session-resume.ts
  • src/shared/protocol-version.ts
  • tests/e2e/agent-session-live-force-exit-resume.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Cursor is now a resumable TUI agent. Resume logic extracts conversation_id, builds cursor-agent --resume arguments, and preserves transcript paths. A Cursor-specific runtime capability gates host authority. Renderer startup and quit capture use conversation-based provider sessions. End-to-end recovery tests now cover both Codex and Cursor.

Merge Risk: ⚪ Minimal · up to 90508

Cursor conversations now persist and resume using their stable conversation ID after terminal exit, including completed-session recovery. The covered recovery and compatibility paths indicate the change is ready to merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description accurately summarizes the change and includes substantial validation details, but it omits the required template sections and information, including ELI5, What Changed, Why, Linked Iss… Rewrite the description using the repository template. Add the missing sections, provide a Linked Issue value after "Fixes #", state "N/A" with a reason for Visual Proof if no UI change exists, complete the Testing and Checklist items, and …
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 10 files. 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 and concisely identifies the primary change: restoring Cursor conversation recovery after restart.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description accurately summarizes the change and includes substantial validation details, but it omits the required template sections and information, including ELI5, What Changed, Why, Linked Issue with an issue number, Visual Proof or N/A, Testing checkboxes, AI Disclosure, Review, boundary confirmation, Notes, and Checklist.

Resolution

Rewrite the description using the repository template. Add the missing sections, provide a Linked Issue value after "Fixes #", state "N/A" with a reason for Visual Proof if no UI change exists, complete the Testing and Checklist items, and address cross-platform, SSH, security, performance, and AI disclosure requirements.

  • Fix all pre-merge checks with AI

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.

@pullfrog pullfrog 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.

ℹ️ No critical issues — two things worth confirming before this lands, plus one small nit.

Reviewed changes

  • cursor added to RESUMABLE_TUI_AGENTS — flips isResumableTuiAgent('cursor') and makes getAgentResumeArgv produce ['cursor-agent', '--resume', <id>].
  • Hook extraction for conversation_id — extractAgentProviderSession now reads a conversation_id (plus optional transcript_path) from Cursor's hook payload instead of returning null.
  • AI Vault provider-session mapping — getAiVaultAgentProviderSession maps a Cursor session's sessionId to { key: 'conversation_id', id }.
  • Cursor-specific runtime capability — adds agent-session.cursor-resume.v1 and gates the remote host-authority resume path on it, mirroring the Kimi gate so older remote hosts keep the legacy fallback.
  • Tests — unit coverage for extraction/argv/store capture, and the force-exit e2e spec generalized into Codex + Cursor recovery cases.

ℹ️ Live capture depends on an unverified external field name

The recovery path only works if Cursor's hook body actually carries a top-level conversation_id. The extraction logic is unit-tested against a hand-built payload, but no test feeds a realistic Cursor hook body through the full normalize path, so the load-bearing external contract is currently unproven.

Technical details
# Cursor hook payload field name is the feature's load-bearing assumption

## Affected sites
- src/shared/agent-session-resume.ts:242-245 — reads `payload.conversation_id`; if Cursor emits the id under a different key (e.g. `conversationId`, or nested), `extractAgentProviderSession` returns `null` and live-session recovery silently never happens.

## Required outcome
- Confirm Cursor's `beforeSubmitPrompt`/`stop` hook bodies actually carry a top-level `conversation_id`, and pin it with a fixture.

## Suggested approach (optional)
- Add a `server-cursor-normalization.test.ts` case that passes a realistic Cursor hook body (with `conversation_id`) through `normalizeHookPayload` and asserts the resulting `providerSession` is `{ key: 'conversation_id', id }`. None of the current Cursor payload fixtures include `conversation_id`, so this path is untested end-to-end.

ℹ️ Making Cursor resumable also opts it into hibernation, not just restart recovery

RESUMABLE_TUI_AGENTS is a shared gate. Adding cursor widens more than the restart path: idle done Cursor panes now become auto-hibernation candidates and gain live-resume anchors, which is broader than the PR title and body describe.

Technical details
# `RESUMABLE_TUI_AGENTS` is a shared gate with wider effects than restart recovery

## Affected sites
- src/shared/agent-session-resume.ts:5-21 — adding `cursor` flips `isResumableTuiAgent` globally.
- src/renderer/src/lib/agent-hibernation-pane-eligibility.ts:111-114 — idle `done` Cursor panes now become auto-hibernation candidates (previously excluded), and they get live-resume anchors.

## Required outcome
- Confirm auto-hibernation of idle Cursor panes is intended, since it will kill and later `--resume` the TUI on idle.

## Open questions for the human (optional)
- If `cursor-agent --resume <id>` resumes into a fresh turn and drops an in-progress composer draft, hibernation is more lossy for Cursor than for agents whose resume restores in-flight state.

ℹ️ Nitpicks

  • extractAgentProviderSession's cursor case wraps the result in withTranscriptPath, but getAiVaultAgentProviderSession returns a bare { key, id }, and Cursor resume ignores transcriptPath entirely (Cursor is not a native-chat transcript agent). Consider dropping withTranscriptPath there for symmetry and to avoid implying the transcript is read.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@philsv

philsv commented Sep 14, 2026

Copy link
Copy Markdown

I would also highly appreciate a merge on this

@edenaion

Copy link
Copy Markdown
Author

Hi @brennanb2025 this is the second contribution I've made that I think are overlooked or stuck in the pipeline? Would appreciate an update

#14293

@edenaion

Copy link
Copy Markdown
Author

Hi @nwparker @AmethystLiang would appreciate some human response :)

@nwparker

nwparker commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Thank you @edenaion for the Cursor conversation identity and restart/resume work. The independently reviewed successor #24670 has now merged as9a1bef48e4d78cdcab7758d604400f7601fd9dbb and retains explicit credit to your PR. Its exact-head hosted checks passed, including the existing restart dispatch tests and cross-version host checks. Closing this predecessor after the replacement merge; authenticated Cursor continuation and broader native Chat/history acceptance remain separately scoped.

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.

3 participants