Repository navigation
feat(session-search): search every computer from the history panel - #20885
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)
There was a problem hiding this comment.
Important
The merged cursor is missing the index-incarnation fence this PR adds for single-host cursors. A merged search resumed mid-host-page ({c: null, e > 0}) re-queries the host with no cursor, so a rebuilt index whose numeric generation repeats can silently drop or duplicate hits. Details inline.
Reviewed changes — all 41 files against session-search-panel-ui at 3a35869.
- All-computers merge (
ai-vault-search-all-hosts.ts,ai-vault-search-merged-cursor.ts,ai-vault-search.ts): one query fans out to the local service plus every enumerated SSH/runtime host, merged by recency or round-robin, with an opaque per-host{c,e,g}cursor and a new optionalhostsoutcome array on the response. - Cursor incarnation (
session-search-page-cursor.ts,session-search-schema.ts,session-search-index-generation.ts,session-search-engine.ts): opaque cursors carry a persistedindex_incarnationso a clear or rebuild invalidates them even when the generation counter collides. - Panel scope widening (
use-ai-vault-search.ts,AiVaultPanelSearch.tsx, preload and websearchSessions): theallscope now reaches the desktop merge, hits are stamped with the host that returned them, and unsearched hosts are named under the results header. - Desktop index controls (
SessionHistoryIndexStatus.tsx,SessionHistorySettingsPane.tsx, settings navigation,en.json): live index status, an opt-in confirmation, and an Advanced delete-index action. - Tests: new suites for the merge (real indexes and stubs), merged-cursor round-trip, clear fencing, panel attribution, and settings polling/clear.
ℹ️ A merged walk never terminates while a host stays unreachable
A leg that fails sets carry: true (ai-vault-search-all-hosts.ts:136) and nextCursorEntry re-emits that entry on every request (:278); hasMore is simply "any cursor entry exists" (:257). If one host is permanently down, every page returns hasMore: true and a client that pages until hasMore === false never stops. The manual "Load more" UI makes this tolerable, but it is worth deciding whether indefinite retry is intended or a retry bound / terminal outcome is wanted.
Technical details
# Persistent unreachable host keeps the merged walk open
## Affected sites
- `src/main/ipc/ai-vault-search-all-hosts.ts:132-136` — every leg failure becomes `endHostWalk(walk, 'unreachable', true)`.
- `src/main/ipc/ai-vault-search-all-hosts.ts:270-279` — the `carry` entry is re-emitted indefinitely.
- `src/main/ipc/ai-vault-search-all-hosts.ts:257` — `hasMore` ignores `walk.outcome`.
## Required outcome
Either bound the retries for a host that never answers (a terminal outcome after N attempts) or document explicitly that a merged walk does not terminate while a host is unreachable.ℹ️ Nitpicks
- The disabled-clear branch the settings UI advertises ("Search stays off", button enabled) is untested below the UI:
session-scanner-service-search.test.tsclears only while enabled,session-scanner-service-search-roots.test.ts:78-82asserts the throw but never callsapply(), andSessionHistorySettingsPane.test.tsxmocksclearSearchIndex. A service test that applies{enabled: false}and then clears would pinsession-scanner-service-search.ts:52.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| } | ||
| // `e` is an offset into one generation's ranked page, so it is only | ||
| // meaningful while that generation stands. Nothing emitted, nothing to fence. | ||
| if (walk.emitted > 0 && walk.generation !== response.generation) { |
There was a problem hiding this comment.
When c === null and e > 0 (a host's first page was only partially drained), the resume at nextCursorEntry (:273) stores no cursor string, so the host is queried with no cursor and decodeSessionSearchCursor's incarnation check never runs. The only fence left is this numeric g comparison, and session-search-instance.test.ts:184 asserts a clear/rebuild can reproduce the same generation — so a rebuild here is accepted and slice(e) silently drops or duplicates hits.
Technical details
# Merged cursor lacks the index incarnation fence
## Affected sites
- `src/main/ipc/ai-vault-search-all-hosts.ts:150` — only fence on a resumed partial host page is numeric `g`; a rebuilt index can repeat it.
- `src/main/ipc/ai-vault-search-all-hosts.ts:271-278` — `nextCursorEntry` stores `{c: walk.cursor, e, g}` with `c === null` for a host's first page.
- `src/main/ipc/ai-vault-search-all-hosts.ts:120-129` — with `c === null` no cursor is sent, so `session-search-page-cursor.ts:107-110` cannot fire.
- `src/main/ipc/ai-vault-search-merged-cursor.ts:9-13` — `MergedSearchCursorEntry` has no field for a host index identity.
## Required outcome
A resume that skips `e` hits inside a host page must be treated as stale when that host's index database identity changed, even when the numeric generation is unchanged. The `carry` entry at `:278` needs the same treatment.
## Suggested approach
Carry a per-host database identity in the merged cursor entry and compare it alongside `g`. The host already computes it (`readIndexIncarnation`); expose it additively on the host results response (an optional field is wire-compatible) or fold it into the opaque host cursor, and record it next to `g`.
## Open questions for the human
Is settings `Delete index` the only way the incarnation changes while a panel search can stay mounted? `openSessionSearchDatabase` also recreates the database on a corrupt/stale open, so the window is not purely settings-driven.|
|
||
| Disabling closes the indexer and keeps the index copy; clearing deletes the copy. | ||
| Changing retention reuses the existing close-and-construct policy application. | ||
| The settings pane reads status only while enabled and visible, polls only an |
There was a problem hiding this comment.
This paragraph describes the opposite of the shipped SessionHistoryIndexStatus: it polls a settled index at SETTLED_POLL_MS (10 s) and recovers after a failed read (SessionHistoryIndexStatus.test.tsx pins both), and the pane has no Refresh control. Please drop the "stops on completion or error" and "pressing Refresh" claims.
📝 WalkthroughWalkthroughThe AI Vault search API now accepts Priority: ➖ Normal Merge Risk: 🔵 Low · up to Non-English users will see English skipped-host reasons in the search status. Localize these labels before merge to keep the panel consistently translated. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the change, motivation, linked issue, implementation, testing, and the reason no E2E test was added. However, it omits the required Visual Proof section for this UI behavior change and does not include the template checklist or explicit manual-testing status. Resolution Add a Visual Proof section with before-and-after screenshots or videos, or write N/A with a brief reason if visual proof is not applicable. Add the required checklist sections and mark the applicable testing, review, cross-platform, and build-validation items. Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 7 files. (1 skipped: 1 unsupported.)
✨ 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: 7ea70ee8-6697-4486-879b-93addcab9ee0
📒 Files selected for processing (8)
src/preload/api/ai-vault-api.tssrc/renderer/src/components/right-sidebar/AiVaultPanelSearch.test.tsxsrc/renderer/src/components/right-sidebar/AiVaultPanelSearch.tsxsrc/renderer/src/components/right-sidebar/use-ai-vault-search.test.tsxsrc/renderer/src/components/right-sidebar/use-ai-vault-search.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/web/preload-api/web-ai-vault-api.tssrc/renderer/src/web/preload-api/web-ai-vault-search-compat.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| return 'index changed' | ||
| case 'disabled': | ||
| return 'search off' | ||
| case 'not-ready': | ||
| return 'not ready' | ||
| case 'no-service': | ||
| return 'unavailable' | ||
| case 'unreachable': | ||
| return 'unreachable' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,190p' src/renderer/src/components/right-sidebar/AiVaultPanelSearch.tsx
sed -n '17845,17870p' src/renderer/src/i18n/locales/en.json
rg -n "value0|hostsSkipped|search off|index changed|not ready|unreachable|chooseHost" src/renderer/src/i18n src/renderer/src/components
find .. -name AGENTS.md -o -name CONTRIBUTING.md | head -30Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
sed -n '1,120p' src/renderer/src/components/right-sidebar/AiVaultPanelSearch.tsx
printf '\n--- i18n implementation candidates ---\n'
rg -n --glob '*.ts' --glob '*.tsx' "function translate|const translate|export .*translate|useTranslation|i18next|fallbackLng|fallbackLocale|currentLocale|getLocale" src/renderer/src/i18n src/renderer/src | head -120
printf '\n--- locale files and focused keys ---\n'
find src/renderer/src/i18n -maxdepth 3 -type f | sort | head -80
rg -n --glob '*.json' '"hostsSkipped"|'"'"'not searched'"'"'|'"'"'search off'"'"'|'"'"'index changed'"'"'|'"'"'not ready'"'"'|'"'"'unavailable'"'"'|'"'"'unreachable'"'"' src/renderer/src/i18n
printf '\n--- instructions ---\n'
find . -name AGENTS.md -o -name CONTRIBUTING.md | head -30Repository: stablyai/orca
Length of output: 19283
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 30068
🏁 Script executed:
printf '%s\n' '--- component render branch ---'
sed -n '110,190p' src/renderer/src/components/right-sidebar/AiVaultPanelSearch.tsx
printf '%s\n' '--- i18n implementation ---'
sed -n '1,115p' src/renderer/src/i18n/i18n.ts
printf '%s\n' '--- focused locale entries ---'
for f in src/renderer/src/i18n/locales/*.json; do
printf '%s: ' "$f"
rg -n --max-count 2 '"hostsSkipped"' "$f" || true
done
printf '%s\n' '--- localization rules/tests ---'
rg -n --glob '*.md' --glob '*.json' --glob '*.ts' --glob '*.tsx' \
'intent[- ]named|named interpolation|placeholder|localization.*key|key.*local|translate\(.*value0|value0.*placeholder|localization catalog' \
AGENTS.md CONTRIBUTING.md src/renderer/src/i18n config scripts 2>/dev/null | head -240
printf '%s\n' '--- applicable instruction files ---'
find . -name AGENTS.md -o -name CONTRIBUTING.md | head -30Repository: stablyai/orca
Length of output: 50369
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4
Length of output: 527
🏁 Script executed:
sed -n '180,215p' config/i18n-translation-source.md
sed -n '50,70p' config/localization-audit.mdRepository: stablyai/orca
Length of output: 2415
Localize skipped-host reasons and use a named placeholder.
When results contain skipped hosts, AiVaultPanelSearch renders describeSkippedHosts. hostSkipReason inserts English labels such as index changed and search off, so non-English users receive English reason text. A translated hostsSkipped template would also produce mixed-language output.
The repository policy requires new localization keys to use intent-named IDs and named interpolation placeholders. Translate each reason with its own key, change {{value0}}/value0 to {{hosts}}/hosts, and update the English catalog entries.
…tablyai#20885) * 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) * fix(settings): let Button and Collapsible own their spacing and type

Reopens #20680, which GitHub auto-closed as merged when its base branch
session-search-verifyabsorbed it. Same commits, cherry-picked onto the stack.The Agent Session History panel's "All computers" scope produced no search at all: the hook parsed the scope down to a single execution host id and bailed when that was null, so the panel answered "Choose one computer to search its sessions."
allscope straight towindow.api.aiVault.searchSessions, which the desktop already merges across every enumerated host.sessionSearch.panel.chooseHoststring are gone.Not searched: Build box (search off) · Laptop (unreachable), from the newsessionSearch.panel.hostsSkippedstring.searchSessionstype and the web client's own-runtime check widen fromExecutionHostIdtoExecutionHostScope; the browser still answersno-serviceforall, which is now expressible instead of a@ts-expect-error.Validation
No Electron e2e case was added.
tests/e2e/ai-vault-panel-search.spec.tscannot take a two-line addition for this: exercising the merge needs the host menu switched to "All hosts" and a stubbedaiVault:searchSessionsreturning ahostsarray, which is a new test block rather than two lines.Base
This targets the
session-search-verifyintegration branch, which is main plus PR 6, PR 7, PR 8 and #20670. It will be rebased onto main once those merge.