Repository navigation
fix(session-search): index OpenCode SQLite sessions - #20870
Conversation
OpenCode sessions live in one SQLite database read on a worker thread, and the worker only ever answered with the newest few messages for the panel preview. The parser therefore published nothing over the transcript channel, so the search index wrote a placeholder row for every OpenCode candidate and no OpenCode message was ever searchable. Adds a `capture` request to the worker protocol that returns the session and every text part of every user/assistant turn from one open of the database. The agent parser asks for it whenever a sink is listening, so OpenCode joins the whole-document sources on the same path as Grok, Cursor and Gemini. The placeholder path (`parserPublishesMessages`, `noteUnreachableParser`) is gone; an OpenCode read that fails now fails like any other file. Bumps the index schema so existing indexes drop their placeholder rows, and adds `sessionsByAgent` to the index status, which is the count that made this bug visible.
OpenCode has two storage shapes, so asking only that some OpenCode session published messages was satisfied by the legacy JSON fixture while every SQLite session in the vault stayed silent. Assert per discovered source and keep the agent-coverage check beside it.
There was a problem hiding this comment.
Important
A schema-probe failure still commits the session as indexed with empty messages — the unsearchable-but-counted shape this PR removes, and the one sessionsByAgent is meant to expose. Details inline.
Reviewed changes
- Capture channel. New
capturekind on the OpenCode SQLite worker protocol returns{ session, messages }from a single open of the database:readOpenCodeSqliteSessionfor the panel andreadOpenCodeSessionMessagesfor everyuser/assistanttype:'text'part, joined into oneTranscriptMessagepermessagerow. - Routing.
readOpenCodeSqliteCandidaterequestscapturewhen a sink is attached andparseotherwise, keeping a list scan preview-only; OpenCode SQLite stays onreadWholeTranscript. - Decline machinery removed.
parserPublishesMessages, the index consumer's unreachable branch /noteUnreachableParser, andsession-search-opencode-decline.test.tsare deleted;readWholeTranscriptnow always reportsincomplete: false. - Diagnostic and schema.
sessionsByAgentadded to store counts, indexer status, and the wire schema (optional); index schema version bumped 5→6 to drop the old placeholder rows. - Tests and fixtures. New end-to-end
session-search-opencode-index.test.tsand per-sourcesession-transcript-every-agent-capture.test.ts; per-agent layouts lifted into shared fixture modules, andwriteJsonlFile/jsonlBodynow newline-terminate the last record.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds OpenCode SQLite transcript capture through the scanner worker and publishes captured messages. It removes the previous non-publishing parser guard. Search indexing now reports session counts by agent and rebuilds indexes with schema version 6. Shared fixtures cover supported agent layouts and OpenCode database updates. Tests cover transcript publication, indexing, reconciliation, status counts, and fixture behavior. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Very large OpenCode messages can lose searchable suffixes, and concurrent updates can briefly expose stale transcript data; both risks are bounded. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the bug, cause, implementation, and testing in detail, but it does not follow several required template sections. It omits the mandatory linked issue, Visual Proof with an explicit N/A when applicable, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections. Resolution Add the missing template sections. Include a valid issue reference under Linked Issue, write ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8baf0a24-7981-4df7-b75e-671a92dbe629
📒 Files selected for processing (28)
src/main/ai-vault-search/session-search-deleted-sources.test.tssrc/main/ai-vault-search/session-search-index-consumer.tssrc/main/ai-vault-search/session-search-indexer.tssrc/main/ai-vault-search/session-search-opencode-decline.test.tssrc/main/ai-vault-search/session-search-opencode-index.test.tssrc/main/ai-vault-search/session-search-schema.tssrc/main/ai-vault-search/session-search-service.test.tssrc/main/ai-vault-search/session-search-store.tssrc/main/ai-vault/session-scanner-agent-parser.tssrc/main/ai-vault/session-scanner-document-agent-fixtures.tssrc/main/ai-vault/session-scanner-every-agent-fixture.tssrc/main/ai-vault/session-scanner-fs-import-guard.test.tssrc/main/ai-vault/session-scanner-log-agent-fixtures.tssrc/main/ai-vault/session-scanner-opencode-sqlite-capture.tssrc/main/ai-vault/session-scanner-opencode-sqlite-fixture.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-client.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-entry.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-protocol.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-response.tssrc/main/ai-vault/session-scanner-opencode-sqlite-worker-spawn.tssrc/main/ai-vault/session-scanner-opencode-sqlite.tssrc/main/ai-vault/session-scanner-test-fixtures.tssrc/main/ai-vault/session-scanner-vault-roots.tssrc/main/ai-vault/session-scanner.test.tssrc/main/ai-vault/session-transcript-consumers.test.tssrc/main/ai-vault/session-transcript-every-agent-capture.test.tssrc/main/ai-vault/session-transcript-reader.tssrc/shared/ai-vault-search-contract.ts
💤 Files with no reviewable changes (3)
- src/main/ai-vault-search/session-search-deleted-sources.test.ts
- src/main/ai-vault-search/session-search-opencode-decline.test.ts
- src/main/ai-vault-search/session-search-index-consumer.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| let openTimestamp: string | null = null | ||
|
|
||
| const flush = (): void => { | ||
| const text = openRole && openParts.length > 0 ? boundedText(openParts.join('\n')) : null |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Do not truncate oversized OpenCode messages.
extractPartText accepts strings of any length, and the capture limit applies only to the number of parts. A joined message can therefore exceed 262,144 UTF-16 code units. boundedText keeps only its prefix before search indexing. User and assistant text is then chunked normally, so the affected message remains indexed but terms and evidence in its suffix are unavailable. If the retained prefix is whitespace, boundedText drops the entire message.
- const text = openRole && openParts.length > 0 ? boundedText(openParts.join('\n')) : null
+ const joined = openParts.join('\n')
+ const text = openRole && joined.trim() ? joined : null📝 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.
| const text = openRole && openParts.length > 0 ? boundedText(openParts.join('\n')) : null | |
| const joined = openParts.join('\n') | |
| const text = openRole && joined.trim() ? joined : null |
| const session = readOpenCodeSqliteSession({ db, ...args }) | ||
| // No session row is no transcript: the id names nothing in this database. | ||
| return { session, messages: session ? readOpenCodeSessionMessages(db, args.sessionId) : [] } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Use one SQLite read transaction for the capture.
captureOpenCodeSqliteSession reads session.time_updated and the message rows with separate statements. A concurrent append can therefore commit between them. The index can commit older session metadata with newer transcript rows and briefly mark that old candidate generation current. The next reconciliation sees the moved time_updated and replaces the rows, so the append is not permanently omitted.
Run both reads inside one read transaction. Roll back the transaction if either read fails.
Text parts alone left OpenCode behind every file-based provider: a command someone ran, what it printed, and the model's reasoning were all unsearchable. Widens the capture query to text, reasoning and tool parts. Reasoning folds into the turn's own words, the way the shared block list already treats a thinking block. Each tool part becomes one `tool` message carrying the call line and what came back, built with the same `toolCallText` every file provider uses; OpenCode's `filePath` is renamed to the `file_path` spelling that list knows, so a call is findable by its file argument. Adds a decoded-size ceiling beside the existing part ceiling. It is the bound a non-streaming source needs and a streaming one does not: a JSONL provider publishes each message as it reads it, while this one holds a whole session before posting it across the worker boundary. Neither ceiling truncates; both fail the read so it is retried and surfaces.
There was a problem hiding this comment.
ℹ️ No critical issues — one new test that cannot fail.
Reviewed changes
- Tool and reasoning capture. The OpenCode SQLite
capturequery now returnstext,reasoningandtoolparts:reasoningfolds into the assistant turn's own words, and eachtoolpart becomes its owntoolmessage carrying the call line plus output (or the error), with OpenCode's camelCasefilePathrenamed to the sharedfile_pathspelling. - Decoded-size ceiling. A new 64 MiB decoded-text bound sits beside the 20,000-part ceiling; both throw rather than return a prefix, so an oversized read fails and is retried.
- Fixture and tests. The SQLite fixture can now write reasoning and tool parts, the index e2e test covers tool-output scope plus a call found by its file argument and a failed call by its error, and the every-source guard asserts OpenCode publishes all three roles.
I confirmed the third-party field assumptions against the real OpenCode schema (tool at top level, state.input / state.output / state.error, filePath), and ran the changed tests: 9 passed. Reverting session-scanner-opencode-sqlite-capture.ts to the prior commit fails the four tool/role tests but leaves the reasoning-fold test green.
ℹ️ Nitpicks
session-scanner-opencode-sqlite-capture.ts:181still throws "holds more than … text parts" while the query now countsreasoningandtoolparts too, and the constant's own comment was updated to "parts".
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| writeVault() | ||
| await startIndexer() | ||
|
|
||
| const hit = openEngine().search({ query: 'checking how the shard map is built' }).hits[0] |
There was a problem hiding this comment.
This test passes with reasoning folding removed. The query shares the token shard with ANSWER (…reindexes every shard), so the assistant turn already matches on its text part and both assertions hold. I confirmed by reverting session-scanner-opencode-sqlite-capture.ts to the prior commit: this test stayed green while the other three new tool/reasoning tests failed.
Query a token that lives only in the reasoning part ('checking'), or assert the folded text directly as session-transcript-every-agent-capture.test.ts:143 does, so the test fails when the fold goes away.
| const hit = openEngine().search({ query: 'checking how the shard map is built' }).hits[0] | |
| const hit = openEngine().search({ query: 'checking' }).hits[0] |
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: b7438c02-b3ab-49ef-8cf2-9700eb5f16fb
📒 Files selected for processing (4)
src/main/ai-vault-search/session-search-opencode-index.test.tssrc/main/ai-vault/session-scanner-opencode-sqlite-capture.tssrc/main/ai-vault/session-scanner-opencode-sqlite-fixture.tssrc/main/ai-vault/session-transcript-every-agent-capture.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…rts of `readOpenCodeSessionMessages` returned an empty list when the message-part schema probe failed. The sink-aware reader treats that as a complete read, so the consumer committed nothing and marked the source `current`: the session stayed out of the index with nothing on its row to say why and no retry. The part limit a few lines below already throws for exactly this reason, so the two now agree. The preview path is unchanged and still degrades to no messages, which is what a list read should do. Also throws from the fixture's `appendOpenCodeSqliteTurn` when the session id names no row, instead of falling back to the fixture epoch and appending orphan messages a test would then assert over.
There was a problem hiding this comment.
ℹ️ No new issues in this delta. The new commit resolves the schema-probe finding; one prior minor thread (the reasoning-fold test shape) remains open and unchanged by these commits.
Reviewed changes
- Fails an unreadable parts schema.
readOpenCodeSessionMessagesnow throws instead of returning[]whencanReadOpenCodeMessagePartsis false, so the read reaches the failed-read/hold-out path rather than committing a counted session with zero messages. - Fixture strictness.
currentUpdatedMsnow throws for an unknown session or a non-numerictime_updatedinstead of silently falling back to the fixture epoch. - Coverage. A new test pins the rejection against a session-table-only database.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…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.
…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.
* feat(session-search): index OpenCode SQLite sessions OpenCode sessions live in one SQLite database read on a worker thread, and the worker only ever answered with the newest few messages for the panel preview. The parser therefore published nothing over the transcript channel, so the search index wrote a placeholder row for every OpenCode candidate and no OpenCode message was ever searchable. Adds a `capture` request to the worker protocol that returns the session and every text part of every user/assistant turn from one open of the database. The agent parser asks for it whenever a sink is listening, so OpenCode joins the whole-document sources on the same path as Grok, Cursor and Gemini. The placeholder path (`parserPublishesMessages`, `noteUnreachableParser`) is gone; an OpenCode read that fails now fails like any other file. Bumps the index schema so existing indexes drop their placeholder rows, and adds `sessionsByAgent` to the index status, which is the count that made this bug visible. * test(session-search): assert every source speaks, not every agent OpenCode has two storage shapes, so asking only that some OpenCode session published messages was satisfied by the legacy JSON fixture while every SQLite session in the vault stayed silent. Assert per discovered source and keep the agent-coverage check beside it. * feat(session-search): capture OpenCode tool and reasoning parts Text parts alone left OpenCode behind every file-based provider: a command someone ran, what it printed, and the model's reasoning were all unsearchable. Widens the capture query to text, reasoning and tool parts. Reasoning folds into the turn's own words, the way the shared block list already treats a thinking block. Each tool part becomes one `tool` message carrying the call line and what came back, built with the same `toolCallText` every file provider uses; OpenCode's `filePath` is renamed to the `file_path` spelling that list knows, so a call is findable by its file argument. Adds a decoded-size ceiling beside the existing part ceiling. It is the bound a non-streaming source needs and a streaming one does not: a JSONL provider publishes each message as it reads it, while this one holds a whole session before posting it across the worker boundary. Neither ceiling truncates; both fail the read so it is retried and surfaces. * fix(ai-vault): fail an OpenCode capture it cannot read the message parts of `readOpenCodeSessionMessages` returned an empty list when the message-part schema probe failed. The sink-aware reader treats that as a complete read, so the consumer committed nothing and marked the source `current`: the session stayed out of the index with nothing on its row to say why and no retry. The part limit a few lines below already throws for exactly this reason, so the two now agree. The preview path is unchanged and still degrades to no messages, which is what a list read should do. Also throws from the fixture's `appendOpenCodeSqliteTurn` when the session id names no row, instead of falling back to the fixture epoch and appending orphan messages a test would then assert over.
…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.
…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.
…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.
…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.
…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.
…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.
…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.

Bug
Nothing any OpenCode agent has said is searchable. On a real machine the index listed 606 OpenCode sessions in its
filestable and held zerosessionsrows and zero messages for them. Every other agent had rows.Cause
OpenCode stores sessions in one SQLite database read on a worker thread. The worker answered two requests,
listandparse, andparsereturned only the newest few messages for the panel preview.parserPublishesMessagestherefore declared OpenCode SQLite candidates as sources the transcript channel could not reach, and the index consumer'snoteUnreachableParserwrote a placeholder row (cursor at file size, no session) so the indexer would stop asking. The capture channel was deferred from PR 2 of the search stack and never built.Fix
A
capturerequest on the worker protocol. It returns the session and every text part of everyuser/assistantturn, from one open of the database, so the panel's session and the index's transcript can never describe different generations of it. Parts of one message are joined into oneTranscriptMessage, which is what every other provider hands a consumer, so a phrase that runs across two blocks of a turn is still one indexable row. Decoding reuses the preview reader's ownextractPartTextand session reader.Routing.
parseAgentSessionFileasks forcapturewhen a sink is listening andparsewhen nobody is, so a list scan still reads only the preview window. OpenCode now joins the whole-document sources (Grok, Cursor, Gemini) on the same path.Nothing declines any more.
parserPublishesMessages, the consumer's unreachable branch,noteUnreachableParserandsession-search-opencode-decline.test.tsare deleted. An OpenCode read that fails — a locked database, a schema probe failure, a capture past its part ceiling — now fails through the same failed-read path as any other file, with the same retry and hold-out rules.Cursor. No new machinery was needed. Discovery already stamps a synthetic candidate's
mtimeMswith the session'stime_updated, which is the stat the decide step compares, so a session that gains a message is re-read and replaced whole. The new test pins that rather than assuming it.Schema version 5 to 6, so existing indexes drop their placeholder rows and read OpenCode sessions for real. (Main is still at 5; the brief's 6 to 7 assumed #20763 had merged.)
Tests
session-search-opencode-index.test.ts— the end-to-end proof. Builds an OpenCode database with two sessions, runs the realSessionSearchIndexerover it, and assertsengine.search({ query: '<sentence an assistant wrote>' })returns that session on thephraseroute with anassistantsnippet. Also pins one read per session across three passes, and a re-read that replaces rows whentime_updatedmoves.session-transcript-every-agent-capture.test.ts— the guard that would have caught this. Writes one fixture per supported agent plus an OpenCode SQLite database, scans them through the real reader with a sink, and asserts every discovered source published at least oneuserorassistantmessage, and that the vault covers every agent inAI_VAULT_AGENTS. Gemini and Antigravity both pass; nothing isit.todo.session-scanner.test.tsinto shared modules so the scan test and this guard read the same layouts.writeJsonlFilenow terminates the last record with a newline. Six agents' fixtures ended mid-record, which the reader correctly withholds from consumers, so the guard was reading a transcript state no finished agent writes.sessionsByAgentadded to the index status and the status schema as an optional field. Grouped on the existingsessions_agentindex over one row per session.messagesByAgentwas skipped deliberately: it needs a scan of every indexed row on a call the panel polls, and the session count already separates an agent the index has read from one it has only listed.Reverting
session-scanner-agent-parser.tsfails all five new tests; restoring it passes them.Tool and reasoning parts
Text parts alone left OpenCode behind every file-based provider. The capture query now takes
text,reasoningandtoolparts.toolmessage, following the turn's words in transcript order. It carries the call line plus what came back, built with the sharedtoolCallTextand its input-key list, so a command is findable whichever agent ran it.state.erroris preferred overstate.output, which is what a failed or cancelled call actually shows; a call still running contributes its call line alone.filePathwhere every other provider, and so the shared key list, writesfile_path. The key is renamed at the OpenCode boundary rather than teaching the shared list one provider's casing. Without it the call line for the second most common tool input would be the bare tool name.Shape taken from one authorized read of the user's database and cross-checked against the reference decoder in
claude-code-history-viewer. Measured there: the busiest session holds 1,427 indexable parts against the 20,000 ceiling, and the largest totals 9.5 MB of part JSON against the 64 MiB one.New assertions: tool output is found under
scope: 'all'and not underscope: 'conversation'; a tool call is found by its file argument and a failed one by its error; a reasoning part is found on its assistant turn; and the every-source guard pins the exact three messages an OpenCode session publishes, with all three roles.Gates