test(session-search): pin the identity and acknowledgement across every entry point

IPC, the runtime RPC method, the relay handler and the shared remote client
each carry the identity out and the acknowledgement back, and the relay -- which
has no repo catalog -- reports the scope rather than widening the search.
This commit is contained in:
Jinwoo-H
2026-09-18 14:19:39 -04:00
parent 8911e5a8a2
commit f864bbc148
2 changed files with 16 additions and 1 deletions
@@ -1,6 +1,7 @@
import { afterEach, describe, expect, it } from 'vitest'
import { AiVaultHandler } from '../../relay/ai-vault-handler'
import type { RelayDispatcher } from '../../relay/dispatcher'
import { createSessionSearchClient } from '../../shared/ai-vault-search-client'
import { fakeSearchService } from '../../shared/ai-vault-search-test-fixture'
import { searchAllExecutionHosts } from '../ipc/ai-vault-search-all-hosts'
import { RpcDispatcher } from '../runtime/rpc/dispatcher'
@@ -87,6 +88,20 @@ describe('every search entry point carries the scope identity through', () => {
})
})
describe('the shared remote client', () => {
it('carries the identity out and the acknowledgement back across a transport', async () => {
setSessionSearchService(fakeSearchService())
installSessionSearchScopeCatalogSource(() => CATALOG)
const client = createSessionSearchClient(
(_method, params) => searchSessionService(params, 'relay'),
'relay'
)
expect(await client.searchSessions({ query: 'needle', within: WITHIN })).toMatchObject({
resolvedWithin: { kind: 'workspace', paths: 1 }
})
})
})
describe('an all-computers merge across mixed host versions', () => {
it('drops an old hosts unscoped hits and names it as needing an update', async () => {
const response = await searchAllExecutionHosts({ query: 'needle', within: WITHIN }, [
@@ -72,7 +72,7 @@ type ScopedSessionSearch = {
* does not know the workspace or project, which is an answer — never a reason to
* fall back to searching everything.
*/
export function applySessionSearchScope(parsed: AiVaultSearchRequest): ScopedSessionSearch | null {
function applySessionSearchScope(parsed: AiVaultSearchRequest): ScopedSessionSearch | null {
const { within, ...request } = parsed
if (!within) {
return { request }