Skip to content

Detect and surface recoverable zero-turn sessions in AI Vault - #7889

Merged
AmethystLiang merged 1 commit into
mainfrom
fix-empty-session-resume-gating
Jul 9, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
fix-empty-session-resume-gating

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Detect and surface recoverable zero-turn sessions in the AI Vault.

Previously, zero-turn sessions (sessions where the conversation transcript persisted zero user or assistant turns) were either hidden or treated as normally resumable, which would lead to resuming into an empty conversation. This PR detects and surfaces recoverable signals—specifically queued (never-flushed) prompts and sibling subagent transcripts—allowing these "unsaved" sessions to be surfaced with a distinct status instead of being hidden or broken on resume.

Key changes:

  • Backend & Parsers: Added support to scan, parse, and count queued messages (via queue-operation records) and sibling subagent transcripts (via subagentTranscriptsDirFor directory counting) for local and remote (SSH) Claude/Gemini sessions.
  • Pruning & Caching: Sibling subagent transcripts are collected and mapped efficiently without extra roundtrips on remote walks, and cached parser entries are refreshed cheap.
  • UI & Layout:
    • Gated resume and copy-resume actions to require actual conversation turns.
    • Added a "Not saved" badge to the session row.
    • Added SessionUnsavedConversationNotice in AiVaultSessionUnsavedNotice.tsx to display detailed breakdown of recoverable items (queued messages, subagent transcripts).
    • Supported keeping recoverable empty sessions visible when "hide empty sessions" is toggled on.

Screenshots

  • Added a "Not saved" badge for zero-turn recoverable empty sessions.
  • Added a dashed details container pointing out the specific queued prompts or subagent transcripts that survive.
  • Otherwise, No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Evidence: Added comprehensive unit tests in session-scanner-recoverable-empty.test.ts and ai-vault-types.test.ts, and updated existing tests in remote-session-scanner.test.ts, ai-vault-session-filters.test.ts, and ai-vault-session-resume.test.ts.

AI Review Report

This change has been reviewed with the following checks:

  • Cross-Platform Compatibility: Checked compatibility across macOS, Linux, and Windows. Used proper platform-independent path methods (basename, dirname, extname, join from node:path) and respected the platform parameter when formatting shell commands and paths. Sibling counting properly filters Windows and POSIX-style paths.
  • Robustness: Ensured remote hosts running older builds remain parseable by adding default values to the Zod schema (queuedMessageCount and subagentTranscriptCount).

Security Audit

  • Input Handling: Path extraction and directory reading are isolated using strict pattern matching to prevent path traversal or reading unrelated files.
  • Command Execution & IPC: Resume command building is securely gated and relies on existing shell-quoting mechanisms. IPC deserialization is fully validated against updated Zod schemas.

Notes

  • Sibling subagent counting for remote walks uses a partition helper to avoid making additional remote readdir calls, preserving SSH scanning performance.

Identify Claude sessions with no saved conversation turns but possessing
recoverable signals such as queued prompts or subagent transcripts.
This displays them in the sidebar with a "Not saved" badge instead of
filtering them out as empty, and provides detailed notices to recover
them via logs while disabling standard resume actions.

Additionally, extract Gemini session parsing logic into a separate
module and support counting sibling subagent transcripts across local
and remote SSH session scans.
@coderabbitai

coderabbitai Bot commented Jul 9, 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: 0c06443d-1888-448f-9998-a53a6dd133c0

📥 Commits

Reviewing files that changed from the base of the PR and between 040e61e and 03faa3e.

📒 Files selected for processing (37)
  • src/main/ai-vault/remote-session-scanner-sources.ts
  • src/main/ai-vault/remote-session-scanner-types.ts
  • src/main/ai-vault/remote-session-scanner.test.ts
  • src/main/ai-vault/remote-session-scanner.ts
  • src/main/ai-vault/runtime-session-scanner.test.ts
  • src/main/ai-vault/runtime-session-scanner.ts
  • src/main/ai-vault/session-scanner-accumulator.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/main/ai-vault/session-scanner-gemini-parsers.ts
  • src/main/ai-vault/session-scanner-parse-cache.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner-recoverable-empty.test.ts
  • src/main/ai-vault/session-scanner-subagent-transcripts.ts
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ipc/ai-vault.test.ts
  • src/renderer/src/components/right-sidebar/AiVaultSessionActionMenuItems.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionUnsavedNotice.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx
  • src/renderer/src/components/right-sidebar/SessionRowTrailingActions.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-original-pane.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-display.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-filters.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-filters.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-projects.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-resume.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-resume.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-row-display.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-session-worktree.test.ts
  • 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/shared/ai-vault-types.test.ts
  • src/shared/ai-vault-types.ts

📝 Walkthrough

Walkthrough

This change adds recoverable-signal tracking for zero-turn AI Vault sessions. New backend logic counts sibling subagent transcript files and tracks queued message operations, extending the shared session type, accumulator, primary parsers, parse cache, and both local and remote scanners with queuedMessageCount and subagentTranscriptCount fields. A new Gemini parser module is added. On the renderer side, resume/copy-resume actions are gated by resumability, a new "conversation not saved" notice component is introduced, session filters recognize recoverable-empty sessions, and a "Not saved" badge is added, accompanied by new i18n strings across locales and test fixture updates.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: recovering and surfacing zero-turn AI Vault sessions.
Description check ✅ Passed All required sections are present and the PR includes summary, screenshots, testing, AI review, security, and notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@AmethystLiang
AmethystLiang merged commit 4ded642 into main Jul 9, 2026
2 checks passed
brennanb2025 added a commit that referenced this pull request Jul 10, 2026
…ts-to-mobile

Reconciles the mobile aiVault.listSessions RPC with main's runtime-host
scanning (#7631), OMP sessions (#7618/#7628), host-aware attribution
(#7367), and zero-turn recovery (#7889):

- One aiVault.listSessions serves mobile (no executionHostId), the desktop
  parent, and web clients: bounded params kept, results served from the
  shared host-local cache and restamped per-caller at the RPC edge.
- Desktop's runtime-host RPC client caps scopePaths to the shared bound so
  large desktops degrade gracefully instead of failing validation.
- Desktop IPC local scope delegates to the shared cache module (single
  cache with the RPC path); ssh/runtime/all merges keep main's outer cache.
- Main's zero-turn empty-session semantics and ExecutionHostId-typed
  project attribution replayed onto the /shared lifted filter core.
- Mobile resume forwards session.filePath so OMP resumes by absolute
  transcript path (desktop parity).

Co-authored-by: Orca <[email protected]>
brennanb2025 added a commit to hmrserver/orca that referenced this pull request Jul 10, 2026
Main already counts sibling subagent transcripts (stablyai#7889) for zero-turn
recovery; this PR was written before that landed and added a parallel
subagentCount doing the same readdir. Keep one field: count every local
session's transcripts in the shared Claude finalize (one readdir per
parse instead of two extra call sites), attach remote counts from the
walk listing for all sessions, and gate the on-demand subagent listing
UI to local sessions. Net effect vs the PR: SSH rows now show a real
subagent count badge; listing stays local-only.

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ai#7889)

Identify Claude sessions with no saved conversation turns but possessing
recoverable signals such as queued prompts or subagent transcripts.
This displays them in the sidebar with a "Not saved" badge instead of
filtering them out as empty, and provides detailed notices to recover
them via logs while disabling standard resume actions.

Additionally, extract Gemini session parsing logic into a separate
module and support counting sibling subagent transcripts across local
and remote SSH session scans.
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