feat(app): add native omni-search screen over the search gateway
Pure request/parse/row logic in lib/features/search/domain, a gateway-backed repository, and Material plus Cupertino bodies. The header and rows share one scroll view, and the server's truncation, scan and cap facts stay visible even when a bounded scan returns no matches. Tests cover the exact search envelope, token parsing, stale replies, retry, truncation bounds and platform layouts. A Web-only fixture and CDP probe support rendered verification; the screen is not yet registered in the shell.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../domain/search_models.dart';
|
||||
|
||||
/// Search protocol requests over the application's shared gateway.
|
||||
///
|
||||
/// The request body is exactly `SearchRequest{query, kind, limit}` with
|
||||
/// `limit: 0`, so the server applies its own default cap (`SearchDefaultLimit`,
|
||||
/// 50) instead of the client choosing a larger one.
|
||||
class SearchRepository {
|
||||
SearchRepository(this._gateway);
|
||||
|
||||
final ApiGateway _gateway;
|
||||
|
||||
/// Returns the bounded `search_results` body, or null when an older server
|
||||
/// answered without it (its default `pong`) so the caller can report the
|
||||
/// "cannot search" sentence rather than showing a false empty success.
|
||||
Future<SearchResponse?> search({
|
||||
required String query,
|
||||
required SearchKind kind,
|
||||
}) async {
|
||||
final reply = await _gateway.call('search', {
|
||||
'search': {'query': query, 'kind': kind.wire, 'limit': 0},
|
||||
});
|
||||
final results = reply['search_results'];
|
||||
if (results is! Map) return null;
|
||||
return SearchResponse.fromJson(Map<String, dynamic>.from(results));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user