merge(app): land changes-visit-entry micro-slice

This commit is contained in:
2026-10-22 03:11:54 +01:00
3 changed files with 242 additions and 9 deletions
@@ -9,6 +9,7 @@ import '../../changes/changes.dart';
/// recorded summary and capture wording, so this bar stays neutral.
const runChangesLabel = 'Changes';
const runChangesButtonKey = ValueKey<String>('run-detail-changes');
const runVisitChangesButtonKey = ValueKey<String>('run-visit-changes');
/// The detail's `steps` exactly as returned by the server. The pushed page
/// snapshots the returned list once, so it never re-derives on each rebuild.
@@ -73,34 +74,118 @@ class RunChangesButton extends StatelessWidget {
/// Opens the already-landed [ChangesViewer] for [steps] on a native page.
/// The bar is the one title bar; the viewer's own summary and capture facts
/// are passed through untouched, except for the caller's [showSummary] gate.
///
/// [title] names the evidence the page shows. The run-level action keeps the
/// neutral [runChangesLabel]; a visit passes [visitChangesTitle] so the pushed
/// page cannot be mistaken for the run-wide aggregate.
Future<void> showRunChanges(
BuildContext context, {
required List<JsonMap> steps,
required bool showSummary,
String title = runChangesLabel,
}) {
final cupertino = usesCupertinoHost(context);
return Navigator.of(context).push<void>(
cupertino
? CupertinoPageRoute<void>(
builder: (_) =>
_CupertinoChangesPage(steps: steps, showSummary: showSummary),
builder: (_) => _CupertinoChangesPage(
steps: steps,
showSummary: showSummary,
title: title,
),
)
: MaterialPageRoute<void>(
builder: (_) =>
_MaterialChangesPage(steps: steps, showSummary: showSummary),
builder: (_) => _MaterialChangesPage(
steps: steps,
showSummary: showSummary,
title: title,
),
),
);
}
/// The page identity for exactly one recorded visit: the stage and visit the
/// timeline row shows, so the page names its evidence rather than the run.
String visitChangesTitle(String stage, int? sequence) {
final name = stage.trim();
final visit = sequence == null ? 'visit unavailable' : 'visit $sequence';
return name.isEmpty
? '$runChangesLabel · $visit'
: '$runChangesLabel · $name · $visit';
}
/// Opens the Changes viewer for exactly one visit's recorded [step].
///
/// The page shows that step's own capture only - never the run's other visits -
/// and no run-wide final-state header, which belongs to the run-level action.
Future<void> showVisitChanges(
BuildContext context, {
required String stage,
required int? sequence,
required JsonMap step,
}) => showRunChanges(
context,
steps: <JsonMap>[step],
showSummary: false,
title: visitChangesTitle(stage, sequence),
);
/// The opened visit pane's own native action. It passes only the visit's step,
/// so the viewer's per-stage section is its single evidence entry.
class RunVisitChangesButton extends StatelessWidget {
const RunVisitChangesButton({
super.key,
required this.stage,
required this.sequence,
required this.step,
});
final String stage;
final int? sequence;
final JsonMap step;
@override
Widget build(BuildContext context) {
void open() =>
showVisitChanges(context, stage: stage, sequence: sequence, step: step);
if (usesCupertinoHost(context)) {
return CupertinoButton(
key: runVisitChangesButtonKey,
padding: EdgeInsets.zero,
onPressed: open,
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(CupertinoIcons.doc_text),
SizedBox(width: 6),
Flexible(child: Text(runChangesLabel)),
],
),
);
}
return TextButton.icon(
key: runVisitChangesButtonKey,
onPressed: open,
icon: const Icon(Icons.difference_outlined),
label: const Text(runChangesLabel),
);
}
}
class _MaterialChangesPage extends StatelessWidget {
const _MaterialChangesPage({required this.steps, required this.showSummary});
const _MaterialChangesPage({
required this.steps,
required this.showSummary,
required this.title,
});
final List<JsonMap> steps;
final bool showSummary;
final String title;
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text(runChangesLabel)),
appBar: AppBar(title: Text(title)),
body: SafeArea(
top: false,
child: ChangesViewer(steps: steps, showSummary: showSummary),
@@ -109,14 +194,19 @@ class _MaterialChangesPage extends StatelessWidget {
}
class _CupertinoChangesPage extends StatelessWidget {
const _CupertinoChangesPage({required this.steps, required this.showSummary});
const _CupertinoChangesPage({
required this.steps,
required this.showSummary,
required this.title,
});
final List<JsonMap> steps;
final bool showSummary;
final String title;
@override
Widget build(BuildContext context) => CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(middle: Text(runChangesLabel)),
navigationBar: CupertinoNavigationBar(middle: Text(title)),
child: SafeArea(
// A CupertinoApp supplies no Material theme; follow the host brightness
// so the viewer's Material-derived section text stays readable.
+16 -1
View File
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import 'run_changes_action.dart';
import 'run_detail_content.dart';
import 'run_detail_visit_facts.dart';
import 'run_detail_visit_sections.dart';
@@ -139,7 +140,21 @@ class _RunVisitPaneState extends State<RunVisitPane> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(alignment: AlignmentDirectional.centerStart, child: close),
// The close and change actions wrap instead of overflowing when the
// pane is narrow or the text is scaled.
Wrap(
spacing: 8,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
close,
RunVisitChangesButton(
stage: widget.visit.stage,
sequence: widget.visit.sequence,
step: widget.step,
),
],
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(8, 0, 0, 0),
child: Column(
@@ -0,0 +1,128 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/changes/changes.dart';
import 'package:pipelines_app/features/runs/ui/run_changes_action.dart';
import '../../changes/fixtures.dart';
import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
/// plan and build each recorded a capture with a different file, so a page that
/// showed the run's steps would leak the other visit's path.
JsonMap _run({JsonMap? planChanges, JsonMap? buildChanges}) =>
<String, dynamic>{
'id': 77,
'title': 'Visit changes',
'name': 'release',
'status': 'succeeded',
'steps': <dynamic>[
stepFixture(stage: 'plan', sequence: 1, fileChanges: planChanges),
stepFixture(stage: 'build', sequence: 2, fileChanges: buildChanges),
],
};
JsonMap _capture(String path) => captureFixture(
files: <JsonMap>[fileChangeFixture(path: path, patch: multiHunkPatch)],
);
Future<void> _openVisitChanges(WidgetTester tester) async {
await tester.tap(find.byKey(runVisitChangesButtonKey));
await tester.pumpAndSettle();
}
void main() {
group('visitChangesTitle', () {
test('names the stage and visit the timeline row shows', () {
expect(visitChangesTitle('plan', 1), 'Changes · plan · visit 1');
});
test('omits a stage the server did not record', () {
expect(visitChangesTitle(' ', 3), 'Changes · visit 3');
});
test('does not invent a visit number when none was recorded', () {
expect(
visitChangesTitle('plan', null),
'Changes · plan · visit unavailable',
);
});
});
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name}: visit Changes opens that visit only', (
tester,
) async {
await openVisit(
tester,
platform,
run: _run(
planChanges: _capture('lib/plan.dart'),
buildChanges: _capture('lib/build.dart'),
),
);
await _openVisitChanges(tester);
expect(find.text('Changes · plan · visit 1'), findsOneWidget);
// The body keeps the landed viewer's own identity for that visit.
expect(find.text('plan'), findsOneWidget);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/plan.dart'), findsOneWidget);
expect(find.text('lib/build.dart'), findsNothing);
});
testWidgets('${platform.name}: visit without a capture is honest', (
tester,
) async {
await openVisit(
tester,
platform,
run: _run(buildChanges: _capture('lib/build.dart')),
);
await _openVisitChanges(tester);
expect(find.text('Changes · plan · visit 1'), findsOneWidget);
expect(find.text(missingCaptureDetail), findsOneWidget);
// A missing capture is evidence, never an observed no-change.
expect(find.text('No changes observed'), findsNothing);
expect(find.text(emptyCaptureDetail), findsNothing);
expect(find.text('lib/build.dart'), findsNothing);
});
}
testWidgets('material: visit Changes returns to the opened pane', (
tester,
) async {
await openVisit(
tester,
RunDetailTestPlatform.material,
run: _run(planChanges: _capture('lib/plan.dart')),
);
await _openVisitChanges(tester);
await tester.tap(find.byTooltip('Back'));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.byKey(runVisitChangesButtonKey), findsOneWidget);
});
testWidgets('cupertino: visit Changes returns to the opened pane', (
tester,
) async {
await openVisit(
tester,
RunDetailTestPlatform.cupertino,
run: _run(planChanges: _capture('lib/plan.dart')),
);
await _openVisitChanges(tester);
await tester.tap(find.byType(CupertinoNavigationBarBackButton));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.byKey(runVisitChangesButtonKey), findsOneWidget);
});
}