Search: find operator chats by title, directory and message text

A search with kind chat matches the operator-session registry's titles and
directories and the newest messages of recent transcripts through the chat
broker (bounded count, concurrency and one-second budget), answered off the
connection's read loop. The all-kind search is unchanged for older clients.

The app sends the chat search after its run search and shows a Chats group
with title, harness, directory and snippet; a chat hit opens that chat in the
Chat tab. The probe fixture answers chat searches over ?chats=N.
This commit is contained in:
2026-11-03 13:01:53 +00:00
parent d34185b56c
commit bff7115e4e
31 changed files with 1659 additions and 118 deletions
+2 -36
View File
@@ -701,42 +701,8 @@ func findMatch(value any, text string) (string, bool) {
return "", false
}
// searchSnippet reduces text to a single clean line and centers a short window
// on the first case-insensitive match, folding runes so UTF-8 boundaries are
// never split and the result is always well-formed.
func searchSnippet(text, query string) string {
normalized := protocol.NormalizeText(text)
runes := []rune(normalized)
index := protocol.RuneIndexFold(runes, []rune(query))
if index < 0 {
return truncateRunes(normalized, 80)
}
const margin = 40
start := index - margin
if start < 0 {
start = 0
}
end := index + len([]rune(query)) + margin
if end > len(runes) {
end = len(runes)
}
snippet := string(runes[start:end])
if start > 0 {
snippet = "…" + snippet
}
if end < len(runes) {
snippet = snippet + "…"
}
return snippet
}
func truncateRunes(text string, limit int) string {
runes := []rune(text)
if len(runes) <= limit {
return text
}
return string(runes[:limit]) + "…"
}
// searchSnippet is the shared protocol snippet window.
func searchSnippet(text, query string) string { return protocol.SearchSnippet(text, query) }
func searchPipelineTarget(id int64) string { return fmt.Sprintf("pipeline:%d", id) }