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.
123 lines
3.9 KiB
Dart
123 lines
3.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../ui/layout/app_list_avatar.dart';
|
|
import '../../../ui/layout/app_list_row.dart';
|
|
import '../domain/search_row.dart';
|
|
import 'search_result_view.dart';
|
|
|
|
/// One search hit in the app's shared row: the kind's icon (or an image
|
|
/// artifact's picture), the title with its recency, and one muted line that
|
|
/// names the kind and then shows the snippet (its first query occurrence
|
|
/// emphasised by weight, never by parsing server text as markup) or, without
|
|
/// one, the kind's own facts. A chat hit with a matching message shows its
|
|
/// harness and directory, then the snippet on a second line. An artifact
|
|
/// hit's open choices are its menu.
|
|
class SearchResultRow extends StatelessWidget {
|
|
const SearchResultRow({
|
|
super.key,
|
|
required this.hit,
|
|
required this.query,
|
|
required this.onOpen,
|
|
required this.cupertino,
|
|
this.divider = true,
|
|
});
|
|
|
|
final JsonMap hit;
|
|
final String query;
|
|
final ValueChanged<JsonMap> onOpen;
|
|
final bool cupertino;
|
|
final bool divider;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final row = searchRowView(hit, query);
|
|
final kind = '${hit['kind'] ?? ''}';
|
|
return AppListRow(
|
|
key: ValueKey('search.result.${hit['target']}'),
|
|
cupertino: cupertino,
|
|
divider: divider,
|
|
onTap: row.openable ? () => onOpen(hit) : null,
|
|
leading:
|
|
searchArtifactThumbnail(context, hit) ??
|
|
AppListAvatar(
|
|
child: Icon(
|
|
cupertino ? searchCupertinoIcon(kind) : searchMaterialIcon(kind),
|
|
),
|
|
),
|
|
title: Text(row.title),
|
|
time: row.recency,
|
|
subtitle: kind == 'chat' && row.snippet != null
|
|
? Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text.rich(_facts(row)),
|
|
Text.rich(TextSpan(children: _snippet(row))),
|
|
],
|
|
)
|
|
: Text.rich(_line(row)),
|
|
compactSubtitle: kind == 'chat' && row.snippet != null
|
|
? Text.rich(TextSpan(children: _snippet(row)))
|
|
: null,
|
|
menu: searchArtifactActions(context, hit),
|
|
);
|
|
}
|
|
|
|
TextSpan _line(SearchRowView row) => row.snippet == null
|
|
? _facts(row)
|
|
: TextSpan(children: [_kind(row), ..._snippet(row)]);
|
|
|
|
/// The kind, then the kind's own facts (a chat's harness and directory).
|
|
TextSpan _facts(SearchRowView row) => TextSpan(
|
|
children: [
|
|
_kind(row),
|
|
TextSpan(text: row.secondary),
|
|
],
|
|
);
|
|
|
|
TextSpan _kind(SearchRowView row) => TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: row.kindLabel,
|
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
|
),
|
|
const TextSpan(text: ' · '),
|
|
],
|
|
);
|
|
|
|
/// The snippet with its first query occurrence emphasised by weight.
|
|
List<TextSpan> _snippet(SearchRowView row) => [
|
|
for (final span in row.snippetSpans)
|
|
TextSpan(
|
|
text: span.text,
|
|
style: span.matched
|
|
? const TextStyle(fontWeight: FontWeight.bold)
|
|
: null,
|
|
),
|
|
];
|
|
}
|
|
|
|
IconData searchMaterialIcon(String kind) => switch (kind) {
|
|
'pipeline' => Icons.account_tree_outlined,
|
|
'version' => Icons.layers_outlined,
|
|
'run' => Icons.play_circle_outline,
|
|
'step' => Icons.arrow_forward,
|
|
'field' => Icons.notes,
|
|
'artifact' => Icons.attach_file,
|
|
'chat' => Icons.chat_bubble_outline,
|
|
_ => Icons.help_outline,
|
|
};
|
|
|
|
IconData searchCupertinoIcon(String kind) => switch (kind) {
|
|
'pipeline' => CupertinoIcons.arrow_branch,
|
|
'version' => CupertinoIcons.square_stack_3d_up,
|
|
'run' => CupertinoIcons.play_circle,
|
|
'step' => CupertinoIcons.arrow_right,
|
|
'field' => CupertinoIcons.doc_text,
|
|
'artifact' => CupertinoIcons.paperclip,
|
|
'chat' => CupertinoIcons.chat_bubble,
|
|
_ => CupertinoIcons.question_circle,
|
|
};
|