Skip to content

Fix live agent resume checkpoints after daemon loss - #5633

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/bug-active-agent-sessions-not-restored-after-aut
Jun 17, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/bug-active-agent-sessions-not-restored-after-aut

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • persist live resumable agent provider session checkpoints as soon as hook metadata arrives
  • preserve checkpoint origin through workspace-session parsing and avoid duplicate activation resumes
  • add regression coverage for missed quit capture, session writer persistence, schema parsing, and pane-owned resume records
  • fix CI-blocking source-control exhaustiveness/localization coverage issues

Fixes #5626.

Verification

  • pnpm typecheck
  • pnpm lint
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/agent-status-quit-capture.test.ts src/shared/workspace-session-schema.test.ts src/renderer/src/lib/resume-sleeping-agent-session.test.ts src/renderer/src/lib/session-write-subscriber.test.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts --testNamePattern "resumes from the quit-captured sleeping record|does not consume the sleeping record|does not resume the provider session when daemon reattach returns a live snapshot|shows the restored banner|."

Open in Stage

@ghost

ghost commented Jun 17, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Update agent session schema for live checkpoints
2 Implement live agent session checkpointing logic
3 Refine agent session resumption and persistence
4 Fix source control localization and exhaustiveness
Open in Stage

Chapters generated by Stage for commit 9753a33 on Jun 17, 2026 9:10pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 17, 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: Pro

Run ID: a85eed6c-dd85-4bb9-aca1-0c965a4f5bfb

📥 Commits

Reviewing files that changed from the base of the PR and between 8a6c3f7de3e916a529aaf485d469c566a437c511 and 9753a33.

📒 Files selected for processing (15)
  • src/renderer/src/components/right-sidebar/source-control-primary-create-pr-intent-action.ts
  • src/renderer/src/components/right-sidebar/source-control-pull-policy-error-notice.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/resume-sleeping-agent-session.test.ts
  • src/renderer/src/lib/resume-sleeping-agent-session.ts
  • src/renderer/src/lib/session-write-subscriber.test.ts
  • src/renderer/src/store/slices/agent-status-quit-capture.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-session-resume.ts
  • src/shared/workspace-session-schema.test.ts
  • src/shared/workspace-session-schema.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/shared/workspace-session-schema.test.ts
  • src/shared/agent-session-resume.ts
  • src/renderer/src/components/right-sidebar/source-control-primary-create-pr-intent-action.ts
  • src/renderer/src/lib/resume-sleeping-agent-session.ts
  • src/shared/workspace-session-schema.ts
  • src/renderer/src/lib/session-write-subscriber.test.ts
  • src/renderer/src/components/right-sidebar/source-control-pull-policy-error-notice.tsx
  • src/renderer/src/lib/resume-sleeping-agent-session.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/zh.json

📝 Walkthrough

Walkthrough

The PR introduces a new 'live' origin value for SleepingAgentSessionRecord to represent warm-reattach recovery checkpoints. setAgentStatus is updated to derive and conditionally persist a live recovery record using a new recoveryRecordMatches helper that avoids redundant map allocations. The worktree resume function is updated to skip both 'quit' and 'live' origin records. The workspace session Zod schema is extended to accept the new origin. Separately, source-control-pull-policy-error-notice.tsx replaces hardcoded English strings with translate() calls, new i18n keys are added for pull-policy notice and create-PR branch-readiness states across all five locale files, and blocked-reason switch cases in create-pr-intent-action.ts are made explicit.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive Description includes summary, verification steps, and issue reference, but lacks screenshots and security audit sections required by the template. Add 'No visual change' for screenshots section and complete Security Audit section with input/auth/dependency risk assessment.
Out of Scope Changes check ❓ Inconclusive Source-control UI changes (PR title/description translation refactoring, pull policy notices) are labeled as fixes for CI-blocking exhaustiveness/localization gaps unrelated to core session-restore fix. Clarify whether source-control UI localization changes are necessary for issue #5626 or represent scope creep; document CI failure dependency.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed Title directly addresses the main change: fixing live agent resume checkpoints after daemon loss, which matches the PR's core objective.
Linked Issues check ✅ Passed Changes address issue #5626 by persisting live checkpoints immediately, preserving origin fields, and adding test coverage for checkpoint restoration scenarios.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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 and usage tips.

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/renderer/src/store/slices/agent-status.ts (1)

277-292: ⚡ Quick win

Document why recoveryRecordMatches only compares identity fields.

The selected field subset is intentional but non-obvious; a short “why” comment here will prevent accidental expansion that reintroduces write churn.

As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6cc0e7f2-61c9-4683-8aaf-0ea368062780

📥 Commits

Reviewing files that changed from the base of the PR and between 18d3545 and 8a6c3f7de3e916a529aaf485d469c566a437c511.

📒 Files selected for processing (15)
  • src/renderer/src/components/right-sidebar/source-control-primary-create-pr-intent-action.ts
  • src/renderer/src/components/right-sidebar/source-control-pull-policy-error-notice.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/resume-sleeping-agent-session.test.ts
  • src/renderer/src/lib/resume-sleeping-agent-session.ts
  • src/renderer/src/lib/session-write-subscriber.test.ts
  • src/renderer/src/store/slices/agent-status-quit-capture.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-session-resume.ts
  • src/shared/workspace-session-schema.test.ts
  • src/shared/workspace-session-schema.ts

"d8a4c0e369": "Authenticate before creating a {{value0}}.",
"e9b5d1f470": "Check out a branch before creating a {{value0}}.",
"f0c6e2a581": "This branch is not ready for a {{value0}} yet.",
"h3i4j5k607": "Checking whether this branch can create a {{value0}}…"

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Replace the non-SHA catalog key on Line 8722.

"h3i4j5k607" breaks the catalog’s SHA1-style auto-key pattern used in this locale section and is likely to drift from other locale files after sync.

Based on learnings, locale entries in src/renderer/src/i18n/locales/*.json should use SHA1-derived auto-keys and be maintained via pnpm run sync:localization-catalog.

Source: Learnings

"d8a4c0e369": "Authenticate before creating a {{value0}}.",
"e9b5d1f470": "Check out a branch before creating a {{value0}}.",
"f0c6e2a581": "This branch is not ready for a {{value0}} yet.",
"h3i4j5k607": "Checking whether this branch can create a {{value0}}…"

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use a valid catalog key format for the new entry.

At Line 8722, h3i4j5k607 breaks the repo’s auto-key convention and is likely to drift from other locale catalogs. Regenerate this key via the localization sync flow so all locale files share the same identifier.

Based on learnings: new locale entries are auto-keyed from SHA1(file path + source text) and catalog parity is maintained via pnpm run sync:localization-catalog.

Source: Learnings

Comment on lines +632 to 656
const liveRecoveryWorktreeId =
entry.state === 'done'
? null
: (entry.worktreeId ?? findAgentPaneWorktreeId(s, entry.paneKey))
const liveRecoveryRecord = liveRecoveryWorktreeId
? sleepingRecordFromEntry({
state: s,
entry,
worktreeId: liveRecoveryWorktreeId,
capturedAt: updatedAt,
origin: 'live'
})
: null
let nextSleepingAgentSessions = s.sleepingAgentSessionsByPaneKey
if (liveRecoveryRecord) {
if (!recoveryRecordMatches(existingSleepingRecord, liveRecoveryRecord)) {
nextSleepingAgentSessions = {
...s.sleepingAgentSessionsByPaneKey,
[paneKey]: liveRecoveryRecord
}
}
} else if (existingSleepingRecord) {
nextSleepingAgentSessions = { ...s.sleepingAgentSessionsByPaneKey }
delete nextSleepingAgentSessions[paneKey]
}

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid dropping an existing checkpoint on non-terminal gaps.

This branch deletes existingSleepingRecord whenever liveRecoveryRecord is null. That includes non-terminal cases (e.g., transiently missing worktreeId/providerSession), which can erase an already durable recovery record before the next metadata tick.

💡 Proposed fix
-        } else if (existingSleepingRecord) {
+        } else if (existingSleepingRecord && entry.state === 'done') {
           nextSleepingAgentSessions = { ...s.sleepingAgentSessionsByPaneKey }
           delete nextSleepingAgentSessions[paneKey]
         }

@Jinwoo-H
Jinwoo-H force-pushed the Jinwoo-H/bug-active-agent-sessions-not-restored-after-aut branch from 8a6c3f7 to 9753a33 Compare June 17, 2026 21:10
@Jinwoo-H
Jinwoo-H merged commit ee2bc5e into main Jun 17, 2026
1 check passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/bug-active-agent-sessions-not-restored-after-aut branch June 17, 2026 21:19
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

[Bug]: Active agent sessions not restored after auto-update on Windows (tab titles kept, panes blank) — post-#5240, distinct from #5356

1 participant