Files
pipelines/app/tool/run_graph_probe.dart
alan 13a5e1dee0 Remove Cupertino branches from probe fixtures
Keep the chat and graph fixtures aligned with the app's Material-only UI by removing alternate Cupertino hosts, imports, and query-controlled rendering paths. Preserve the existing Material scenarios and document the focused probe coverage.
2026-11-11 20:08:06 +00:00

183 lines
4.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
/// plan -> build -> audit with a taken path that stops at the running build and
/// untaken routes to audit and both terminals.
JsonMap _graph() => <String, dynamic>{
'stages': <dynamic>[
<String, dynamic>{
'key': 'plan',
'type': 'model',
'edges': <String, String?>{'success': 'build', 'error': '#'},
'fallback_error': true,
},
<String, dynamic>{
'key': 'build',
'type': 'shell',
'edges': <String, String?>{'success': 'audit', 'error': '#'},
},
<String, dynamic>{
'key': 'audit',
'type': 'model',
'edges': <String, String?>{'success': '#success', 'error': '#failure'},
},
],
};
JsonMap _runningRun() {
final started = DateTime.now().toUtc().subtract(
const Duration(minutes: 2, seconds: 5),
);
return <String, dynamic>{
'id': 42,
'executing': true,
'current_stage': 'build',
'steps': <dynamic>[
<String, dynamic>{
'sequence': 1,
'stage': 'plan',
'status': 'completed',
'outcome': 'success',
'target': 'build',
},
<String, dynamic>{
'sequence': 2,
'stage': 'build',
'status': 'running',
'outcome': '',
'target': '',
'started_at': started.toIso8601String(),
},
],
};
}
JsonMap _finishedRun() => <String, dynamic>{
'id': 42,
'executing': false,
'current_stage': '',
'steps': <dynamic>[
<String, dynamic>{
'sequence': 1,
'stage': 'plan',
'status': 'completed',
'outcome': 'success',
'target': 'build',
},
<String, dynamic>{
'sequence': 2,
'stage': 'build',
'status': 'completed',
'outcome': 'success',
'target': 'audit',
},
<String, dynamic>{
'sequence': 3,
'stage': 'audit',
'status': 'completed',
'outcome': 'success',
'target': '#',
},
],
};
/// Isolated browser fixture for `RunGraphView` only.
///
/// `dark=1` selects the dark theme and `scale=2` a real 2x text scale.
/// `case=finished` records a resolved success
/// terminal instead of the running path; `case=missing` omits the graph. A
/// click reports the exact visited stage key; unvisited nodes report nothing.
void main() {
final parameters = Uri.base.queryParameters;
runApp(
_ProbeApp(
dark: parameters['dark'] == '1',
scale: double.tryParse(parameters['scale'] ?? '') ?? 1,
fixture: parameters['case'] ?? 'running',
),
);
}
class _ProbeApp extends StatelessWidget {
const _ProbeApp({
required this.dark,
required this.scale,
required this.fixture,
});
final bool dark;
final double scale;
final String fixture;
@override
Widget build(BuildContext context) {
final page = _ProbePage(
scale: scale,
graph: fixture == 'missing' ? null : _graph(),
run: fixture == 'finished' ? _finishedRun() : _runningRun(),
);
return MaterialApp(
theme: ThemeData(
platform: TargetPlatform.android,
brightness: Brightness.light,
),
darkTheme: ThemeData(
platform: TargetPlatform.android,
brightness: Brightness.dark,
),
themeMode: dark ? ThemeMode.dark : ThemeMode.light,
home: Scaffold(
appBar: AppBar(title: const Text('Run graph')),
body: SafeArea(child: page),
),
);
}
}
class _ProbePage extends StatefulWidget {
const _ProbePage({
required this.scale,
required this.graph,
required this.run,
});
final double scale;
final JsonMap? graph;
final JsonMap run;
@override
State<_ProbePage> createState() => _ProbePageState();
}
class _ProbePageState extends State<_ProbePage> {
String? _selected;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Selected: ${_selected ?? 'none'}'),
const SizedBox(height: 8),
Expanded(
child: MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(widget.scale)),
child: RunGraphView(
graph: widget.graph,
run: widget.run,
selectedStage: _selected,
onStageSelected: (key) => setState(() => _selected = key),
),
),
),
],
),
);
}
}