Repository navigation
fix(ai-vault): support session scanning in SSH worktrees - #11004
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 8e7355173b8cc3ec601d67e9c52d5b26a4197f87 and a286c70. 📒 Files selected for processing (86)
📝 WalkthroughWalkthroughThis change adds cancellation-aware AI Vault scanning across local, runtime, remote, and SSH paths. It adds bounded and unlimited session-history limits, depth-aware caches, scan coordination, result validation, issue aggregation, SSH relay requests, IPC cancellation, and renderer controls. Remote parsing now streams lines with cancellation checks. Relay and fallback scans use separate time budgets. WSL stdin EPIPE handling and SSH reconnect worktree setup are also updated. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/components/right-sidebar/AiVaultPanel.tsx (1)
337-349: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winHost-level issues get folded into the generic "transcript skipped" count when sessions are also present.
blockingAiVaultScanIssueonly surfaces akind: 'host'issue whensessions.length === 0; if a scan returns some sessions plus a host-level failure (e.g.'all'scope: local succeeds, one SSH host is unreachable), the fallback branch rendersscanResult.issues.lengthtranscripts skipped — mislabeling a host connectivity failure as a skipped transcript file. Consider filteringkind === 'host'issues out of this count (or surfacing them with their own copy) so the message stays accurate in the partial-success case.src/main/ipc/ai-vault.ts (1)
121-161: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick winForward cancellation options to local and runtime scans.
scanAiVaultSessionsByHostScopeonly passessignalinto the SSH scan path. With cancellation enabled, local-filesystem scans and runtime RPCaiVault.listSessionscalls can continue to completion even after the caller cancels an'all'or runtime-scope request; pass the abort signal through both scan paths.
🧹 Nitpick comments (1)
src/main/ai-vault/remote-session-scanner.ts (1)
251-264: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThree near-identical batch/cancel/yield loops could be a single shared helper.
mapRemoteScanConcurrently,mapDiscoveryConcurrently, and the inline loop inscanRemoteInScopeSessionsall implement the same "slice into batches of N, check cancellation,Promise.allthe batch, yield to the event loop" pattern with only the concurrency constant differing.
src/main/ai-vault/remote-session-scanner.ts#L251-L264:mapRemoteScanConcurrently— candidate location for a shared generic helper (e.g. in the scanning-contracts layer alongsidethrowIfRemoteSessionScanCancelled).src/main/ai-vault/remote-session-scanner-discovery.ts#L138-L151:mapDiscoveryConcurrentlyduplicates the same logic withREMOTE_DISCOVERY_CONCURRENCY.src/main/ai-vault/remote-session-scanner.ts#L135-L167: the inline batching loop inscanRemoteInScopeSessionsduplicates the same logic again instead of calling a shared helper.♻️ Suggested shared helper shape
export async function mapConcurrentlyWithCancellation<T, U>( items: readonly T[], concurrency: number, mapper: (item: T) => Promise<U>, signal?: AbortSignal ): Promise<U[]> { const results: U[] = [] for (let index = 0; index < items.length; index += concurrency) { throwIfRemoteSessionScanCancelled(signal) const batch = items.slice(index, index + concurrency) results.push(...(await Promise.all(batch.map(mapper)))) await yieldToEventLoop() } return results }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6963214b-dad0-4f66-a5c3-f9c2b36c43f2
📒 Files selected for processing (36)
src/main/ai-vault/remote-session-content-lines.tssrc/main/ai-vault/remote-session-file-stat.tssrc/main/ai-vault/remote-session-scan-cancellation.tssrc/main/ai-vault/remote-session-scan-issues.tssrc/main/ai-vault/remote-session-scanner-codex-index.tssrc/main/ai-vault/remote-session-scanner-discovery.tssrc/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/remote-session-scanner-types.tssrc/main/ai-vault/remote-session-scanner.tssrc/main/ai-vault/runtime-session-scanner.test.tssrc/main/ai-vault/runtime-session-scanner.tssrc/main/ai-vault/session-list-result-validation.test.tssrc/main/ai-vault/session-list-result-validation.tssrc/main/ai-vault/session-list-results.tssrc/main/ai-vault/session-scanner-codex-parser.tssrc/main/ai-vault/ssh-session-list.tssrc/main/ipc/ai-vault.test.tssrc/main/ipc/ai-vault.tssrc/main/ipc/ssh.tssrc/main/ssh/ssh-relay-session.tssrc/preload/api-types.tssrc/preload/index.tssrc/relay/ai-vault-handler.test.tssrc/relay/ai-vault-handler.tssrc/relay/ai-vault-scan-coordinator.test.tssrc/relay/ai-vault-scan-coordinator.tssrc/relay/relay.tssrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/ai-vault-scan-issue-state.test.tssrc/renderer/src/components/right-sidebar/ai-vault-scan-issue-state.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.tssrc/renderer/src/web/web-preload-api.tssrc/shared/ai-vault-types.tssrc/shared/ssh-ai-vault-relay.tstests/e2e/ssh-codex-reconnect-replay-driver.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 763aea50-56e5-4baf-9e07-80309a317faf
📒 Files selected for processing (8)
src/main/ai-vault/ai-vault-scan-coordinator.test.tssrc/main/ai-vault/ai-vault-scan-coordinator.tssrc/main/ai-vault/remote-session-content-lines.tssrc/main/ai-vault/remote-session-scan-batching.tssrc/main/ai-vault/remote-session-scanner-codex-index.tssrc/main/ai-vault/remote-session-scanner-discovery.tssrc/main/ai-vault/remote-session-scanner.tssrc/main/ai-vault/ssh-session-list.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/ai-vault/remote-session-content-lines.ts
- src/main/ai-vault/remote-session-scanner-codex-index.ts
- src/main/ai-vault/ssh-session-list.ts
|
@coderabbitai[bot] resvoled |
|
Tip For best results, initiate chat on the files or code changes.
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/adhoc-mac-build.yml (1)
165-178: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTwo copies of the origin/main version lookup exist. The workflow reads
origin/main:package.jsonin shell, and the script reads it again inreadMainPackageJsonVersion. Only one copy runs in CI, because the workflow always setsORCA_ADHOC_BASE_VERSION, so the script path stays untested in CI and can drift.
.github/workflows/adhoc-mac-build.yml#L165-L178: delete the inlinenode -ereader and thebase_versionexport. Letconfig/scripts/adhoc-build-version.mjsresolve the base version throughresolveAdhocBaseVersion. Keep thegit fetchonly if the script must not fetch.config/scripts/adhoc-build-version.mjs#L113-L129: keep this as the single owner of the lookup, and log the failure reason onstderrbefore returningundefinedso a fallback to the branch version is visible in the workflow log.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 621426c7-5d69-40b1-8069-8bb2e018cbd3
📥 Commits
Reviewing files that changed from the base of the PR and between 22b6da3 and a26a18eb3fd83f7e7d2db9a6a7c3e02e0f79089a.
📒 Files selected for processing (3)
.github/workflows/adhoc-mac-build.ymlconfig/scripts/adhoc-build-version.mjsconfig/scripts/adhoc-build-version.test.mjs
fd18e4f to
8e73551
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/ai-vault/session-scanner.ts (1)
127-152: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCheck cancellation before scheduling the cache write and returning.
If cancellation occurs after
scanInScopeSessionssettles, this function can return a completed result for a cancelled request. It can also persist that result before the caller observes cancellation.Proposed fix
const scopeSessions = await scanInScopeSessions({ discoveries, scopePaths: options.scopePaths ?? [], limit, alreadyParsedFilePaths: new Set(cappedSessions.map((session) => session.filePath)), platform, executionHostId, issues, parseStats, signal: options.signal }) + throwIfAiVaultScanCancelled(options.signal) span.setAttribute('candidates', candidates.length)
🧹 Nitpick comments (5)
src/main/ai-vault/session-list-results.ts (1)
61-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReuse the shared depth normalization.
This limit normalization now duplicates
requestedAiVaultSessionDepthinsrc/shared/ai-vault-session-depth.tsand the same expression inscanRemoteAiVaultSessions. The local copy also omits theNumber.isFiniteguard, so a non-finitelimitreachessliceinstead of falling back toDEFAULT_AI_VAULT_SCAN_LIMIT. Deriving the depth once keeps the three sites in agreement.♻️ Proposed refactor
- const limit = unlimited - ? Number.POSITIVE_INFINITY - : rawLimit && rawLimit > 0 - ? Math.floor(rawLimit) - : DEFAULT_AI_VAULT_SCAN_LIMIT + const depth = requestedAiVaultSessionDepth({ limit: rawLimit, unlimited }) + const limit = depth === 'unlimited' ? Number.POSITIVE_INFINITY : depthUpdate the import accordingly:
-import { DEFAULT_AI_VAULT_SCAN_LIMIT } from '../../shared/ai-vault-session-depth' +import { requestedAiVaultSessionDepth } from '../../shared/ai-vault-session-depth'src/main/ai-vault/ai-vault-scan-coordinator.ts (1)
78-131: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAvoid aborting an entry after it resolved successfully.
detachruns beforeresolvein the success path. When the last waiter leaves,entry.waiterCountreaches 0 andentry.controller.signal.abortedis still false, soentry.controller.abort()fires on an already-settled scan. Any consumer that keys cleanup or logging off that signal sees a spurious cancellation. Skip the abort when the entry promise already settled.♻️ Suggested guard
type ScanEntry = { controller: AbortController force: boolean startedAt: number promise: Promise<AiVaultListResult> waiterCount: number + settled: boolean preemptedBy: ScanEntry | null }- if (entry.waiterCount === 0 && !entry.controller.signal.aborted) { + if (entry.waiterCount === 0 && !entry.settled && !entry.controller.signal.aborted) {src/relay/ai-vault-handler.test.ts (1)
148-151: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winWait for the scan call instead of one microtask tick.
The coordinator starts
scanRemoteSessionsinside aPromise.resolve().then(...)continuation. A singleawait Promise.resolve()depends on the exact microtask count betweendispatcher.calland that continuation, so this assertion can flake if the call chain gains one moreawait. The other tests in this file already usevi.waitFor.💚 Suggested change
const second = dispatcher.call(SSH_AI_VAULT_LIST_SESSIONS_METHOD, { limit: 20 }) - await Promise.resolve() - - expect(scanRemoteSessions).toHaveBeenCalledTimes(1) + await vi.waitFor(() => expect(scanRemoteSessions).toHaveBeenCalledTimes(1))src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.tsx (1)
63-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDerive the performance label from the limits list instead of a hardcoded value.
Line 69 compares
limit === 500to pick between "May be slower" and "Slowest". This ties the label logic to one specific value inAI_VAULT_SESSION_LIMITS. If a maintainer adds, removes, or reorders a tier in that array later, this comparison silently misclassifies the new tier, and no compiler error signals the mismatch.Derive the tier label from the array position instead of a literal value, for example by treating the last non-unlimited entry as "Slowest" and all other non-default numeric entries as "May be slower".
♻️ Proposed refactor to derive labels from the limits list
+const numericLimits = AI_VAULT_SESSION_LIMITS.filter( + (limit): limit is Exclude<AiVaultSessionLimit, 'unlimited'> => limit !== 'unlimited' +) +const slowestNumericLimit = numericLimits[numericLimits.length - 1] + export function AiVaultSessionLimitMenu({ sessionLimit, onSessionLimitChange }: { sessionLimit: AiVaultSessionLimit onSessionLimitChange: (limit: AiVaultSessionLimit) => void }): React.JSX.Element { ... <span className="ml-auto text-[11px] font-normal text-muted-foreground"> {limit === DEFAULT_AI_VAULT_SESSION_LIMIT ? translate( 'auto.components.right.sidebar.AiVaultSessionLimitMenu.recommended', 'Recommended' ) - : limit === 500 - ? translate( - 'auto.components.right.sidebar.AiVaultSessionLimitMenu.mayBeSlower', - 'May be slower' - ) - : translate( + : limit === 'unlimited' || limit === slowestNumericLimit + ? translate( 'auto.components.right.sidebar.AiVaultSessionLimitMenu.slowest', 'Slowest' ) + : translate( + 'auto.components.right.sidebar.AiVaultSessionLimitMenu.mayBeSlower', + 'May be slower' + ) } </span>src/shared/ai-vault-session-depth.test.ts (1)
40-46: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd boundary assertions for depth normalization.
requestedAiVaultSessionDepthfloors finite limits and falls back for non-positive or non-finite values. The current tests do not cover those branches, andaiVaultSessionDepthCoversdoes not test finite equality. Add these cases to prevent normalization regressions. The expected behavior followssrc/shared/ai-vault-session-depth.ts:8-17.Suggested assertions
it('recognizes which loaded depths cover a request', () => { + expect(aiVaultSessionDepthCovers(250, 250)).toBe(true) expect(aiVaultSessionDepthCovers(1000, 250)).toBe(true) expect(aiVaultSessionDepthCovers(250, 500)).toBe(false) it('normalizes default, finite, and unlimited requests', () => { expect(requestedAiVaultSessionDepth()).toBe(1000) expect(requestedAiVaultSessionDepth({ limit: 500 })).toBe(500) + expect(requestedAiVaultSessionDepth({ limit: 500.75 })).toBe(500) + expect(requestedAiVaultSessionDepth({ limit: 0 })).toBe(1000) + expect(requestedAiVaultSessionDepth({ limit: -1 })).toBe(1000) + expect(requestedAiVaultSessionDepth({ limit: Number.NaN })).toBe(1000) + expect(requestedAiVaultSessionDepth({ limit: Number.POSITIVE_INFINITY })).toBe(1000) expect(requestedAiVaultSessionDepth({ limit: 500, unlimited: true })).toBe('unlimited') })Also applies to: 48-52
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8e67c582-6b75-40db-b115-49cad8894eb2
📥 Commits
Reviewing files that changed from the base of the PR and between a26a18eb3fd83f7e7d2db9a6a7c3e02e0f79089a and 8e7355173b8cc3ec601d67e9c52d5b26a4197f87.
📒 Files selected for processing (86)
src/main/agent-hooks/wsl-hook-relay-sentinel.test.tssrc/main/agent-hooks/wsl-hook-relay-sentinel.tssrc/main/ai-vault/ai-vault-scan-cancellation.test.tssrc/main/ai-vault/ai-vault-scan-cancellation.tssrc/main/ai-vault/ai-vault-scan-coordinator.test.tssrc/main/ai-vault/ai-vault-scan-coordinator.tssrc/main/ai-vault/cached-session-list.tssrc/main/ai-vault/remote-session-content-lines.tssrc/main/ai-vault/remote-session-file-stat.tssrc/main/ai-vault/remote-session-scan-batching.test.tssrc/main/ai-vault/remote-session-scan-batching.tssrc/main/ai-vault/remote-session-scan-concurrency.tssrc/main/ai-vault/remote-session-scan-issues.tssrc/main/ai-vault/remote-session-scanner-codex-index.tssrc/main/ai-vault/remote-session-scanner-discovery.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/runtime-session-scanner.test.tssrc/main/ai-vault/runtime-session-scanner.tssrc/main/ai-vault/session-list-result-validation.test.tssrc/main/ai-vault/session-list-result-validation.tssrc/main/ai-vault/session-list-results.test.tssrc/main/ai-vault/session-list-results.tssrc/main/ai-vault/session-scanner-antigravity-parser.tssrc/main/ai-vault/session-scanner-codex-parser.tssrc/main/ai-vault/session-scanner-copilot-parser.tssrc/main/ai-vault/session-scanner-cursor-parser.tssrc/main/ai-vault/session-scanner-droid-parser.tssrc/main/ai-vault/session-scanner-gemini-parsers.tssrc/main/ai-vault/session-scanner-graph-parsers.tssrc/main/ai-vault/session-scanner-opencode-sqlite-bounds.test.tssrc/main/ai-vault/session-scanner-opencode-sqlite-list.tssrc/main/ai-vault/session-scanner-primary-parsers.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner.test.tssrc/main/ai-vault/session-scanner.tssrc/main/ai-vault/ssh-session-list.test.tssrc/main/ai-vault/ssh-session-list.tssrc/main/ipc/ai-vault-host-discovery.tssrc/main/ipc/ai-vault-host-leg-cache.tssrc/main/ipc/ai-vault-runtime-scan.tssrc/main/ipc/ai-vault-scan-coalescing.test.tssrc/main/ipc/ai-vault.test.tssrc/main/ipc/ai-vault.tssrc/main/ipc/ssh.tssrc/main/runtime/rpc/methods/ai-vault.test.tssrc/main/runtime/rpc/methods/ai-vault.tssrc/main/ssh/ssh-channel-multiplexer.tssrc/main/ssh/ssh-relay-session.tssrc/preload/api-types.tssrc/preload/index.tssrc/relay/ai-vault-handler.test.tssrc/relay/ai-vault-handler.tssrc/relay/relay.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/AiVaultScanIssueBanners.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionListStates.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsxsrc/renderer/src/components/right-sidebar/ai-vault-scan-issue-state.test.tssrc/renderer/src/components/right-sidebar/ai-vault-scan-issue-state.tssrc/renderer/src/components/right-sidebar/ai-vault-session-limit.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-result-cache.tssrc/renderer/src/components/right-sidebar/ai-vault-view-defaults.test.tssrc/renderer/src/components/right-sidebar/ai-vault-view-defaults.tssrc/renderer/src/components/right-sidebar/ai-vault-view-options-persistence.test.tssrc/renderer/src/components/right-sidebar/ai-vault-view-options-persistence.tssrc/renderer/src/components/right-sidebar/use-persisted-ai-vault-view-options.test.tsxsrc/renderer/src/components/right-sidebar/use-persisted-ai-vault-view-options.tssrc/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/web/web-preload-api.tssrc/shared/ai-vault-session-depth.test.tssrc/shared/ai-vault-session-depth.tssrc/shared/ai-vault-types.tssrc/shared/ssh-ai-vault-relay.tstests/e2e/ssh-codex-reconnect-replay-driver.ts
🚧 Files skipped from review as they are similar to previous changes (13)
- src/renderer/src/web/web-preload-api.ts
- src/main/ai-vault/runtime-session-scanner.test.ts
- src/shared/ssh-ai-vault-relay.ts
- src/preload/api-types.ts
- src/main/ai-vault/session-scanner-codex-parser.ts
- src/relay/relay.ts
- src/main/ai-vault/remote-session-scan-issues.ts
- src/main/ai-vault/remote-session-scanner-types.ts
- src/preload/index.ts
- src/main/ai-vault/remote-session-scanner-discovery.ts
- src/main/ai-vault/runtime-session-scanner.ts
- src/main/ssh/ssh-relay-session.ts
- src/main/ipc/ssh.ts
|
@coderabbitai[bot] fixed all comments |
|
Tip For best results, initiate chat on the files or code changes.
🐇 ✅ You are interacting with an AI system. |
Add relay-native aiVault.listSessions scanning that discovers agent sessions on SSH hosts. Includes fallback to filesystem crawl for legacy relays, full cancellation support, result validation, and scan coalescing to reduce redundant work.
- Extract batching logic to `mapRemoteScanBatches` for reuse and proper cancellation checkpoints - Move `AiVaultScanCoordinator` from relay to main to handle concurrent same-key requests with individual cancellation signals - Report scope path truncation consistently across relay and SSH fallback paths - Gracefully degrade relay handler on unsupported platforms instead of aborting startup - Refactor issue display to separate blocking errors, scope notices, and skipped transcript counts
Swallow async WSL relay stdin EPIPE so the live hook-relay shard no longer fails after all tests pass. Merge main, resolve scan/relay conflicts, and align cancellation/host-issue reporting with IPC expectations.
…preemption Thread the abort signal through every scan and parse path so superseded or cancelled scans stop promptly instead of parsing every remaining transcript for a caller that already left. Replace the fragile message-text relay timeout check with a typed error code so unrelated errors carrying the phrase "timed out after" no longer suppress the filesystem fallback. Fix scan coordinator preemption so a forced Refresh in one window no longer re-enters as a spurious cancellation in another. Add a host-leg cache for the all-hosts view and cap filesystem concurrency so a single slow remote home cannot stall the whole merge. Co-authored-by: Orca <[email protected]>
Drop array-index keys so react-doctor/no-array-index-as-key passes. Uniqueness comes from host, kind, agent, path, and message.
Implement depth-aware caching and proper scan boundaries to make SSH session scanning reliable in worktrees. Users can now select between faster (250 sessions) and comprehensive (unlimited) history scans. The scanner: - Deduplicates scans across relay, host leg, runtime, and renderer layers - Reuses larger scans to serve smaller depth requests - Properly bounds in-scope discovery per-limit - Fixes timeout enforcement when SSH providers ignore abort signals
Keep render pure for React Doctor by deferring ref updates to a layout effect, which still executes before render-dependent effects that consume the ref.
Adhoc builds check out arbitrary refs whose package.json often lags version bumps (e.g. 1.4.165-rc.0 while main is 1.4.168-rc.1). Hourly always builds main so it already tracks the product line; adhoc now resolves the base version from origin/main (or ORCA_ADHOC_BASE_VERSION) so branch builds share that prefix.
…ranch" This reverts commit a26a18eb3fd83f7e7d2db9a6a7c3e02e0f79089a.
Resolve race where the last waiter leaving could abort an already-settled scan (add `settled` flag). Redesign scoped session backfill to keep searching through newer files until the scope reaches its requested session quota instead of stopping at the candidate limit; out-of-scope files no longer consume the scope budget. Centralize scan limit normalization and fix error classification for cancelled scans using the proper helper instead of checking Error.name. Disambiguate cache keys using JSON and add cancellation check after scope discovery phase.
e32e015 to
a286c70
Compare
) * fix(ai-vault): support session scanning in SSH worktrees Add relay-native aiVault.listSessions scanning that discovers agent sessions on SSH hosts. Includes fallback to filesystem crawl for legacy relays, full cancellation support, result validation, and scan coalescing to reduce redundant work. * fix(ai-vault): scan sessions in SSH worktrees with coordinated cancellat - Extract batching logic to `mapRemoteScanBatches` for reuse and proper cancellation checkpoints - Move `AiVaultScanCoordinator` from relay to main to handle concurrent same-key requests with individual cancellation signals - Report scope path truncation consistently across relay and SSH fallback paths - Gracefully degrade relay handler on unsupported platforms instead of aborting startup - Refactor issue display to separate blocking errors, scope notices, and skipped transcript counts * fix(ai-vault): stabilize SSH session scan CI Swallow async WSL relay stdin EPIPE so the live hook-relay shard no longer fails after all tests pass. Merge main, resolve scan/relay conflicts, and align cancellation/host-issue reporting with IPC expectations. * fix(ai-vault): harden session scan cancellation, relay timeouts, and preemption Thread the abort signal through every scan and parse path so superseded or cancelled scans stop promptly instead of parsing every remaining transcript for a caller that already left. Replace the fragile message-text relay timeout check with a typed error code so unrelated errors carrying the phrase "timed out after" no longer suppress the filesystem fallback. Fix scan coordinator preemption so a forced Refresh in one window no longer re-enters as a spurious cancellation in another. Add a host-leg cache for the all-hosts view and cap filesystem concurrency so a single slow remote home cannot stall the whole merge. Co-authored-by: Orca <[email protected]> * fix(ai-vault): use stable React keys for scan issue banners Drop array-index keys so react-doctor/no-array-index-as-key passes. Uniqueness comes from host, kind, agent, path, and message. * fix(ai-vault): SSH session scanning with configurable depth limits Implement depth-aware caching and proper scan boundaries to make SSH session scanning reliable in worktrees. Users can now select between faster (250 sessions) and comprehensive (unlimited) history scans. The scanner: - Deduplicates scans across relay, host leg, runtime, and renderer layers - Reuses larger scans to serve smaller depth requests - Properly bounds in-scope discovery per-limit - Fixes timeout enforcement when SSH providers ignore abort signals * Move sessionLimit ref update to useLayoutEffect Keep render pure for React Doctor by deferring ref updates to a layout effect, which still executes before render-dependent effects that consume the ref. * fix(adhoc): stamp version prefix from main, not the feature branch Adhoc builds check out arbitrary refs whose package.json often lags version bumps (e.g. 1.4.165-rc.0 while main is 1.4.168-rc.1). Hourly always builds main so it already tracks the product line; adhoc now resolves the base version from origin/main (or ORCA_ADHOC_BASE_VERSION) so branch builds share that prefix. * Revert "fix(adhoc): stamp version prefix from main, not the feature branch" This reverts commit a26a18eb3fd83f7e7d2db9a6a7c3e02e0f79089a. * fix(ai-vault): fix scoped backfill and coordinator race conditions Resolve race where the last waiter leaving could abort an already-settled scan (add `settled` flag). Redesign scoped session backfill to keep searching through newer files until the scope reaches its requested session quota instead of stopping at the candidate limit; out-of-scope files no longer consume the scope budget. Centralize scan limit normalization and fix error classification for cancelled scans using the proper helper instead of checking Error.name. Disambiguate cache keys using JSON and add cancellation check after scope discovery phase. --------- Co-authored-by: Orca <[email protected]>
Summary
Adds relay-side Agent Session History scanning for SSH worktrees. Previously session listing relied entirely on desktop-side filesystem crawling. This change enables scanning directly on the SSH host when the relay supports it, with automatic fallback to desktop crawling for older relays.
Key improvements:
forcepreemption of a hung scan, and cache fencing so an aborted scan never poisons the cachetimeoutMsbudget as the relay round trip, and a host that throws or times out degrades to one issue row instead of discarding local/runtime resultsScreenshots
No visual change.
Testing
pnpm run typecheck:node,pnpm run typecheck:webpnpm run check:code-quality:changed(0 new findings / 47 changed files),pnpm run check:max-lines-ratchet,git diff --check,oxfmt --checkai-vault-scan-coordinator.test.ts— waiter lifecycle, forced preemption, abort fencingssh-session-list.test.ts(new) — bounded legacy crawl, unbounded when no budget, crawl throw degrades to a host issue, caller cancellation still propagatessession-list-results.test.ts(new) — scope-truncation notice survivesmergeAiVaultListResults, one notice per host, never counted as a skipped transcriptai-vault-scan-coalescing.test.ts(new) — coalescing across independent caller signalsai-vault.test.ts— all-scope host-discovery failures and a throwing local leg both degrade to issue rows without dropping other hostssession-list-result-validation.test.ts— all-invalid relay payload rejects so the leg falls backai-vault-scan-issue-state.test.ts/ai-vault-session-refresh.test.ts— issue classification, skipped-transcript reasons, cancellation recognitionssh-codex-reconnect-replay-driver.ts) to poll for remote worktrees instead of assuming instant availabilityReview Answers
Does the relay path avoid the SSH filesystem stream/mux limits (#11396, #11364)?
Partly — and the distinction matters:
AiVaultHandler(src/relay/ai-vault-handler.ts) runsscanRemoteAiVaultSessions(src/main/ai-vault/remote-session-scanner.ts) inside the remote relay process, against a host-local provider built bycreateRelayAiVaultFilesystemProvider()—readdir/lstatfromnode:fs/promisesplusreadRelayFileContent. No transcript bytes cross the desktop SSH filesystem stream/mux, so the chunked-stream pump and its unacked-chunk backpressure are out of the picture entirely. This does not reduce [Bug]: SSH AI Vault skips session transcripts larger than 10 MB #11396's urgency: that issue tracks the 10 MiB cap, which remains on both paths.readRelayFileContentenforcesMAX_TEXT_FILE_SIZE = 10 * 1024 * 1024(src/relay/fs-handler-utils.ts:25) before returning content, exactly mirroring the desktop reader's own10 * 1024 * 1024(src/main/ssh/ssh-filesystem-stream-reader.ts:9). A >10 MiB transcript is skipped on both paths; it is just skipped host-locally now instead of after a stream setup. Raising that cap for transcripts is out of scope here.Does the older-relay fallback still carry the original risks?
Yes. When the relay has no
aiVault.listSessionsmethod the leg falls through to the desktop crawl overssh-filesystem-stream-reader.ts, so both the missing per-read inactivity timeout and the 10 MiB cap still apply. This PR bounds that crawl with an overall wall-clock budget in all-host scope (scanRemoteSessionsWithinBudgetinssh-session-list.ts), which stops one stalled host from holding every other host's results hostage — but it does not add the per-read inactivity timeout. #11364 remains a required companion, not something this PR closes.How does the 64-path scope warning behave end to end?
It is an
AiVaultScanIssuewithkind: 'scope', emitted identically by both legs (relay leg inai-vault-handler.ts, fallback leg viascopeTruncationIssueinssh-session-list.ts) so neither can silently scan more paths than the other. It survivesmergeAiVaultListResults, which concatenates every result's issues without dedup — covered bysession-list-results.test.ts, including one notice per host and a scope notice surviving alongside a failing host. It renders throughAiVaultScanIssueBanners(mounted inAiVaultPanel.tsx:338) using the scanner-authoredissue.message. BecauseskippedAiVaultTranscriptCountcounts only issues with nokind, it is excluded from the skipped-transcript footer.First user prompt, relative to #12006 on main
Keeping remote prompts null — no change needed here. Two independent reasons:
firstUserPromptdoes not exist anywhere in the branch's source (src/main/ai-vault/session-first-user-prompt-read.tsand friends areorigin/main-only). There is nothing in this diff that can regress or implement it.readAiVaultFirstUserPromptreturns{ prompt: null }for anyexecutionHostId !== LOCAL_EXECUTION_HOST_ID, with the comment "transcript bodies live on the session host. Remote rows are skipped (same posture aslistSubagentSessions); UI falls back to preview text." So after this branch merges main, SSH rows will resolve tonulland fall back to preview text, which is the intended behavior — not a regression introduced here.Serving full first prompts for remote hosts would need a new relay method to read the transcript body host-side. That is a separate change and is not attempted in this PR.
CI Housekeeping
Run 30385188010 is stale — it predates the fixes in the current working tree.
static analysis— real, work-caused, now fixed. It failed on a single--deny-warningswarning, "Modules should not be imported multiple times in the same file":remote-session-scanner.tsimported from./remote-session-scanner-typestwice (lines 17 and 24 at that commit). The current tree merges them into oneimport type, andcheck:code-quality:changednow reports 0 new findings.e2e 9-of-10—cancelled, not a failure. The GitHub API job conclusion is literallycancelled; it is not independent evidence of a broken test and should not be counted as one.e2e 1/3/7-of-10— unrelated red. Failures are agent-session force-exit/quit resume, new-workspace Jira/GitHub linked-item project switching, and OpenCode alt-screen reveal artifacts (STA-2694). None touch AI Vault.tests 7/16— unrelated infrastructure error. All 2175 tests passed; the job failed on an unhandledEPIPEthrown fromwsl-hook-relay-sentinel.tsduringwsl-hook-relay-live.integration.test.tsteardown.No live reproduction of the e2e shards was attempted locally; the above is read off the run's logs and job conclusions.
Notes
aiVault.listSessionstimeout: 130s; timeouts do not trigger fallback crawlforcepropagates desktop → relay (SshAiVaultRelayListParams.force) but is deliberately excluded from the relay coordinator's coalescing key, so a forced refresh preempts a stale scan instead of fragmenting the cacheFORCED_SCAN_PREEMPT_AFTER_MS), so a hung scan can't strand every later RefreshAI_VAULT_SCAN_CANCELLED_MESSAGE) because IPC dropsError.name; a cancelled scan leaves the existing list in place rather than painting an abort error over good stateparseAiVaultListResultso the leg falls back to the desktop crawl, instead of silently reporting an empty hostKnown out-of-scope risks: #11364 (missing per-read inactivity timeout on the legacy SSH stream reader) is still required as a companion; #11395 remains open for the legacy fallback path, and #11396 remains open for both relay and legacy paths because both enforce the 10 MiB cap.