bff7115e4e
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.
74 lines
2.6 KiB
Dart
74 lines
2.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/search/domain/search_row.dart';
|
|
import 'package:pipelines_app/features/search/domain/search_target.dart';
|
|
|
|
import 'search_test_support.dart' show chatHit;
|
|
|
|
void main() {
|
|
test('a message hit shows the title, harness and directory and its '
|
|
'snippet with the match split out', () {
|
|
final row = searchRowView(
|
|
chatHit('ses_a', snippet: 'the FLAKY retry'),
|
|
'flaky',
|
|
);
|
|
expect(row.title, 'Fix CI');
|
|
expect(row.kindLabel, 'Chat');
|
|
expect(row.secondary, 'Claude Code · /work/api');
|
|
expect(row.snippet, 'the FLAKY retry');
|
|
expect(row.snippetSpans.map((span) => (span.text, span.matched)), [
|
|
('the ', false),
|
|
('FLAKY', true),
|
|
(' retry', false),
|
|
]);
|
|
expect(row.target, 'chat:ses_a');
|
|
expect(row.openable, isTrue);
|
|
});
|
|
|
|
test('a title hit has no snippet; closed and untitled chats say so', () {
|
|
final base = chatHit('ses_b', title: ' ');
|
|
final hit = {
|
|
...base,
|
|
'chat': <String, dynamic>{
|
|
...(base['chat'] as Map),
|
|
'backend': '',
|
|
'closed': true,
|
|
},
|
|
};
|
|
final row = searchRowView(hit, 'x');
|
|
expect(row.title, 'Untitled chat');
|
|
expect(row.secondary, 'OpenCode · /work/api · closed');
|
|
expect(row.snippet, isNull);
|
|
});
|
|
|
|
test('a chat hit resolves to its session, keeping the matched message', () {
|
|
final resolved = searchTargetFor(chatHit('ses_a'));
|
|
expect(resolved, isA<ResolvedSearchTarget>());
|
|
final target = (resolved as ResolvedSearchTarget).target;
|
|
expect(target, isA<SearchChatTarget>());
|
|
expect((target as SearchChatTarget).sessionId, 'ses_a');
|
|
expect(target.kind, SearchTargetKind.chat);
|
|
expect(target.wire, 'chat:ses_a');
|
|
|
|
final message = chatHit('ses_a', snippet: 'x');
|
|
(message['chat'] as Map)['message_id'] = 'm9';
|
|
final withMessage =
|
|
(searchTargetFor(message) as ResolvedSearchTarget).target
|
|
as SearchChatTarget;
|
|
expect(withMessage.messageId, 'm9');
|
|
expect(withMessage, target);
|
|
|
|
expect(SearchTarget.fromWire('chat:ses_a'), target);
|
|
expect(SearchTarget.fromWire('chat:'), isNull);
|
|
});
|
|
|
|
test('a chat hit without a session id or with a mismatched target is not '
|
|
'openable', () {
|
|
final missing = chatHit('ses_a');
|
|
(missing['chat'] as Map).remove('session_id');
|
|
expect(searchTargetFor(missing), isA<UnresolvedSearchTarget>());
|
|
|
|
final mismatched = {...chatHit('ses_a'), 'target': 'chat:ses_b'};
|
|
expect(searchTargetFor(mismatched), isA<UnresolvedSearchTarget>());
|
|
});
|
|
}
|