Files
alan 69ae0519bd Remove Cupertino fixture alternatives
Keep capture and probe tooling on the app's single Material surface by removing obsolete platform switches, hosts, and documentation. Preserve the existing Material routes and fixture behavior while retaining compatibility APIs outside this lane.
2026-11-11 20:10:51 +00:00

163 lines
4.1 KiB
Dart

// Web-only fixture entrypoint for rendered search evidence. It is not part of
// the application's `main.dart`; build it explicitly with:
// flutter build web -t tool/search_fixture/main.dart
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/search/search_screen.dart';
void main() {
runApp(const MaterialApp(title: 'Search fixture', home: _FixtureHost()));
}
class _FixtureHost extends StatelessWidget {
const _FixtureHost();
@override
Widget build(BuildContext context) => SearchScreen(
gateway: const _FixtureGateway(),
onOpen: (hit) {
Navigator.of(context).push(
MaterialPageRoute<void>(builder: (_) => _Opened(hit: hit)),
);
},
);
}
class _Opened extends StatelessWidget {
const _Opened({required this.hit});
final JsonMap hit;
@override
Widget build(BuildContext context) {
final body = Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Text(
'Opened ${hit['kind']} target: ${hit['target']}',
textAlign: TextAlign.center,
),
),
);
return Scaffold(
appBar: AppBar(title: const Text('Opened')),
body: body,
);
}
}
class _FixtureGateway implements ApiGateway {
const _FixtureGateway();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
if (type != 'search') throw StateError('unexpected request: $type');
final request = Map<String, dynamic>.from(fields['search'] as Map);
final query = '${request['query'] ?? ''}'.trim().toLowerCase();
final kind = '${request['kind'] ?? ''}';
await Future<void>.delayed(const Duration(milliseconds: 180));
var hits = _fixtureHits
.where((hit) {
if (kind.isNotEmpty && hit['kind'] != kind) return false;
if (query.isEmpty) return true;
return jsonEncode(hit).toLowerCase().contains(query);
})
.toList(growable: false);
return {
'search_results': {
'query': request['query'],
'kind': kind,
'results': hits,
'truncated': true,
'scanned_steps': 2000,
'scanned_bytes': 1048576,
'cap': 50,
'scan_bound_bytes': 1048576,
},
};
}
@override
Stream<JsonMap> get frames => const Stream.empty();
}
const _fixtureHits = <JsonMap>[
{
'kind': 'pipeline',
'target': 'pipeline:24',
'score': 3,
'recency': '2026-10-20T09:18:00Z',
'pipeline': {'id': 24, 'name': 'Plan and land', 'version': 5, 'stages': 4},
},
{
'kind': 'run',
'target': 'run:457',
'score': 2,
'recency': '2026-10-20T08:42:00Z',
'run': {
'id': 457,
'pipeline_name': 'Plan and land',
'status': 'succeeded',
'workspace': '/home/user/project',
'created_at': '2026-10-20T08:12:00Z',
'finished_at': '2026-10-20T08:42:00Z',
},
},
{
'kind': 'field',
'target': 'run:457:3:input',
'score': 1,
'matched_field': 'input',
'recency': '2026-10-20T08:20:00Z',
'field': {
'run_id': 457,
'sequence': 3,
'field': 'input',
'snippet': 'Plan the change before implementing it',
},
},
{
'kind': 'artifact',
'target': '/artifacts/457/2/plan.md',
'score': 1,
'recency': '2026-10-20T08:24:00Z',
'artifact': {
'run_id': 457,
'sequence': 2,
'name': 'plan.md',
'content_type': 'text/markdown',
'size_bytes': 2048,
'url': '/artifacts/457/2/plan.md',
},
},
{
'kind': 'version',
'target': 'pipeline:22:v6',
'score': 2,
'recency': '2026-10-18T16:05:00Z',
'version': {
'pipeline_id': 22,
'version': 6,
'content_hash': '9f2c1ad',
'created_at': '2026-10-18T16:05:00Z',
},
},
{
'kind': 'step',
'target': 'run:457:1',
'score': 1,
'recency': '2026-10-20T08:14:00Z',
'step': {
'run_id': 457,
'sequence': 1,
'stage': 'planner',
'visit': 1,
'outcome': 'success',
'target': '#success',
'diagnostic': 'plan accepted',
},
},
];