Repository navigation
fix(ai-vault): make SSH session history host-aware - #7367
AmethystLiang merged 5 commits into
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR threads execution-host identity through AI Vault session scanning, remote SSH scanning, IPC host-scope routing, and renderer resume/display flows. Shared AI Vault types now carry host fields, scanners and parsers preserve host metadata, and remote scans are sourced from SSH filesystem providers. The UI adds host-scope selection, refresh logic is scoped by host, and resume/drag/drop checks now compare session and target execution hosts. An e2e test covers SSH session history filtering and resume behavior. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/ipc/ai-vault.ts (1)
42-77: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winIn-flight scan tracking can be clobbered by concurrent different-scope requests.
The
.finally()callback unconditionally nulls the module-levelinflightKey/inflightListregardless of whether they still refer to this request. Now that the cache/in-flight key includesexecutionHostScope, concurrent requests for different scopes (e.g. rapid Local/SSH/All switching in the UI) are expected. If request A settles while request B (a different key) is still in-flight, A'sfinallywipes B's tracking, so a subsequent request matching B's key won't dedupe against the still-running B and triggers a redundant duplicate transcript scan.🔧 Proposed fix: only clear tracking if it still matches this request's key
inflightList = scanAiVaultSessionsByHostScope(args, executionHostScope) .then((result) => { cachedList = { key, result, expiresAt: Date.now() + AI_VAULT_CACHE_TTL_MS } return result }) .finally(() => { - inflightKey = null - inflightList = null + if (inflightKey === key) { + inflightKey = null + inflightList = null + } })
🧹 Nitpick comments (5)
src/renderer/src/lib/ai-vault-resume-target.ts (1)
103-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate worktree/folder-resolution logic vs. the existing
TargetStatustwins.
getAiVaultResumeWorkspaceExecutionHostId/getAiVaultResumeFolderExecutionHostIdre-implement the same worktree lookup (Object.values(state.worktreesByRepo ?? {}).flat().find(...)) and folder-group/connection resolution order already present ingetAiVaultResumeWorkspaceTargetStatus/getAiVaultResumeFolderTargetStatus. Keeping two parallel implementations risks them drifting out of sync (e.g., if the worktree/folder match criteria change in one but not the other).Consider extracting a shared
findWorktreeById(state, worktreeId)helper (and reusing the same host/connection resolution order) so both status and host-id resolution stay consistent.Also applies to: 180-202
src/renderer/src/lib/ai-vault-resume-target.test.ts (1)
72-98: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the WSL exception when both host ids are known.
The new tests cover exact-match and mismatch cases for
canResumeAiVaultSessionOnTargetwhen bothsessionExecutionHostId/targetExecutionHostIdare supplied, but there's no test for the WSL carve-out in that same branch (Lines 60-64 ofai-vault-resume-target.ts): a local-tagged, WSL-stored session with an explicittargetExecutionHostIdset to an SSH host that doesn't matchsessionExecutionHostId. This is exactly the newly introduced non-obvious branch and warrants direct coverage.✅ Suggested additional test
it('allows WSL-stored local sessions on any SSH target even with explicit host ids', () => { expect( canResumeAiVaultSessionOnTarget({ sessionFilePath: wslSessionFile, sessionExecutionHostId: 'local', targetStatus: 'ssh', targetExecutionHostId: 'ssh:dev-box' }) ).toBe(true) })src/renderer/src/lib/ai-vault-resume-command.ts (1)
22-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd unit test coverage for the new bypass branch.
This is a significant behavioral fork (skips the entire
getAiVaultResumePlatform/buildAgentResumeStartupPlanpipeline) but no test changes are included forai-vault-resume-command.tsin this diff. Given the branch's conditions are somewhat intricate (executionHostId truthy + non-local + resumeCommand truthy + no/blank override), direct unit tests would guard against regressions.Also applies to: 55-78
tests/e2e/ssh-ai-vault-session-history.spec.ts (1)
96-98: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFragile positional locator for the SSH host menu item.
orcaPage.getByRole('menuitemradio').nth(1)selects by index rather than by an accessible name, unlike the adjacentLocal/All hostsselections (Lines 89, 93) which match by text. If the host-scope menu's item order ever changes (e.g., a new scope inserted), this click silently targets the wrong item and the test would fail with a confusing assertion mismatch rather than a clear locator error.🔧 Suggested more robust locator
- await hostButton.click() - await orcaPage.getByRole('menuitemradio').nth(1).click() + await hostButton.click() + await orcaPage + .getByRole('menuitemradio') + .filter({ hasNotText: /Local|All hosts/ }) + .click()src/renderer/src/components/right-sidebar/ai-vault-host-scope.ts (1)
32-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd a short "why" comment for the reset-vs-preserve host-scope logic.
The effect encodes a non-obvious rule: a manually chosen scope (e.g. "All") survives incidental rerenders, but resets to the new default once it becomes invalid for the active host. As per coding guidelines,
**/*.{ts,tsx,js,jsx}: "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."📝 Proposed comment
useEffect(() => { + // Why: preserve an explicit user choice (e.g. "All") across incidental + // rerenders, but reset to the new default once that choice no longer + // applies to the active worktree's host. const allowedScopes = new Set<ExecutionHostScope>([Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: dd246e54-ade4-4774-bf2e-42fe32de22be
📒 Files selected for processing (32)
src/main/ai-vault/remote-codex-session-scanner.test.tssrc/main/ai-vault/remote-codex-session-scanner.tssrc/main/ai-vault/session-scanner-accumulator.tssrc/main/ai-vault/session-scanner-codex-parser.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner.tssrc/main/ipc/ai-vault.test.tssrc/main/ipc/ai-vault.tssrc/main/ipc/ssh.tssrc/main/ssh/ssh-relay-session.tssrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/AiVaultPanelControls.tsxsrc/renderer/src/components/right-sidebar/AiVaultPanelHeader.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionRow.tsxsrc/renderer/src/components/right-sidebar/ai-vault-host-scope.test.tssrc/renderer/src/components/right-sidebar/ai-vault-host-scope.tssrc/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.tssrc/renderer/src/components/right-sidebar/ai-vault-session-resume.tssrc/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/ai-vault-resume-command.tssrc/renderer/src/lib/ai-vault-resume-target.test.tssrc/renderer/src/lib/ai-vault-resume-target.tssrc/renderer/src/lib/ai-vault-session-drag.tssrc/shared/ai-vault-types.tstests/e2e/ssh-ai-vault-session-history.spec.ts
Replace the Codex-only remote SSH session history scanner with a unified scanner supporting all registered agents. This ensures remote transcripts for Claude, Gemini, Devin, Droid, and others are scanned and listed alongside local history. - Propagate host metadata (host ID and platform) to scanned sessions - Scope remote actions by host, disabling local OS path actions on remote session logs - Resolve ambiguous project/worktree matching for overlapping paths by verifying matching host setup IDs - Update tests and E2E specs to validate multi-agent remote scanning
61003f3 to
fbda84d
Compare
AmethystLiang
left a comment
There was a problem hiding this comment.
Approved. I reviewed the latest stack of commits, including the maintainer follow-up that broadens the original SSH AI Vault fix.
What changed across the PR:
- The original commits make Agent Session History host-aware: local, active SSH host, and all-host scopes are routed through IPC, SSH worktrees default to their remote host history, and resume/drop actions are gated by the session/workspace execution host.
- SSH relay sessions now expose the remote home and platform needed for remote history scanning and platform-correct resume commands.
- The maintainer commit generalizes the remote scanner from Codex-only to all registered AI Vault file-backed agents by splitting remote scanner sources/types/index handling and adding remote content parsers for Claude, Gemini, Copilot, Cursor, Hermes, Devin, Droid, Pi/OpenClaw, and Codex.
- Remote sessions now carry host metadata, local-only path actions are hidden for remote log paths, and project/worktree attribution is host-aware so overlapping local/SSH paths do not steal each other's sessions.
- Review fixes cover cache/in-flight host-scope behavior and stale renderer scan results when switching scopes mid-scan.
Validation I ran locally:
- Targeted scanner, IPC, refresh, resume, target/worktree/project/filter/original-pane/drag Vitest suites.
pnpm run typecheckpnpm run lint(passed with unrelated existing warnings)- localization catalog and coverage checks
git diff --check
Looks good to land once the current merge conflict with main is resolved and CI is green.
…ion-history # Conflicts: # src/renderer/src/i18n/locales/es.json # src/renderer/src/i18n/locales/zh.json
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/main/ai-vault/session-scanner-devin-parser.ts (1)
21-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate
ParserSessionOptionstype across 5 parser files.The exact same type (
executionHostId?: ExecutionHostId; executionHostPlatform?: NodeJS.Platform | null) is redeclared identically insession-scanner-devin-parser.ts,session-scanner-droid-parser.ts,session-scanner-graph-parsers.ts,session-scanner-primary-parsers.ts, andsession-scanner-secondary-parsers.ts. This shape also mirrors the inline options type onfinalizeSessionandRemoteParserOptions. Consider hoisting a single shared type (e.g. intosession-scanner-types.ts) and importing it everywhere to avoid future drift between these definitions.♻️ Proposed consolidation
-type ParserSessionOptions = { - executionHostId?: ExecutionHostId - executionHostPlatform?: NodeJS.Platform | null -} +import type { ParserSessionOptions } from './session-scanner-types'(repeat the import in the other 4 files and remove their local declarations; export
ParserSessionOptionsfromsession-scanner-types.tsonce)src/main/ai-vault/remote-session-scanner-sources.ts (1)
219-221: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUnnecessary indirection through
normalizePiSessionsDir.
remotePiSessionsSegments()feeds a hardcoded literal intonormalizePiSessionsDirjust to split it back into segments — equivalent to writing['.pi', 'agent', 'sessions']directly.normalizePiSessionsDirexists to normalize a user-configurable raw path (per its usage elsewhere), so routing a fixed constant through it here adds confusion without benefit.♻️ Proposed simplification
function remotePiSessionsSegments(): string[] { - return normalizePiSessionsDir('/.pi/agent/sessions').split('/').filter(Boolean) + return ['.pi', 'agent', 'sessions'] }src/main/ai-vault/remote-session-scanner.ts (1)
99-129: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider parallelizing subdirectory walks for latency.
Each subdirectory recursion (
walkRemoteSessionFiles) is awaited sequentially inside theforloop overentries. Since everyreadDircall is a network round trip over the SSH relay, directory trees with many session-source subfolders (e.g..cursor/projects/**,.claude/projects/**) will be walked one directory at a time, compounding latency. Only the outer per-source fan-out usesmapRemoteScanConcurrently.Consider batching subdirectory recursion through
mapRemoteScanConcurrently(or similar) to bound round trips per depth level rather than per whole subtree.♻️ Proposed parallelization of subdirectory recursion
- const extensions = new Set(source.extensions) - const files: string[] = [] - for (const entry of entries) { - const fullPath = joinRemotePath(hostPlatform, dirPath, entry.name) - if (entry.isDirectory && !entry.isSymlink) { - files.push(...(await walkRemoteSessionFiles(source, provider, hostPlatform, fullPath))) - continue - } - if ( - !entry.isSymlink && - extensions.has(extname(entry.name).toLowerCase()) && - (source.filePredicate?.(fullPath) ?? true) - ) { - files.push(fullPath) - } - } - return files + const extensions = new Set(source.extensions) + const files: string[] = [] + const subdirPaths: string[] = [] + for (const entry of entries) { + const fullPath = joinRemotePath(hostPlatform, dirPath, entry.name) + if (entry.isDirectory && !entry.isSymlink) { + subdirPaths.push(fullPath) + continue + } + if ( + !entry.isSymlink && + extensions.has(extname(entry.name).toLowerCase()) && + (source.filePredicate?.(fullPath) ?? true) + ) { + files.push(fullPath) + } + } + const nested = await mapRemoteScanConcurrently(subdirPaths, (subdirPath) => + walkRemoteSessionFiles(source, provider, hostPlatform, subdirPath) + ) + files.push(...nested.flat()) + return files
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cb0e1f7c-d66e-414d-8536-1c18da5f88bb
📥 Commits
Reviewing files that changed from the base of the PR and between 61003f3dec9118d9805fe31b58d474e252c597f4 and fbda84d.
📒 Files selected for processing (47)
src/main/ai-vault/remote-session-scanner-codex-index.tssrc/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/remote-session-scanner-types.tssrc/main/ai-vault/remote-session-scanner.test.tssrc/main/ai-vault/remote-session-scanner.tssrc/main/ai-vault/session-scanner-accumulator.tssrc/main/ai-vault/session-scanner-agent-parser.tssrc/main/ai-vault/session-scanner-codex-parser.tssrc/main/ai-vault/session-scanner-devin-parser.tssrc/main/ai-vault/session-scanner-droid-parser.tssrc/main/ai-vault/session-scanner-graph-parsers.tssrc/main/ai-vault/session-scanner-primary-parsers.tssrc/main/ai-vault/session-scanner-secondary-parsers.tssrc/main/ipc/ai-vault.test.tssrc/main/ipc/ai-vault.tssrc/main/ipc/ssh.tssrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionActionMenuItems.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionRow.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsxsrc/renderer/src/components/right-sidebar/SessionRowTrailingActions.tsxsrc/renderer/src/components/right-sidebar/ai-vault-host-scope.tssrc/renderer/src/components/right-sidebar/ai-vault-original-pane.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-display.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-filters.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.tssrc/renderer/src/components/right-sidebar/ai-vault-session-path-actions.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-path-actions.tssrc/renderer/src/components/right-sidebar/ai-vault-session-projects.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-projects.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.tssrc/renderer/src/components/right-sidebar/ai-vault-session-worktree.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-worktree.tssrc/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/ai-vault-resume-command.test.tssrc/renderer/src/lib/ai-vault-resume-command.tssrc/renderer/src/lib/ai-vault-resume-target.test.tssrc/renderer/src/lib/ai-vault-resume-target.tssrc/shared/ai-vault-types.tstests/e2e/ssh-ai-vault-session-history.spec.ts
✅ Files skipped from review due to trivial changes (7)
- src/renderer/src/components/right-sidebar/ai-vault-session-path-actions.test.ts
- src/renderer/src/components/right-sidebar/ai-vault-session-filters.test.ts
- src/renderer/src/components/right-sidebar/ai-vault-session-display.test.ts
- src/main/ai-vault/session-scanner-agent-parser.ts
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (16)
- src/renderer/src/components/right-sidebar/ai-vault-original-pane.test.ts
- src/main/ipc/ssh.ts
- src/renderer/src/components/right-sidebar/ai-vault-host-scope.ts
- src/main/ai-vault/session-scanner-accumulator.ts
- src/renderer/src/lib/ai-vault-resume-target.test.ts
- src/renderer/src/components/right-sidebar/ai-vault-session-projects.test.ts
- src/renderer/src/lib/ai-vault-resume-command.ts
- src/shared/ai-vault-types.ts
- src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
- src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts
- src/main/ipc/ai-vault.test.ts
- src/main/ai-vault/session-scanner-codex-parser.ts
- src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx
- src/renderer/src/components/right-sidebar/ai-vault-session-refresh.ts
- tests/e2e/ssh-ai-vault-session-history.spec.ts
- src/main/ipc/ai-vault.ts
…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]>
* fix(ai-vault): scan sessions by execution host * fix(ai-vault): route history resume by host * test(e2e): cover SSH AI Vault history * Generalize remote session scanning for all AI Vault agents Replace the Codex-only remote SSH session history scanner with a unified scanner supporting all registered agents. This ensures remote transcripts for Claude, Gemini, Devin, Droid, and others are scanned and listed alongside local history. - Propagate host metadata (host ID and platform) to scanned sessions - Scope remote actions by host, disabling local OS path actions on remote session logs - Resolve ambiguous project/worktree matching for overlapping paths by verifying matching host setup IDs - Update tests and E2E specs to validate multi-agent remote scanning --------- Co-authored-by: Jinjing <[email protected]>
Summary
Fixes #7164.
Agent Session History is now host-aware for SSH worktrees. The AI Vault session scan can target Local, the active SSH host, or All hosts; SSH worktrees default to their remote host; and Codex resume actions launch against the correct local or SSH execution host.
The remote scan is intentionally Codex-first for this PR. It reads the default remote Codex history directory and Orca-managed remote Codex runtime home, while leaving broader remote scanning for other agents as follow-up work.
Screenshots
Before: SSH worktree session history only scanned local history, so the remote Codex session was missing.
After: SSH worktree defaults to the SSH host scope and shows the remote Codex session, with Local / SSH / All host controls available.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAdditional validation:
ORCA_E2E_FORWARD_APP_LOGS=1 ORCA_E2E_SSH_DOCKER=1 ORCA_E2E_SSH_DOCKER_IMAGE=orca-e2e-ssh-ai-vault-relay:8dbb1d2f4eb4 pnpm exec playwright test tests/e2e/ssh-ai-vault-session-history.spec.ts --config tests/playwright.config.ts --project electron-headlesspnpm test:e2e:ssh-codex-artifacts-repropnpm test:e2eNotes on non-green local checks:
pnpm testwas run and failed in unrelated local renderer test-environment failures wherewindow.localStorage.getItem/removeItem/clearwere unavailable. The failing files were PR comments/sidebar tests, not AI Vault.pnpm test:e2e:ssh-codex-artifacts-reprowas run and failed an existing Codex artifact-display assertion, unrelated to session history.pnpm test:e2ewas run and failed across unrelated existing UI/worktree/onboarding/source-control/terminal specs. The focused SSH AI Vault E2E passed separately.AI Review Report
The AI review checked that the change stays scoped to #7164 and only touches AI Vault session scanning, host-aware IPC/routing, SSH relay metadata, AI Vault UI controls, resume/drop routing, i18n labels, and targeted tests.
Cross-platform compatibility was reviewed for macOS, Linux, and Windows. The change avoids new shortcuts or platform-specific labels, keeps path handling in the main/remote scanner rather than assuming local filesystem paths, and uses the remote platform when building Codex resume commands. SSH/local compatibility was checked by keeping local scans on the existing scanner path, adding explicit
ssh:<target>host scoping, and returning scan issues instead of crashing when an SSH target is disconnected. Agent compatibility was reviewed by keeping remote scanning Codex-specific and not changing non-Codex local session parsing. Performance risk was checked by preserving scoped scans and cache keys so host changes do not reuse stale results. UI quality was checked manually with before/after screenshots and by keeping the host control compact beside the existing session scope controls.Security Audit
Reviewed IPC and command/path handling touched by this PR. The new host scope is an explicit enum-like value (
local,ssh:<target>,all) and disconnected/unknown SSH targets return scan issues rather than falling through to arbitrary local paths. Remote session scanning is limited to known Codex history locations under the remote home and Orca-managed remote runtime home. Resume commands continue to be generated through the existing AI Vault launch path, with remoteCODEX_HOMEand shell quoting selected from the remote platform. No new dependencies, credential handling, auth flows, network listeners, or secret persistence are added.Notes
Remote scanning in this PR covers Codex history only. Broader non-Codex remote agent discovery can be added later without expanding this bug fix.
SSH-specific behavior tested with the Docker SSH fixture: create a remote Codex transcript, open an SSH worktree, open Agent Session History, switch Local / SSH / All host scopes, and resume the remote session into the SSH worktree.
X handle: @Avichal2205