Files
pipelines/app/tool/run_detail_visit_probe.dart
T
alan b60ad6d98f Remove alternate hosts from tooling probes
Keep the probe suite on the Material composition so browser fixtures and capture drivers no longer render or select Cupertino hosts. Record the final residual legacy arguments and implementation checks for the delivery gate.
2026-11-11 21:38:30 +00:00

240 lines
6.7 KiB
Dart

// Standalone fixture entry for real-browser recorded-visit pane evidence.
//
// Build and probe (from app/):
// flutter build web --target tool/run_detail_visit_probe.dart \
// --output build/probe-run-detail-visit
// OPENCODE_ARTIFACT_DIR=DIR \
// node tool/run_detail_visit_probe.mjs
//
// Server-shaped fixtures only: a fake gateway answers the same get_run envelope
// the app consumes. No server or operator run is touched.
import 'package:flutter/material.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
final JsonMap detail;
@override
Stream<JsonMap> get frames => const Stream<JsonMap>.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type != 'get_run') throw UnsupportedError(type);
return Future.value({'run_detail': detail});
}
}
/// plan -> build, with a rich first visit, a sparse second visit, a third visit
/// whose complete export carries a recorded failed repair, and a fourth whose
/// export is partial with a diagnostic.
JsonMap _graph() => <String, dynamic>{
'name': 'Release verification',
'stages': <dynamic>[
<String, dynamic>{
'key': 'plan',
'type': 'model',
'prompt': 'Draft the plan.',
'output': 'A plan.',
'edges': <String, String?>{'success': 'build', 'error': '#'},
},
<String, dynamic>{
'key': 'build',
'type': 'model',
'prompt': 'Build the candidate.',
'edges': <String, String?>{'success': '#success', 'error': '#'},
},
],
};
JsonMap _run() => <String, dynamic>{
'id': 512,
'title': 'Release verification',
'name': 'release',
'pipeline_id': 7,
'version': 3,
'status': 'succeeded',
'executing': false,
'input': <String, dynamic>{'prompt': 'Verify the candidate release.'},
'output': <String, dynamic>{'result': 'verified'},
'graph': _graph(),
'steps': <dynamic>[
<String, dynamic>{
'stage': 'plan',
'sequence': 1,
'status': 'completed',
'outcome': 'success',
'target': 'build',
'provider': 'anthropic',
'model': 'claude-x',
'started_at': '2026-10-22T00:00:00Z',
'finished_at': '2026-10-22T00:02:05Z',
'diagnostic': 'Plan checked.',
'verdict': <String, dynamic>{
'option': 'approve',
'reason': 'Looks good.',
},
'input': <String, dynamic>{'markdown': 'Draft the plan.\n'},
'output': <String, dynamic>{'result': 'ok'},
'session_id': 'sess-1',
'session_export': <String, dynamic>{
'html': 'session.html',
'status': 'complete',
'messages': 3,
'html_bytes': 1234,
},
'artifacts': <dynamic>[
<String, dynamic>{
'name': 'plan.csv',
'url': 'https://example.test/artifacts/plan.csv',
'content_type': 'text/csv',
'size_bytes': 42,
},
<String, dynamic>{
'name': 'session.html',
'url': 'https://example.test/artifacts/session.html',
'content_type': 'text/html',
'size_bytes': 100,
},
],
},
<String, dynamic>{
'stage': 'build',
'sequence': 2,
'status': 'completed',
'outcome': 'success',
'target': '#success',
'diagnostic': 'Built.',
},
<String, dynamic>{
'stage': 'audit',
'sequence': 3,
'status': 'completed',
'outcome': 'success',
'target': '#success',
'diagnostic': 'Audited.',
'session_id': 'sess-2',
'session_export': <String, dynamic>{
'html': 'session.html',
'status': 'complete',
'messages': 3,
'html_bytes': 500,
},
'session_export_repairs': <dynamic>[
<String, dynamic>{
'html': 'session-repair-1.html',
'status': 'failed',
'messages': 0,
'diagnostic': 'The repair read failed.',
},
],
'artifacts': <dynamic>[
<String, dynamic>{
'name': 'session.html',
'url': 'https://example.test/artifacts/session.html',
'content_type': 'text/html',
'size_bytes': 100,
},
<String, dynamic>{
'name': 'session-repair-1.html',
'url': 'https://example.test/artifacts/session-repair-1.html',
'content_type': 'text/html',
'size_bytes': 100,
},
],
},
<String, dynamic>{
'stage': 'partial',
'sequence': 4,
'status': 'completed',
'outcome': 'success',
'target': '#success',
'diagnostic': 'Partial export recorded.',
'session_id': 'sess-3',
'session_export': <String, dynamic>{
'html': 'session.html',
'status': 'failed',
'messages': 2,
'diagnostic': 'The native read was refused.',
},
'artifacts': <dynamic>[
<String, dynamic>{
'name': 'session.html',
'url': 'https://example.test/artifacts/session.html',
'content_type': 'text/html',
'size_bytes': 100,
},
],
},
],
};
void main() {
final params = Uri.base.queryParameters;
final dark = params['theme'] == 'dark';
final scale = double.tryParse(params['scale'] ?? '') ?? 1;
runApp(
_ProbeBody(dark: dark, scale: scale, run: _run()),
);
}
class _ProbeBody extends StatefulWidget {
const _ProbeBody({
required this.dark,
required this.scale,
required this.run,
});
final bool dark;
final double scale;
final JsonMap run;
@override
State<_ProbeBody> createState() => _ProbeBodyState();
}
class _ProbeBodyState extends State<_ProbeBody> {
late final _FakeGateway _gateway = _FakeGateway(widget.run);
late final RunsController _controller = RunsController(
RunsRepository(_gateway),
);
@override
void initState() {
super.initState();
_controller.select(512);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final detail = RunDetailView(
controller: _controller,
gateway: _gateway,
onBack: () {},
);
final theme = widget.dark ? Brightness.dark : Brightness.light;
Widget scaled(BuildContext context, Widget? app) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(widget.scale)),
child: app!,
);
return MaterialApp(
title: 'Visit pane fixture',
theme: ThemeData(brightness: theme, platform: TargetPlatform.android),
builder: scaled,
home: Scaffold(body: SafeArea(child: detail)),
);
}
}