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.
135 lines
3.5 KiB
Dart
135 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../domain/search_controller.dart';
|
|
import 'search_result_slivers.dart';
|
|
import 'search_layout.dart';
|
|
|
|
/// The Material search view: an optional status header and a flat native
|
|
/// result list in one scroll view that runs behind the top bar.
|
|
class MaterialSearchBody extends StatelessWidget {
|
|
const MaterialSearchBody({
|
|
super.key,
|
|
required this.controller,
|
|
required this.query,
|
|
required this.onOpen,
|
|
required this.header,
|
|
});
|
|
|
|
final OmniSearchController controller;
|
|
final String query;
|
|
final ValueChanged<JsonMap> onOpen;
|
|
final Widget header;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SearchScrollView(
|
|
slivers: [
|
|
SliverToBoxAdapter(child: header),
|
|
if (controller.showProgress)
|
|
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
|
..._content(context),
|
|
],
|
|
);
|
|
}
|
|
|
|
List<Widget> _content(BuildContext context) {
|
|
switch (controller.bodyKind) {
|
|
case SearchBodyKind.error:
|
|
return [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _SearchError(
|
|
message: controller.error!,
|
|
onRetry: controller.retry,
|
|
),
|
|
),
|
|
];
|
|
case SearchBodyKind.searching:
|
|
return const [
|
|
SliverFillRemaining(hasScrollBody: false, child: _Searching()),
|
|
];
|
|
case SearchBodyKind.results:
|
|
return searchResultSlivers(
|
|
controller: controller,
|
|
query: query,
|
|
onOpen: onOpen,
|
|
cupertino: false,
|
|
message: (text) => _SearchMessage(message: text),
|
|
);
|
|
case SearchBodyKind.empty:
|
|
return [
|
|
SliverToBoxAdapter(
|
|
child: _SearchMessage(message: controller.emptyMessage!),
|
|
),
|
|
];
|
|
case SearchBodyKind.idle:
|
|
return const [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _SearchMessage(
|
|
message: 'Search pipelines, runs, artifacts and chats.',
|
|
),
|
|
),
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
class _Searching extends StatelessWidget {
|
|
const _Searching();
|
|
|
|
@override
|
|
Widget build(BuildContext context) => const Center(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: 12,
|
|
children: [CircularProgressIndicator(), Text('Searching…')],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _SearchMessage extends StatelessWidget {
|
|
const _SearchMessage({required this.message});
|
|
|
|
final String message;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Text(message, textAlign: TextAlign.center),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _SearchError extends StatelessWidget {
|
|
const _SearchError({required this.message, required this.onRetry});
|
|
|
|
final String message;
|
|
final Future<void> Function() onRetry;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: 12,
|
|
children: [
|
|
Text(message, textAlign: TextAlign.center),
|
|
FilledButton.tonalIcon(
|
|
key: const ValueKey('search.retry'),
|
|
onPressed: onRetry,
|
|
icon: const Icon(Icons.refresh),
|
|
label: const Text('Retry'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|