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.
72 lines
2.3 KiB
Dart
72 lines
2.3 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../ui/layout/section_heading.dart';
|
|
import '../domain/search_controller.dart';
|
|
import '../domain/search_models.dart';
|
|
import 'search_bounds_note.dart';
|
|
import 'search_result_row.dart';
|
|
|
|
const searchChatsSectionKey = ValueKey<String>('search.section.chats');
|
|
const searchOthersSectionKey = ValueKey<String>('search.section.others');
|
|
const searchChatsNoteKey = ValueKey<String>('search.chats.note');
|
|
|
|
/// The results body shared by both hosts. With every kind searched, chat hits
|
|
/// lead as their own "Chats" group above the pipeline/run/artifact hits; with
|
|
/// Chats selected alone they are the list. A run search with no hits still
|
|
/// says so under the Chats group.
|
|
List<Widget> searchResultSlivers({
|
|
required OmniSearchController controller,
|
|
required String query,
|
|
required ValueChanged<JsonMap> onOpen,
|
|
required bool cupertino,
|
|
required Widget Function(String message) message,
|
|
}) {
|
|
final chats = controller.shownChats;
|
|
final others = controller.shownResults;
|
|
final grouped = controller.showsChatSection;
|
|
final note = controller.chatsNote;
|
|
Widget rows(List<JsonMap> hits) => SliverList.builder(
|
|
itemCount: hits.length,
|
|
itemBuilder: (context, index) => SearchResultRow(
|
|
hit: hits[index],
|
|
query: query,
|
|
onOpen: onOpen,
|
|
cupertino: cupertino,
|
|
divider: index < hits.length - 1,
|
|
),
|
|
);
|
|
final empty = controller.emptyMessage;
|
|
return [
|
|
if (grouped)
|
|
SliverToBoxAdapter(
|
|
child: SectionHeading(
|
|
key: searchChatsSectionKey,
|
|
title: chats.isEmpty ? 'Chats' : 'Chats (${chats.length})',
|
|
header: true,
|
|
),
|
|
),
|
|
if (chats.isNotEmpty) rows(chats),
|
|
if (note != null)
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
child: SearchBoundsNote(key: searchChatsNoteKey, text: note),
|
|
),
|
|
),
|
|
if (grouped && others.isNotEmpty)
|
|
const SliverToBoxAdapter(
|
|
child: SectionHeading(
|
|
key: searchOthersSectionKey,
|
|
title: 'Pipelines and runs',
|
|
header: true,
|
|
),
|
|
),
|
|
if (others.isNotEmpty) rows(others),
|
|
if (others.isEmpty &&
|
|
controller.parsed.kind != SearchKind.chat &&
|
|
empty != null)
|
|
SliverToBoxAdapter(child: message(empty)),
|
|
];
|
|
}
|