Skip to content

feat(session): crash recovery — auto-resume sessions after crash - #43489

Open
AndyS77 wants to merge 8 commits into
anomalyco:devfrom
AndyS77:crash-recovery
Open

feat(session): crash recovery — auto-resume sessions after crash#43489
AndyS77 wants to merge 8 commits into
anomalyco:devfrom
AndyS77:crash-recovery

Conversation

@AndyS77

@AndyS77 AndyS77 commented Aug 19, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #43488

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an opt-in config option (session.auto_resume) that persists active session IDs to a manifest file on disk. On next startup, if the manifest exists (previous process didn't shut down cleanly), opencode automatically resumes the most recently active session. The manifest is cleared on clean shutdown via process.on("exit"). Manifest writes are atomic and shape-validated; corrupt JSON degrades gracefully.

How did you verify your code works?

17 tests pass (13 unit + 4 e2e). Live-tested crash, partial-idle, clean-shutdown, corrupt-JSON, multi-session, and write-update scenarios against the real data directory.

bun test test/session/active-manifest.test.ts test/session/crash-recovery-e2e.test.ts --timeout 30000
# 17 pass, 0 fail

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found one highly related PR:

PR #39684: feat(core): recover interrupted sessions on startup

This PR appears to address a similar concern about recovering sessions on startup, which overlaps with the crash recovery auto-resume functionality in PR #43489. You may want to review that PR to ensure there's no duplication of effort and to understand any prior approaches to session recovery.

@AndyS77

AndyS77 commented Aug 19, 2026

Copy link
Copy Markdown
Author

Thanks for the heads up. I reviewed PR #39684 — it's complementary, not a duplicate:

  • feat(core): recover interrupted sessions on startup #39684 fixes database durability: SQLite WAL hardening and recovery of in-flight assistant messages (marks incomplete turns as interrupted).
  • This PR adds auto-resume: tracks which sessions were active in a manifest and automatically resumes the most recently active session on next startup, so the user doesn't need to manually find and pass --continue.

They solve different layers of the same problem: #39684 ensures session data survives the crash, this PR ensures the user gets back into their session automatically.

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.

[FEATURE]: Crash recovery — auto-resume sessions after crash

1 participant