From a51dea09243a15ca57f369713edd97a47f8cd7d3 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 23 Oct 2026 01:03:27 +0100 Subject: [PATCH] fix(app): runs attention action shares the filter toolbar row --- app/lib/features/runs/ui/runs_filters.dart | 5 +- app/lib/features/runs/ui/runs_list.dart | 53 +++++++++---------- .../runs/ui/runs_list_widget_test.dart | 24 +++++++++ 3 files changed, 53 insertions(+), 29 deletions(-) diff --git a/app/lib/features/runs/ui/runs_filters.dart b/app/lib/features/runs/ui/runs_filters.dart index e6f89d30..a3f333e3 100644 --- a/app/lib/features/runs/ui/runs_filters.dart +++ b/app/lib/features/runs/ui/runs_filters.dart @@ -12,9 +12,10 @@ import 'runs_controller.dart'; /// The buttons sit in a single horizontally scrollable row so a phone at a /// doubled text scale can still reach them without crushing the list. class RunsFilters extends StatelessWidget { - const RunsFilters({super.key, required this.controller}); + const RunsFilters({super.key, required this.controller, this.action}); final RunsController controller; + final Widget? action; @override Widget build(BuildContext context) { @@ -37,6 +38,7 @@ class RunsFilters extends StatelessWidget { Widget _materialToolbar(int count) => Row( mainAxisSize: MainAxisSize.min, children: [ + if (action case final action?) ...[action, const SizedBox(width: 4)], PopupMenuButton<_FilterChoice>( tooltip: count > 0 ? '$count active ${count == 1 ? 'filter' : 'filters'}' @@ -154,6 +156,7 @@ class RunsFilters extends StatelessWidget { Widget _cupertinoToolbar(BuildContext context, int count) => Row( mainAxisSize: MainAxisSize.min, children: [ + if (action case final action?) ...[action, const SizedBox(width: 4)], CupertinoButton( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6), minimumSize: Size.zero, diff --git a/app/lib/features/runs/ui/runs_list.dart b/app/lib/features/runs/ui/runs_list.dart index 3eafc210..4432aaa0 100644 --- a/app/lib/features/runs/ui/runs_list.dart +++ b/app/lib/features/runs/ui/runs_list.dart @@ -75,7 +75,19 @@ class RunsList extends StatelessWidget { onChanged: controller.setQuery, ), ), - RunsFilters(controller: controller), + RunsFilters( + controller: controller, + action: NeedsYouRunsHeading( + rows: controller.runs, + frames: controller.repository.gateway.frames, + onOpen: (entry) => onSelected(entry.runId), + syncToken: syncToken, + store: attentionStore, + now: attentionNow, + notifications: notifications, + attention: attention, + ), + ), Expanded( child: controller.visibleRuns.isEmpty ? const Center(child: Text('No runs found.')) @@ -85,33 +97,18 @@ class RunsList extends StatelessWidget { ); } - Widget _heading(BuildContext context) => Padding( - padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: controller.usage == null - ? const SizedBox.shrink() - : Text( - 'Usage: ${controller.usage}', - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - NeedsYouRunsHeading( - rows: controller.runs, - frames: controller.repository.gateway.frames, - onOpen: (entry) => onSelected(entry.runId), - syncToken: syncToken, - store: attentionStore, - now: attentionNow, - notifications: notifications, - attention: attention, - ), - ], - ), - ); + Widget _heading(BuildContext context) { + final usage = controller.usage; + if (usage == null) return const SizedBox.shrink(); + return Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0), + child: Text( + 'Usage: $usage', + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ); + } Widget _groupedRuns(BuildContext context) { final groups = groupRunsByDay(controller.visibleRuns, DateTime.now()); diff --git a/app/test/features/runs/ui/runs_list_widget_test.dart b/app/test/features/runs/ui/runs_list_widget_test.dart index 7b352e40..cd901dff 100644 --- a/app/test/features/runs/ui/runs_list_widget_test.dart +++ b/app/test/features/runs/ui/runs_list_widget_test.dart @@ -4,8 +4,10 @@ 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/attention/ui/needs_you_runs_heading.dart'; import 'package:pipelines_app/features/runs/data/runs_repository.dart'; import 'package:pipelines_app/features/runs/ui/runs_controller.dart'; +import 'package:pipelines_app/features/runs/ui/runs_filters.dart'; import 'package:pipelines_app/features/runs/ui/runs_list.dart'; class _Gateway implements ApiGateway { @@ -188,4 +190,26 @@ void main() { }, variant: TargetPlatformVariant.only(TargetPlatform.iOS), ); + + for (final cupertino in [false, true]) { + testWidgets('the attention action shares the Filter toolbar row ' + '(${cupertino ? 'Cupertino' : 'Material'})', (tester) async { + await mount(tester, cupertino: cupertino); + await tester.pumpAndSettle(); + final bell = find.descendant( + of: find.byType(RunsFilters), + matching: find.byType(NeedsYouRunsHeading), + ); + expect(bell, findsOneWidget); + final filter = find.descendant( + of: find.byType(RunsFilters), + matching: find.text('Filter'), + ); + expect( + (tester.getCenter(bell).dy - tester.getCenter(filter).dy).abs(), + lessThan(1), + ); + expect(tester.takeException(), isNull); + }); + } }