Skip to content

feat(session-search): merge all-computers search across hosts - #20670

Merged
Jinwoo-H merged 14 commits into
mainfrom
session-search-all-hosts
Sep 16, 2026
Merged

Jinwoo-H merged 14 commits into
mainfrom
session-search-all-hosts

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​710 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​706
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​454 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​444

What it does

Searching Agent Session History with the All computers scope now answers, instead of being refused. aiVault:searchSessions with scope all fans 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

  1. Entry and legs — only the desktop fans out (aiVault:searchStatus with all stays refused, and neither the runtime RPC nor the CLI gains the scope, so a merge is never two hops). The local leg goes through searchSessionService, remote legs through the existing remoteSearchClient, all in parallel with the existing per-host timeout.
  2. Ordering — two fixed functions. newest forces recency on every leg 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, because scores from independent indexes are not comparable.
  3. Composite cursor — an opaque base64url payload, zod-validated: per host the host 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 decode failure, an unknown or unparseable host key, or a changed page size or sort is malformed-cursor.
  4. Fencing and bounds — a host that refuses its own cursor, or whose generation moved under a first-page skip count, is reported stale and contributes nothing more while the other hosts keep paging. At most three host pages per host per merged request; freshness passes through unchanged.
  5. Per-host outcomes — one new optional hosts field on the results response carries searched, stale, disabled, not-ready, no-service or unreachable. Merged hasMore is 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 SessionSearchInstance indexes 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.

$ ORCA_BACKGROUND_LAUNCH=1 pnpm tc
EXIT=0

$ ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/ipc src/main/ai-vault-search src/shared/ai-vault-search-contract.test.ts
 Test Files  441 passed | 1 skipped (442)
      Tests  4408 passed | 11 skipped (4419)

$ ORCA_BACKGROUND_LAUNCH=1 pnpm run check:code-quality:changed
code quality: 0 new finding(s) across 33 changed file(s).
casting code quality: 0 new finding(s) across 33 changed file(s).
type-aware code quality: 0 new finding(s) across 33 changed file(s).
React Doctor: 0 new finding(s) across 33 changed file(s).
casting SAFETY: rationale: 0 new finding(s) across 33 changed file(s).
Changed-code quality gate passed since c6a72169843e.

$ ORCA_BACKGROUND_LAUNCH=1 pnpm run audit:code-quality:type-aware
EXIT=0

$ ORCA_BACKGROUND_LAUNCH=1 pnpm test tests/e2e/cross-version-wire
 Test Files  7 passed (7)
      Tests  50 passed (50)

Base

This targets #20582 (session-search-settings-ui), not main, because it builds on that branch's local search settings and index status. It will be rebased onto main after #20582 merges.

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.

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

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 is malformed-cursor.
  • IPC wiring (ai-vault-search.ts, ai-vault.ts, ai-vault-all-host-timeouts.ts) — aiVault:searchSessions with scope all routes 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 optional hosts outcome array on the results response.
  • 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 generation is hardcoded 0 and legs are called with debug stripped, so a caller requesting debug: true under all silently receives no debug. Consider documenting that all does not produce debug, or omitting the field contract explicitly.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/ipc/ai-vault-search.test.ts Resolved
@pullfrog

pullfrog Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Run failed. View the logs →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

✅ 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 all scope — ai-vault-bridge.ts now types the search scope as ExecutionHostScope (leaving searchStatus narrowed to ExecutionHostId) and treats all like local for transport, so the bridged call typechecks and the merged page is no longer relay-redacted a second time.
  • Local hits keep their paths — routing all through ipc preserves the local leg's source.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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H changed the base branch from session-search-settings-ui to main September 16, 2026 16:14
@Jinwoo-H
Jinwoo-H merged commit 46ed53b into main Sep 16, 2026
28 checks passed
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The 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 f4ad9

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 ups… Complete the required template sections. Add an explicit issue link such as "Fixes #20582", provide Visual Proof or state N/A with a reason, complete the testing and checklist items, address Review, Agent skill upstream boundary, and Notes,…
Docstring Coverage ⚠️ Warning Docstring coverage is 18.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: merging All computers session searches across hosts.
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.
Full details: Description check

Explanation

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 #20582", provide Visual Proof or state N/A with a reason, complete the testing and checklist items, address Review, Agent skill upstream boundary, and Notes, and include the ELI5 and Why sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 6ec95a9f-e0c9-4dbd-8959-f09b13bb768a

📥 Commits

Reviewing files that changed from the base of the PR and between a7e34d5 and f4ad9b6.

📒 Files selected for processing (12)
  • src/main/ipc/ai-vault-all-host-timeouts.ts
  • src/main/ipc/ai-vault-search-all-hosts-real-index.test.ts
  • src/main/ipc/ai-vault-search-all-hosts.test.ts
  • src/main/ipc/ai-vault-search-all-hosts.ts
  • src/main/ipc/ai-vault-search-merged-cursor.test.ts
  • src/main/ipc/ai-vault-search-merged-cursor.ts
  • src/main/ipc/ai-vault-search.test.ts
  • src/main/ipc/ai-vault-search.ts
  • src/main/ipc/ai-vault.ts
  • src/preload/api/ai-vault-bridge.ts
  • src/shared/ai-vault-search-contract.ts
  • src/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

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.

🗄️ 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

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.

🎯 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.

Comment on lines +16 to +19
/** Page size and sort the cursor was minted for; a cursor belongs to one query. */
limit: number
sort: 'relevance' | 'newest'
hosts: Record<string, MergedSearchCursorEntry>

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.

🎯 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.ts

Repository: 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 -240

Repository: 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.ts

Repository: 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.ts

Repository: 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.ts

Repository: 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 }) =>

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.

🎯 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

ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
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