Repository navigation
feat(session-search): merge all-computers search across hosts - #20670
Conversation
The `all` scope on `aiVault:searchSessions` now fans out from the desktop to every host the session list enumerates and merges the pages into one. Legs run in parallel: the local index through the search service, SSH and runtime hosts through the existing remote search client. Two fixed orders, because relevance scores from independent indexes are not comparable. `newest` asks every leg for recency and k-way merges on `updatedAt`, nulls last, ties broken on execution host id. `relevance` rotates hosts in host-id order by their own rank. The merged cursor is an opaque base64url payload holding each host's cursor, how many of its current page were already emitted, and the generation that offset counts into, plus the page size and sort the cursor belongs to. A host whose index moved is fenced to `stale` and stops contributing; the rest keep paging. Per-host outcomes ride back on one new optional `hosts` field on the results response. `aiVault:searchStatus` with `all` stays refused, and neither the runtime RPC nor the CLI gains the scope, so a fan-out is never two hops.
There was a problem hiding this comment.
Important
pnpm tc fails at head on the PR's own new test, and the desktop-only merge currently strips source.filePath / resumeCommand from local hits when the scope is all. Both need an API/transport decision before this can land.
Reviewed changes
- All-hosts merge engine (
ai-vault-search-all-hosts.ts) — fans a query out to local + SSH + runtime legs, k-way merges by recency or round-robins by relevance, and reports per-host outcomes. - Composite cursor (
ai-vault-search-merged-cursor.ts) — opaque base64url/zod payload of per-host cursor, emitted count, generation, plus limit/sort; decode or shape mismatch ismalformed-cursor. - IPC wiring (
ai-vault-search.ts,ai-vault.ts,ai-vault-all-host-timeouts.ts) —aiVault:searchSessionswith scopeallroutes to the merge; host enumerators are exported; a 15s leg budget is added. - Contract (
ai-vault-search-contract.ts,ai-vault-search-types.ts) — additive optionalhostsoutcome array on theresultsresponse. - Tests — 4 new files: merge semantics, cursor round-trip/refusal, and a three-real-index acceptance fixture.
⚠️ Local hits lose source.filePath and resumeCommand under the all scope
The merged response is assembled in main and returned through the preload, which decides redaction from the requested scope, not from where each hit came from. Because all is not local, the preload applies relay redaction to the whole page, including the local leg's hits. I confirmed this with a throwaway test: a local hit's resumeCommand is undefined under all but present under local (and the existing single-host test asserts it is present). The remote legs are already relay-redacted in main inside remoteSearchClient, so the second pass only harms the local rows.
Technical details
# Local-leg hits are relay-redacted by the preload under `all`
## Affected sites
- `src/main/ipc/ai-vault-search.ts:110` — local leg returns `searchSessionService(request, 'ipc')` hits, which keep `source.filePath`/`resumeCommand`.
- `src/preload/api/ai-vault-bridge.ts:21` — `remote = executionHostScope !== undefined && executionHostScope !== LOCAL_EXECUTION_HOST_ID`, so `all` selects transport `relay`.
- `src/shared/ai-vault-search-client.ts:65` — `redactForTransport(hit, 'relay')` drops `source.filePath`, `source.codexHome`, and `resumeCommand` for every hit in the merged page.
- `src/shared/ai-vault-search-transport.ts:12` — the redaction that strips those fields.
## Required outcome
- Local hits returned under `all` must expose the same `source` and `resumeCommand` they expose under `local`; remote hits must stay relay-redacted.
## Suggested approach (optional)
- Since `remoteHostLeg` already redacts remote hits in main, have the `all` scope use transport `ipc` at the preload (treat `ALL_EXECUTION_HOSTS_SCOPE` like `local` in `searchClient`), or re-stamp per-hit transport in the merge output. Either way, add an assertion on the local hit's `source.filePath`/`resumeCommand` to the new `merges every enumerated host` test, which currently checks only `executionHostId`/`sessionId`.
## Open questions for the human
- Is withholding local paths under `all` intentional (defense in depth), or should local rows behave exactly as they do under `local`?ℹ️ A permanently unreachable host holds hasMore open forever
Per the design, a failed leg is carried so the next merged page retries it, and merged hasMore stays true while any host is unreachable. A disconnected SSH/runtime host is a normal steady state, not a transient one, so pagination can never reach a terminal page and every subsequent page pays the 15s leg timeout before it can answer. Worth defining a terminal outcome (or a retry cap / cooldown) so one dead host does not keep the list "loadable" indefinitely.
Technical details
# Unreachable legs retry on every page with no terminal state
## Affected sites
- `src/main/ipc/ai-vault-search-all-hosts.ts:135` — `endHostWalk(walk, 'unreachable', true)` carries the host.
- `src/main/ipc/ai-vault-search-all-hosts.ts:257` — `hasMore = Object.keys(nextHosts).length > 0`, so a carried host always yields another cursor.
- `src/main/ipc/ai-vault-all-host-timeouts.ts:12` — the 15s search budget is paid again on each retry.
## Required outcome
- A host that cannot be reached should stop being counted as "more results" after a bounded number of attempts (or after it reports a terminal reason), so the merged page can settle.
## Open questions for the human
- What should the UI do after the retry budget is exhausted — drop the host from `hasMore` and show its `unreachable` outcome, or surface it as a list error?ℹ️ Nitpicks
- Merged
generationis hardcoded0and legs are called withdebugstripped, so a caller requestingdebug: trueunderallsilently receives no debug. Consider documenting thatalldoes not produce debug, or omitting the field contract explicitly.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Run failed. View the logs →
|
…gs-ui # Conflicts: # src/renderer/src/i18n/locales/en.json
… session-search-all-hosts
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the incremental delta since the prior pullfrog review (05187bf) — one fix commit plus a base-branch merge. The merge (9b1b55df) brings in session-search-settings-ui noise and adds no PR content; the substantive change is:
- Preload admits the
allscope —ai-vault-bridge.tsnow types the search scope asExecutionHostScope(leavingsearchStatusnarrowed toExecutionHostId) and treatsalllikelocalfor transport, so the bridged call typechecks and the merged page is no longer relay-redacted a second time. - Local hits keep their paths — routing
allthroughipcpreserves the local leg'ssource.filePath/resumeCommand, while remote legs stay relay-redacted in main (remoteSearchClient), so fidelity is gained only where it was lost.
Verified locally at 9b1b55d: pnpm tc exits 0 (the prior TS2345 at ai-vault-search.test.ts:169 is gone), and the five search test files pass (36 tests). pnpm run check:code-quality:changed reports 3 findings, but all are in base-branch SessionHistorySettingsPane.tsx, not in this PR's 12 files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
📝 WalkthroughWalkthroughThe pull request adds merged session search across local, SSH, and runtime execution hosts. It introduces per-host pagination state, cursor validation, host timeouts, relevance and newest ordering, retry handling, stale and unavailable outcomes, and aggregated truncation metadata. The all-host scope now uses this merger through desktop IPC. Search responses can report per-host outcomes. New unit, IPC, and real-index tests cover pagination, ordering, cursor rejection, retries, and host changes. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to All-computer searches can return incomplete or misleading paginated results under ordinary failure and cursor conditions, so these issues should be resolved before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the implementation and testing, but it omits most required template sections, including ELI5, Why, an explicit Linked Issue entry, Visual Proof or N/A, Review, Agent skill upstream boundary, Notes, and the Checklist. Resolution Complete the required template sections. Add an explicit issue link such as "Fixes
✨ Finishing Touches 💡 1📝 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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6ec95a9f-e0c9-4dbd-8959-f09b13bb768a
📒 Files selected for processing (12)
src/main/ipc/ai-vault-all-host-timeouts.tssrc/main/ipc/ai-vault-search-all-hosts-real-index.test.tssrc/main/ipc/ai-vault-search-all-hosts.test.tssrc/main/ipc/ai-vault-search-all-hosts.tssrc/main/ipc/ai-vault-search-merged-cursor.test.tssrc/main/ipc/ai-vault-search-merged-cursor.tssrc/main/ipc/ai-vault-search.test.tssrc/main/ipc/ai-vault-search.tssrc/main/ipc/ai-vault.tssrc/preload/api/ai-vault-bridge.tssrc/shared/ai-vault-search-contract.tssrc/shared/ai-vault-search-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| walk.outcome = 'searched' | ||
| walk.generation = response.generation | ||
| walk.pending = stampExecutionHost(response.hits, walk.executionHostId).slice(walk.emitted) | ||
| walk.nextCursor = response.page.hasMore ? response.page.cursor : null |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Reject invalid or non-advancing host cursors.
If hasMore is true and cursor is null, this code marks the host as complete after its pending hits drain. The remaining hits are lost.
If the cursor equals walk.cursor, later pages can repeat hits or produce an endless sequence of merged cursors. MAX_HOST_PAGES_PER_REQUEST limits one request, but subsequent requests repeat the same state.
Fence the host unless a hasMore response supplies a non-null cursor that advances from the request cursor.
Based on learnings, pagination must reject hasMore responses with an unchanged cursor.
Source: Learnings
| sort: MergedSort | ||
| ): Promise<AiVaultSearchHit[]> { | ||
| const hits: AiVaultSearchHit[] = [] | ||
| let turn = 0 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve relevance rotation across page boundaries.
turn resets to zero for every merged request. With hosts A and B and limit: 1, consecutive pages select A1, A2, and so on until host A is exhausted. They do not select A1, B1, A2, B2.
This makes ordering depend on page size and can starve later hosts. Store the next host turn in the composite cursor and restore it when pagination resumes.
| /** Page size and sort the cursor was minted for; a cursor belongs to one query. */ | ||
| limit: number | ||
| sort: 'relevance' | 'newest' | ||
| hosts: Record<string, MergedSearchCursorEntry> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,120p' src/main/ipc/ai-vault-search-merged-cursor.ts
sed -n '55,100p' src/main/ipc/ai-vault-search-all-hosts.ts
sed -n '285,330p' src/main/ipc/ai-vault-search-all-hosts.test.tsRepository: stablyai/orca
Length of output: 5256
🏁 Script executed:
sed -n '1,240p' src/main/ipc/ai-vault-search-all-hosts.ts
printf '\n--- search request and host bindings ---\n'
rg -n --context 5 "type AiVaultSearchRequest|interface AiVaultSearchRequest|search\\(|fetchHostPage|cursor|offset|filters" src/main/ipc -g '*ai-vault-search*' -g '*.ts'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
fd -i 'session-search|ai-vault-search' src
printf '\n--- request type and index search definitions ---\n'
rg -n --glob '*.ts' "export type AiVaultSearchRequest|interface AiVaultSearchRequest|class .*Search|function .*search|query.*filters|request\\.query|request\\.filters" src/shared src/main/ai-vault-search src/main/ipc/ai-vault-search* 2>/dev/null | head -240Repository: stablyai/orca
Length of output: 12382
🏁 Script executed:
sed -n '1,190p' src/main/ipc/ai-vault-search.ts
printf '\n--- host search service and cursor contract ---\n'
sed -n '1,210p' src/main/ai-vault-search/session-search-service-registry.ts
sed -n '1,180p' src/main/ai-vault-search/session-search-page-cursor.ts
printf '\n--- engine request and cursor use ---\n'
sed -n '70,175p' src/main/ai-vault-search/session-search-engine.ts
sed -n '1,90p' src/shared/ai-vault-search-types.tsRepository: stablyai/orca
Length of output: 18948
🏁 Script executed:
rg -n --context 10 "SessionSearchCursorError|different-query|stale-cursor|malformed-cursor|current\\.search|search\\(request" src/main/ai-vault-search src/shared/ai-vault-search-contract.ts src/shared/ai-vault-search-client.tsRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
sed -n '215,330p' src/main/ipc/ai-vault-search-all-hosts.ts
sed -n '20,100p' src/main/ai-vault-search/session-search-service.tsRepository: stablyai/orca
Length of output: 5892
Bind the merged cursor to the complete search request.
The merged cursor validates only limit, sort, and host IDs. It does not validate query, scope, or the other result-affecting filters. The changed-query test also does not change query.
The per-host engine rejects its cursor as different-query, but fetchHostPage converts every non-result response into a stale host. mergedSearchResponse then returns a successful empty result instead of malformed-cursor. Store and validate a stable fingerprint of all result-affecting request fields, and add a changed-query case that requires malformed-cursor.
| executionHostId: LOCAL_EXECUTION_HOST_ID, | ||
| search: (request) => searchSessionService(request, 'ipc') | ||
| } | ||
| const sshLegs = getActiveSshAiVaultHostInfosResult().hostInfos.map(({ targetId }) => |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve host-discovery failures in the all-host response.
Both discovery calls return an issue when enumeration throws, but this code reads only hostInfos. A failed SSH or runtime enumerator therefore removes that host class and returns a successful merged search with no failure outcome. This causes silent false negatives for the all scope.
Carry the discovery issue into an explicit partial/failure response state, or fail the request. Add coverage for throwing SSH and runtime enumerators. The host-discovery contract already exposes this case through issue.
Also applies to: 115-115
…ai#20670) * feat(session-history): add local search settings and index controls * Use shared local host identifier for session index status * feat(session-search): merge all-computers search across hosts The `all` scope on `aiVault:searchSessions` now fans out from the desktop to every host the session list enumerates and merges the pages into one. Legs run in parallel: the local index through the search service, SSH and runtime hosts through the existing remote search client. Two fixed orders, because relevance scores from independent indexes are not comparable. `newest` asks every leg for recency and k-way merges on `updatedAt`, nulls last, ties broken on execution host id. `relevance` rotates hosts in host-id order by their own rank. The merged cursor is an opaque base64url payload holding each host's cursor, how many of its current page were already emitted, and the generation that offset counts into, plus the page size and sort the cursor belongs to. A host whose index moved is fenced to `stale` and stops contributing; the rest keep paging. Per-host outcomes ride back on one new optional `hosts` field on the results response. `aiVault:searchStatus` with `all` stays refused, and neither the runtime RPC nor the CLI gains the scope, so a fan-out is never two hops. * fix(preload): let the search bridge address the all-computers scope * feat(settings): live index status, enable confirm, advanced delete * fix(settings): let Button and Collapsible own their spacing and type

What it does
Searching Agent Session History with the All computers scope now answers, instead of being refused.
aiVault:searchSessionswith scopeallfans out from the desktop to every host the session list already enumerates, and merges the pages into one paginated answer with per-host outcomes.The design, in five lines
aiVault:searchStatuswithallstays refused, and neither the runtime RPC nor the CLI gains the scope, so a merge is never two hops). The local leg goes throughsearchSessionService, remote legs through the existingremoteSearchClient, all in parallel with the existing per-host timeout.newestforces recency on every leg and k-way merges onupdatedAt, nulls last, ties broken on execution host id.relevancerotates hosts in host-id order by their own rank, because scores from independent indexes are not comparable.malformed-cursor.staleand contributes nothing more while the other hosts keep paging. At most three host pages per host per merged request;freshnesspasses through unchanged.hostsfield on theresultsresponse carriessearched,stale,disabled,not-ready,no-serviceorunreachable. MergedhasMoreis true if any host has more or any host was unreachable, so the next page retries it. No new opcode, no new RPC method, no other contract change.Validation
The acceptance fixture builds three real
SessionSearchInstanceindexes over real transcripts in temp directories and wires them as three legs, then proves full pagination at limit 5 and limit 20 in both sort modes, a purge fencing one host mid-walk, an unreachable leg retried on the next page, and refused cursors. A 15-mutant sweep over the merge and cursor logic killed every mutant.Base
This targets #20582 (
session-search-settings-ui), notmain, because it builds on that branch's local search settings and index status. It will be rebased ontomainafter #20582 merges.