Repository navigation
feat(session-search): enable indexing on paired servers from a client - #20886
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.
…gs-ui # Conflicts: # src/renderer/src/i18n/locales/en.json
… session-search-all-hosts
# Conflicts: # src/renderer/src/components/right-sidebar/AiVaultSessionRow.test.tsx # src/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsx # src/renderer/src/i18n/locales/en.json
…ession-search-panel-all-hosts-2 # Conflicts: # src/renderer/src/i18n/locales/en.json
The panel's "All computers" scope produced no request: the hook parsed the scope into a single host id and stopped when that was null, so the panel answered "Choose one computer to search its sessions." The desktop already merges every enumerated host behind `aiVault:searchSessions`, so pass the scope straight through and stamp each hit with the host it came back on. Hosts the merge could not search are named under the results header with a short reason, since a silent partial answer reads as "no such session". (cherry picked from commit c6b9179)
Adds `aiVault.setSearchEnabled` so a desktop can turn a paired Orca server's transcript index on or off and have the server apply it without a restart. The runtime method refuses any caller without a `pairedDeviceId` with a `forbidden`-class error, writes the whole resolved policy through the runtime store so retention rides along untouched, then reaches the index through a host-supplied hook: `applySessionSearchSettingsChange` on the desktop, the in-process instance's new `apply` on orcad. The relay is unchanged. Wire compatibility is Rule 1 shaped: a new optional method. A server that predates it answers method-not-found, which the desktop IPC handler maps to an error whose message is exactly `host-too-old`. Old clients never call it. The method is deliberately absent from the mobile allowlist, and `aiVaultSearch` stays out of the paired settings projection. (cherry picked from commit 640c715)
… host-too-old on status reads (cherry picked from commit 1463e8a)
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Consent contract —
AiVaultSetSearchEnabledParamsSchema({ enabled: boolean }) shared type and the regenerated RPC params catalog entry. - Runtime RPC method —
aiVault.setSearchEnabledrefuses any caller withoutpairedDeviceId(structuredforbidden), writes the setting throughruntime.setSessionSearchEnabled, logs the device id, and answers with the host's status. - Runtime service controller — new
RuntimeSessionSearchSettingsController.setEnabledpreserves retention on the write and hands the host a(before, after)pair through the existing command surface. - Desktop IPC + preload —
aiVault:setSearchEnabledmaps local/SSH/unroutable/non-boolean to refusals and an unknown method to the literalhost-too-old; web preload rejects. - Host wiring — desktop/headless reuse
applySessionSearchSettingsChange; orcad wired through a newapplyon the in-process service with a sharedchangedAiVaultSearchSettingsdedupe. - Status read change — runtime-host
searchStatusnow callsaiVault.searchStatusdirectly and throwshost-too-oldon an unknown method instead of reportingunavailable.
The consent boundary holds. pairedDeviceId reaches a handler only through dispatchStreaming, whose sole pairedDeviceId-bearing ingress is the device-token-validated WebSocket path; the unary dispatch (Unix socket, renderer IPC, CLI helpers) never populates it. Mobile callers are refused by MOBILE_RPC_METHOD_ALLOWLIST before dispatch, and the only production runtime hosts both wire the apply hook. The runtimeHostStatus redaction with 'relay' matches aiVault.searchStatus and is safe because paired callers always carry clientKind.
ℹ️ Two observations, no action requested
- The new method and the
host-too-oldmapping have no cross-version wire case (tests/e2e/cross-version-wire/only exercisesaiVault.listSessions/prepareSessionResume). The PR body explains there was no aiVault search case to extend, so this is a note rather than a gap that needs filling here. - The web preload's
unsupportedrefusal is renderer-level only: a paired browser receives aruntime-scope device token, so the raw RPC is admitted server-side. That is still an authenticated paired client, so it is not a boundary hole — just worth knowing the effective server rule is "paired, non-mobile".
Technical details
# Verification notes
## Gating
- `src/main/runtime/rpc/methods/ai-vault.ts:43` — handler refuses when `pairedDeviceId` is falsy.
- `src/main/runtime/rpc/dispatcher.ts:95` — unary context omits `pairedDeviceId`; only `runtime-rpc-websocket-dispatch.ts:140` supplies it, from a `deviceRegistry.validateToken`-validated token.
- `src/main/runtime/runtime-rpc/runtime-rpc-websocket-dispatch.ts:76` — `clientKind: 'mobile'` gate against `MOBILE_RPC_METHOD_ALLOWLIST`, which omits this method.
## Apply path
- `src/main/runtime/runtime-session-search-settings.ts:25` — write preserves `historyDays` via `resolveAiVaultSearchSettings(before)`, then applies.
- `src/main/startup/main-process-runtime-service.ts:139` and `src/main/orcad/orcad-entry.ts:256` are the two production hosts, both wire the hook.
- `src/main/ai-vault/session-search-enablement.ts:45` now shares `changedAiVaultSearchSettings`, so an unchanged write cannot restart the index.
## Redaction / schema
- `src/shared/ai-vault-search-contract.ts:115` — `degradedRoots[].root` is optional, so `redactStatusForTransport` output still parses.
- `src/main/ipc/ai-vault-search.ts:106` parses the host answer but does not re-redact; correct because the server already redacted (`clientKind ? 'relay' : 'runtime'`).
## `forbidden` passthrough
- `src/main/runtime/rpc/errors.ts:135` only affects errors thrown through `mapRuntimeError`. The other `code: 'forbidden'` throw (`runtime-browser-commands-browser-tab-create.ts:58`) goes through `mapBrowserError`, which already forwarded all structured codes, so no existing method's error code changes.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
📝 WalkthroughWalkthroughThe change adds per-host search consent updates through runtime RPC, IPC, and preload APIs. Runtime settings persistence updates only the Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A paired-host response may expose degraded filesystem paths. Confirm or enforce redaction before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 0182de47-e410-4973-8a80-e1564c5ae158
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (23)
src/main/ai-vault-search/session-search-enablement.tssrc/main/ai-vault-search/session-search-host-registration.test.tssrc/main/ai-vault-search/session-search-in-process-service.tssrc/main/ipc/ai-vault-search.test.tssrc/main/ipc/ai-vault-search.tssrc/main/orcad/orcad-entry.tssrc/main/orcad/orcad-session-search.tssrc/main/runtime/orca-runtime-state-fields.tssrc/main/runtime/rpc/errors.tssrc/main/runtime/rpc/methods/ai-vault-search.test.tssrc/main/runtime/rpc/methods/ai-vault.tssrc/main/runtime/runtime-service-command-surface.tssrc/main/runtime/runtime-session-search-settings.test.tssrc/main/runtime/runtime-session-search-settings.tssrc/main/runtime/runtime-store-contract.tssrc/main/startup/main-process-runtime-service.tssrc/preload/api/ai-vault-api.tssrc/preload/api/ai-vault-bridge.tssrc/renderer/src/web/preload-api/web-ai-vault-api.tssrc/shared/ai-vault-search-client.tssrc/shared/ai-vault-search-contract.tssrc/shared/ai-vault-search-settings.tssrc/shared/ai-vault-search-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| return AiVaultSearchStatusSchema.parse( | ||
| await call(environmentId, 'aiVault.setSearchEnabled', { enabled }) | ||
| ) |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick win
Information Disclosure
Reachability: External
Exploitability: Moderate
CWE: CWE-200 — Exposure of Sensitive Information to an Unauthorized Actor
Redact the paired-host status before returning it.
This path validates the runtime status but returns degradedRoots[].root unchanged through IPC. A paired client can invoke setSearchEnabled and receive remote filesystem paths when the host is degraded. Apply redactStatusForTransport(..., 'relay') before returning the status, as runtimeHostStatus already does.
Proposed fix
- return AiVaultSearchStatusSchema.parse(
- await call(environmentId, 'aiVault.setSearchEnabled', { enabled })
+ return redactStatusForTransport(
+ AiVaultSearchStatusSchema.parse(
+ await call(environmentId, 'aiVault.setSearchEnabled', { enabled })
+ ),
+ 'relay'
)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return AiVaultSearchStatusSchema.parse( | |
| await call(environmentId, 'aiVault.setSearchEnabled', { enabled }) | |
| ) | |
| return redactStatusForTransport( | |
| AiVaultSearchStatusSchema.parse( | |
| await call(environmentId, 'aiVault.setSearchEnabled', { enabled }) | |
| ), | |
| 'relay' | |
| ) |
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, stablyai#20986), so that layer is now upstream's: `searchAllExecutionHosts` over `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…stablyai#20886) * feat(session-search): add ranked history panel search and consent * test: wait for initial session indexing before refreshing results * 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 * feat(session-search): search every computer from the history panel The panel's "All computers" scope produced no request: the hook parsed the scope into a single host id and stopped when that was null, so the panel answered "Choose one computer to search its sessions." The desktop already merges every enumerated host behind `aiVault:searchSessions`, so pass the scope straight through and stamp each hit with the host it came back on. Hosts the merge could not search are named under the results header with a short reason, since a silent partial answer reads as "no such session". (cherry picked from commit c6b9179) * feat(session-search): enable indexing on paired servers from a client Adds `aiVault.setSearchEnabled` so a desktop can turn a paired Orca server's transcript index on or off and have the server apply it without a restart. The runtime method refuses any caller without a `pairedDeviceId` with a `forbidden`-class error, writes the whole resolved policy through the runtime store so retention rides along untouched, then reaches the index through a host-supplied hook: `applySessionSearchSettingsChange` on the desktop, the in-process instance's new `apply` on orcad. The relay is unchanged. Wire compatibility is Rule 1 shaped: a new optional method. A server that predates it answers method-not-found, which the desktop IPC handler maps to an error whose message is exactly `host-too-old`. Old clients never call it. The method is deliberately absent from the mobile allowlist, and `aiVaultSearch` stays out of the paired settings projection. (cherry picked from commit 640c715) * fix(session-search): report a paired server without session search as host-too-old on status reads (cherry picked from commit 1463e8a) * fix(settings): let Button and Collapsible own their spacing and type
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.
…on index Agent Session History was a filesystem walk plus a parse of every transcript it found, so one load cost O(corpus) in readdirs, stats and reads on every scan. The index already holds one row per session with everything a row renders, so a list is now one indexed read. The scanner stays as the fallback for a host where no pass has completed or `node:sqlite` is absent, and it now applies the same plain-text query the index would, because an unfiltered answer would read as "everything matches". Search gains a metadata tier: - Metadata (a `sessions` row plus `sessions_fts` over titles, working directories, branches and agent names) is always indexed and answers with `evidence: null` — there is no transcript text to quote and none is fabricated. Content (`messages`, `messages_fts`) stays opt-in. The pre-tier `enabled` flag named that same consent, so a profile that recorded it keeps it as `contentEnabled` rather than having the question silently re-opened, and `status.enabled` now means only that an index exists and runs. The index writer takes that consent as `storeContent`, so a metadata-only index stores no message rows at all rather than storing and hiding them, and drops the `sessions_fts` row wherever it drops the session row. The scanner service protocol grows `refresh` and `query` so a host can answer the panel's list itself; both sides call `aiVaultHostListQuery`, so what the client sends and what the host accepts cannot drift. Remote scanning gains a Copilot source that walks a session directory without descending into the artifact trees beside `events.jsonl`, which hold no sessions and cost a readdir each. Rebased onto upstream 2026-09-18. Upstream landed its own all-computers search merge in these same files (stablyai#20582, stablyai#20753, stablyai#20754, stablyai#20870, stablyai#20886, stablyai#20887, `SessionSearchHostLeg`s, walking each host page by page and merging on recency and round-robin ranking with an encoded merged cursor. This commit's own fan-out was dropped rather than left to diverge with it — `ai-vault-search-all-hosts.ts`, `-host-fanout.ts` and their tests now follow upstream, and the fork's `ai-vault-search-merged-order.ts`, `ai-vault-search-status-aggregation.ts`, `session-search-rank-fusion.ts` and their tests are gone. What survives is what upstream has no equivalent of: the metadata FTS tier, the indexed list, the service `query`/`refresh` protocol, and the Copilot source. `contentEnabled` stays as an additive, optional status field. Re-porting per-host status vocabularies and reciprocal-rank fusion onto upstream's engine is deliberately left open, not lost. Wire compatibility: `contentEnabled` is additive and optional, so an older peer ignores it, and a host that predates the list `query` answers the scan request it already understood. See docs/reference/agent-session-search-contract.md and docs/reference/remote-wire-compatibility.md.
Two breaks the convergence onto upstream's all-hosts engine left behind, both found by tests rather than by reading the diff: - The index writer gated `add` on `released || fenced || closed || !storeContent` and called `discard()` on the way out. `discard()` marks the write released and `commit()` gates on that, so a metadata-only index never wrote its session row and the list answered empty. The content skip is now its own early return, ahead of the released check, and keeps the session row. - Upstream's per-host "enable indexing" toggle (stablyai#20886) writes `aiVaultSearch: { ..., enabled }` — a field this fork no longer has, because the commit that added the metadata tier renamed that consent to `contentEnabled` and made metadata always-on. The toggle was a no-op against AiVaultSearchSettings. `setEnabled` now writes `contentEnabled`, so a paired client turns the content tier on and off for that host while its metadata keeps answering. The registration test asserts that, instead of the `disabled` verdict that no production path produces any more.

Reopens #20727, which GitHub auto-closed as merged when its base branch
session-search-verifyabsorbed it. Same commits, cherry-picked onto the stack.What and why
A desktop client can now turn Agent Session History indexing on or off on a paired Orca server (runtime host), and the server applies the change immediately without a restart. Before this, consent for a remote host's index could only be set by someone sitting at that host.
SSH hosts are out of scope here and are refused client-side.
Contract
Shared —
AiVaultSetSearchEnabledParamsSchema = z.object({ enabled: z.boolean() })insrc/shared/ai-vault-search-contract.ts, withAiVaultSetSearchEnabledParamsinferred inai-vault-search-types.ts. The response is the existingAiVaultSearchStatus.Runtime RPC —
aiVault.setSearchEnabledinsrc/main/runtime/rpc/methods/ai-vault.ts. It is registered through the generated params catalog (pnpm run generate:rpc-params-catalog), deliberately not added toruntime-rpc-mobile-method-allowlist.ts, andaiVaultSearchis not added to the paired settings projection.Runtime service —
setSessionSearchEnabled(enabled): Promise<void>, owned by the newRuntimeSessionSearchSettingsControllerand exposed onOrcaRuntimeServicethrough the existing service command surface. It reads the current settings, writesaiVaultSearch: { ...resolveAiVaultSearchSettings(current), enabled }so retention rides along untouched, then hands(before, after)to a host-supplied hook.Desktop IPC + preload —
aiVault:setSearchEnabledinsrc/main/ipc/ai-vault-search.ts, reached fromsetSearchEnabled(executionHostId, enabled)on the preload bridge, the preload type, and the web preload (which rejects withunsupported).Gating decision
The method refuses unless
context.pairedDeviceIdis set. In-process and undefined callers get a structuredforbiddenerror, which required adding'forbidden'to the runtime error passthrough set so a method-level refusal reads the same as the transport-level mobile-allowlist refusal. The server logs one line naming the paired device id and the new value as an audit trail.Note that
pairedDeviceIdonly reaches a handler throughdispatchStreaming, which is the path the WebSocket transport a paired client connects over actually uses. The unarydispatchpath is the local Unix socket, which has no paired device and is therefore correctly refused.One deviation from the brief, deliberate. The brief specified
sessionSearchServiceStatus({}, 'runtime'). This shipsclientKind ? 'relay' : 'runtime', matchingaiVault.searchStatusexactly. BecausepairedDeviceIdandclientKindare always set together by the WebSocket dispatcher, the'runtime'transport would have returned unredacteddegradedRoots[].roothost filesystem paths to every remote caller, whilesearchStatuson the same surface redacts them. The response type is identical either way, so the preload contract the settings UI is being built against is unaffected. A test covers the redaction.Host wiring
main-process-runtime-service.ts) passapplySessionSearchSettingsChangeitself, so a paired client's write and a local settings write reconcile the scanner child through one code path.orcad-entry.ts) reaches its in-process index through the newapply(settings)oninstallInProcessSessionSearchService. BecauseSessionSearchInstance.applycloses and reconstructs unconditionally, orcad dedupes with the new sharedchangedAiVaultSearchSettingshelper, whichapplySessionSearchSettingsChangenow also uses.relay-runtime-services.ts) is unchanged and registers no such method.Wire compatibility
Rule 1: a new optional method, no protocol bump. A server that predates it answers method-not-found, and the desktop maps it through the same
-32601/method_not_foundpredicate the search client uses to an error whosemessageis exactlyhost-too-old, so the UI can map it to its own copy. Old clients never call it.callRuntimeSessionSearchdoes not restrict method names, so no change was needed there.No case was added to the cross-version wire suite: nothing in
tests/e2e/cross-version-wire/coversaiVault.searchStatusor any otheraiVault.*search method today, so there was no existing case to extend.Tests
rpc/methods/ai-vault-search.test.ts): refuses an unpaired caller withforbiddenand never touches the setting; a paired call applies once and answers with this host's status; host roots are withheld from a paired client; a runtime with no settings store answersruntime_unavailable, which also proves the command surface really installed the method; a non-boolean is rejected before reaching the runtime.runtime-session-search-settings.test.ts): writes the whole policy with retention preserved and hands the hostbefore/afterexactly once; normalizes an absent stored policy; an unchanged value still writes but hands the host an unchanged pair; no store meansruntime_unavailable.ipc/ai-vault-search.test.ts): a runtime host forwards{enabled}and returns the parsed status without touching the local index; unknown-method maps tohost-too-oldwhile every other failure is preserved; a non-status answer is rejected; local, SSH, unroutable hosts and a non-boolean are all refused; no injected runtime transport reportshost-too-old.session-search-host-registration.test.ts):applyflips a live service between disabled and answering without reinstalling it, plus a wiring assertion that orcad's runtime hook reaches it.Gate output
Also green:
verify:rpc-params-catalog,check:max-lines-ratchet,check:ts-nocheck-ratchet,check:reliability-gates, and the four localization verifiers.