Skip to content

Restore interrupted Orca sessions after crashes - #4

Merged
ffffhx merged 4 commits into
mainfrom
agent/restore-interrupted-sessions
Aug 21, 2026
Merged

ffffhx merged 4 commits into
mainfrom
agent/restore-interrupted-sessions

Conversation

@ffffhx

@ffffhx ffffhx commented Jul 24, 2026

Copy link
Copy Markdown
Owner

What changed

  • persist the Codex and Claude sessions that are genuinely running inside Orca
  • show crash-recovery readiness and provide one-click bulk restore in the launcher and tray
  • retain failed restores for retry and clear successful restores immediately
  • make development builds use a stable Agent Snapshots settings directory and register the correct hidden login command
  • migrate legacy development settings and document the recovery behavior
  • add focused recovery/process-matching tests and Electron E2E coverage

Why

A computer crash closes Orca terminals even though the underlying Codex or Claude transcripts remain available. Previously, Agent Snapshots could resume sessions one at a time but did not remember which sessions were open before the crash.

The existing liveOnly session heuristic also includes old transcripts without an explicit completion event. Using it directly for recovery could incorrectly reopen many historical sessions. Recovery now matches real Orca agent processes to session metadata by engine, workspace, start time, and explicit resume ID when available.

Impact

After Agent Snapshots has observed an Orca session, an abnormal app or computer shutdown leaves that session in a recoverable queue. At the next launch, users can restore all interrupted sessions with one action. Normal exits do not create false recovery entries. The launcher always shows whether crash protection is ready.

Validation

  • node scripts/test-session-recovery.mjs
  • node scripts/test-orca-live-sessions.mjs
  • pnpm typecheck
  • pnpm test:client-ui (17/17)
  • pnpm test:electron-e2e
  • manual verification that the development login item is registered and the app runs on port 4321

ffffhx added 4 commits July 24, 2026 16:50
Packaged apps still use the system login item. In electron . / pnpm app:dev,
install a LaunchAgent that runs pnpm app:dev from the project directory so
login launch does not open Electron's default template. Disable the leftover
development login item on startup.
…aths

Move process matching onto the server, cache ps/lsof briefly, and serve
/api/sessions?liveOnly=1 from actual Orca agent processes. Stop treating a
Codex sessions/ path as live, keep pinned running rows marked live, and let
desktop recovery reuse the API result instead of matching processes twice.
Do not warm or periodically rebuild the search index while the desktop app
is idle. Poll live sessions less often, drop infinite live-dot keyframes,
and let macOS vibrancy follow the window so idle windows stop animating.
@ffffhx
ffffhx marked this pull request as ready for review August 21, 2026 06:05
@ffffhx
ffffhx merged commit d8eff3a into main Aug 21, 2026
1 check passed

@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: 47a7a4faa4

ℹ️ 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 on lines 190 to 192
scanLimit: 20000,
updateLimit: 20000,
updateLimit: 200,
includeTools: true,

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 Keep live-search fallback until bootstrap finishes

When a profile has more than 200 uncached or changed sessions, this bootstrap stops updating at updateLimit and reports the rest as pending, but syncSearchIndex still records the Codex-home coverage marker. The next request therefore considers coversAll true and calls searchIndexed, silently omitting every session beyond the first 200; the later 20-row refreshes only repair this gradually. Keep using the live fallback until the sync reports no pending sessions, or avoid marking partial indexes as covering the corpus.

Useful? React with 👍 / 👎.

Comment on lines +16 to +17
/(?:^|\s)node\s+\S*[/\\]codex(?:\s|$)/.test(text)
|| /(?:^|\s)\S*[/\\]codex\s+(?!app-server\b)/.test(text)

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 Recognize bare Codex and Claude process names

When Orca launches the commands produced by this repository (codex resume ... and claude --resume ...) with a bare executable name, the process command line can begin directly with codex or claude. These patterns require a preceding path separator, so processEngine rejects those agents and /api/sessions?liveOnly=1 remains empty, disabling completion detection, sleep prevention, and crash-recovery recording for the normal launch form. Accept bare executable names as well as qualified paths.

Useful? React with 👍 / 👎.

Comment thread electron/main.mjs
// A deliberate Agent Snapshots quit is not evidence that Orca died. Pending
// recovery entries remain, but currently live sessions are not promoted on
// the next launch unless this process itself terminates unexpectedly.
persistSessionRecovery({ monitoring: 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.

P1 Badge Preserve monitored sessions during system shutdown

When the OS performs an orderly logout or reboot and Electron delivers before-quit, this writes monitoring: false. On the next launch, readSessionRecoveryState only promotes the saved liveSessions when that flag is true, so all sessions running immediately before a normal reboot are discarded from recovery—the primary reboot scenario advertised by this change. The clean-shutdown marker needs to distinguish an explicit in-app quit from an OS shutdown, or otherwise retain those live entries.

Useful? React with 👍 / 👎.

@ffffhx
ffffhx deleted the agent/restore-interrupted-sessions branch August 21, 2026 06:11
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