From 0c1e399e179aefc9acdd6e9c0cd8baed87c6982c Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 23 Oct 2026 17:25:25 +0100 Subject: [PATCH] feat(app): the Changes tab lists the run's final changes, without a filter field --- .../changes/widgets/capture_section.dart | 7 +- .../changes/widgets/changes_viewer.dart | 162 ++++++++---------- app/lib/features/runs/ui/run_detail_tabs.dart | 5 +- .../features/changes/changes_viewer_test.dart | 126 ++++---------- .../features/changes/visit_paging_test.dart | 20 --- .../runs/ui/run_changes_action_test.dart | 17 +- .../runs/ui/run_changes_status_test.dart | 54 +++--- 7 files changed, 138 insertions(+), 253 deletions(-) diff --git a/app/lib/features/changes/widgets/capture_section.dart b/app/lib/features/changes/widgets/capture_section.dart index f82d2988..8d096497 100644 --- a/app/lib/features/changes/widgets/capture_section.dart +++ b/app/lib/features/changes/widgets/capture_section.dart @@ -95,7 +95,7 @@ class StageCaptureSection extends StatelessWidget { ) else for (final file in filtered) - _FileRow( + ChangeFileRow( key: ValueKey('change-${stage.sequence}-${file.path}'), file: file, onOpen: onOpen, @@ -105,8 +105,9 @@ class StageCaptureSection extends StatelessWidget { } } -class _FileRow extends StatelessWidget { - const _FileRow({super.key, required this.file, required this.onOpen}); +/// One changed file: its kind, path and line counts; tapping opens its diff. +class ChangeFileRow extends StatelessWidget { + const ChangeFileRow({super.key, required this.file, required this.onOpen}); final FileChange file; final ValueChanged onOpen; diff --git a/app/lib/features/changes/widgets/changes_viewer.dart b/app/lib/features/changes/widgets/changes_viewer.dart index 0c156660..77520636 100644 --- a/app/lib/features/changes/widgets/changes_viewer.dart +++ b/app/lib/features/changes/widgets/changes_viewer.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; @@ -7,7 +6,6 @@ import '../domain/change_wording.dart'; import '../domain/file_change.dart'; import '../domain/run_changes.dart'; import 'capture_section.dart'; -import 'change_style.dart'; import 'file_diff_viewer.dart'; import 'visit_pager.dart'; @@ -28,6 +26,7 @@ class ChangesViewer extends StatefulWidget { super.key, required this.steps, this.showSummary = true, + this.finalOnly = false, }); /// The run detail's steps exactly as the server returned them. Each step's @@ -43,12 +42,15 @@ class ChangesViewer extends StatefulWidget { /// sections stay the evidence for a run without a settled final state. final bool showSummary; + /// The run's final changes only: the summary and every changed path once, + /// as the last recorded visit left it, with no visit pages. + final bool finalOnly; + @override State createState() => _ChangesViewerState(); } class _ChangesViewerState extends State { - final _filter = TextEditingController(); late List _captures; late RunChanges _run; @@ -88,13 +90,8 @@ class _ChangesViewerState extends State { setState(() => _visitIndex = next); } - @override - void dispose() { - _filter.dispose(); - super.dispose(); - } - - String get _query => _filter.text; + /// No filter field: the visit lists every file its capture recorded. + static const _query = ''; @override Widget build(BuildContext context) { @@ -131,55 +128,79 @@ class _ChangesViewerState extends State { Padding( padding: const EdgeInsets.only(top: 8), child: Text( - 'The summary counts each path once, as the last recorded ' - 'visit left it. Each stage/visit page below lists what ' - 'its own capture recorded.', + widget.finalOnly + ? 'Each path once, as the last recorded visit left ' + 'it. A stage\'s own changes are in its timeline ' + 'detail.' + : 'The summary counts each path once, as the last ' + 'recorded visit left it. Each stage/visit page ' + 'below lists what its own capture recorded.', style: Theme.of(context).textTheme.bodySmall, ), ), ], ), ), - if (showSummary && hasFiles) - Padding( - padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), - child: _filterField(context, run), - ), if (showSummary) const Divider(height: 1), - Expanded( - child: visit == null - ? SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Text(noChangeDetail(run)), - ) - : SingleChildScrollView( - // Keying the body by visit keeps each page's pager and heading - // at the top instead of inheriting the previous scroll offset. - key: ValueKey( - 'changes-visit-${visit.stage}-${visit.sequence}', - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, + // The run's final changes: every changed path once, as it ended. + if (widget.finalOnly) + Expanded( + child: run.files.isEmpty + ? SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Text(noChangeDetail(run)), + ) + : ListView( + key: const ValueKey('changes-final'), children: [ - StageCaptureSection( - stage: visit, - query: _query, - // The page steps through the files this visit shows. - onOpen: (file) => showFileDiffViewer( - context, - file, - files: filterFileChanges( - visit.capture?.files ?? const [], - _query, + for (final file in run.files) + ChangeFileRow( + key: ValueKey('change-final-${file.path}'), + file: file, + onOpen: (file) => showFileDiffViewer( + context, + file, + files: run.files, ), ), - ), ], ), - ), - ), + ), + if (!widget.finalOnly) + Expanded( + child: visit == null + ? SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Text(noChangeDetail(run)), + ) + : SingleChildScrollView( + // Keying the body by visit keeps each page's pager and heading + // at the top instead of inheriting the previous scroll offset. + key: ValueKey( + 'changes-visit-${visit.stage}-${visit.sequence}', + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + StageCaptureSection( + stage: visit, + query: _query, + // The page steps through the files this visit shows. + onOpen: (file) => showFileDiffViewer( + context, + file, + files: filterFileChanges( + visit.capture?.files ?? const [], + _query, + ), + ), + ), + ], + ), + ), + ), // Previous/next visit sit at the bottom right, under the visit. - if (visit != null) + if (!widget.finalOnly && visit != null) ChangesVisitPager( index: _visitIndex, count: captures.length, @@ -189,53 +210,4 @@ class _ChangesViewerState extends State { ], ); } - - Widget _filterField(BuildContext context, RunChanges run) { - final query = _query; - final matched = query.trim().isEmpty - ? run.files.length - : filterFileChanges(run.files, query).length; - // The summary counts paths while the sections below list one row per stage - // visit, so the counter names what it actually counts. - final counter = query.trim().isEmpty - ? '' - : '$matched of ${run.files.length} changed ' - '${run.files.length == 1 ? 'path' : 'paths'} match'; - final field = usesCupertino(context) - ? CupertinoSearchTextField( - controller: _filter, - placeholder: 'Filter changed files', - onChanged: (_) => setState(() {}), - ) - : TextField( - controller: _filter, - decoration: InputDecoration( - labelText: 'Filter changed files', - hintText: 'Filename contains…', - prefixIcon: const Icon(Icons.search), - suffixIcon: query.isEmpty - ? null - : IconButton( - tooltip: 'Clear filter', - onPressed: () { - _filter.clear(); - setState(() {}); - }, - icon: const Icon(Icons.clear), - ), - ), - onChanged: (_) => setState(() {}), - ); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - field, - if (counter.isNotEmpty) - Padding( - padding: const EdgeInsets.only(top: 4), - child: Text(counter, style: Theme.of(context).textTheme.bodySmall), - ), - ], - ); - } } diff --git a/app/lib/features/runs/ui/run_detail_tabs.dart b/app/lib/features/runs/ui/run_detail_tabs.dart index 841703e3..e7be2268 100644 --- a/app/lib/features/runs/ui/run_detail_tabs.dart +++ b/app/lib/features/runs/ui/run_detail_tabs.dart @@ -362,7 +362,10 @@ class _RunDetailTabsState extends State { final viewer = ChangesViewer( key: ValueKey('run-detail-changes-${widget.run['id']}'), steps: runDetailChangeSteps(widget.run), - showSummary: showRunChangesSummary(widget.run['status']), + // The tab is the run's final changes; each visit's own are in its + // timeline detail. + showSummary: true, + finalOnly: true, ); // A CupertinoApp supplies no Material theme; follow the host so the // viewer's section text stays readable. diff --git a/app/test/features/changes/changes_viewer_test.dart b/app/test/features/changes/changes_viewer_test.dart index c30a4446..2ceaa320 100644 --- a/app/test/features/changes/changes_viewer_test.dart +++ b/app/test/features/changes/changes_viewer_test.dart @@ -210,56 +210,6 @@ void main() { }, ); - testWidgets('filtering changed filenames keeps matching rows and says so', ( - tester, - ) async { - await tester.pumpWidget( - materialHost( - ChangesViewer( - steps: [ - stepFixture( - fileChanges: captureFixture( - files: [ - fileChangeFixture(path: 'assets/logo.bin', binary: true), - fileChangeFixture( - path: 'lib/feature.dart', - patch: multiHunkPatch, - ), - fileChangeFixture( - path: 'docs/notes.md', - kind: 'added', - patch: '@@ -0,0 +1 @@\n+x', - ), - ], - ), - ), - ], - ), - ), - ); - expect(find.text('assets/logo.bin'), findsOneWidget); - expect(find.text('lib/feature.dart'), findsOneWidget); - - await tester.enterText(find.byType(TextField), 'feature'); - await tester.pump(); - expect(find.text('lib/feature.dart'), findsOneWidget); - expect(find.text('assets/logo.bin'), findsNothing); - expect(find.text('docs/notes.md'), findsNothing); - expect(find.text('1 of 3 changed paths match'), findsOneWidget); - - await tester.enterText(find.byType(TextField), 'nothing-here'); - await tester.pump(); - expect( - find.text('No changed filenames match "nothing-here".'), - findsOneWidget, - ); - - await tester.enterText(find.byType(TextField), ''); - await tester.pump(); - expect(find.text('assets/logo.bin'), findsOneWidget); - expect(find.textContaining('changed files match'), findsNothing); - }); - testWidgets( 'opening a file shows the rendered patch and copies exact bytes', (tester) async { @@ -400,48 +350,48 @@ void main() { ); }); - testWidgets( - 'Cupertino uses native list tiles, search field and segmented control', - (tester) async { - await tester.pumpWidget( - cupertinoHost( - ChangesViewer( - steps: [ - stepFixture( - fileChanges: captureFixture( - files: [ - fileChangeFixture( - path: 'lib/feature.dart', - patch: multiHunkPatch, - ), - ], - ), + testWidgets('Cupertino uses native list tiles and segmented control', ( + tester, + ) async { + await tester.pumpWidget( + cupertinoHost( + ChangesViewer( + steps: [ + stepFixture( + fileChanges: captureFixture( + files: [ + fileChangeFixture( + path: 'lib/feature.dart', + patch: multiHunkPatch, + ), + ], ), - ], - ), + ), + ], ), - ); - expect(find.byType(CupertinoListTile), findsOneWidget); - expect(find.byType(CupertinoSearchTextField), findsOneWidget); - expect(find.byType(TextField), findsNothing); + ), + ); + expect(find.byType(CupertinoListTile), findsOneWidget); + // No filter field: the changes list shows every recorded file. + expect(find.byType(CupertinoSearchTextField), findsNothing); + expect(find.byType(TextField), findsNothing); - await tester.tap(find.byKey(const ValueKey('change-1-lib/feature.dart'))); - await tester.pumpAndSettle(); - expect( - find.byType(CupertinoSlidingSegmentedControl), - findsOneWidget, - ); - expect(find.text('Rendered'), findsOneWidget); - expect(find.text('Raw patch'), findsOneWidget); + await tester.tap(find.byKey(const ValueKey('change-1-lib/feature.dart'))); + await tester.pumpAndSettle(); + expect( + find.byType(CupertinoSlidingSegmentedControl), + findsOneWidget, + ); + expect(find.text('Rendered'), findsOneWidget); + expect(find.text('Raw patch'), findsOneWidget); - await tester.tap(find.byIcon(CupertinoIcons.xmark)); - await tester.pumpAndSettle(); - expect( - find.byType(CupertinoSlidingSegmentedControl), - findsNothing, - ); - }, - ); + await tester.tap(find.byIcon(CupertinoIcons.xmark)); + await tester.pumpAndSettle(); + expect( + find.byType(CupertinoSlidingSegmentedControl), + findsNothing, + ); + }); testWidgets('narrow viewport and large text keep every control reachable', ( tester, diff --git a/app/test/features/changes/visit_paging_test.dart b/app/test/features/changes/visit_paging_test.dart index 2f865834..c8b99427 100644 --- a/app/test/features/changes/visit_paging_test.dart +++ b/app/test/features/changes/visit_paging_test.dart @@ -138,26 +138,6 @@ void main() { expect(find.text('lib/only.dart'), findsOneWidget); }); - testWidgets('the filter and its aggregate counter survive paging', ( - tester, - ) async { - await tester.pumpWidget(materialHost(ChangesViewer(steps: twoVisitRun()))); - - await tester.enterText(find.byType(TextField), 'a.dart'); - await tester.pump(); - expect(find.text('1 of 3 changed paths match'), findsOneWidget); - expect(find.text('lib/a.dart'), findsOneWidget); - - await tester.tap(find.byKey(ChangesVisitPager.nextKey)); - await tester.pump(); - // The filter still applies to the shown visit, and the counter still - // describes the whole run's changed paths. - expect(find.text('1 of 3 changed paths match'), findsOneWidget); - expect(find.text('No changed filenames match "a.dart".'), findsOneWidget); - expect(find.text('lib/c.dart'), findsNothing); - expect(find.text('reviewer'), findsOneWidget); - }); - testWidgets('a shorter reply clamps the shown visit instead of overflowing', ( tester, ) async { diff --git a/app/test/features/runs/ui/run_changes_action_test.dart b/app/test/features/runs/ui/run_changes_action_test.dart index 786e75d1..3ddbf41b 100644 --- a/app/test/features/runs/ui/run_changes_action_test.dart +++ b/app/test/features/runs/ui/run_changes_action_test.dart @@ -118,22 +118,11 @@ void main() { find.text('1 file changed · +2 -2 · capture incomplete'), findsOneWidget, ); - // The page opens on the run's first recorded visit; its stage/visit - // heading identifies the evidence, and Next reaches the second visit. - expect(find.text('Visit 1 · completed'), findsOneWidget); - expect(find.text('implementer'), findsOneWidget); - expect(find.byKey(ChangesVisitPager.nextKey), findsOneWidget); - await tester.tap(find.byKey(ChangesVisitPager.nextKey)); - await tester.pump(); - expect(find.text('reviewer'), findsOneWidget); - expect(find.text('Visit 1 · completed'), findsOneWidget); - expect(find.text('lib/feature.dart'), findsNothing); - await tester.tap(find.byKey(ChangesVisitPager.previousKey)); - await tester.pump(); - expect(find.text('lib/feature.dart'), findsOneWidget); + // The tab is the final state: each path once, no visit pages. + expect(find.byKey(ChangesVisitPager.nextKey), findsNothing); await tester.tap( - find.byKey(const ValueKey('change-1-lib/feature.dart')), + find.byKey(const ValueKey('change-final-lib/feature.dart')), ); await tester.pumpAndSettle(); final rendered = tester diff --git a/app/test/features/runs/ui/run_changes_status_test.dart b/app/test/features/runs/ui/run_changes_status_test.dart index 284455c6..8544e6c2 100644 --- a/app/test/features/runs/ui/run_changes_status_test.dart +++ b/app/test/features/runs/ui/run_changes_status_test.dart @@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.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/changes/widgets/visit_pager.dart'; import 'package:pipelines_app/features/runs/data/runs_repository.dart'; import 'package:pipelines_app/features/runs/ui/run_changes_action.dart'; @@ -124,38 +123,29 @@ void main() { }); for (final platform in _Platform.values) { - testWidgets( - '${platform.name}: a failed run keeps visit evidence, not a summary', - (tester) async { - await _openChanges( - tester, - platform, - _run( - status: 'failed', - fileChanges: captureFixture( - files: [fileChangeFixture(path: 'lib/feature.dart')], - ), + testWidgets('${platform.name}: a failed run tab shows its final changes', ( + tester, + ) async { + await _openChanges( + tester, + platform, + _run( + status: 'failed', + fileChanges: captureFixture( + files: [fileChangeFixture(path: 'lib/feature.dart')], ), - ); + ), + ); - // The web client shows the aggregate only for succeeded runs. - expect(find.textContaining('file changed ·'), findsNothing); - expect( - find.textContaining('The summary counts each path once'), - findsNothing, - ); - // The visit's own recorded capture stays reachable, one visit page at - // a time; the second visit's gap is reachable with Next. - expect(find.text('lib/feature.dart'), findsOneWidget); - expect(find.text('implementer'), findsOneWidget); - expect(find.text('Visit 1 · completed'), findsOneWidget); - await tester.tap(find.byKey(ChangesVisitPager.nextKey)); - await tester.pump(); - expect(find.text('reviewer'), findsOneWidget); - expect(find.text(missingCaptureDetail), findsOneWidget); - expect(tester.takeException(), isNull); - }, - ); + // The tab is the end state: each changed path once, no visit pages. + expect(find.byKey(const ValueKey('changes-final')), findsOneWidget); + expect( + find.byKey(const ValueKey('change-final-lib/feature.dart')), + findsOneWidget, + ); + expect(find.byKey(ChangesVisitPager.nextKey), findsNothing); + expect(tester.takeException(), isNull); + }); testWidgets( '${platform.name}: an active run offers no snapshot Changes page', @@ -206,7 +196,7 @@ void main() { // The diff opens on the app Navigator, above the page's theme, so its // own header must follow the host brightness too. await tester.tap( - find.byKey(const ValueKey('change-1-lib/feature.dart')), + find.byKey(const ValueKey('change-final-lib/feature.dart')), ); await tester.pumpAndSettle(); final title = tester.widget(find.text('Modified'));