merge(app): land pipelines-layout

This commit is contained in:
2026-10-22 15:07:12 +01:00
8 changed files with 307 additions and 96 deletions
@@ -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<PipelineDetailPanel> {
);
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,
),
),
],
),
);
@@ -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<PipelineSummary> 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 = <Widget>[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 = <String>[
'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) {
@@ -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),
@@ -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);
@@ -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;
}
});
}
@@ -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));
});
@@ -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(<String>['list_pipelines', 'list_runs'])),
);
expect(find.text('id 9 · v1 · 2 stages'), findsOneWidget);
expect(find.textContaining('id 9 · 2 stages'), findsOneWidget);
});
});
}
@@ -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();