Skip to content

feat: opt-in resume of interrupted runs after restart (#1512 I3) - #1513

Merged
currentbits merged 3 commits into
mainfrom
coder/1512-i3-opt-in-auto-continue-after-crash-02b879
Oct 6, 2026
Merged

currentbits merged 3 commits into
mainfrom
coder/1512-i3-opt-in-auto-continue-after-crash-02b879

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Item I3 of #1512.

What changed

  • Setting: Settings › Threads › "Resume interrupted runs after restart", off by default.
  • Interrupted runs: a run cut off by a quit or crash carries interruptedAt (stamped by stopAll and recoverInterruptedRuns, cleared by any new run).
  • On boot, after first paint and whenPathReady, each eligible thread gets one machine turn: "[restart] The app restarted while you were working. Continue where you left off."
    • It goes through deliverNotice, so the budget gate and the auto-turn cap apply, and it's an auto turn: never user approval for thread_merge/thread_pr.
  • Eligible: interrupted within 12 h, has a session, not trashed, archived, settled or a memory pass, and the worktree still exists.
  • Concurrency: 2 at a time.
  • No double resume: autoResumedAt is written and flushed with saveNow before any turn starts, and only a human turn clears it. A crash during boot can't re-resume the same threads, and a resumed run that crashes again isn't resumed again.
  • Visibility: a "Resumed after restart" transcript event, and a dismissible notice listing what was resumed, with Stop all. Stop on a not-yet-started thread drops its queued resume.

Verified independently, on main merged with this branch:

  • typecheck exits 0 and vite build passes.
  • test:renderer passes 2864 of 2864.
  • test:electron passes 4296 of 4296. auto-resume.test.js covers the setting off and on, each exclusion, the concurrency cap, no double resume, and auto-turn status.

Known limits

  • A resumed run waiting on a permission prompt holds one of the 2 slots, so later resumes wait behind it.
  • The notice shares the toast position with undo toasts, and is gone after a window reload.
  • Providers without session ids are never resumed.

🤖 Generated with Claude Code

Willem and others added 2 commits October 6, 2026 18:03
…I3)

Quit and crash both stamp interruptedAt; any new run clears it. With
settings.resumeInterruptedRuns on, boot (after first paint and PATH)
gives each eligible thread one machine-delivered turn through
deliverNotice, two at a time. autoResumedAt is saved before anything
starts and only a human turn clears it, so an interruption is never
resumed twice, even across another crash. stopRun drops a queued resume.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Settings › Threads gets "Resume interrupted runs after restart" (off
by default). A dismissible notice lists the threads this launch resumed,
with Stop all; stopping a still-queued thread drops its resume.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T16:18:16.328390Z 0f7d925 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f7d925f1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread electron/runner.js
Comment on lines +2395 to +2397
stoppedAt: Date.now(),
// Opt-in resume after restart (issue #1512 I3).
interruptedAt: Date.now(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exclude workflow runs from restart continuation

When the user quits or crashes during a Build workflow on a thread that already has a provider sessionId, this stamps the workflow exactly like an ordinary provider run. On the next launch, isResumable accepts it and deliverNotice starts a normal startRun against the thread's old provider session; workflow state is only held in memory and is neither restored nor restarted. The automatic turn can therefore perform unrelated or duplicate work while claiming to continue the interrupted workflow. Persist the interrupted run kind and exclude workflows, or implement an actual workflow-resume path.

Useful? React with 👍 / 👎.

Comment on lines +37 to +38
if (!t.sessionId) return false;
if (services.isTrashed(t) || t.archived) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip ejected sessions when selecting resumable threads

If a previously interrupted thread is ejected while auto-resume is disabled, then auto-resume is enabled before a later restart, this filter still selects it because an ejected thread retains its sessionId. deliverNotice deliberately parks notices for ejected Codex sessions, so the thread is marked and displayed as resumed without starting; worse, the queued [restart] notice can flush as an unexpected extra automatic turn after the user reclaims the session and completes another turn. Treat t.ejected === true as ineligible.

Useful? React with 👍 / 👎.

Comment on lines +39 to +41
if (t.settledOverride === "settled" || t.memoryConsolidate === true) {
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply computed settle rules before resuming

This only recognizes an explicit settle override, but effectiveSettled also classifies CLOSED PRs, and MERGED PRs when autoSettleOnMerge is enabled, as settled unless explicitly kept active. If a PR reaches one of those terminal states while its run is active and the app then quits or crashes, recovery makes the thread idle/failed and therefore settled, yet this filter launches another unattended turn on it. Check the same PR-state and settings-based settle rules used by the sidebar before selecting the thread.

Useful? React with 👍 / 👎.

…I3)

The scheduler's poll timers are unref'd so they never hold the app open,
which let node:test exit mid-await and cancel tests. Tests now inject a
ref'd sleep. cancelAll (stopAll at quit) also releases any lane still
polling, so a lane cannot wait forever.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@currentbits
currentbits merged commit dadb18e into main Oct 6, 2026
6 checks passed
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.

1 participant