Files
pipelines/app/lib/features/search/domain/search_chat_row.dart
T
alan bff7115e4e 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.
2026-11-03 13:01:53 +00:00

48 lines
1.5 KiB
Dart

import '../../../core/api_gateway.dart';
import 'search_row.dart';
/// The chat payload of a `chat` search hit, or null for any other hit.
JsonMap? searchChatOf(JsonMap hit) {
final chat = hit['chat'];
return hit['kind'] == 'chat' && chat is Map
? Map<String, dynamic>.from(chat)
: null;
}
/// A chat hit's row: the chat's title, its harness and directory as the
/// muted facts, and the matching message's snippet when message text matched.
/// It opens only with the server's own `chat:<session id>` target.
SearchRowView searchChatRowView(
JsonMap chat, {
required String query,
required String? target,
required String? recency,
}) {
final title = '${chat['title'] ?? ''}'.trim();
final directory = '${chat['directory'] ?? ''}'.trim();
final snippet = '${chat['snippet'] ?? ''}';
final facts = [
searchHarnessLabel('${chat['backend'] ?? ''}'),
if (directory.isNotEmpty) directory,
if (chat['closed'] == true) 'closed',
].join(' · ');
return SearchRowView(
title: title.isEmpty ? 'Untitled chat' : title,
secondary: facts,
kindLabel: 'Chat',
snippet: snippet.isEmpty ? null : snippet,
snippetSpans: snippetSpans(snippet, query),
recency: recency,
target: target,
);
}
/// The harness's display name, matching the server's own names; an unknown
/// harness shows as sent.
String searchHarnessLabel(String backend) => switch (backend) {
'claude' => 'Claude Code',
'codex' => 'Codex',
'' || 'opencode' => 'OpenCode',
_ => backend,
};