From 78e9d0375972c35eb58348d4ffde1090a22259db Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 14:25:59 +0100 Subject: [PATCH] feat(app): follow the web pipeline list composition Compact list toolbar and rows on the web's 12px inset, a title line with the trailing version, one muted facts line plus the last-run line, and row separators. The detail header becomes one identity line; its recorded id/version/stage facts move to the top of Summary, where web renders detail-subtitle. --- .../widgets/pipeline_detail_panel.dart | 62 ++++--- .../widgets/pipeline_list_panel.dart | 154 ++++++++++++------ .../widgets/pipeline_summary_view.dart | 9 + .../pipelines_registration_test.dart | 5 +- .../pipeline_list_composition_test.dart | 139 ++++++++++++++++ .../pipelines/pipeline_row_metadata_test.dart | 13 +- .../pipeline_row_miniature_test.dart | 8 +- .../pipelines/pipelines_screen_test.dart | 13 +- 8 files changed, 307 insertions(+), 96 deletions(-) create mode 100644 app/test/features/pipelines/pipeline_list_composition_test.dart diff --git a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart index 1516bb23..69014cad 100644 --- a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart @@ -6,7 +6,6 @@ import '../../../core/api_gateway.dart'; import '../../graph/domain/graph_definition.dart'; import '../../graph/widgets/stage_definition_view.dart'; import '../pipeline_models.dart'; -import '../pipeline_query.dart'; import '../pipelines_controller.dart'; import '../ui/run_pipeline_action.dart'; import 'pipeline_controls.dart'; @@ -303,42 +302,41 @@ class _PipelineDetailPanelState extends State { ); Widget _header(BuildContext context, PipelineDetail detail) { - final title = Text(detail.displayName, style: pipelineTitleStyle(context)); - final subtitle = Text( - pipelineSubtitle(detail), - style: pipelineMutedStyle(context), - ); - final heading = Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [title, subtitle], - ); - final action = Align( - alignment: AlignmentDirectional.centerStart, - child: RunPipelineAction( - controller: _controller, - detail: detail, - gateway: widget.gateway, - onRunStarted: widget.onRunStarted, - ), + final title = Text( + detail.displayName, + style: pipelineTitleStyle(context), + maxLines: 1, + overflow: TextOverflow.ellipsis, ); + final heading = widget.showBack + ? Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + PipelineBackButton(onPressed: _controller.clearSelection), + const SizedBox(width: 4), + Expanded(child: title), + ], + ) + : title; return Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + key: const Key('pipeline-detail-header'), + // The web detail head is a compact single identity line; the recorded + // id/version/stage facts live at the top of the Summary tab. + padding: const EdgeInsets.fromLTRB(12, 6, 12, 4), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - if (widget.showBack) - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - PipelineBackButton(onPressed: _controller.clearSelection), - const SizedBox(width: 4), - Expanded(child: heading), - ], - ) - else - heading, - const SizedBox(height: 8), - action, + heading, + const SizedBox(height: 4), + Align( + alignment: AlignmentDirectional.centerStart, + child: RunPipelineAction( + controller: _controller, + detail: detail, + gateway: widget.gateway, + onRunStarted: widget.onRunStarted, + ), + ), ], ), ); diff --git a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart index 2820f605..522910f7 100644 --- a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart @@ -16,6 +16,10 @@ import '../pipelines_controller.dart'; import 'pipeline_controls.dart'; import 'pipeline_filter_page.dart'; +/// The list's horizontal rhythm, matching the web's toolbar and row inset +/// (`var(--space-s)`: 12px). The detail pane keeps its own content padding. +const double kPipelineListInset = 12; + /// The left/top pane: filter and sort controls, then the truthful list states. class PipelineListPanel extends StatelessWidget { const PipelineListPanel({super.key, required this.controller}); @@ -29,14 +33,50 @@ class PipelineListPanel extends StatelessWidget { (pipeline) => pipeline.scheduleState == PipelineScheduleState.unclassified, ); + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _toolbar(context, filters, hasUnclassified), + if (controller.listError != null) + PipelineErrorBanner( + message: controller.listError!, + onRetry: controller.load, + ), + if (controller.runsError != null) + PipelineErrorBanner( + message: + '${controller.runsLoaded ? 'Last runs could not be refreshed' : 'Last runs unavailable'}: ' + '${controller.runsError}', + onRetry: controller.load, + ), + if (controller.listLoading && controller.pipelinesLoaded) + const Padding( + padding: EdgeInsets.symmetric(horizontal: kPipelineListInset), + child: PipelineProgress(label: 'Refreshing pipelines'), + ), + Expanded(child: _content(context)), + ], + ); + } + + /// The web's compact toolbar: filter (whose page carries the name search), + /// sort and clear, on the list's 12px inset with a separator underneath. + Widget _toolbar( + BuildContext context, + PipelineFilters filters, + bool hasUnclassified, + ) { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 4), + padding: const EdgeInsets.symmetric( + horizontal: kPipelineListInset, + vertical: 2, + ), child: Wrap( - spacing: 8, - runSpacing: 4, + key: const Key('pipeline-toolbar'), + spacing: 4, crossAxisAlignment: WrapCrossAlignment.center, children: [ PipelineTextButton( @@ -65,24 +105,7 @@ class PipelineListPanel extends StatelessWidget { ], ), ), - if (controller.listError != null) - PipelineErrorBanner( - message: controller.listError!, - onRetry: controller.load, - ), - if (controller.runsError != null) - PipelineErrorBanner( - message: - '${controller.runsLoaded ? 'Last runs could not be refreshed' : 'Last runs unavailable'}: ' - '${controller.runsError}', - onRetry: controller.load, - ), - if (controller.listLoading && controller.pipelinesLoaded) - const Padding( - padding: EdgeInsets.symmetric(horizontal: 16), - child: PipelineProgress(label: 'Refreshing pipelines'), - ), - Expanded(child: _content(context)), + const Divider(height: 1), ], ); } @@ -150,9 +173,10 @@ class PipelineListPanel extends StatelessWidget { Widget _materialList(BuildContext context, List items) { final now = DateTime.now(); - return ListView.builder( + return ListView.separated( key: const Key('pipeline-list'), itemCount: items.length, + separatorBuilder: (context, index) => const Divider(height: 1), itemBuilder: (context, index) { final pipeline = items[index]; return ListTile( @@ -160,8 +184,12 @@ class PipelineListPanel extends StatelessWidget { selected: controller.selectedId == pipeline.id, onTap: () => controller.openPipeline(pipeline.id, version: pipeline.version), + contentPadding: const EdgeInsets.symmetric( + horizontal: kPipelineListInset, + ), + visualDensity: VisualDensity.compact, title: _rowTitle(context, pipeline), - subtitle: _subtitle(context, pipeline, now), + subtitle: _rowMetadata(context, pipeline, now), ); }, ); @@ -178,7 +206,7 @@ class PipelineListPanel extends StatelessWidget { CupertinoListTile( key: Key('pipeline-row-${pipeline.id}'), title: _rowTitle(context, pipeline), - subtitle: _subtitle(context, pipeline, now), + subtitle: _rowMetadata(context, pipeline, now), trailing: const CupertinoListTileChevron(), onTap: () => controller.openPipeline( pipeline.id, @@ -191,43 +219,71 @@ class PipelineListPanel extends StatelessWidget { ); } - /// The row's name plus its recorded miniature, when the reply carried one. - /// The trailing cue never replaces or fills in any metadata line. + /// The row's title line: its name and its version at the trailing edge. Widget _rowTitle(BuildContext context, PipelineSummary pipeline) { - final shape = pipeline.shape; + final muted = _mutedStyle(context); return Row( children: [ - Expanded(child: Text(pipeline.displayName)), - if (shape != null) - PipelineMiniGraph( - key: Key('pipeline-mini-${pipeline.id}'), - shape: shape, + Expanded( + child: Text( + pipeline.displayName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + // Weight only: the native tile owns size and the selected colour. + style: const TextStyle(fontWeight: FontWeight.w600), ), + ), + const SizedBox(width: 8), + Text(pipelineVersionLabel(pipeline), style: muted), ], ); } - Widget _subtitle( + /// The row's one muted metadata line plus its last-run line. + /// + /// Everything printed comes from recorded values: the identity, the stage + /// count, the configured schedules and the parseable updated time. The run + /// line keeps the web's state word and `row-meta` fragments + /// (`Succeeded · 2h ago · 1m 5s · run 42`). + Widget _rowMetadata( BuildContext context, PipelineSummary pipeline, DateTime now, ) { - final rows = [Text(pipelineSubtitle(pipeline))]; - final updated = pipelineUpdatedLine(pipeline); - if (updated != null) rows.add(Text(updated)); - if (pipeline.scheduleLabel.isNotEmpty) { - rows.add(Text(pipeline.scheduleLabel)); - } - if (controller.runsLoaded) { - final run = controller.latestRuns[pipeline.id]; - if (run == null) { - rows.add(Text('no runs recorded', style: _mutedStyle(context))); - } else { - final badge = runBadge(run, now); - rows.add(Text('${runStateLabel(badge.state)} · ${badge.metaLine}')); - } - } - return Column(crossAxisAlignment: CrossAxisAlignment.start, children: rows); + final style = _mutedStyle(context); + final facts = [ + 'id ${pipeline.id}', + pipelineStageSummary(pipeline), + if (pipeline.scheduleLabel.isNotEmpty) pipeline.scheduleLabel, + ?pipelineUpdatedLine(pipeline), + ].join(' · '); + final run = controller.runsLoaded + ? controller.latestRuns[pipeline.id] + : null; + final badge = run == null ? null : runBadge(run, now); + final runLine = controller.runsLoaded + ? badge == null + ? 'no runs recorded' + : '${runStateLabel(badge.state)} · ${badge.metaLine}' + : null; + final shape = pipeline.shape; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // The web prints the miniature as its own right-aligned block below the + // title rather than inside the title line. + if (shape != null) + Align( + alignment: AlignmentDirectional.centerEnd, + child: PipelineMiniGraph( + key: Key('pipeline-mini-${pipeline.id}'), + shape: shape, + ), + ), + Text(facts, style: style), + if (runLine != null && runLine.isNotEmpty) Text(runLine, style: style), + ], + ); } TextStyle? _mutedStyle(BuildContext context) { diff --git a/app/lib/features/pipelines/widgets/pipeline_summary_view.dart b/app/lib/features/pipelines/widgets/pipeline_summary_view.dart index ea78de0a..51787715 100644 --- a/app/lib/features/pipelines/widgets/pipeline_summary_view.dart +++ b/app/lib/features/pipelines/widgets/pipeline_summary_view.dart @@ -31,6 +31,15 @@ class PipelineSummaryView extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + // The web's Summary subtitle: the compact header names the pipeline, + // this line carries its recorded identity. + Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 0), + child: Text( + pipelineSubtitle(detail), + style: pipelineMutedStyle(context), + ), + ), if (historical) Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), diff --git a/app/test/application/pipelines_registration_test.dart b/app/test/application/pipelines_registration_test.dart index 19a9d6e3..edce4eb5 100644 --- a/app/test/application/pipelines_registration_test.dart +++ b/app/test/application/pipelines_registration_test.dart @@ -56,7 +56,10 @@ void main() { await tester.pump(); expect(find.text('Alpha review'), findsOneWidget); - expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget); + expect( + find.text('id 1 · 2 stages · 1 schedule · updated 17 Oct 21:26'), + findsOneWidget, + ); expect(find.text('Pipelines — Not implemented'), findsNothing); expect(sockets, 1); diff --git a/app/test/features/pipelines/pipeline_list_composition_test.dart b/app/test/features/pipelines/pipeline_list_composition_test.dart new file mode 100644 index 00000000..7e5299cc --- /dev/null +++ b/app/test/features/pipelines/pipeline_list_composition_test.dart @@ -0,0 +1,139 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/pipelines/screen.dart'; +import 'package:pipelines_app/features/pipelines/widgets/pipeline_list_panel.dart'; + +import 'fixtures.dart'; +import 'test_helpers.dart'; + +/// The list/detail composition follows the web list: one compact toolbar on a +/// 12px inset, rows with a title line, a muted facts line, the version and the +/// last run, separated from each other, and a one-line detail identity header +/// whose recorded facts live at the top of Summary. +void main() { + testWidgets('toolbar, rows and separators share the web list inset', ( + tester, + ) async { + final fixture = PipelineFixture(); + await pumpWide(tester, gatewayFor(fixture)); + + final list = find.byKey(const Key('pipeline-list')); + final listLeft = tester.getTopLeft(list).dx; + + expect( + tester.getTopLeft(find.byKey(const Key('pipeline-toolbar'))).dx - + listLeft, + kPipelineListInset, + ); + expect( + tester.getTopLeft(find.text('Alpha review')).dx - listLeft, + kPipelineListInset, + ); + + expect( + find.descendant(of: list, matching: find.byType(Divider)), + findsNWidgets(fixture.summaries.length - 1), + ); + + // The version trails the title line; the recorded facts are one line and + // the run line keeps the web's state word and fragments. + expect(find.text('v2'), findsOneWidget); + expect( + find.text('id 1 · 2 stages · 1 schedule · updated 17 Oct 21:26'), + findsOneWidget, + ); + expect(find.textContaining('Succeeded · '), findsOneWidget); + expect(find.textContaining('Failed · '), findsOneWidget); + expect(find.text('no runs recorded'), findsOneWidget); + }); + + testWidgets('the detail header is one identity line; Summary keeps facts', ( + tester, + ) async { + final fixture = PipelineFixture(); + await pumpWide(tester, gatewayFor(fixture)); + await tester.tap(find.byKey(const Key('pipeline-row-1'))); + await tester.pumpAndSettle(); + + final detail = find.byKey(const Key('pipeline-detail')); + final header = find.byKey(const Key('pipeline-detail-header')); + expect(header, findsOneWidget); + expect( + find.descendant(of: header, matching: find.text('Alpha review')), + findsOneWidget, + ); + expect( + find.descendant(of: header, matching: find.text('id 1 · v2 · 2 stages')), + findsNothing, + ); + // The recorded identity now sits at the top of the Summary tab. + expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget); + expect( + tester + .getTopLeft( + find.descendant( + of: header, + matching: find.text('Alpha review'), + ), + ) + .dx - + tester.getTopLeft(detail).dx, + 12, + ); + }); + + testWidgets('narrow 2x keeps the row identity and facts without overflow', ( + tester, + ) async { + tester.view.physicalSize = const Size(320, 640); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget( + MaterialApp( + builder: (context, child) => MediaQuery( + data: MediaQuery.of( + context, + ).copyWith(textScaler: const TextScaler.linear(2)), + child: child!, + ), + home: PipelinesScreen(gateway: gatewayFor(PipelineFixture())), + ), + ); + await tester.pumpAndSettle(); + + expect(tester.takeException(), isNull); + expect(find.text('Alpha review'), findsOneWidget); + expect(find.text('v2'), findsOneWidget); + // The facts line wraps instead of truncating at large text. + expect(find.textContaining('updated 17 Oct 21:26'), findsOneWidget); + }); + + testWidgets('Cupertino keeps native tiles with the same row identity', ( + tester, + ) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + tester.view.physicalSize = const Size(1100, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + try { + await tester.pumpWidget( + CupertinoApp( + home: PipelinesScreen(gateway: gatewayFor(PipelineFixture())), + ), + ); + await tester.pumpAndSettle(); + + expect(find.byType(CupertinoListTile), findsWidgets); + expect( + find.text('id 1 · 2 stages · 1 schedule · updated 17 Oct 21:26'), + findsOneWidget, + ); + expect(find.text('v2'), findsOneWidget); + expect(find.textContaining('Succeeded · '), findsOneWidget); + } finally { + debugDefaultTargetPlatformOverride = null; + } + }); +} diff --git a/app/test/features/pipelines/pipeline_row_metadata_test.dart b/app/test/features/pipelines/pipeline_row_metadata_test.dart index 678ec5b8..b6732fbc 100644 --- a/app/test/features/pipelines/pipeline_row_metadata_test.dart +++ b/app/test/features/pipelines/pipeline_row_metadata_test.dart @@ -114,13 +114,18 @@ void main() { await pumpWide(tester, gateway); expect(find.text('Seven'), findsOneWidget); - expect(find.text('id 7 · v3 · 2 stages'), findsOneWidget); - expect(find.text('updated 17 Oct 21:26'), findsOneWidget); + expect( + find.text('id 7 · 2 stages · updated 17 Oct 21:26'), + findsOneWidget, + ); + expect(find.text('v3'), findsOneWidget); expect(find.text('pipeline 8'), findsOneWidget); - expect(find.text('id 8 · v1 · 2 stages'), findsOneWidget); + expect(find.text('id 8 · 2 stages'), findsOneWidget); + expect(find.text('v1'), findsOneWidget); - expect(find.text('id 9 · v4 · 0 stages'), findsOneWidget); + expect(find.text('id 9 · 0 stages'), findsOneWidget); + expect(find.text('v4'), findsOneWidget); expect(find.textContaining('updated '), findsOneWidget); expect(find.text('no runs recorded'), findsNWidgets(3)); }); diff --git a/app/test/features/pipelines/pipeline_row_miniature_test.dart b/app/test/features/pipelines/pipeline_row_miniature_test.dart index 176ef6dc..12f81ce1 100644 --- a/app/test/features/pipelines/pipeline_row_miniature_test.dart +++ b/app/test/features/pipelines/pipeline_row_miniature_test.dart @@ -22,8 +22,8 @@ void main() { await pumpWide(tester, gateway); expect(find.byKey(const Key('pipeline-mini-7')), findsOneWidget); - // The cue is additive: the recorded metadata line is unchanged. - expect(find.text('id 7 · v1 · 2 stages'), findsOneWidget); + // The cue is additive: the recorded facts line is unchanged. + expect(find.textContaining('id 7 · 2 stages'), findsOneWidget); }); testWidgets('a summary without a shape draws no miniature', (tester) async { @@ -37,7 +37,7 @@ void main() { expect(find.byType(PipelineMiniGraph), findsNothing); expect(find.byKey(const Key('pipeline-mini-8')), findsNothing); - expect(find.text('id 8 · v1 · 1 stage'), findsOneWidget); + expect(find.textContaining('id 8 · 1 stage'), findsOneWidget); }); testWidgets('a miniature never fetches another origin or pipeline detail', ( @@ -66,7 +66,7 @@ void main() { gateway.calls.map((call) => call.type), everyElement(isIn(['list_pipelines', 'list_runs'])), ); - expect(find.text('id 9 · v1 · 2 stages'), findsOneWidget); + expect(find.textContaining('id 9 · 2 stages'), findsOneWidget); }); }); } diff --git a/app/test/features/pipelines/pipelines_screen_test.dart b/app/test/features/pipelines/pipelines_screen_test.dart index e4e98579..a61f4d36 100644 --- a/app/test/features/pipelines/pipelines_screen_test.dart +++ b/app/test/features/pipelines/pipelines_screen_test.dart @@ -18,9 +18,10 @@ void main() { expect(find.text('Pipelines'), findsOneWidget); expect(find.text('Alpha review'), findsOneWidget); - expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget); - expect(find.text('updated 17 Oct 21:26'), findsOneWidget); - expect(find.text('1 schedule'), findsOneWidget); + expect( + find.text('id 1 · 2 stages · 1 schedule · updated 17 Oct 21:26'), + findsOneWidget, + ); expect(find.textContaining('run 42'), findsOneWidget); expect(find.text('no runs recorded'), findsOneWidget); expect(find.text('Select a pipeline.'), findsOneWidget); @@ -30,7 +31,7 @@ void main() { expect(find.byKey(const Key('pipeline-detail')), findsOneWidget); expect(find.text('hash-alpha'), findsOneWidget); - expect(find.text('id 1 · v2 · 2 stages'), findsNWidgets(2)); + expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget); expect(gateway.callsOf('get_pipeline').single.fields, { 'pipeline_id': 1, 'version': 2, @@ -53,8 +54,8 @@ void main() { await tester.tap(find.byKey(const Key('pipeline-row-1'))); await tester.pumpAndSettle(); - expect(find.text('v1'), findsOneWidget); - expect(find.text('v2'), findsNWidgets(2)); + expect(find.byKey(const Key('pipeline-version-1')), findsOneWidget); + expect(find.byKey(const Key('pipeline-version-2')), findsOneWidget); await tester.tap(find.byKey(const Key('pipeline-version-1'))); await tester.pumpAndSettle();