Skip to content

feat(desktop): resume interrupted tasks gradually after restart - #4636

Merged
reachjalil merged 2 commits into
devfrom
feature/restart-task-recovery
Sep 8, 2026
Merged

reachjalil merged 2 commits into
devfrom
feature/restart-task-recovery

Conversation

@reachjalil

@reachjalil reachjalil commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Automatically continue eligible local tasks after restarting OpenWork, including update restarts, without requiring their conversation tabs to be mounted.

Follow-up to merged #4590. This PR targets dev and contains only the recovery increment and its review fixes.

Behavior

  • A desktop-owned server coordinator records task identity, workspace path, original engine (v1 or v2), last observed user turn, and recovery phase in the existing runtime SQLite database. No prompts, transcripts, or credentials are added to the journal.
  • Track admitted prompt/command work, not todo-list labels or a sweep of old conversations. Normal shutdown checkpoints before engine teardown; crash recovery requires an observed running task and a still-unfinished matching turn.
  • Reconcile through the existing authenticated workspace proxy, preserving ownership and policy checks. Wait for policy restoration before claiming a continuation. Keep the original engine; v1 reads the original model/agent/variant from the user turn and v2 uses its native session model.
  • Admit one recovery every 2 seconds, with at most 2 recovered tasks active. Native active work also limits admission. Check at most 2 task snapshots per cycle; cap the journal at 1,000 records. Shutdown checkpointing has a 10-second budget.
  • Never re-prompt a run the native engine already recovered. Persist the claim before dispatch; a lost acknowledgement is not blindly retried on this or a later boot.
  • Exclude completed, archived, explicitly stopped, approval/question-blocked, and active delegated work. Manual session mutations invalidate old recovery intent before forwarding. Changed/removed workspaces and unverified outcomes never authorize sends.
  • Automation and remote-command execution opt out because their existing execution receipts own recovery. Standalone servers, attached engines, remote workspaces, and read-only servers are not enabled.

Review Fixes

  • Fix the failing Electron IPC-contract typecheck: HeadlessFetch passes a URL string, so build headers from its RequestInit instead of using an invalid instanceof Request branch. Recovery opt-out and authentication headers are preserved.
  • Extend the existing background-desktop-update journey with real native work and a confirmed Electron relaunch. The release feed and model are synthetic; confirmation invokes the real main-process shell relaunch IPC rather than incrementing an install counter. No binary replacement is attempted.
  • Assert a new renderer, exactly one continuation and model reply on the original engine, no repeated original tool call, and unchanged message identities for stopped/completed tasks across later recovery ticks. The scenario selects v1 or v2 through OPENWORK_EVAL_ENGINE.

Verification: Incomplete

Current head: 1c48405. Commit signature verified.

Passed for this update:

  • pnpm --filter @openwork/desktop typecheck:electron: exit 0. This exact CI command previously reproduced TS2358 in automation-runner.mjs:79; the fix removes that failure.
  • node --test apps/desktop/electron/automation-runner.test.mjs: exit 0; 45 passed, 0 failed, 0 skipped.
  • pnpm --dir apps/server exec bun --conditions=development test src/task-recovery.test.ts: exit 0; 22 passed, 0 failed, 0 skipped; 51 assertions, with 11 cases per engine.
  • pnpm --dir evals exec tsc --noEmit --strict --skipLibCheck --module preserve --moduleResolution bundler --target es2023 --lib esnext,dom,dom.iterable --allowImportingTsExtensions --allowJs --jsx react-jsx packages/cdp/src/browser-globals.d.ts specs/background-desktop-update.e2e.test.ts: exit 0. Typechecks the modified journey and its imported worlds without launching resources.
  • pnpm --dir evals check:browser -- worlds/chat.ts specs/background-desktop-update.e2e.test.ts: exit 0; 739 browser callbacks checked.
  • git diff --check origin/dev...HEAD: exit 0.

Deferred by execution scope:

  • OPENWORK_EVAL_ENGINE=v1 pnpm evals:e2e background-desktop-update
  • OPENWORK_EVAL_ENGINE=v2 pnpm evals:e2e background-desktop-update
  • Exact-head runtime evidence publication, crash/load journey execution, and binary replacement verification.

The new restart scenario is authored and typechecked, not runtime-validated. The earlier copy-only assertion is not used as recovery proof. No Daytona resources or expensive eval commands were started. New-head CI is pending its own results; the old-head build failure is not described as a passing check.

Limits

Only work admitted after this feature is present can be recovered; the first upgrade from an older version has no recovery journal to consume. V1 needs its original user turn/model within the recent 100-message snapshot. Failed or unconfirmed admissions/checkpoints remain manual. Active delegated work is conservatively excluded rather than independently restarting its parent.

The continuation instructs the task to inspect already-completed effects and ask when uncertain. At-most-once recovery admission is not an exactly-once guarantee for external tool side effects. Missing real-engine proof keeps the overall verdict Incomplete.

No merge, release, or deployment is part of this PR.

@vercel

vercel Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Preview Sep 8, 2026 8:06pm UTC
openwork-den Ignored Ignored Preview Sep 8, 2026 8:06pm UTC
openwork-diagnostics Ignored Ignored Preview Sep 8, 2026 8:06pm UTC
openwork-landing Ignored Ignored Preview Sep 8, 2026 8:06pm UTC

diff-warden[bot]
diff-warden Bot previously approved these changes Sep 8, 2026

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (69e32b28c34396248f8263906af84ea32deb5fb0). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (1c48405d3b69ae9dc41e3ad6771ba9b7ea2baf60). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil
reachjalil merged commit 0857e81 into dev Sep 8, 2026
28 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