Files
pipelines/app/lib/features/search/ui/cupertino_search_body.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

143 lines
3.7 KiB
Dart

import 'package:flutter/cupertino.dart';
import '../../../core/api_gateway.dart';
import '../domain/search_controller.dart';
import 'search_result_slivers.dart';
import 'search_layout.dart';
/// The Cupertino search view: an optional status header and the shared list
/// rows in one scroll view that runs behind the top bar, with standard
/// activity and retry controls.
class CupertinoSearchBody extends StatelessWidget {
const CupertinoSearchBody({
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: Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: CupertinoActivityIndicator(),
),
),
..._content(context),
],
);
}
List<Widget> _content(BuildContext context) {
switch (controller.bodyKind) {
case SearchBodyKind.error:
return [
SliverFillRemaining(
hasScrollBody: false,
child: _CupertinoError(
message: controller.error!,
onRetry: controller.retry,
),
),
];
case SearchBodyKind.searching:
return const [
SliverFillRemaining(
hasScrollBody: false,
child: _CupertinoSearching(),
),
];
case SearchBodyKind.results:
return searchResultSlivers(
controller: controller,
query: query,
onOpen: onOpen,
cupertino: true,
message: (text) => _CupertinoMessage(message: text),
);
case SearchBodyKind.empty:
return [
SliverToBoxAdapter(
child: _CupertinoMessage(message: controller.emptyMessage!),
),
];
case SearchBodyKind.idle:
return const [
SliverFillRemaining(
hasScrollBody: false,
child: _CupertinoMessage(
message: 'Search pipelines, runs, artifacts and chats.',
),
),
];
}
}
}
class _CupertinoSearching extends StatelessWidget {
const _CupertinoSearching();
@override
Widget build(BuildContext context) => const Center(
child: Padding(
padding: EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
spacing: 12,
children: [CupertinoActivityIndicator(), Text('Searching…')],
),
),
);
}
class _CupertinoMessage extends StatelessWidget {
const _CupertinoMessage({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 _CupertinoError extends StatelessWidget {
const _CupertinoError({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),
CupertinoButton.filled(
key: const ValueKey('search.retry'),
onPressed: onRetry,
child: const Text('Retry'),
),
],
),
),
);
}