Skip to content

@sqlrooms/ai-core / ChatSearchContextValue

Type Alias: ChatSearchContextValue ​

ChatSearchContextValue = object

State and actions shared by Chat.Root's search provider.

registerBlocks/unregisterBlocks declare which text exists to search (per turn group), independent of whether anything painted it on screen. reportRenderedBlock is the rendered-set half: a slot calls reportRenderedBlock(blockId, text) on mount and calls the function it returns on unmount. A block stays indexed as long as at least one call's release has not run yet, and the text matched against is the text passed by whichever live call reported most recently, so an earlier reporter releasing after a later one never makes the block fall back to stale text. A block that registered but was never reported as rendered is excluded from search entirely. activeMatchId identifies the active match's DOM anchor, while activeMatchKey changes on every query or navigation attempt so reveal and scroll effects can run again even when that DOM id is reused.

Properties ​

query ​

query: string


setQuery ​

setQuery: (query) => void

Parameters ​

ParameterType
querystring

Returns ​

void


matches ​

matches: ChatSearchMatch[]


activeMatchId? ​

optional activeMatchId?: string


activeMatchKey? ​

optional activeMatchKey?: string


activeMatchNumber ​

activeMatchNumber: number


registerBlocks ​

registerBlocks: (groupId, blocks) => void

Parameters ​

ParameterType
groupIdstring
blocksChatSearchBlock[]

Returns ​

void


unregisterBlocks ​

unregisterBlocks: (groupId) => void

Parameters ​

ParameterType
groupIdstring

Returns ​

void


getMatchesForBlock ​

getMatchesForBlock: (blockId) => ChatSearchMatch[]

Parameters ​

ParameterType
blockIdstring

Returns ​

ChatSearchMatch[]


goToNextMatch ​

goToNextMatch: () => void

Returns ​

void


goToPreviousMatch ​

goToPreviousMatch: () => void

Returns ​

void


clearSearch ​

clearSearch: () => void

Returns ​

void


reportRenderedBlock ​

reportRenderedBlock: (blockId, text?) => () => void

Parameters ​

ParameterType
blockIdstring
text?string

Returns ​

() => void