diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index b6350c2d..5778dd03 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -380,6 +380,8 @@ class _PipelinesAppState extends State server: widget.server, refreshToken: _pipelinesRefresh, onRunStarted: _runStarted, + onViewPipelineRuns: (id) => + _delegate.goTo(AppRoute.runsForPipeline(id)), initialPipelineId: route.pipelineId, initialVersion: route.version, initialStageKey: route.stageKey, @@ -393,6 +395,7 @@ class _PipelinesAppState extends State session: _session, server: widget.server, initialRunId: route.runId, + initialPipelineId: route.pipelineId, initialStageKey: route.stageKey, initialVisit: route.visit, initialDecide: route.decide, @@ -400,7 +403,12 @@ class _PipelinesAppState extends State notifications: _notifications, attention: _attention, onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)), - onBack: () => _delegate.goTo(AppRoute.runs), + onBack: (id) => _delegate.goTo( + id == null ? AppRoute.runs : AppRoute.runsForPipeline(id), + ), + onPipelineFilterChanged: (id) => _delegate.goTo( + id == null ? AppRoute.runs : AppRoute.runsForPipeline(id), + ), ), ), AppDestination.chat: (_) => ChatDestination( diff --git a/app/lib/application/pipelines_destination.dart b/app/lib/application/pipelines_destination.dart index e7c492e1..5720c3e6 100644 --- a/app/lib/application/pipelines_destination.dart +++ b/app/lib/application/pipelines_destination.dart @@ -19,6 +19,7 @@ class PipelinesDestination extends StatelessWidget { required this.server, this.refreshToken = 0, this.onRunStarted, + this.onViewPipelineRuns, this.initialPipelineId, this.initialVersion = 0, this.initialStageKey, @@ -34,6 +35,7 @@ class PipelinesDestination extends StatelessWidget { /// Receives the run id an accepted launch named; the shell opens that route. final ValueChanged? onRunStarted; + final ValueChanged? onViewPipelineRuns; /// The pipeline and pinned version a deep link names. final int? initialPipelineId; @@ -77,6 +79,7 @@ class PipelinesDestination extends StatelessWidget { gateway: session.gateway, embedded: true, onRunStarted: onRunStarted, + onViewPipelineRuns: onViewPipelineRuns, initialPipelineId: initialPipelineId, initialVersion: initialVersion, initialStageKey: initialStageKey, diff --git a/app/lib/application/runs_destination.dart b/app/lib/application/runs_destination.dart index a987b086..005b2243 100644 --- a/app/lib/application/runs_destination.dart +++ b/app/lib/application/runs_destination.dart @@ -20,11 +20,13 @@ class RunsDestination extends StatelessWidget { required this.session, required this.server, this.initialRunId, + this.initialPipelineId, this.initialStageKey, this.initialVisit, this.initialDecide = false, this.onRunSelected, this.onBack, + this.onPipelineFilterChanged, this.listRefreshToken = 0, this.notifications, this.attention, @@ -33,6 +35,7 @@ class RunsDestination extends StatelessWidget { final AppSession session; final ServerEndpoint server; final int? initialRunId; + final int? initialPipelineId; /// The stage key and optional visit a `/runs/:id/stage/:key[?visit=N]` route /// names. They reach the detail only through [RunsScreen]; the destination @@ -45,7 +48,8 @@ class RunsDestination extends StatelessWidget { final bool initialDecide; final ValueChanged? onRunSelected; - final VoidCallback? onBack; + final ValueChanged? onBack; + final ValueChanged? onPipelineFilterChanged; /// Advances when a launch was accepted elsewhere. The mounted Runs screen /// re-reads its list once; no row is inserted locally. @@ -92,6 +96,7 @@ class RunsDestination extends StatelessWidget { Widget _runsScreen() => RunsScreen( gateway: session.gateway, initialRunId: initialRunId, + initialPipelineId: initialPipelineId, initialStageKey: initialStageKey, initialVisit: initialVisit, initialDecide: initialDecide, @@ -101,5 +106,6 @@ class RunsDestination extends StatelessWidget { attention: attention, onRunSelected: onRunSelected, onBack: onBack, + onPipelineFilterChanged: onPipelineFilterChanged, ); } diff --git a/app/lib/features/pipelines/screen.dart b/app/lib/features/pipelines/screen.dart index c7de8828..590281c5 100644 --- a/app/lib/features/pipelines/screen.dart +++ b/app/lib/features/pipelines/screen.dart @@ -28,6 +28,7 @@ class PipelinesScreen extends StatefulWidget { this.embedded = false, this.syncToken = 0, this.onRunStarted, + this.onViewPipelineRuns, this.initialPipelineId, this.initialVersion = 0, this.initialStageKey, @@ -45,6 +46,7 @@ class PipelinesScreen extends StatefulWidget { /// Receives the run id an accepted launch names, so the composition can open /// the existing run route. The feature never navigates on its own. final ValueChanged? onRunStarted; + final ValueChanged? onViewPipelineRuns; /// The pipeline a deep link names, opened after the list read starts. final int? initialPipelineId; @@ -170,6 +172,7 @@ class _PipelinesScreenState extends State { gateway: widget.gateway, showBack: true, onRunStarted: widget.onRunStarted, + onViewPipelineRuns: widget.onViewPipelineRuns, stageKey: stageKey, stagePipelineId: widget.initialPipelineId, stageVersion: widget.initialVersion, @@ -192,6 +195,7 @@ class _PipelinesScreenState extends State { gateway: widget.gateway, showBack: false, onRunStarted: widget.onRunStarted, + onViewPipelineRuns: widget.onViewPipelineRuns, stageKey: stageKey, stagePipelineId: widget.initialPipelineId, stageVersion: widget.initialVersion, diff --git a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart index 69014cad..351cea2c 100644 --- a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart @@ -30,6 +30,7 @@ class PipelineDetailPanel extends StatefulWidget { required this.gateway, required this.showBack, this.onRunStarted, + this.onViewPipelineRuns, this.stageKey, this.stagePipelineId, this.stageVersion = 0, @@ -45,6 +46,7 @@ class PipelineDetailPanel extends StatefulWidget { /// A run started from this detail's Run action; receives the server's id. final ValueChanged? onRunStarted; + final ValueChanged? onViewPipelineRuns; /// The stage the route names for this detail, or null when it names none. final String? stageKey; @@ -337,6 +339,25 @@ class _PipelineDetailPanelState extends State { onRunStarted: widget.onRunStarted, ), ), + Align( + alignment: AlignmentDirectional.centerStart, + child: Semantics( + button: true, + label: detail.name.trim().isEmpty + ? 'View runs of this pipeline' + : 'View runs of ${detail.name}', + child: ExcludeSemantics( + child: TextButton.icon( + onPressed: widget.onViewPipelineRuns == null + ? null + : () => widget.onViewPipelineRuns!(detail.id), + icon: const Icon(Icons.list_alt), + label: const Text('Runs'), + key: const Key('pipeline-view-runs'), + ), + ), + ), + ), ], ), ); diff --git a/app/lib/features/runs/screen.dart b/app/lib/features/runs/screen.dart index 444aad3e..33ee84da 100644 --- a/app/lib/features/runs/screen.dart +++ b/app/lib/features/runs/screen.dart @@ -25,6 +25,7 @@ class RunsScreen extends StatefulWidget { super.key, required this.gateway, this.initialRunId, + this.initialPipelineId, this.initialStageKey, this.initialVisit, this.initialDecide = false, @@ -32,6 +33,7 @@ class RunsScreen extends StatefulWidget { this.listRefreshToken = 0, this.onRunSelected, this.onBack, + this.onPipelineFilterChanged, this.attentionStore = const SharedPreferencesAttentionStore(), this.attentionNow, this.notifications, @@ -42,6 +44,7 @@ class RunsScreen extends StatefulWidget { /// The run the current route names, or null for the list. final int? initialRunId; + final int? initialPipelineId; /// The recorded stage visit the route names inside [initialRunId]. The detail /// applies it once per route target; the feature never invents a visit. @@ -62,7 +65,8 @@ class RunsScreen extends StatefulWidget { final int listRefreshToken; final ValueChanged? onRunSelected; - final VoidCallback? onBack; + final ValueChanged? onBack; + final ValueChanged? onPipelineFilterChanged; /// Persisted attention dismissals and the clock for its local-day window. /// The app uses SharedPreferences; tests and fixtures inject a memory store. @@ -82,6 +86,8 @@ class RunsScreen extends StatefulWidget { class _RunsScreenState extends State { late final RunsController controller; num? _shownRunId; + int? _reportedPipelineId; + bool _applyingRoutePipeline = false; /// The route's decision request is one-shot: the first loaded detail for the /// named run consumes it, whether or not that run is waiting. @@ -91,8 +97,14 @@ class _RunsScreenState extends State { void initState() { super.initState(); controller = RunsController(RunsRepository(widget.gateway)); + _reportedPipelineId = widget.initialPipelineId; + if (widget.initialPipelineId != null) { + controller.clearFilters(); + controller.setPipeline(widget.initialPipelineId); + } controller.listen(widget.gateway.frames); controller.addListener(_selectionChanged); + controller.addListener(_pipelineFilterChanged); controller.addListener(_detailChanged); controller.load(widget.initialRunId); } @@ -104,6 +116,21 @@ class _RunsScreenState extends State { widget.initialDecide != oldWidget.initialDecide) { _decideConsumed = false; } + if (widget.initialPipelineId != oldWidget.initialPipelineId) { + final id = widget.initialPipelineId; + // A run detail replaces the list URL but retains its active list filter. + // Only a route back to the list can explicitly clear that facet. + if (id != null || widget.initialRunId == null) { + _applyingRoutePipeline = true; + try { + if (id != null) controller.clearFilters(); + controller.setPipeline(id); + _reportedPipelineId = id; + } finally { + _applyingRoutePipeline = false; + } + } + } if (widget.syncToken != oldWidget.syncToken) { controller.resync(); } @@ -137,6 +164,19 @@ class _RunsScreenState extends State { if (mounted) setState(() {}); } + void _pipelineFilterChanged() { + final id = controller.pipelineId; + if (_applyingRoutePipeline) { + _reportedPipelineId = id; + return; + } + if (id == _reportedPipelineId) return; + _reportedPipelineId = id; + if (controller.selectedRunId == null) { + widget.onPipelineFilterChanged?.call(id); + } + } + /// Opens the route's decision prompt after the named detail has arrived. /// A non-waiting run consumes the request without a prompt, and the prompt /// itself only closes; the detail underneath is left as it is. @@ -171,12 +211,13 @@ class _RunsScreenState extends State { void _back() { controller.back(); - widget.onBack?.call(); + widget.onBack?.call(controller.pipelineId); } @override void dispose() { controller.removeListener(_selectionChanged); + controller.removeListener(_pipelineFilterChanged); controller.removeListener(_detailChanged); controller.dispose(); super.dispose(); diff --git a/app/test/application/runs_destination_test.dart b/app/test/application/runs_destination_test.dart index abdd07fd..977a3482 100644 --- a/app/test/application/runs_destination_test.dart +++ b/app/test/application/runs_destination_test.dart @@ -21,7 +21,7 @@ Widget materialApp( ServerEndpoint server, { int? initialRunId, ValueChanged? onRunSelected, - VoidCallback? onBack, + ValueChanged? onBack, }) => MaterialApp( home: Scaffold( body: RunsDestination( diff --git a/app/test/features/pipelines/pipelines_screen_test.dart b/app/test/features/pipelines/pipelines_screen_test.dart index a61f4d36..a4ccc60b 100644 --- a/app/test/features/pipelines/pipelines_screen_test.dart +++ b/app/test/features/pipelines/pipelines_screen_test.dart @@ -86,6 +86,30 @@ void main() { expect(find.text('Viewing v1 (latest v2).'), findsNothing); }); + testWidgets('detail Runs action names and opens that pipeline filter', ( + tester, + ) async { + final fixture = PipelineFixture(); + final gateway = gatewayFor(fixture); + final opened = []; + tester.view.physicalSize = const Size(1100, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget( + MaterialApp( + home: PipelinesScreen(gateway: gateway, onViewPipelineRuns: opened.add), + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('pipeline-row-1'))); + await tester.pumpAndSettle(); + + expect(find.bySemanticsLabel('View runs of Alpha review'), findsOneWidget); + await tester.tap(find.byKey(const Key('pipeline-view-runs'))); + expect(opened, [1]); + }); + testWidgets('refresh keeps the selected row and its detail', (tester) async { final fixture = PipelineFixture(); final gateway = gatewayFor(fixture); diff --git a/app/test/features/runs/ui/runs_screen_test.dart b/app/test/features/runs/ui/runs_screen_test.dart index e66cdfb8..e044e234 100644 --- a/app/test/features/runs/ui/runs_screen_test.dart +++ b/app/test/features/runs/ui/runs_screen_test.dart @@ -46,17 +46,21 @@ const _runs = [ Widget _materialScreen( _Gateway gateway, { int? initialRunId, + int? initialPipelineId, int syncToken = 0, ValueChanged? onRunSelected, - VoidCallback? onBack, + ValueChanged? onBack, + ValueChanged? onPipelineFilterChanged, }) => MaterialApp( home: Scaffold( body: RunsScreen( gateway: gateway, initialRunId: initialRunId, + initialPipelineId: initialPipelineId, syncToken: syncToken, onRunSelected: onRunSelected, onBack: onBack, + onPipelineFilterChanged: onPipelineFilterChanged, ), ), ); @@ -149,12 +153,12 @@ void main() { tester, ) async { int? selected; - var backs = 0; + int? backedPipeline; await tester.pumpWidget( _materialScreen( gateway, onRunSelected: (id) => selected = id, - onBack: () => backs++, + onBack: (id) => backedPipeline = id, ), ); await _mountList(tester, gateway); @@ -167,10 +171,60 @@ void main() { await tester.tap(find.text('Back to list')); await tester.pump(); - expect(backs, 1); + expect(backedPipeline, isNull); expect(find.text('Alpha run'), findsOneWidget); }); + testWidgets( + 'pipeline route shows its chip and clearing reports the URL change', + (tester) async { + int? changedPipeline = 3; + await tester.pumpWidget( + _materialScreen( + gateway, + initialPipelineId: 3, + onPipelineFilterChanged: (id) => changedPipeline = id, + ), + ); + await _mountList(tester, gateway); + + expect(find.text('Pipeline 3'), findsOneWidget); + expect(changedPipeline, 3); + await tester.tap(find.byTooltip('Clear filter: Pipeline 3')); + await tester.pump(); + expect(changedPipeline, isNull); + expect(find.text('Pipeline 3'), findsNothing); + }, + ); + + testWidgets('run detail keeps the pipeline filter for Back routing', ( + tester, + ) async { + int? backPipeline; + await tester.pumpWidget( + _materialScreen( + gateway, + initialPipelineId: 3, + onBack: (id) => backPipeline = id, + ), + ); + await _mountList(tester, gateway); + await tester.pumpWidget( + _materialScreen( + gateway, + initialRunId: 2, + onBack: (id) => backPipeline = id, + ), + ); + await tester.pump(); + gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'}); + await tester.pump(); + + await tester.tap(find.text('Back to list')); + await tester.pump(); + expect(backPipeline, 3); + }); + testWidgets('a route change opens and closes the named run', (tester) async { await tester.pumpWidget(_materialScreen(gateway, initialRunId: 2)); await _mountList(tester, gateway);