diff --git a/app/lib/features/chat/conversation/chat_card_styles.dart b/app/lib/features/chat/conversation/chat_card_styles.dart index 65135523..d2b12f58 100644 --- a/app/lib/features/chat/conversation/chat_card_styles.dart +++ b/app/lib/features/chat/conversation/chat_card_styles.dart @@ -8,8 +8,7 @@ import 'package:flutter/material.dart'; /// style. Keeping the styles here stops each card file from inventing its own /// size and colour; everything still comes from the active Material/Cupertino /// theme, so light, dark and text scaling follow the host. -TextStyle? chatCardTitleStyle(BuildContext context, bool cupertino) => - cupertino +TextStyle? chatCardTitleStyle(BuildContext context, bool cupertino) => cupertino ? CupertinoTheme.of(context).textTheme.navTitleTextStyle : Theme.of(context).textTheme.titleMedium; @@ -21,9 +20,9 @@ TextStyle? chatCardBodyStyle(BuildContext context, bool cupertino) => cupertino /// (the same subordinate style the rest of the app uses for secondary copy) /// keeps labels from reading as extra headings; Material keeps `titleSmall`. TextStyle? chatCardLabelStyle(BuildContext context, bool cupertino) => cupertino - ? CupertinoTheme.of( - context, - ).textTheme.tabLabelTextStyle.copyWith(color: chatCardSecondaryColor(context, true)) + ? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith( + color: chatCardSecondaryColor(context, true), + ) : Theme.of(context).textTheme.titleSmall; /// Body text that supports a control, such as a field description. diff --git a/app/lib/features/chat/conversation/chat_question_card_fields.dart b/app/lib/features/chat/conversation/chat_question_card_fields.dart index 5577149f..c227f5a1 100644 --- a/app/lib/features/chat/conversation/chat_question_card_fields.dart +++ b/app/lib/features/chat/conversation/chat_question_card_fields.dart @@ -63,10 +63,7 @@ Widget _field({ children: [ Text(label, style: chatCardLabelStyle(context, cupertino)), if (description.isNotEmpty && description != title) - Text( - description, - style: chatCardSecondaryStyle(context, cupertino), - ), + Text(description, style: chatCardSecondaryStyle(context, cupertino)), if ('${field['type'] ?? ''}' == 'external') _external(context, field, cupertino) else if ('${field['type'] ?? ''}' == 'boolean') diff --git a/app/lib/features/chat/conversation/chat_question_card_model.dart b/app/lib/features/chat/conversation/chat_question_card_model.dart index d86a527f..e8a07f39 100644 --- a/app/lib/features/chat/conversation/chat_question_card_model.dart +++ b/app/lib/features/chat/conversation/chat_question_card_model.dart @@ -44,8 +44,7 @@ Object? chatFormFieldValue(JsonMap field, String raw) { case 'integer': final parsed = num.tryParse(raw); if (parsed == null) return double.nan; - final integral = - parsed.isFinite && parsed == parsed.roundToDouble(); + final integral = parsed.isFinite && parsed == parsed.roundToDouble(); return type == 'integer' && integral ? parsed.toInt() : parsed; default: return raw; diff --git a/app/lib/features/chat/conversation/chat_question_recorded_answers.dart b/app/lib/features/chat/conversation/chat_question_recorded_answers.dart index 1009ca32..2c0429bb 100644 --- a/app/lib/features/chat/conversation/chat_question_recorded_answers.dart +++ b/app/lib/features/chat/conversation/chat_question_recorded_answers.dart @@ -33,12 +33,7 @@ List chatQuestionRecordedAnswers({ for (final entry in answers.entries) { if (shown.contains(entry.key)) continue; widgets.add( - _recorded( - context, - entry.key, - _answerText(null, entry.value), - cupertino, - ), + _recorded(context, entry.key, _answerText(null, entry.value), cupertino), ); } if (widgets.isEmpty) { diff --git a/app/lib/features/chat/conversation/chat_scroll.dart b/app/lib/features/chat/conversation/chat_scroll.dart index 90334da5..20d3acc4 100644 --- a/app/lib/features/chat/conversation/chat_scroll.dart +++ b/app/lib/features/chat/conversation/chat_scroll.dart @@ -65,7 +65,9 @@ int chatNewMessageCount(List messageIds, String? newestAtRelease) { /// native client adds while the operator is reading above the end. String chatJumpToLatestLabel(int newMessages) { if (newMessages <= 0) return 'Jump to latest'; - final suffix = newMessages == 1 ? '1 new message' : '$newMessages new messages'; + final suffix = newMessages == 1 + ? '1 new message' + : '$newMessages new messages'; return 'Jump to latest · $suffix'; } diff --git a/app/lib/features/chat/conversation/chat_thread_cards.dart b/app/lib/features/chat/conversation/chat_thread_cards.dart index 12946988..5fb6efd6 100644 --- a/app/lib/features/chat/conversation/chat_thread_cards.dart +++ b/app/lib/features/chat/conversation/chat_thread_cards.dart @@ -44,8 +44,7 @@ class ChatThreadCards { String answerFor(String requestId) => _answers[requestId] ?? ''; - String? permissionErrorFor(String requestId) => - _permissionErrors[requestId]; + String? permissionErrorFor(String requestId) => _permissionErrors[requestId]; String? formErrorFor(String formId) => _formErrors[formId]; @@ -105,8 +104,7 @@ class ChatThreadCards { _forms[id] = { ...form, 'resolved': true, - if (answers.isNotEmpty) - 'answers': Map.from(answers), + if (answers.isNotEmpty) 'answers': Map.from(answers), }; _pruneSettledForms(); notify(); diff --git a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart index e64d9c07..5ee9175f 100644 --- a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart @@ -127,11 +127,21 @@ class PipelineListPanel extends StatelessWidget { if (empty == null) return const SizedBox.shrink(); return _empty(context, empty); } - return useCupertinoControls(context) - ? _cupertinoList(context, items) - : _materialList(context, items); + // A list pane beside a detail can be very narrow (a 640px window leaves + // it ~130px): there the rows drop the identity icon and chevron so the + // name keeps the width. + return LayoutBuilder( + builder: (context, constraints) { + final compact = constraints.maxWidth < _compactRowWidth; + return useCupertinoControls(context) + ? _cupertinoList(context, items, compact: compact) + : _materialList(context, items, compact: compact); + }, + ); } + static const double _compactRowWidth = 220; + Widget _centered(BuildContext context, List messages) { return Center( child: Padding( @@ -174,7 +184,11 @@ class PipelineListPanel extends StatelessWidget { ); } - Widget _materialList(BuildContext context, List items) { + Widget _materialList( + BuildContext context, + List items, { + required bool compact, + }) { final now = DateTime.now(); return ListView.separated( key: const Key('pipeline-list'), @@ -193,6 +207,7 @@ class PipelineListPanel extends StatelessWidget { horizontal: kPipelineListInset, ), visualDensity: VisualDensity.compact, + leading: compact ? null : _pipelineIdentityIcon(context), title: _rowTitle(context, pipeline), subtitle: _rowMetadata(context, pipeline, now), ); @@ -200,7 +215,11 @@ class PipelineListPanel extends StatelessWidget { ); } - Widget _cupertinoList(BuildContext context, List items) { + Widget _cupertinoList( + BuildContext context, + List items, { + required bool compact, + }) { final now = DateTime.now(); return ListView( key: const Key('pipeline-list'), @@ -216,9 +235,10 @@ class PipelineListPanel extends StatelessWidget { backgroundColor: controller.selectedId == pipeline.id ? CupertinoColors.tertiarySystemFill.resolveFrom(context) : null, + leading: compact ? null : _pipelineIdentityIcon(context), title: _rowTitle(context, pipeline), subtitle: _rowMetadata(context, pipeline, now), - trailing: const CupertinoListTileChevron(), + trailing: compact ? null : const CupertinoListTileChevron(), onTap: () => controller.openPipeline( pipeline.id, version: pipeline.version, @@ -372,6 +392,15 @@ class PipelineListPanel extends StatelessWidget { color: theme.colorScheme.onSurfaceVariant, ); } + + Widget _pipelineIdentityIcon(BuildContext context) => Semantics( + label: 'Pipeline', + child: Icon( + useCupertinoControls(context) + ? CupertinoIcons.flowchart + : Icons.account_tree_outlined, + ), + ); } /// The row's recorded flow cue: label-free stage boxes and their routes. diff --git a/app/lib/features/runs/ui/run_more_menu.dart b/app/lib/features/runs/ui/run_more_menu.dart index 124fc86f..00cffee8 100644 --- a/app/lib/features/runs/ui/run_more_menu.dart +++ b/app/lib/features/runs/ui/run_more_menu.dart @@ -38,6 +38,7 @@ class RunMoreMenu extends StatefulWidget { required this.onRunChanged, required this.cupertino, this.onRunOpened, + this.menuKey = runMoreMenuKey, }); final JsonMap run; @@ -48,6 +49,9 @@ class RunMoreMenu extends StatefulWidget { /// Opens the new run an accepted retry names. final ValueChanged? onRunOpened; + /// Detail menus retain the shared key; list rows supply a per-run key. + final Key menuKey; + @override State createState() => _RunMoreMenuState(); } @@ -93,7 +97,7 @@ class _RunMoreMenuState extends State { if (items.isEmpty) return const SizedBox.shrink(); if (!widget.cupertino) { return PopupMenuButton<_RunMoreItem>( - key: runMoreMenuKey, + key: widget.menuKey, icon: const Icon(Icons.more_vert), tooltip: 'More actions', onSelected: (item) => _pick(context, item), @@ -108,7 +112,7 @@ class _RunMoreMenuState extends State { label: 'More actions', excludeSemantics: true, child: CupertinoButton( - key: runMoreMenuKey, + key: widget.menuKey, padding: EdgeInsets.zero, minimumSize: const Size.square(kMinInteractiveDimensionCupertino), onPressed: () async { diff --git a/app/lib/features/runs/ui/runs_list.dart b/app/lib/features/runs/ui/runs_list.dart index ddca99aa..5956e6eb 100644 --- a/app/lib/features/runs/ui/runs_list.dart +++ b/app/lib/features/runs/ui/runs_list.dart @@ -13,6 +13,7 @@ import '../../attention/ui/needs_you_runs_heading.dart'; import '../domain/run_models.dart'; import '../../../shell/shell_bar.dart'; import 'run_path_mini.dart'; +import 'run_more_menu.dart'; import 'runs_controller.dart'; import 'runs_stats_page.dart'; import 'runs_filters.dart'; @@ -100,10 +101,12 @@ class RunsList extends StatelessWidget { Widget _list(BuildContext context) { if (controller.loading && controller.runs.isEmpty) { - return Center( - child: usesCupertinoHost(context) + return _state( + context, + icon: usesCupertinoHost(context) ? const CupertinoActivityIndicator() : const CircularProgressIndicator(), + title: 'Loading runs…', ); } if (controller.error != null && controller.runs.isEmpty) { @@ -116,7 +119,16 @@ class RunsList extends StatelessWidget { RunsFilters(controller: controller), Expanded( child: controller.visibleRuns.isEmpty - ? const Center(child: Text('No runs found.')) + ? _state( + context, + icon: Icon( + usesCupertinoHost(context) + ? CupertinoIcons.tray + : Icons.inbox_outlined, + ), + title: 'No runs found.', + subtitle: 'Try changing or clearing the filters.', + ) : _groupedRuns(context), ), ], @@ -161,21 +173,63 @@ class RunsList extends StatelessWidget { } Widget _emptyError(BuildContext context) => Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text(controller.error!), - const SizedBox(height: 8), - usesCupertinoHost(context) - ? CupertinoButton( - onPressed: controller.load, - child: const Text('Retry'), - ) - : FilledButton( - onPressed: controller.load, - child: const Text('Retry'), + child: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + usesCupertinoHost(context) + ? CupertinoIcons.exclamationmark_triangle + : Icons.error_outline, + ), + const SizedBox(height: 8), + Text(controller.error!), + const SizedBox(height: 8), + usesCupertinoHost(context) + ? CupertinoButton( + onPressed: controller.load, + child: const Text('Retry'), + ) + : FilledButton( + onPressed: controller.load, + child: const Text('Retry'), + ), + ], + ), + ), + ); + + Widget _state( + BuildContext context, { + required Widget icon, + required String title, + String? subtitle, + }) => Center( + // A short pane (a list beside a detail, or the keyboard up) scrolls the + // state instead of overflowing it. + child: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + icon, + const SizedBox(height: 12), + Text(title, textAlign: TextAlign.center), + if (subtitle != null) ...[ + const SizedBox(height: 4), + Text( + subtitle, + textAlign: TextAlign.center, + style: TextStyle( + color: usesCupertinoHost(context) + ? CupertinoColors.secondaryLabel.resolveFrom(context) + : Theme.of(context).colorScheme.onSurfaceVariant, ), - ], + ), + ], + ], + ), ), ); @@ -202,6 +256,9 @@ class RunsList extends StatelessWidget { selected: id == controller.selectedRunId, now: DateTime.now(), onTap: id is num ? () => onSelected(id) : null, + gateway: controller.repository.gateway, + onRunChanged: controller.acceptRunDetail, + onRunOpened: onSelected, ); } } @@ -210,18 +267,27 @@ class RunsList extends StatelessWidget { /// number on top, the pipeline and duration below, then when it ran and how /// far it got. class RunListRow extends StatelessWidget { + /// The narrowest row that still shows its own actions menu. + static const double _menuMinRowWidth = 280; + const RunListRow({ super.key, required this.run, required this.now, this.selected = false, this.onTap, + this.gateway, + this.onRunChanged, + this.onRunOpened, }); final JsonMap run; final DateTime now; final bool selected; final VoidCallback? onTap; + final ApiGateway? gateway; + final ValueChanged? onRunChanged; + final ValueChanged? onRunOpened; @override Widget build(BuildContext context) { @@ -233,6 +299,14 @@ class RunListRow extends StatelessWidget { // A run without its own title is named by its pipeline, so the pipeline // line does not repeat it. final pipeline = identity.pipeline?.trim(); + // With no stored title, `name` is already the row title; repeating it as + // a subtitle adds no identity. A titled run with an empty name genuinely + // lacks its pipeline, so make that absence explicit. + final pipelineLabel = pipeline == null + ? null + : pipeline.isEmpty + ? 'Pipeline unavailable' + : pipeline; final secondary = cupertino ? CupertinoColors.secondaryLabel.resolveFrom(context) : Theme.of(context).colorScheme.onSurfaceVariant; @@ -290,7 +364,7 @@ class RunListRow extends StatelessWidget { }, ); final scheduled = run['scheduled'] == true; - final body = Row( + Widget body(bool withMenu) => Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( @@ -307,11 +381,7 @@ class RunListRow extends StatelessWidget { line(title, id == null ? null : '#$id', titleStyle), const SizedBox(height: 2), line( - [ - if (pipeline != null) - pipeline.isEmpty ? 'Pipeline unavailable' : pipeline, - if (scheduled) 'Scheduled', - ].join(' · '), + [?pipelineLabel, if (scheduled) 'Scheduled'].join(' · '), facts.duration, small, ), @@ -327,11 +397,29 @@ class RunListRow extends StatelessWidget { ], ), ), + if (withMenu && + gateway != null && + onRunChanged != null && + showRunMoreMenu(run)) + RunMoreMenu( + run: run, + gateway: gateway!, + onRunChanged: onRunChanged!, + onRunOpened: onRunOpened, + cupertino: cupertino, + menuKey: ValueKey('run-list-more-menu-$id'), + ), ], ); + // A narrow list pane beside the open run leaves the row no room for a + // second control (a tap on its centre would land on the menu); the open + // run's detail beside it carries the same menu. final padded = Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), - child: body, + child: LayoutBuilder( + builder: (context, constraints) => + body(constraints.maxWidth >= _menuMinRowWidth), + ), ); return Semantics( selected: selected, diff --git a/app/test/application/app_lifecycle_reconnect_test.dart b/app/test/application/app_lifecycle_reconnect_test.dart index 44d76547..45bea855 100644 --- a/app/test/application/app_lifecycle_reconnect_test.dart +++ b/app/test/application/app_lifecycle_reconnect_test.dart @@ -165,11 +165,13 @@ void main() { await pumpApp(tester, provider: provider, client: client); await waitForRequest(tester, channel, 'list_runs'); final initialRuns = pipelineRequest(channel, 'list_runs')!; - channel.incoming.add(jsonEncode({ - 'id': initialRuns['id'], - 'type': 'runs', - 'runs': PipelineFixture().runs, - })); + channel.incoming.add( + jsonEncode({ + 'id': initialRuns['id'], + 'type': 'runs', + 'runs': PipelineFixture().runs, + }), + ); await tester.pump(); final before = countType(channel, 'list_runs'); showDialog( @@ -198,11 +200,13 @@ void main() { await pumpApp(tester, provider: provider, client: client); await waitForRequest(tester, channel, 'list_runs'); final initialRuns = pipelineRequest(channel, 'list_runs')!; - channel.incoming.add(jsonEncode({ - 'id': initialRuns['id'], - 'type': 'runs', - 'runs': PipelineFixture().runs, - })); + channel.incoming.add( + jsonEncode({ + 'id': initialRuns['id'], + 'type': 'runs', + 'runs': PipelineFixture().runs, + }), + ); await tester.pump(); final before = countType(channel, 'list_runs'); showDialog( diff --git a/app/test/features/pipelines/pipeline_list_composition_test.dart b/app/test/features/pipelines/pipeline_list_composition_test.dart index 78555698..0c45f550 100644 --- a/app/test/features/pipelines/pipeline_list_composition_test.dart +++ b/app/test/features/pipelines/pipeline_list_composition_test.dart @@ -23,10 +23,18 @@ void main() { // Filter and sort are app-bar actions; no toolbar row without a filter. expect(find.byKey(const Key('pipeline-toolbar')), findsNothing); + // A native leading flow icon gives each pipeline a durable identity while + // the title follows its normal ListTile spacing. + expect(find.byIcon(Icons.account_tree_outlined), findsNWidgets(3)); expect( - tester.getTopLeft(find.text('Alpha review')).dx - listLeft, + tester.getTopLeft(find.byIcon(Icons.account_tree_outlined).first).dx - + listLeft, kPipelineListInset, ); + expect( + tester.getTopLeft(find.text('Alpha review')).dx, + greaterThan(listLeft), + ); expect( find.descendant(of: list, matching: find.byType(Divider)), diff --git a/app/test/features/runs/ui/run_list_row_test.dart b/app/test/features/runs/ui/run_list_row_test.dart index a1b3ef67..1759b50c 100644 --- a/app/test/features/runs/ui/run_list_row_test.dart +++ b/app/test/features/runs/ui/run_list_row_test.dart @@ -1,6 +1,8 @@ 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/runs/domain/run_models.dart'; +import 'package:pipelines_app/features/runs/ui/run_more_menu.dart'; import 'package:pipelines_app/features/runs/ui/runs_list.dart'; final _finished = { @@ -14,6 +16,14 @@ final _finished = { 'completed_steps': 3, }; +class _FakeGateway implements ApiGateway { + @override + Future call(String type, [JsonMap fields = const {}]) async => {}; + + @override + Stream get frames => const Stream.empty(); +} + void main() { test('row facts: when, how long and how far', () { final facts = runRowFacts(_finished, DateTime.utc(2026, 10, 22)); @@ -59,4 +69,39 @@ void main() { expect(right.right, greaterThan(800 - 32)); } }); + + testWidgets('uses a muted pipeline fallback only when it is absent', ( + tester, + ) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: RunListRow( + run: {..._finished, 'name': ''}, + now: DateTime.utc(2026, 10, 22), + ), + ), + ), + ); + + expect(find.text('Pipeline unavailable'), findsOneWidget); + }); + + testWidgets('gives a list action menu a per-run key', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: RunListRow( + run: _finished, + now: DateTime.utc(2026, 10, 22), + gateway: _FakeGateway(), + onRunChanged: (_) {}, + ), + ), + ), + ); + + expect(find.byKey(const ValueKey('run-list-more-menu-42')), findsOneWidget); + expect(find.byKey(runMoreMenuKey), findsNothing); + }); }