From a6db4ba20e5d5594ecb2463f18b0836470754c1a Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 3 Dec 2026 00:55:50 +0000 Subject: [PATCH] App: run tabs under the header on wide layouts, stable Artifacts tab, spelled-out pipeline status, shared list selection, code block header and edge fades MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Run detail: on a wide window (>= 840, pane >= 600) the tabs are Material segments under the run header; phones keep the floating bottom bar. Artifacts is always a tab, badged with its count and disabled with 0 (its tooltip says why), so Changes never moves. - Pipelines list: 'Failed · last run 19 Oct' beside the status dot; facts on the next line; compact rows keep 'Failed · 19 Oct'. - Settings: Disconnect is outlined beside a tonal Reconnect. - Lists: one selection style (tonal fill plus one leading accent bar) for runs, pipelines and chats; chat's border, fill and pointer removed. - Transcript: overflowing blocks fade at the edge with a chevron instead of a 'Scroll horizontally' line (semantics hint kept); code blocks get a header strip with language and Copy; lighter light-mode code fill. - Runs list: rows under a day heading show only the time of day. - Artifact search reveal re-centres once the lazy list's extent settles. Co-Authored-By: Claude Opus 5.5 --- .../artifacts/ui/artifact_gallery_action.dart | 7 ++ .../artifacts/ui/artifact_visit_reveal.dart | 10 +- .../ui/sessions/chat_compact_sidebar.dart | 14 ++- .../ui/sessions/chat_visibility_marker.dart | 92 +++--------------- .../chat/ui/sessions/session_row_content.dart | 11 ++- .../chat/ui/transcript/chat_code_hover.dart | 97 +++++++++++-------- .../transcript/chat_horizontal_viewport.dart | 93 ++++++++++++------ .../ui/transcript/chat_markdown_view.dart | 25 +++-- .../features/pipelines/pipeline_query.dart | 10 ++ .../widgets/pipeline_list_panel.dart | 36 +++++-- app/lib/features/runs/domain/run_models.dart | 7 ++ .../runs/ui/run_detail_tab_strip.dart | 59 +++++++++-- app/lib/features/runs/ui/run_detail_tabs.dart | 75 +++++++++----- .../features/runs/ui/run_detail_top_tabs.dart | 82 ++++++++++++++++ .../runs/ui/run_detail_wide_chrome.dart | 88 +++++++---------- app/lib/features/runs/ui/run_list_row.dart | 7 ++ app/lib/features/runs/ui/runs_list.dart | 27 +++++- .../features/settings/settings_controls.dart | 49 +++++++--- .../features/settings/settings_sections.dart | 2 + .../ui/adaptive/floating_destination_bar.dart | 13 +++ .../adaptive/floating_destination_labels.dart | 11 ++- app/lib/ui/adaptive/floating_tab_button.dart | 18 +++- app/lib/ui/layout/app_list_row.dart | 36 ++++++- .../chat/chat_open_transition_test.dart | 4 +- .../sessions/chat_active_selection_test.dart | 14 ++- .../chat/ui/sessions/chat_color_test.dart | 18 ++-- .../sessions/chat_visibility_marker_test.dart | 42 ++++++-- .../ui/transcript/chat_code_hover_test.dart | 59 +++++------ .../chat_horizontal_viewport_test.dart | 24 +++-- .../chat_markdown_table_wrap_test.dart | 6 +- .../pipeline_list_composition_test.dart | 15 ++- .../runs/ui/run_artifacts_action_test.dart | 61 +++++++----- .../runs/ui/run_detail_flat_bodies_test.dart | 18 ++-- .../runs/ui/run_detail_tabs_test.dart | 32 +++--- .../features/runs/ui/run_list_row_test.dart | 26 +++++ .../settings/settings_actions_test.dart | 49 ++++++++++ app/test/ui/layout/app_list_row_test.dart | 10 ++ 37 files changed, 848 insertions(+), 399 deletions(-) create mode 100644 app/lib/features/runs/ui/run_detail_top_tabs.dart create mode 100644 app/test/features/settings/settings_actions_test.dart diff --git a/app/lib/features/artifacts/ui/artifact_gallery_action.dart b/app/lib/features/artifacts/ui/artifact_gallery_action.dart index 8e02ad41..e6bbe5fc 100644 --- a/app/lib/features/artifacts/ui/artifact_gallery_action.dart +++ b/app/lib/features/artifacts/ui/artifact_gallery_action.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../../../core/transport/pipelines_client.dart'; import '../domain/artifact_chat_context.dart'; +import '../domain/artifact_groups.dart'; import 'artifact_external_open.dart'; import 'artifact_gallery_page.dart'; @@ -28,6 +29,12 @@ List runDetailArtifactSteps(JsonMap run) { bool showRunArtifactsAction(JsonMap run) => runDetailArtifactSteps(run).isNotEmpty; +/// How many recorded entries the run's gallery lists (stage files plus +/// recorded turn documents), as the gallery header counts them. +int runArtifactCount(JsonMap run) => galleryGroups( + runDetailArtifactSteps(run), +).fold(0, (sum, group) => sum + group.recordedCount); + /// Whether the run is still executing, so the page can say capture pending /// instead of claiming nothing was recorded. bool runDetailExecuting(JsonMap run) => _runExecuting(run); diff --git a/app/lib/features/artifacts/ui/artifact_visit_reveal.dart b/app/lib/features/artifacts/ui/artifact_visit_reveal.dart index 1d56e72d..3a6f910e 100644 --- a/app/lib/features/artifacts/ui/artifact_visit_reveal.dart +++ b/app/lib/features/artifacts/ui/artifact_visit_reveal.dart @@ -28,7 +28,15 @@ class ArtifactVisitReveal { final row = target.currentContext; if (row != null && row.mounted) { Scrollable.ensureVisible(row, alignment: 0.5); - onDone(); + // The lazy list's extent is an estimate until the rows past the + // target are laid out; a row near the end, clamped to that estimate, + // is centred again once the next frame has measured them. + WidgetsBinding.instance.addPostFrameCallback((_) { + if (generation != _generation) return; + if (row.mounted) Scrollable.ensureVisible(row, alignment: 0.5); + onDone(); + }); + WidgetsBinding.instance.scheduleFrame(); return; } final anchorContext = anchor.currentContext; diff --git a/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart b/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart index 1e60be0e..53b2b3d4 100644 --- a/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart +++ b/app/lib/features/chat/ui/sessions/chat_compact_sidebar.dart @@ -1,3 +1,4 @@ +import '../../../../ui/layout/app_list_row.dart'; import '../../../../core/servers/chat/federated_chat_gateway.dart'; import '../../../../core/servers/server_context.dart'; import 'dart:async'; @@ -127,7 +128,18 @@ class ChatCompactSidebar extends StatelessWidget { duration: MediaQuery.disableAnimationsOf(context) ? Duration.zero : const Duration(milliseconds: 200), - color: selected ? Colors.transparent : color.withValues(alpha: .07), + // The lists' shared open-row style: the tonal fill and one leading + // bar in the chat's colour. + color: selected + ? AppListRow.selectedColor(context) + : color.withValues(alpha: .07), + foregroundDecoration: selected + ? BoxDecoration( + border: BorderDirectional( + start: BorderSide(color: color, width: kAppListRowBarWidth), + ), + ) + : null, child: Draggable( // A mouse drags at once (a click still opens the chat); the chip // follows the pointer. diff --git a/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart b/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart index d7d4b895..3458f2f8 100644 --- a/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart +++ b/app/lib/features/chat/ui/sessions/chat_visibility_marker.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; -import 'chat_color_palette.dart'; /// A chat's colour identifies it; this animated edge identifies where it is -/// visible. The active chat has a stronger edge in both list presentations. +/// visible. A chat shown in another pane (visible, not the open one) keeps a +/// thin leading bar. The open chat is marked by the lists' shared selection +/// style on its row (`AppListRow.selected`: tonal fill and one leading bar), +/// the same in every list, so this adds nothing more to it. class ChatVisibilityMarker extends StatelessWidget { const ChatVisibilityMarker({ super.key, @@ -19,41 +21,24 @@ class ChatVisibilityMarker extends StatelessWidget { final bool active; final Widget child; + /// The thin bar of a chat visible in another pane. + static const double visibleBarWidth = 3; + @override Widget build(BuildContext context) { - final dark = chatColorDarkSurface(context); - // The open chat: selected and shown beside the list. - final open = active && visible; + final elsewhere = visible && !active; final row = AnimatedContainer( key: ValueKey('chat-visibility-$sessionId'), duration: MediaQuery.disableAnimationsOf(context) ? Duration.zero : const Duration(milliseconds: 220), curve: Curves.easeInOut, - // The open chat is unmistakable: a strong fill in its colour, a full - // outline, a thick leading bar and (below) a pointer toward the - // conversation shown beside the list. A chat visible elsewhere keeps a - // thin leading bar. - decoration: BoxDecoration( - color: open - ? color.withValues(alpha: dark ? .40 : .28) - : active - ? color.withValues(alpha: dark ? .30 : .22) - : null, - ), foregroundDecoration: BoxDecoration( - border: open - ? BorderDirectional( - start: BorderSide(color: color, width: 8), - top: BorderSide(color: color, width: 2), - end: BorderSide(color: color, width: 2), - bottom: BorderSide(color: color, width: 2), - ) - : BorderDirectional( - start: visible - ? BorderSide(color: color, width: 3) - : BorderSide.none, - ), + border: BorderDirectional( + start: elsewhere + ? BorderSide(color: color, width: visibleBarWidth) + : BorderSide.none, + ), ), child: child, ); @@ -64,56 +49,7 @@ class ChatVisibilityMarker extends StatelessWidget { ? 'Visible chat' : null, selected: active, - // Always a Stack, so selecting a chat never rebuilds its row. - child: Stack( - children: [ - row, - if (open) - PositionedDirectional( - end: 0, - top: 0, - bottom: 0, - child: IgnorePointer( - child: Center( - child: CustomPaint( - key: Key('chat-active-pointer-$sessionId'), - size: const Size(9, 18), - painter: _Pointer( - color: color, - rtl: Directionality.of(context) == TextDirection.rtl, - ), - ), - ), - ), - ), - ], - ), + child: row, ); } } - -/// A small triangle on the row's trailing edge, pointing toward the open -/// conversation beside the list. -class _Pointer extends CustomPainter { - const _Pointer({required this.color, required this.rtl}); - - final Color color; - final bool rtl; - - @override - void paint(Canvas canvas, Size size) { - final path = rtl - ? (Path() - ..moveTo(size.width, 0) - ..lineTo(0, size.height / 2) - ..lineTo(size.width, size.height)) - : (Path() - ..moveTo(0, 0) - ..lineTo(size.width, size.height / 2) - ..lineTo(0, size.height)); - canvas.drawPath(path..close(), Paint()..color = color); - } - - @override - bool shouldRepaint(_Pointer old) => old.color != color || old.rtl != rtl; -} diff --git a/app/lib/features/chat/ui/sessions/session_row_content.dart b/app/lib/features/chat/ui/sessions/session_row_content.dart index 0e15b405..be8aebb8 100644 --- a/app/lib/features/chat/ui/sessions/session_row_content.dart +++ b/app/lib/features/chat/ui/sessions/session_row_content.dart @@ -25,8 +25,9 @@ import 'chat_awaiting.dart'; /// An unread chat is emphasised (heavier title, accent time) with an accent /// dot ending its line; a starred chat shows a small star after its title; a /// running chat carries an activity badge on its avatar. A chat with a colour -/// wears a faint row tint and a coloured avatar. An animated leading edge -/// marks visible chats, growing wider for the active chat. The menu remains +/// wears a faint row tint and a coloured avatar. The open chat wears the +/// lists' shared selection (tonal fill and one leading bar); a thin animated +/// leading edge marks a chat visible elsewhere. The menu remains /// the row's way to its actions. class ChatSessionRow extends StatelessWidget { const ChatSessionRow({ @@ -80,7 +81,7 @@ class ChatSessionRow extends StatelessWidget { id: id, color: tint == null ? background : Color.alphaBlend(tint, background), marker: marker, - markerWidth: visible ? (selected ? 10 : 3) : 0, + markerWidth: selected ? kAppListRowBarWidth : (visible ? 3 : 0), child: draggable ? Draggable( // A mouse drags at once (a click still opens the chat); the chip @@ -130,7 +131,9 @@ class ChatSessionRow extends StatelessWidget { child: AppListRow( key: Key('chat-row-$id'), selected: selected, - selectedFill: Colors.transparent, + // The shared open-row style (tonal fill and one leading bar), the + // bar in the chat's own colour when it has one. + selectionAccent: marker, emphasized: unread, divider: divider, onTap: () => onOpen(session), diff --git a/app/lib/features/chat/ui/transcript/chat_code_hover.dart b/app/lib/features/chat/ui/transcript/chat_code_hover.dart index 18acc455..2d222433 100644 --- a/app/lib/features/chat/ui/transcript/chat_code_hover.dart +++ b/app/lib/features/chat/ui/transcript/chat_code_hover.dart @@ -116,9 +116,14 @@ class _CopyPosition extends SingleChildLayoutDelegate { anchor != oldDelegate.anchor; } -/// The copy slot always occupies the same space, so hover never shifts code. -/// Keyboard focus also reveals it; a touch on the code still selects normally. -class ChatCodeCopyRegion extends StatefulWidget { +/// A fenced code block as one framed piece: a header strip with the +/// language label and Copy, then the code on its own fill. +/// +/// Copy is always in the header (a touch screen has no hover to reveal it), +/// outside the selectable document, so selecting the code never takes the +/// button's label with it. Light mode keeps the code fill light, framed by a +/// hairline, so code text keeps its full contrast; dark mode lifts it a step. +class ChatCodeCopyRegion extends StatelessWidget { const ChatCodeCopyRegion({ super.key, required this.code, @@ -127,49 +132,57 @@ class ChatCodeCopyRegion extends StatefulWidget { }); final String code; final Widget label, child; - @override - State createState() => _ChatCodeCopyRegionState(); -} -class _ChatCodeCopyRegionState extends State { - bool _hover = false, _focus = false; + /// The block's corner radius. + static const double radius = 8; + + /// The code body's fill. + static Color fill(BuildContext context) { + final scheme = Theme.of(context).colorScheme; + return scheme.brightness == Brightness.light + ? scheme.surfaceContainerLow + : scheme.surfaceContainerHighest; + } + + /// The header strip's fill, one step from the body's. + static Color headerFill(BuildContext context) => + Theme.of(context).colorScheme.surfaceContainerHigh; + @override Widget build(BuildContext context) { - final visible = _hover || _focus; - return MouseRegion( - onEnter: (_) => setState(() => _hover = true), - onExit: (_) => setState(() => _hover = false), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - children: [ - Expanded(child: widget.label), - Focus( - skipTraversal: true, - onFocusChange: (value) => setState(() => _focus = value), - child: ExcludeSemantics( - excluding: !visible, - child: IgnorePointer( - ignoring: !visible, - child: Opacity( - opacity: visible ? 1 : 0, - child: SelectionContainer.disabled( - child: ChatCopyButton( - text: widget.code, - showLabel: true, - ), - ), - ), - ), - ), - ), - ], + final scheme = Theme.of(context).colorScheme; + final header = ColoredBox( + key: const Key('chat-code-header'), + color: headerFill(context), + child: Padding( + padding: const EdgeInsetsDirectional.only(start: 12, end: 4), + child: Row( + children: [ + Expanded(child: label), + SelectionContainer.disabled( + child: ChatCopyButton(text: code, showLabel: true), + ), + ], + ), + ), + ); + return DecoratedBox( + position: DecorationPosition.foreground, + decoration: BoxDecoration( + border: Border.all(color: scheme.outlineVariant), + borderRadius: BorderRadius.circular(radius), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(radius), + child: ColoredBox( + key: const Key('chat-code-body'), + color: fill(context), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisSize: MainAxisSize.min, + children: [header, child], ), - const SizedBox(height: 4), - widget.child, - ], + ), ), ); } diff --git a/app/lib/features/chat/ui/transcript/chat_horizontal_viewport.dart b/app/lib/features/chat/ui/transcript/chat_horizontal_viewport.dart index b477c458..0124ba24 100644 --- a/app/lib/features/chat/ui/transcript/chat_horizontal_viewport.dart +++ b/app/lib/features/chat/ui/transcript/chat_horizontal_viewport.dart @@ -2,8 +2,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import '../../../../ui/layout/wheel_scroll_forwarding.dart'; -/// Native, persistent overflow affordances for a code block or table. The -/// footer is outside the selectable document and never overlays its content. +/// Native, persistent overflow affordances for a code block or table: the +/// side with more content fades out under a small chevron, and the scrollbar +/// thumb stays visible. The chevrons are outside the selectable document and +/// take no taps; the semantics hint names the gestures and keys. class ChatHorizontalViewport extends StatefulWidget { const ChatHorizontalViewport({ super.key, @@ -89,20 +91,67 @@ class _ChatHorizontalViewportState extends State { super.dispose(); } + /// The width over which content fades out at a side with more to scroll. + static const double _fadeWidth = 32; + @override Widget build(BuildContext context) { final color = Theme.of(context).colorScheme.onSurfaceVariant; final focusColor = Theme.of(context).colorScheme.primary; - final view = Padding( - padding: EdgeInsets.only(bottom: _overflow ? 12 : 0), + Widget view = Padding( + padding: EdgeInsets.only(bottom: _overflow ? 10 : 0), child: HorizontalScrollView(controller: _controller, child: widget.child), ); + if (_left || _right) { + // The side with more content fades out, the usual sign that a row + // continues past the edge; content at rest is never covered. + view = ShaderMask( + key: const Key('chat-horizontal-fade'), + blendMode: BlendMode.dstIn, + shaderCallback: (bounds) { + final fade = bounds.width <= 0 + ? 0.0 + : (_fadeWidth / bounds.width).clamp(0.0, 0.5); + const shown = Colors.white; + const hidden = Color(0x00FFFFFF); + return LinearGradient( + colors: [ + _left ? hidden : shown, + shown, + shown, + _right ? hidden : shown, + ], + stops: [0, fade, 1 - fade, 1], + ).createShader(bounds); + }, + child: view, + ); + } final scrollbar = Scrollbar( controller: _controller, thumbVisibility: _overflow, - trackVisibility: _overflow, child: view, ); + Widget chevron(bool left) => Positioned( + left: left ? 0 : null, + right: left ? null : 0, + top: 0, + bottom: 10, + child: IgnorePointer( + child: Center( + child: Icon( + left ? Icons.chevron_left : Icons.chevron_right, + key: Key( + left ? 'chat-horizontal-more-left' : 'chat-horizontal-more-right', + ), + size: 18, + // Physical sides: the arrow points where the content continues. + textDirection: TextDirection.ltr, + color: color.withValues(alpha: .7), + ), + ), + ), + ); return NotificationListener( onNotification: (notification) { if (notification.metrics.axis == Axis.horizontal) _scheduleMetrics(); @@ -127,35 +176,17 @@ class _ChatHorizontalViewportState extends State { color: _focused ? focusColor : Colors.transparent, ), ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, + child: Stack( children: [ scrollbar, - if (_overflow) - SelectionContainer.disabled( - child: ExcludeSemantics( - child: Padding( - padding: const EdgeInsets.only(top: 4), - child: Row( + if (_left || _right) + Positioned.fill( + child: SelectionContainer.disabled( + child: ExcludeSemantics( + child: Stack( children: [ - Icon( - _left && _right - ? Icons.swap_horiz - : _left - ? Icons.arrow_back - : Icons.arrow_forward, - size: 16, - textDirection: TextDirection.ltr, - color: color, - ), - const SizedBox(width: 4), - Flexible( - child: Text( - 'Scroll horizontally', - style: TextStyle(color: color), - ), - ), + if (_left) chevron(true), + if (_right) chevron(false), ], ), ), diff --git a/app/lib/features/chat/ui/transcript/chat_markdown_view.dart b/app/lib/features/chat/ui/transcript/chat_markdown_view.dart index d0d51dca..bbe564b2 100644 --- a/app/lib/features/chat/ui/transcript/chat_markdown_view.dart +++ b/app/lib/features/chat/ui/transcript/chat_markdown_view.dart @@ -260,22 +260,19 @@ class _ChatMarkdownViewState extends State { return ChatCodeCopyRegion( code: code, label: Text(markdownCodeLabel(language), style: labelStyle), - child: DecoratedBox( - decoration: BoxDecoration(color: _codeFill(context)), - child: Padding( - padding: const EdgeInsets.all(12), - child: ChatTranscriptHorizontalScrollView( - label: 'code block', - child: Text.rich( - TextSpan( - children: _linked( - context, - code, - (part) => TextSpan(text: part), - ), + child: Padding( + padding: const EdgeInsets.all(12), + child: ChatTranscriptHorizontalScrollView( + label: 'code block', + child: Text.rich( + TextSpan( + children: _linked( + context, + code, + (part) => TextSpan(text: part), ), - style: const TextStyle(fontFamily: appMonospaceFamily), ), + style: const TextStyle(fontFamily: appMonospaceFamily), ), ), ), diff --git a/app/lib/features/pipelines/pipeline_query.dart b/app/lib/features/pipelines/pipeline_query.dart index 56c0b1ee..13fd889a 100644 --- a/app/lib/features/pipelines/pipeline_query.dart +++ b/app/lib/features/pipelines/pipeline_query.dart @@ -28,6 +28,16 @@ class RunBadge { final String? ranAgo; final String? duration; + /// When the last run started, said as such for a list row: `last run + /// 19 Oct`, `last run 2h ago`, `last run just now`. Null without a time. + String? get lastRun { + final ago = ranAgo; + if (ago == null || ago.isEmpty) return null; + // `5m`, `2h`, `3d` are ages; a date or `just now` reads as it is. + final age = RegExp(r'^\d+[mhd]$').hasMatch(ago) ? '$ago ago' : ago; + return 'last run $age'; + } + /// `2h · 1m 5s · run 42`; missing fragments are omitted. String get metaLine => [ ranAgo, diff --git a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart index 7e958e32..38f93297 100644 --- a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart @@ -248,7 +248,9 @@ class PipelineListPanel extends StatelessWidget { controller.openPipeline(pipeline.id, version: pipeline.version), leading: _pipelineIdentityIcon(context, pipeline), title: Text(pipeline.displayName), - time: badge?.ranAgo, + // The latest run's state is spelled out, not colour alone, with + // when it ran: `Failed · last run 19 Oct`. The pipeline's own + // facts (stages, schedules) follow on the next line. subtitleLeading: badge == null ? null : AppListStatusDot( @@ -260,16 +262,28 @@ class PipelineListPanel extends StatelessWidget { semanticLabel: runStateLabel(badge.state), ), subtitle: Text( - ServerContext.metadata(context, _rowMetadata(pipeline)), + badge == null + ? ServerContext.metadata(context, _rowMetadata(pipeline)) + : ServerContext.metadata( + context, + _statusLine(badge, badge.lastRun), + ), + key: Key('pipeline-status-text-${pipeline.id}'), ), - // A narrow pane keeps the latest state, the useful decision signal; - // stage counts, schedules and version live in the detail instead. - // Do not turn an in-flight or failed run-history read into a false - // no-runs claim: the line stays blank until history is known. + detail: badge == null ? null : Text(_rowMetadata(pipeline)), + compactDetail: false, + // A narrow pane keeps the latest state and its date, the useful + // decision signal; stage counts, schedules and version live in the + // detail instead. Do not turn an in-flight or failed run-history + // read into a false no-runs claim: the line stays blank until + // history is known. compactSubtitle: badge == null ? Text(ServerContext.metadata(context, '')) : Text( - ServerContext.metadata(context, runStateLabel(badge.state)), + ServerContext.metadata( + context, + _statusLine(badge, badge.ranAgo), + ), ), menu: onOpenInChat == null ? null @@ -292,7 +306,13 @@ class PipelineListPanel extends StatelessWidget { ); } - /// The row's one muted subtitle: stage count and schedules. + /// `Failed · last run 19 Oct`: the latest run's state and when it ran. + String _statusLine(RunBadge badge, String? when) => [ + runStateLabel(badge.state), + if (when != null && when.isNotEmpty) when, + ].join(' · '); + + /// The row's muted facts line: stage count and schedules. String _rowMetadata(PipelineSummary pipeline) { final schedules = switch (pipeline.scheduleState) { PipelineScheduleState.scheduled => pipeline.scheduleLabel, diff --git a/app/lib/features/runs/domain/run_models.dart b/app/lib/features/runs/domain/run_models.dart index 90bc23b7..f3502e5c 100644 --- a/app/lib/features/runs/domain/run_models.dart +++ b/app/lib/features/runs/domain/run_models.dart @@ -23,6 +23,13 @@ String localDayKey(DateTime date) { return '${local.year}-${two(local.month)}-${two(local.day)}'; } +/// The local time of day, `HH:mm`, for a run listed under its day heading. +String runTimeOfDay(DateTime instant) { + final local = instant.toLocal(); + String two(int value) => value.toString().padLeft(2, '0'); + return '${two(local.hour)}:${two(local.minute)}'; +} + String runDayLabel(String createdAt, DateTime today) { final created = DateTime.tryParse(createdAt)?.toLocal(); if (created == null) return 'Unknown date'; diff --git a/app/lib/features/runs/ui/run_detail_tab_strip.dart b/app/lib/features/runs/ui/run_detail_tab_strip.dart index 7a7adaa2..a82d2623 100644 --- a/app/lib/features/runs/ui/run_detail_tab_strip.dart +++ b/app/lib/features/runs/ui/run_detail_tab_strip.dart @@ -1,4 +1,4 @@ -import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; import '../../../ui/adaptive/floating_destination_bar.dart'; @@ -16,14 +16,41 @@ const List renderedRunDetailTabs = [ RunDetailTab.changes, ]; -/// The run detail's tabs: the app's floating glass tab bar, full width at the -/// bottom of a phone page; beside a list, sized to its tabs at the bottom of -/// the detail pane (the shell's own tab bar stays over the list pane). +/// The run's Artifacts count as a small badge: `0` on a run with none, so +/// the (disabled) tab still says why it cannot open. +class RunArtifactsCount extends StatelessWidget { + const RunArtifactsCount({super.key, required this.count, this.child}); + + final int count; + + /// The icon the badge sits on; null draws the badge on its own. + final Widget? child; + + @override + Widget build(BuildContext context) { + final scheme = Theme.of(context).colorScheme; + return Badge( + key: const ValueKey('run-detail-artifacts-count'), + label: Text('$count'), + backgroundColor: count == 0 + ? scheme.surfaceContainerHighest + : scheme.secondary, + textColor: count == 0 ? scheme.onSurfaceVariant : scheme.onSecondary, + child: child, + ); + } +} + +/// The run detail's tabs on a phone: the app's floating glass tab bar, full +/// width at the bottom of the page (a wide layout puts `RunDetailTopTabs` +/// under the run header instead). /// /// Float it over the tab body with `FloatingBarOverlay` at the same [edge]; /// every tab is always visible, so a tab selected by the Graph is shown -/// selected without scrolling. The whole bar is keyed `run-detail-tabs`, each -/// tab `run-detail-tab-`. +/// selected without scrolling. Artifacts is always a tab, disabled with a +/// `0` count on a run with none, so the tabs after it never move between +/// runs. The whole bar is keyed `run-detail-tabs`, each tab +/// `run-detail-tab-`. class RunDetailTabStrip extends StatelessWidget { const RunDetailTabStrip({ super.key, @@ -31,8 +58,14 @@ class RunDetailTabStrip extends StatelessWidget { required this.onSelected, this.tabs = renderedRunDetailTabs, this.edge = FloatingBarEdge.bottom, + this.artifactCount, + this.disabled = const {}, + this.disabledReasons = const {}, }); + /// Why a disabled tab cannot open, as its tooltip. + final Map disabledReasons; + final RunDetailTab selected; final ValueChanged onSelected; final FloatingBarEdge edge; @@ -40,9 +73,17 @@ class RunDetailTabStrip extends StatelessWidget { /// The tabs this run offers, in [renderedRunDetailTabs] order. final List tabs; + /// The run's recorded artifacts, badged on the Artifacts tab; null draws + /// no badge. + final int? artifactCount; + + /// Tabs shown greyed out that take no taps. + final Set disabled; + @override Widget build(BuildContext context) { final index = tabs.indexOf(selected); + final count = artifactCount; return KeyedSubtree( key: const Key('run-detail-tabs'), child: FloatingDestinationBar( @@ -56,8 +97,12 @@ class RunDetailTabStrip extends StatelessWidget { for (final tab in tabs) FloatingDestinationItem( key: ValueKey('run-detail-tab-${tab.name}'), - icon: Icon(tab.icon), + icon: tab == RunDetailTab.artifacts && count != null + ? RunArtifactsCount(count: count, child: Icon(tab.icon)) + : Icon(tab.icon), label: tab.label, + enabled: !disabled.contains(tab), + tooltip: disabled.contains(tab) ? disabledReasons[tab] : null, ), ], ), diff --git a/app/lib/features/runs/ui/run_detail_tabs.dart b/app/lib/features/runs/ui/run_detail_tabs.dart index 0ee737dc..64cf757d 100644 --- a/app/lib/features/runs/ui/run_detail_tabs.dart +++ b/app/lib/features/runs/ui/run_detail_tabs.dart @@ -13,6 +13,7 @@ import '../../graph/widgets/run_graph_view.dart'; import '../../artifacts/ui/artifact_gallery_action.dart'; import '../../artifacts/ui/artifact_gallery_page.dart'; import '../../artifacts/domain/artifact_chat_context.dart'; +import '../../artifacts/domain/artifact_summary.dart'; import '../../changes/changes.dart'; import 'run_changes_action.dart'; import 'run_detail_content.dart'; @@ -20,6 +21,7 @@ import 'run_graph_preview.dart'; import 'run_detail_tab.dart'; import 'run_detail_tab_bodies.dart'; import 'run_detail_tab_strip.dart'; +import 'run_detail_top_tabs.dart'; import 'run_detail_timeline.dart'; import 'run_detail_visit.dart'; import 'run_detail_wide_chrome.dart'; @@ -253,8 +255,8 @@ class _RunDetailTabsState extends State { case RunArtifactTarget(:final url): _selectedStage = null; _selectedVisit = null; - if (!_tabsFor(widget.run).contains(RunDetailTab.artifacts)) { - // A run with no recorded steps has no gallery to open it in. + if (_disabledTabs(widget.run).contains(RunDetailTab.artifacts)) { + // A run with no recorded artifacts has no gallery to open it in. _tab = RunDetailTab.summary; WidgetsBinding.instance.addPostFrameCallback( (_) => mounted ? _showSearchArtifactMissingNotice() : null, @@ -369,18 +371,19 @@ class _RunDetailTabsState extends State { }); } - /// Artifacts once the run has recorded steps; Changes once it has stopped - /// executing, since a snapshot would not follow live captures. + /// Every tab but Changes always, so a tab never moves between runs; + /// Changes (the last) once the run has stopped executing, since a snapshot + /// would not follow live captures. List _tabsFor(JsonMap run) => [ for (final tab in renderedRunDetailTabs) - if (switch (tab) { - RunDetailTab.artifacts => showRunArtifactsAction(run), - RunDetailTab.changes => showRunChangesAction(run), - _ => true, - }) - tab, + if (tab != RunDetailTab.changes || showRunChangesAction(run)) tab, ]; + /// Artifacts stays in place but disabled while the run recorded none. + Set _disabledTabs(JsonMap run) => { + if (runArtifactCount(run) == 0) RunDetailTab.artifacts, + }; + @override Widget build(BuildContext context) { // A selected visit opens on its own page; the tab keeps the list. @@ -388,8 +391,12 @@ class _RunDetailTabsState extends State { _syncVisitPage(); } final tabs = _tabsFor(widget.run); - // A tab the run no longer offers falls back to Summary. - final shown = tabs.contains(_tab) || !renderedRunDetailTabs.contains(_tab) + final disabled = _disabledTabs(widget.run); + final artifactCount = runArtifactCount(widget.run); + // A tab the run no longer offers (or cannot open) falls back to Summary. + final shown = + (tabs.contains(_tab) && !disabled.contains(_tab)) || + !renderedRunDetailTabs.contains(_tab) ? _tab : RunDetailTab.summary; final edge = PageTabsEdge.of(context); @@ -403,29 +410,49 @@ class _RunDetailTabsState extends State { child: widget.header, ), ); - final tabStrip = RunDetailTabStrip( - tabs: tabs, - edge: edge, - selected: shown, - onSelected: (tab) => setState(() => _tab = tab), - ); + void select(RunDetailTab tab) => setState(() => _tab = tab); final body = FadeThroughStack( key: ValueKey('run-detail-body-${widget.run['id']}'), index: tabs.indexOf(shown), lazy: true, children: [for (final tab in tabs) _body(tab)], ); - if (edge == FloatingBarEdge.top && - constraints.maxWidth >= kRunDetailWideChromeMinWidth) { - // Beside a list the tabs and the header share one row under the - // pane's bar, so only that row (not a header strip over a tabs - // strip) sits above the tab's content. + // Why a disabled Artifacts tab cannot open: none recorded, capture + // pending or unavailable. + final reasons = { + RunDetailTab.artifacts: artifactsHeader( + runDetailArtifactSteps(widget.run), + executing: runDetailExecuting(widget.run), + ), + }; + if (runDetailTabsOnTop(context, constraints.maxWidth)) { + // A wide layout puts the tabs right under the run header, at the + // top of the detail, in one strip with it. return FloatingBarOverlay( edge: FloatingBarEdge.top, - bar: RunDetailWideChrome(tabs: tabStrip, header: header), + bar: RunDetailWideChrome( + header: header, + tabs: RunDetailTopTabs( + tabs: tabs, + selected: shown, + onSelected: select, + artifactCount: artifactCount, + disabled: disabled, + disabledReasons: reasons, + ), + ), child: body, ); } + final tabStrip = RunDetailTabStrip( + tabs: tabs, + edge: edge, + selected: shown, + onSelected: select, + artifactCount: artifactCount, + disabled: disabled, + disabledReasons: reasons, + ); // The header (status, actions, notices) is a glass strip floating // just under the top bar, so every tab scrolls behind both and pads // its first item clear of them at rest. Below it, the tabs float over diff --git a/app/lib/features/runs/ui/run_detail_top_tabs.dart b/app/lib/features/runs/ui/run_detail_top_tabs.dart new file mode 100644 index 00000000..90e7db85 --- /dev/null +++ b/app/lib/features/runs/ui/run_detail_top_tabs.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; + +import 'run_detail_tab.dart'; +import 'run_detail_tab_strip.dart'; + +/// The run detail's tabs on a wide layout: a Material [SegmentedButton] of +/// icon-and-label segments under the run header, at the top of the detail +/// where the eye already is, with labels at the button text size. +/// +/// The segments keep their order and positions across runs: Artifacts is +/// always one, disabled with a `0` count when the run recorded none. Keys +/// match the phone bar's: the whole row `run-detail-tabs`, each label +/// `run-detail-tab-`. +class RunDetailTopTabs extends StatelessWidget { + const RunDetailTopTabs({ + super.key, + required this.tabs, + required this.selected, + required this.onSelected, + this.artifactCount, + this.disabled = const {}, + this.disabledReasons = const {}, + }); + + final List tabs; + final RunDetailTab selected; + final ValueChanged onSelected; + final int? artifactCount; + final Set disabled; + + /// Why a disabled tab cannot open, as its tooltip. + final Map disabledReasons; + + @override + Widget build(BuildContext context) { + final count = artifactCount; + final scheme = Theme.of(context).colorScheme; + return Align( + key: const Key('run-detail-tabs'), + alignment: AlignmentDirectional.centerStart, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: SegmentedButton( + showSelectedIcon: false, + // On the frosted strip the unselected segments take the surface, + // so the selected one's tonal fill stands out from the glass. + style: ButtonStyle( + backgroundColor: WidgetStateProperty.resolveWith( + (states) => states.contains(WidgetState.selected) + ? scheme.secondaryContainer + : scheme.surface, + ), + ), + segments: [ + for (final tab in tabs) + ButtonSegment( + value: tab, + enabled: !disabled.contains(tab), + tooltip: disabled.contains(tab) ? disabledReasons[tab] : null, + icon: Icon(tab.icon), + label: Row( + key: ValueKey('run-detail-tab-${tab.name}'), + mainAxisSize: MainAxisSize.min, + children: [ + Text(tab.label), + if (tab == RunDetailTab.artifacts && count != null) ...[ + const SizedBox(width: 6), + RunArtifactsCount(count: count), + ], + ], + ), + ), + ], + selected: {selected}, + onSelectionChanged: (value) { + if (value.isNotEmpty) onSelected(value.first); + }, + ), + ), + ); + } +} diff --git a/app/lib/features/runs/ui/run_detail_wide_chrome.dart b/app/lib/features/runs/ui/run_detail_wide_chrome.dart index 4f9b512f..592441d6 100644 --- a/app/lib/features/runs/ui/run_detail_wide_chrome.dart +++ b/app/lib/features/runs/ui/run_detail_wide_chrome.dart @@ -1,26 +1,31 @@ import 'package:flutter/widgets.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; -import '../../../ui/adaptive/floating_destination_bar.dart'; -import '../../../ui/adaptive/glass_pill.dart'; import '../../../ui/adaptive/top_glass_strip.dart'; -/// The narrowest detail pane that puts its tabs and header in one row; -/// narrower panes stack the header strip over the tabs. +/// The narrowest detail pane that puts its tabs under the run header. const double kRunDetailWideChromeMinWidth = kFloatingBarWideWidth; -/// The most of the row the tabs take, leaving the rest to the header. -const double kRunDetailWideTabsShare = 0.6; +/// The narrowest window whose run detail puts its tabs at the top: a wide +/// (desktop or tablet) window. Phones keep the floating bottom tab bar. +const double kRunDetailTopTabsMinWindowWidth = 840; -/// The run detail's controls beside a list (a wide split): its tabs and its -/// header (status, run actions, notices) share one row under the pane's top -/// bar, instead of stacking the header strip above a second tabs strip. +/// Whether the run detail at [context], [width] wide, shows its tabs under +/// the run header rather than as the floating bottom bar: on a wide window +/// with a wide enough detail pane, or where the host asks for top tabs. +bool runDetailTabsOnTop(BuildContext context, double width) { + if (width < kRunDetailWideChromeMinWidth) return false; + return PageTabsEdge.of(context) == FloatingBarEdge.top || + MediaQuery.sizeOf(context).width >= kRunDetailTopTabsMinWindowWidth; +} + +/// The run detail's controls on a wide layout: one frosted strip under the +/// pane's top bar holding the header (status, run actions, notices) and, +/// under it, the tabs, so the tabs sit right below the run's title instead +/// of floating at the far corner of a wide pane. /// -/// The tabs lead, in line with the bar's title; the header follows as a glass -/// piece as wide as its content, and wraps (or scrolls inside its height -/// limit) when the pane is narrow. Float the row with `FloatingBarOverlay` -/// at the top edge so the tab body pads past it at rest. The header keeps the -/// key `run-detail-header`. +/// Float it with `FloatingBarOverlay` at the top edge so the tab body pads +/// past it at rest. The strip keeps the key `run-detail-header`. class RunDetailWideChrome extends StatelessWidget { const RunDetailWideChrome({ super.key, @@ -28,7 +33,7 @@ class RunDetailWideChrome extends StatelessWidget { required this.header, }); - /// The tab strip at [FloatingBarEdge.top]; it brings its own 12px margins. + /// The tabs (`RunDetailTopTabs`). final Widget tabs; /// The header's content, already bounded in height. @@ -36,46 +41,19 @@ class RunDetailWideChrome extends StatelessWidget { @override Widget build(BuildContext context) { - final insets = MediaQuery.paddingOf(context); - return Padding( - padding: EdgeInsets.only(left: insets.left), - child: LayoutBuilder( - builder: (context, constraints) => Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // The tabs keep at most 60% of the row, so the header always has - // room for its status and actions (scaled text included). - ConstrainedBox( - constraints: BoxConstraints( - maxWidth: constraints.maxWidth * kRunDetailWideTabsShare, - ), - child: tabs, - ), - Flexible( - child: Padding( - // The tabs' own trailing margin is the gap before the header. - padding: EdgeInsets.only( - right: FloatingDestinationBar.topMargin + insets.right, - bottom: 8, - ), - child: Align( - alignment: AlignmentDirectional.centerStart, - heightFactor: 1, - child: GlassPill( - key: const Key('run-detail-header'), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(kTopGlassStripRadius), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: header, - ), - ), - ), - ), - ), - ], - ), + return TopGlassStrip( + key: const Key('run-detail-header'), + padding: const EdgeInsets.fromLTRB(0, 4, 0, 12), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + header, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: tabs, + ), + ], ), ); } diff --git a/app/lib/features/runs/ui/run_list_row.dart b/app/lib/features/runs/ui/run_list_row.dart index f636da29..eb6c5c32 100644 --- a/app/lib/features/runs/ui/run_list_row.dart +++ b/app/lib/features/runs/ui/run_list_row.dart @@ -38,8 +38,13 @@ class RunListRow extends StatelessWidget { this.onLongPress, this.onOpenInChat, this.onRunAgain, + this.timeOfDay = false, }); + /// The row sits under a day heading, so its time is the time of day + /// (`09:12`) rather than a date the heading already names. + final bool timeOfDay; + final ValueChanged? onRunAgain; final JsonMap run; @@ -137,6 +142,8 @@ class RunListRow extends StatelessWidget { title: Text(title), timeWidget: createdAt == null ? null + : timeOfDay + ? Text(runTimeOfDay(createdAt), key: ValueKey('run-row-time-$id')) : RelativeTimeLabel(instant: createdAt, now: now), subtitle: line(subtitle), compactSubtitle: line(compactSubtitle), diff --git a/app/lib/features/runs/ui/runs_list.dart b/app/lib/features/runs/ui/runs_list.dart index b132c00f..1504eac8 100644 --- a/app/lib/features/runs/ui/runs_list.dart +++ b/app/lib/features/runs/ui/runs_list.dart @@ -247,7 +247,12 @@ class RunsList extends StatelessWidget { final last = next >= entries.length || entries[next].run == null; return Arrival( id: '${entry.run!['id']}', - child: _runTile(context, entry.run!, divider: !last), + child: _runTile( + context, + entry.run!, + divider: !last, + timeOfDay: !flatRunSorts.contains(controller.sort), + ), ); }, ); @@ -310,7 +315,12 @@ class RunsList extends StatelessWidget { ), ); - Widget _runTile(BuildContext context, JsonMap run, {bool divider = true}) { + Widget _runTile( + BuildContext context, + JsonMap run, { + bool divider = true, + bool timeOfDay = false, + }) { final id = run['id']; final selection = controller.selection; final now = DateTime.now(); @@ -320,6 +330,7 @@ class RunsList extends StatelessWidget { memo: ( MemoMap(run), divider, + timeOfDay, selection.active, selection.contains(id), id == controller.selectedRunId, @@ -327,11 +338,18 @@ class RunsList extends StatelessWidget { onSelected, // An executing run's duration ticks inside the row, not from here. ), - builder: (context) => _runRow(run, id, now, divider: divider), + builder: (context) => + _runRow(run, id, now, divider: divider, timeOfDay: timeOfDay), ); } - Widget _runRow(JsonMap run, Object? id, DateTime now, {bool divider = true}) { + Widget _runRow( + JsonMap run, + Object? id, + DateTime now, { + bool divider = true, + bool timeOfDay = false, + }) { final selection = controller.selection; return RunListRow( selecting: selection.active, @@ -342,6 +360,7 @@ class RunsList extends StatelessWidget { onDeleted: controller.applyDeletion, run: run, divider: divider, + timeOfDay: timeOfDay, selected: id == controller.selectedRunId, now: now, onTap: id is num ? () => onSelected(id) : null, diff --git a/app/lib/features/settings/settings_controls.dart b/app/lib/features/settings/settings_controls.dart index 6473d59a..b60ada9c 100644 --- a/app/lib/features/settings/settings_controls.dart +++ b/app/lib/features/settings/settings_controls.dart @@ -93,8 +93,14 @@ class SettingsTextField extends StatelessWidget { } } -/// The filled primary and outlined secondary settings actions. Buttons wrap on -/// a narrow window (or with large text) instead of overflowing. +/// The settings actions: the emphasised one filled, the other outlined. +/// Buttons wrap on a narrow window (or with large text) instead of +/// overflowing. +/// +/// [primaryOutlined] turns the order of emphasis around for a primary action +/// that ends something (Disconnect): the secondary action leads as a tonal +/// button and the primary follows outlined, so the filled emphasis never sits +/// on the action that drops the connection. class SettingsActions extends StatelessWidget { const SettingsActions({ super.key, @@ -104,6 +110,7 @@ class SettingsActions extends StatelessWidget { required this.onSecondary, this.primaryKey, this.secondaryKey, + this.primaryOutlined = false, }); final String primaryLabel; @@ -112,24 +119,38 @@ class SettingsActions extends StatelessWidget { final VoidCallback onSecondary; final Key? primaryKey; final Key? secondaryKey; + final bool primaryOutlined; @override Widget build(BuildContext context) { + final primary = primaryOutlined + ? OutlinedButton( + key: primaryKey, + onPressed: onPrimary, + child: Text(primaryLabel), + ) + : FilledButton( + key: primaryKey, + onPressed: onPrimary, + child: Text(primaryLabel), + ); + final secondary = primaryOutlined + ? FilledButton.tonal( + key: secondaryKey, + onPressed: onSecondary, + child: Text(secondaryLabel), + ) + : OutlinedButton( + key: secondaryKey, + onPressed: onSecondary, + child: Text(secondaryLabel), + ); return Wrap( spacing: settingsControlGap, runSpacing: settingsControlGap, - children: [ - FilledButton( - key: primaryKey, - onPressed: onPrimary, - child: Text(primaryLabel), - ), - OutlinedButton( - key: secondaryKey, - onPressed: onSecondary, - child: Text(secondaryLabel), - ), - ], + children: primaryOutlined + ? [secondary, primary] + : [primary, secondary], ); } } diff --git a/app/lib/features/settings/settings_sections.dart b/app/lib/features/settings/settings_sections.dart index bcde5f62..3681c232 100644 --- a/app/lib/features/settings/settings_sections.dart +++ b/app/lib/features/settings/settings_sections.dart @@ -55,6 +55,8 @@ class SettingsConnectionSection extends StatelessWidget { SettingsActions( primaryLabel: controller.primaryActionLabel, secondaryLabel: controller.secondaryActionLabel, + // Disconnect is outlined beside a tonal Reconnect. + primaryOutlined: controller.connectionActive, primaryKey: controller.connectionActive ? SettingsKeys.disconnect : SettingsKeys.connect, diff --git a/app/lib/ui/adaptive/floating_destination_bar.dart b/app/lib/ui/adaptive/floating_destination_bar.dart index 70424084..4c4fd432 100644 --- a/app/lib/ui/adaptive/floating_destination_bar.dart +++ b/app/lib/ui/adaptive/floating_destination_bar.dart @@ -197,6 +197,7 @@ class _FloatingDestinationBarState extends State final labels = FloatingDestinationLabels( key: FloatingDestinationBar.rowKey, labels: [for (final item in items) item.label], + enabled: [for (final item in items) item.enabled], selected: currentIndex, buttonBuilder: (index) => _button(context, index), onTap: widget.onTap, @@ -267,6 +268,8 @@ class _FloatingDestinationBarState extends State iconSize: iconSize * size / _size, label: item.label, icon: selected ? item.selectedIcon ?? item.icon : item.icon, + enabled: item.enabled, + tooltip: item.tooltip, onTap: () => widget.onTap(index), ), ), @@ -281,8 +284,18 @@ class FloatingDestinationItem { required this.label, this.selectedIcon, this.key, + this.enabled = true, + this.tooltip, }); + /// The tab's tooltip (and accessibility hint) instead of its label, such + /// as why a disabled tab cannot open. + final String? tooltip; + + /// False shows the tab greyed out and takes no taps, so a tab that has + /// nothing to show keeps its place in the bar. + final bool enabled; + final Widget icon; /// The tab's accessible name (and Material tooltip); not drawn. diff --git a/app/lib/ui/adaptive/floating_destination_labels.dart b/app/lib/ui/adaptive/floating_destination_labels.dart index 10e33bc0..eac7bd5f 100644 --- a/app/lib/ui/adaptive/floating_destination_labels.dart +++ b/app/lib/ui/adaptive/floating_destination_labels.dart @@ -7,11 +7,16 @@ class FloatingDestinationLabels extends StatelessWidget { const FloatingDestinationLabels({ super.key, required this.labels, + this.enabled = const [], required this.selected, required this.buttonBuilder, required this.onTap, }); final List labels; + + /// Per label; a missing entry is enabled. + final List enabled; + bool _enabled(int index) => index >= enabled.length || enabled[index]; final int selected; final Widget Function(int) buttonBuilder; final ValueChanged onTap; @@ -36,7 +41,7 @@ class FloatingDestinationLabels extends StatelessWidget { GestureDetector( key: ValueKey('destination-label-${labels[index]}'), excludeFromSemantics: true, - onTap: () => onTap(index), + onTap: _enabled(index) ? () => onTap(index) : null, child: TextFieldTapRegion( child: Column( mainAxisSize: MainAxisSize.min, @@ -46,7 +51,9 @@ class FloatingDestinationLabels extends StatelessWidget { child: Text( labels[index], style: style.copyWith( - color: color, + color: _enabled(index) + ? color + : color.withValues(alpha: .38), fontWeight: index == selected ? FontWeight.w600 : style.fontWeight, diff --git a/app/lib/ui/adaptive/floating_tab_button.dart b/app/lib/ui/adaptive/floating_tab_button.dart index 9575e58a..b5fb15fc 100644 --- a/app/lib/ui/adaptive/floating_tab_button.dart +++ b/app/lib/ui/adaptive/floating_tab_button.dart @@ -33,8 +33,16 @@ class FloatingTabButton extends StatelessWidget { required this.label, required this.icon, required this.onTap, + this.enabled = true, + this.tooltip, }); + /// Shown (and given as the accessibility hint) instead of [label]. + final String? tooltip; + + /// False greys the tab out and ignores taps; it keeps its place. + final bool enabled; + final FloatingTabMotion motion; final int index; final int count; @@ -64,12 +72,14 @@ class FloatingTabButton extends StatelessWidget { child: Semantics( role: SemanticsRole.tab, selected: selected, + enabled: enabled, + hint: tooltip, button: true, label: kIsWeb ? label : '$label\n${_tabLabel(context)}', // Switching tabs does not unfocus a text field (the composer). child: TextFieldTapRegion( child: Tooltip( - message: label, + message: tooltip ?? label, excludeFromSemantics: true, child: button, ), @@ -87,7 +97,9 @@ class FloatingTabButton extends StatelessWidget { return ( tint: scheme.secondaryContainer, selectedIcon: scheme.onSecondaryContainer, - icon: scheme.onSurfaceVariant, + icon: enabled + ? scheme.onSurfaceVariant + : scheme.onSurface.withValues(alpha: .38), ); } @@ -105,7 +117,7 @@ class FloatingTabButton extends StatelessWidget { key: fillKey, decoration: decoration, child: InkResponse( - onTap: onTap, + onTap: enabled ? onTap : null, customBorder: const CircleBorder(), containedInkWell: true, highlightShape: BoxShape.circle, diff --git a/app/lib/ui/layout/app_list_row.dart b/app/lib/ui/layout/app_list_row.dart index a5e2f078..6f7500f3 100644 --- a/app/lib/ui/layout/app_list_row.dart +++ b/app/lib/ui/layout/app_list_row.dart @@ -28,6 +28,11 @@ const double _lineGap = 4; const appListRowSurfaceKey = ValueKey('app-list-row-surface'); const appListRowDividerKey = ValueKey('app-list-row-divider'); const appListRowAccentKey = ValueKey('app-list-row-accent'); +const appListRowSelectionKey = ValueKey('app-list-row-selection'); + +/// The width of a row's leading bar: the open row's accent, or an identity +/// colour's mark. +const double kAppListRowBarWidth = 4; /// The app's one list row (runs, pipelines, chats, search results, /// schedules). @@ -42,7 +47,9 @@ const appListRowAccentKey = ValueKey('app-list-row-accent'); /// under the text column separates rows. Nothing has a fixed height: the row /// grows with text scaling and every line ellipsises. /// -/// [selected] paints the open row (Material `secondaryContainer`); [emphasized] +/// [selected] paints the open row: Material `secondaryContainer` with one +/// [selectionAccent] bar on its leading edge, the one selection style every +/// list shares; [emphasized] /// marks unread/attention (a heavier title and an accent time). Rows ripple. class AppListRow extends StatelessWidget { const AppListRow({ @@ -54,6 +61,7 @@ class AppListRow extends StatelessWidget { this.subtitle, this.compactSubtitle, this.detail, + this.compactDetail = true, this.subtitleLeading, this.subtitleTrailing, this.menu, @@ -68,8 +76,14 @@ class AppListRow extends StatelessWidget { this.compactWidth = kAppListRowCompactWidth, this.accent, this.showAccentBorder = true, + this.selectionAccent, }); + /// The leading bar's colour on the open row; Material `primary` when null. + /// Every list marks its open row the same way: the tonal fill plus this + /// one bar. + final Color? selectionAccent; + /// The item's own colour (a chat's highlight): a bar on the row's leading /// edge and a faint tint under an unselected row. The selected fill still /// marks the open row, so the two never read as one another. @@ -93,6 +107,10 @@ class AppListRow extends StatelessWidget { /// An optional third line under the subtitle (a failed run's reason), one /// ellipsised line in the subtitle style unless the widget styles itself. final Widget? detail; + + /// Whether a compact row keeps [detail]; false leaves a narrow row its + /// title and [compactSubtitle] only. + final bool compactDetail; final Widget? subtitleLeading; final Widget? subtitleTrailing; final Widget? menu; @@ -184,14 +202,22 @@ class AppListRow extends StatelessWidget { // The colour bar runs the row's whole height, divider included, and // the tint fills the divider's inset too, so coloured rows read as // one band each. - Widget marked(Widget row) => accent == null || !showAccentBorder + // The open row's bar, else an identity colour's own bar. + final bar = selected + ? selectionAccent ?? + accent ?? + Theme.of(context).colorScheme.primary + : showAccentBorder + ? accent + : null; + Widget marked(Widget row) => bar == null ? row : DecoratedBox( - key: appListRowAccentKey, + key: selected ? appListRowSelectionKey : appListRowAccentKey, position: DecorationPosition.foreground, decoration: BoxDecoration( border: BorderDirectional( - start: BorderSide(color: accent!, width: 4), + start: BorderSide(color: bar, width: kAppListRowBarWidth), ), ), child: row, @@ -276,7 +302,7 @@ class AppListRow extends StatelessWidget { // A compact row has no room beside its title: the time takes a line of // its own under the subtitle. final timeLine = compact ? time : null; - final detailLine = detail == null + final detailLine = detail == null || (compact && !compactDetail) ? null : Padding( padding: const EdgeInsets.only(top: _lineGap), diff --git a/app/test/features/chat/chat_open_transition_test.dart b/app/test/features/chat/chat_open_transition_test.dart index 15068046..8b729ec8 100644 --- a/app/test/features/chat/chat_open_transition_test.dart +++ b/app/test/features/chat/chat_open_transition_test.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/ui/layout/app_list_row.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/chat/screen.dart'; @@ -175,7 +176,8 @@ void main() { final background = appLightTheme().scaffoldBackgroundColor; expect(origin.color, isNot(background), reason: 'the chat colour tints it'); expect(origin.color.a, 1); - expect(origin.markerWidth, 10); + // The open row's one bar, as every list marks its open row. + expect(origin.markerWidth, kAppListRowBarWidth); expect(origin.marker, isNotNull); }); diff --git a/app/test/features/chat/ui/sessions/chat_active_selection_test.dart b/app/test/features/chat/ui/sessions/chat_active_selection_test.dart index 11e5ccad..04d17fce 100644 --- a/app/test/features/chat/ui/sessions/chat_active_selection_test.dart +++ b/app/test/features/chat/ui/sessions/chat_active_selection_test.dart @@ -58,13 +58,17 @@ void main() { of: row, matching: find.byKey(appListRowSurfaceKey), ); + // The lists' shared open-row style: the tonal fill and one bar. final color = tester.widget(surface).color; - expect(color, const Color(0x00000000)); - final highlight = tester.widget( - find.byKey(ValueKey('chat-visibility-$id')), + final context = tester.element(row); + expect(color == AppListRow.selectedColor(context), active); + expect( + find.descendant( + of: find.byKey(ValueKey('chat-visibility-$id')), + matching: find.byKey(appListRowSelectionKey), + ), + active ? findsOneWidget : findsNothing, ); - final fill = (highlight.decoration as BoxDecoration).color; - expect(fill != null && fill.a > 0, active); } expectRow('a', true); diff --git a/app/test/features/chat/ui/sessions/chat_color_test.dart b/app/test/features/chat/ui/sessions/chat_color_test.dart index d82fdd40..2c458222 100644 --- a/app/test/features/chat/ui/sessions/chat_color_test.dart +++ b/app/test/features/chat/ui/sessions/chat_color_test.dart @@ -210,16 +210,16 @@ void main() { ), ), ); - final surface = tester.widget(find.byKey(appListRowSurfaceKey)); - expect(surface.color, Colors.transparent); - final highlight = tester.widget( - find.byKey(const ValueKey('chat-visibility-s1')), - ); - // The selected row is filled in its own colour. - final fill = (highlight.decoration as BoxDecoration).color!; - expect(fill.a, greaterThan(0)); + // The shared open-row style: the tonal fill, and its one bar in the + // chat's own colour. final context = tester.element(find.byType(ChatSessionRow)); - expect(fill.withValues(alpha: 1), chatColorShade(context, 'amber')); + final surface = tester.widget(find.byKey(appListRowSurfaceKey)); + expect(surface.color, AppListRow.selectedColor(context)); + final bar = tester.widget(find.byKey(appListRowSelectionKey)); + final side = + ((bar.decoration as BoxDecoration).border as BorderDirectional).start; + expect(side.color, chatColorShade(context, 'amber')); + expect(side.width, kAppListRowBarWidth); expect(find.byKey(appListRowAccentKey), findsNothing); expect(find.byKey(const ValueKey('chat-visibility-s1')), findsOneWidget); }); diff --git a/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart b/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart index 8a7a86d2..8aa482f2 100644 --- a/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart +++ b/app/test/features/chat/ui/sessions/chat_visibility_marker_test.dart @@ -25,9 +25,20 @@ BorderSide edge(WidgetTester tester, String id) { return ((box.decoration as BoxDecoration).border as BorderDirectional).start; } +/// The shared open-row bar [AppListRow] draws on the selected row of [id]. +BorderSide? selectionBar(WidgetTester tester, String id) { + final bar = find.descendant( + of: find.byKey(ValueKey('chat-visibility-$id')), + matching: find.byKey(appListRowSelectionKey), + ); + if (bar.evaluate().isEmpty) return null; + final box = tester.widget(bar); + return ((box.decoration as BoxDecoration).border as BorderDirectional).start; +} + void main() { testWidgets( - 'only visible chats have an edge; active edge widens continuously', + 'visible chats have a thin edge; the open chat has the shared selection', (tester) async { tester.platformDispatcher.accessibilityFeaturesTestValue = const FakeAccessibilityFeatures(disableAnimations: false); @@ -72,19 +83,25 @@ void main() { ), ), ); + // A selected chat not shown in a pane wears only the shared selection. expect(edge(tester, 'off').style, BorderStyle.none); + expect(selectionBar(tester, 'off')!.width, kAppListRowBarWidth); + // A chat visible elsewhere keeps its thin edge. expect(edge(tester, 'on').width, 3); + expect(selectionBar(tester, 'on'), isNull); expect(find.byKey(appListRowAccentKey), findsNothing); update(() => active = true); - await tester.pump(); - await tester.pump(const Duration(milliseconds: 100)); - expect(edge(tester, 'on').width, greaterThan(3)); - expect(edge(tester, 'on').width, lessThan(8)); await tester.pumpAndSettle(); - expect(edge(tester, 'on').width, 8); + // Opened, it is marked exactly like any open row: one bar in the + // chat's colour over the tonal fill, and no second edge. + expect(edge(tester, 'on').style, BorderStyle.none); + final bar = selectionBar(tester, 'on')!; + expect(bar.width, kAppListRowBarWidth); + expect(bar.color, isNot(Colors.transparent)); update(() => active = false); await tester.pumpAndSettle(); expect(edge(tester, 'on').width, 3); + expect(selectionBar(tester, 'on'), isNull); }, ); testWidgets('compact chats keep identity colours and visible/active edges', ( @@ -128,7 +145,18 @@ void main() { await tester.tap(find.byTooltip('New chat')); expect(newChatPressed, isTrue); expect(find.byTooltip('Expand chat list'), findsOneWidget); - expect(edge(tester, 'a').width, 8); + // The open chat: no second edge, the shared fill and bar instead. + expect(edge(tester, 'a').style, BorderStyle.none); + final open = tester + .widgetList( + find.descendant( + of: find.byKey(const ValueKey('chat-visibility-a')), + matching: find.byType(AnimatedContainer), + ), + ) + .singleWhere((box) => box.foregroundDecoration != null); + final bar = (open.foregroundDecoration as BoxDecoration).border; + expect((bar as BorderDirectional).start.width, kAppListRowBarWidth); expect(edge(tester, 'b').width, 3); expect(edge(tester, 'c').style, BorderStyle.none); final avatars = tester diff --git a/app/test/features/chat/ui/transcript/chat_code_hover_test.dart b/app/test/features/chat/ui/transcript/chat_code_hover_test.dart index 1e913b2a..e1d9d689 100644 --- a/app/test/features/chat/ui/transcript/chat_code_hover_test.dart +++ b/app/test/features/chat/ui/transcript/chat_code_hover_test.dart @@ -48,31 +48,36 @@ void main() { .setMockMethodCallHandler(SystemChannels.platform, null), ); - testWidgets( - 'fenced code reveals Copy without shifting and copies exact whitespace', - (tester) async { - const code = ' final x = 1;\n\tkeep spaces '; - await tester.pumpWidget(_host('```dart\n$code\n```')); - await tester.pumpAndSettle(); - final before = tester.getTopLeft(find.text(code)); - expect(find.text('Copy').hitTestable(), findsNothing); - final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse); - await mouse.addPointer(location: const Offset(1, 1)); - await mouse.moveTo(tester.getCenter(find.text(code))); - await tester.pump(); - expect(find.text('Copy').hitTestable(), findsOneWidget); - expect(tester.getTopLeft(find.text(code)), before); - await tester.tap(find.text('Copy').hitTestable()); - await tester.pump(); - expect(copied, code); - expect(find.text('Copied').hitTestable(), findsOneWidget); - await mouse.moveTo(const Offset(1, 1)); - await tester.pump(); - expect(find.text('Copied').hitTestable(), findsNothing); - await mouse.removePointer(); - await tester.pumpWidget(const SizedBox()); - }, - ); + testWidgets('fenced code has a header strip with its language and Copy', ( + tester, + ) async { + const code = ' final x = 1;\n\tkeep spaces '; + await tester.pumpWidget(_host('```dart\n$code\n```')); + await tester.pumpAndSettle(); + // One framed block: the header strip (label and Copy) sits on top of + // the code, inside the block, and Copy needs no hover (touch has none). + final header = tester.getRect(find.byKey(const Key('chat-code-header'))); + final block = tester.getRect(find.byKey(const Key('chat-code-body'))); + final label = tester.getRect(find.text('dart')); + final copy = tester.getRect(find.text('Copy').hitTestable()); + expect(header.top, block.top); + expect(header.contains(label.center), isTrue); + expect(header.contains(copy.center), isTrue); + expect(tester.getTopLeft(find.text(code)).dy, greaterThan(header.bottom)); + expect(block.contains(tester.getCenter(find.text(code))), isTrue); + final before = tester.getTopLeft(find.text(code)); + final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse); + await mouse.addPointer(location: const Offset(1, 1)); + await mouse.moveTo(tester.getCenter(find.text(code))); + await tester.pump(); + expect(tester.getTopLeft(find.text(code)), before); + await tester.tap(find.text('Copy').hitTestable()); + await tester.pump(); + expect(copied, code); + expect(find.text('Copied').hitTestable(), findsOneWidget); + await mouse.removePointer(); + await tester.pumpWidget(const SizedBox()); + }); testWidgets( 'inline spans retain selection, hover transfer and copy the right raw snippet', @@ -168,11 +173,11 @@ void main() { await tester.pumpWidget(const SizedBox()); }); - testWidgets('keyboard focus exposes the reserved block action', ( + testWidgets('the block action is reachable from the keyboard', ( tester, ) async { await tester.pumpWidget(_host('```text\nraw\n```')); - expect(find.text('Copy').hitTestable(), findsNothing); + expect(find.text('Copy').hitTestable(), findsOneWidget); // The selectable transcript itself is the first focus stop. await tester.sendKeyEvent(LogicalKeyboardKey.tab); await tester.pump(); diff --git a/app/test/features/chat/ui/transcript/chat_horizontal_viewport_test.dart b/app/test/features/chat/ui/transcript/chat_horizontal_viewport_test.dart index 728e6d53..6ff57484 100644 --- a/app/test/features/chat/ui/transcript/chat_horizontal_viewport_test.dart +++ b/app/test/features/chat/ui/transcript/chat_horizontal_viewport_test.dart @@ -45,6 +45,9 @@ Widget _host({ ); } +/// The chevron over the faded side with more content. +Finder _more(String side) => find.byKey(Key('chat-horizontal-more-$side')); + ScrollController _controller(WidgetTester tester) => tester.widget(find.byType(Scrollbar)).controller!; @@ -55,14 +58,16 @@ void main() { (tester) async { await tester.pumpWidget(_host(brightness: brightness)); await tester.pumpAndSettle(); - expect(find.text('Scroll horizontally'), findsOneWidget); + expect(find.byKey(const Key('chat-horizontal-fade')), findsOneWidget); final controller = _controller(tester); expect(controller.position.maxScrollExtent, 640); expect( tester.widget(find.byType(Scrollbar)).thumbVisibility, isTrue, ); - expect(find.byIcon(Icons.arrow_forward), findsOneWidget); + // More content to the right: that side fades under a chevron. + expect(_more('right'), findsOneWidget); + expect(_more('left'), findsNothing); final focus = tester .widgetList(find.byType(Focus)) .firstWhere( @@ -73,15 +78,17 @@ void main() { await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); await tester.pumpAndSettle(); expect(controller.offset, 80); - expect(find.byIcon(Icons.swap_horiz), findsOneWidget); + expect(_more('left'), findsOneWidget); + expect(_more('right'), findsOneWidget); controller.jumpTo(controller.position.maxScrollExtent); await tester.pumpAndSettle(); - expect(find.byIcon(Icons.arrow_back), findsOneWidget); + expect(_more('left'), findsOneWidget); + expect(_more('right'), findsNothing); await tester.pumpWidget( _host(brightness: brightness, contentWidth: 120), ); await tester.pumpAndSettle(); - expect(find.text('Scroll horizontally'), findsNothing); + expect(find.byKey(const Key('chat-horizontal-fade')), findsNothing); expect(tester.takeException(), isNull); }, ); @@ -92,9 +99,10 @@ void main() { (tester) async { await tester.pumpWidget(_host(direction: TextDirection.rtl)); await tester.pumpAndSettle(); - expect(find.byIcon(Icons.arrow_back), findsOneWidget); + expect(_more('left'), findsOneWidget); + expect(_more('right'), findsNothing); expect( - tester.widget(find.byIcon(Icons.arrow_back)).textDirection, + tester.widget(_more('left')).textDirection, TextDirection.ltr, ); final controller = _controller(tester); @@ -169,7 +177,7 @@ void main() { find.bySemanticsLabel('Horizontally scrollable table'), findsNothing, ); - expect(find.text('Scroll horizontally'), findsOneWidget); + expect(find.byKey(const Key('chat-horizontal-fade')), findsOneWidget); final viewport = tester.getRect(find.byType(ChatMarkdownView)); expect( tester.getRect(find.byType(Table)).right, diff --git a/app/test/features/chat/ui/transcript/chat_markdown_table_wrap_test.dart b/app/test/features/chat/ui/transcript/chat_markdown_table_wrap_test.dart index fc363745..19443bf9 100644 --- a/app/test/features/chat/ui/transcript/chat_markdown_table_wrap_test.dart +++ b/app/test/features/chat/ui/transcript/chat_markdown_table_wrap_test.dart @@ -27,7 +27,7 @@ void main() { '| No | Text | Ok |\n| --- | --- | --- |\n' '| one | ${List.filled(30, 'word').join(' ')} | done |', ); - expect(find.text('Scroll horizontally'), findsNothing); + expect(find.byKey(const Key('chat-horizontal-fade')), findsNothing); expect(tableRect(tester).right, lessThanOrEqualTo(screenRight)); final description = tester.getSize(find.textContaining('word word')); final status = tester.getSize(find.text('done')); @@ -55,7 +55,7 @@ void main() { '| --- | --- | --- | --- | --- | --- | --- |\n' '| a b | c d | e f | g h | i j | k l | m n |', ); - expect(find.text('Scroll horizontally'), findsOneWidget); + expect(find.byKey(const Key('chat-horizontal-fade')), findsOneWidget); expect( find.bySemanticsLabel('Horizontally scrollable table'), findsOneWidget, @@ -76,7 +76,7 @@ void main() { '| Column | Notes |\n| --- | --- |\n' '| x | ${List.filled(40, 'note').join(' ')} |', ); - expect(find.text('Scroll horizontally'), findsNothing); + expect(find.byKey(const Key('chat-horizontal-fade')), findsNothing); expect(tableRect(tester).right, lessThanOrEqualTo(screenRight)); final header = tester.getSize(find.text('Column')).height; expect(header, tester.getSize(find.text('x')).height); diff --git a/app/test/features/pipelines/pipeline_list_composition_test.dart b/app/test/features/pipelines/pipeline_list_composition_test.dart index c35ae3f9..0ccefe56 100644 --- a/app/test/features/pipelines/pipeline_list_composition_test.dart +++ b/app/test/features/pipelines/pipeline_list_composition_test.dart @@ -55,6 +55,11 @@ void main() { expect(find.textContaining('v2 · #'), findsNothing); expect(find.text('2 stages · 1 schedule'), findsOneWidget); expect(find.byKey(const Key('pipeline-status-1')), findsOneWidget); + // The state is spelled out beside its dot, with when the run was. + expect( + tester.widget(find.byKey(const Key('pipeline-status-text-1'))).data, + matches(RegExp(r'^Succeeded · last run .+')), + ); expect(find.byKey(const Key('pipeline-status-2')), findsOneWidget); expect(find.text('no runs recorded'), findsNothing); }); @@ -142,7 +147,10 @@ void main() { findsOneWidget, ); expect( - find.descendant(of: firstRow, matching: find.text('Succeeded')), + find.descendant( + of: firstRow, + matching: find.textContaining(RegExp(r'^Succeeded( · .+)?$')), + ), findsOneWidget, ); expect( @@ -204,7 +212,10 @@ void main() { runs.complete(runListReply(fixture.runs)); await tester.pumpAndSettle(); expect( - find.descendant(of: firstRow, matching: find.text('Succeeded')), + find.descendant( + of: firstRow, + matching: find.textContaining(RegExp(r'^Succeeded( · .+)?$')), + ), findsOneWidget, ); expect(tester.takeException(), isNull); diff --git a/app/test/features/runs/ui/run_artifacts_action_test.dart b/app/test/features/runs/ui/run_artifacts_action_test.dart index fd1595a3..970ec49c 100644 --- a/app/test/features/runs/ui/run_artifacts_action_test.dart +++ b/app/test/features/runs/ui/run_artifacts_action_test.dart @@ -4,6 +4,7 @@ import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/runs/data/runs_repository.dart'; import 'package:pipelines_app/features/runs/ui/run_detail_view.dart'; import 'package:pipelines_app/features/runs/ui/runs_controller.dart'; +import 'package:pipelines_app/ui/adaptive/floating_tab_button.dart'; import '../../artifacts/domain/artifact_fixtures.dart'; @@ -97,16 +98,44 @@ void main() { expect(find.text('reviewer · visit 1'), findsOneWidget); }); - testWidgets('the action is offered only when the detail has steps', ( + /// The Artifacts tab keeps its place on a run with none: disabled, badged + /// `0`, and its tooltip (and accessibility hint) says why. + Future expectDisabledArtifacts(WidgetTester tester, String why) async { + final tab = find.byKey(const ValueKey('run-detail-tab-artifacts')); + expect(tab, findsOneWidget); + final button = tester.widget(tab); + expect(button.enabled, isFalse); + expect(button.tooltip, why); + expect( + find.descendant( + of: tab, + matching: find.byKey(const ValueKey('run-detail-artifacts-count')), + ), + findsOneWidget, + ); + expect(find.descendant(of: tab, matching: find.text('0')), findsOneWidget); + // A tap does not open an empty gallery: Summary stays. + await tester.tap(tab, warnIfMissed: false); + await tester.pumpAndSettle(); + expect(find.text(why), findsNothing); + // Changes, after it, keeps its place. + final order = [ + for (final name in ['summary', 'timeline', 'artifacts', 'changes']) + tester.getCenter(find.byKey(ValueKey('run-detail-tab-$name'))).dx, + ]; + expect(order, orderedEquals([...order]..sort())); + } + + testWidgets('a run without steps keeps a disabled Artifacts tab', ( tester, ) async { final gateway = _FakeGateway(_run(steps: const [])); final controller = await _loaded(gateway); addTearDown(controller.dispose); await _pumpDetail(tester, controller, gateway); - expect( - find.byKey(const ValueKey('run-detail-tab-artifacts')), - findsNothing, + await expectDisabledArtifacts( + tester, + 'No artifacts recorded for this run.', ); }); @@ -121,16 +150,10 @@ void main() { final controller = await _loaded(gateway); addTearDown(controller.dispose); await _pumpDetail(tester, controller, gateway); - - await tester.ensureVisible( - find.byKey(const ValueKey('run-detail-tab-artifacts')), + await expectDisabledArtifacts( + tester, + 'No artifacts recorded for this run.', ); - - await tester.pumpAndSettle(); - - await tester.tap(find.byKey(const ValueKey('run-detail-tab-artifacts'))); - await tester.pumpAndSettle(); - expect(find.text('No artifacts recorded for this run.'), findsOneWidget); }); testWidgets('an unavailable capture is never reported as empty', ( @@ -142,16 +165,6 @@ void main() { final controller = await _loaded(gateway); addTearDown(controller.dispose); await _pumpDetail(tester, controller, gateway); - - await tester.ensureVisible( - find.byKey(const ValueKey('run-detail-tab-artifacts')), - ); - - await tester.pumpAndSettle(); - - await tester.tap(find.byKey(const ValueKey('run-detail-tab-artifacts'))); - await tester.pumpAndSettle(); - expect(find.text('Artifacts · capture unavailable'), findsOneWidget); - expect(find.text('No artifacts recorded for this run.'), findsNothing); + await expectDisabledArtifacts(tester, 'Artifacts · capture unavailable'); }); } diff --git a/app/test/features/runs/ui/run_detail_flat_bodies_test.dart b/app/test/features/runs/ui/run_detail_flat_bodies_test.dart index 1a48bff5..a8f7f3e5 100644 --- a/app/test/features/runs/ui/run_detail_flat_bodies_test.dart +++ b/app/test/features/runs/ui/run_detail_flat_bodies_test.dart @@ -10,8 +10,8 @@ import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart'; import 'run_detail_graph_support.dart'; import 'run_detail_visit_support.dart'; -/// The run and stage detail bodies are flat on the page, and beside a list one -/// row of tabs and header. +/// The run and stage detail bodies are flat on the page, and beside a list +/// the tabs sit under the header in one strip. void main() { testWidgets('Summary and Timeline show their bodies', (tester) async { await pumpRunDetail(tester, RunDetailTestPlatform.material); @@ -28,7 +28,7 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('beside a list the tabs and the header share one row', ( + testWidgets('beside a list the tabs sit under the header at the top', ( tester, ) async { tester.view.physicalSize = const Size(720, 900); @@ -51,11 +51,13 @@ void main() { final tabs = tester.getRect(find.byKey(const Key('run-detail-tabs'))); final header = tester.getRect(find.byKey(const Key('run-detail-header'))); - // Side by side, not stacked: the header starts after the tabs and - // overlaps them vertically. - expect(header.left, greaterThanOrEqualTo(tabs.right - 12)); - expect(header.top, lessThan(tabs.bottom)); - expect(header.bottom, greaterThan(tabs.top)); + // One strip at the top: the tabs are inside it, at its foot, and the + // whole strip sits near the top of the 900px detail. + expect(tabs.top, greaterThan(header.top)); + expect(tabs.bottom, lessThanOrEqualTo(header.bottom)); + expect(tabs.left, greaterThanOrEqualTo(header.left)); + expect(header.top, lessThan(120)); + expect(tester.getRect(find.text('Summary')).top, greaterThan(header.top)); expect(tester.takeException(), isNull); }); } diff --git a/app/test/features/runs/ui/run_detail_tabs_test.dart b/app/test/features/runs/ui/run_detail_tabs_test.dart index 02a01658..b3a48af5 100644 --- a/app/test/features/runs/ui/run_detail_tabs_test.dart +++ b/app/test/features/runs/ui/run_detail_tabs_test.dart @@ -59,18 +59,21 @@ void main() { previous = center.dx; } expect(find.byKey(runMoreMenuKey), findsOneWidget); - // The tabs are the floating glass bar: on this 900px detail it is sized - // to its tabs at the right edge, above the bottom. - final pill = tester.getRect( + // On this wide 900px detail the tabs are Material segments under the + // run header, at the top of the detail, not a floating bottom bar. + final row = tester.getRect(strip); + final header = tester.getRect(find.byKey(const Key('run-detail-header'))); + expect(find.byType(SegmentedButton), findsOneWidget); + expect( find.descendant( of: strip, matching: find.byKey(FloatingDestinationBar.rowKey), ), + findsNothing, ); - expect(pill.right, 900 - 16); - expect(pill.bottom, 1000 - 16); - // (The test font draws every glyph a full em wide.) - expect(pill.width, lessThan(900 * 0.7)); + expect(row.top, greaterThan(header.top)); + expect(row.bottom, lessThanOrEqualTo(header.bottom)); + expect(row.top, lessThan(1000 / 3)); for (final tab in [ RunDetailTab.timeline, @@ -122,19 +125,24 @@ void main() { greaterThanOrEqualTo(844 - pill.top), ); + // Wide, the tabs move to the top under the header; the content still + // fills the pane and starts below them at rest. await pumpRunDetail(tester, platform, size: const Size(1000, 844)); - final widePill = tester.getRect( + final wideTabs = tester.getRect(strip); + expect(wideTabs.top, lessThan(844 / 3)); + expect( find.descendant( of: strip, matching: find.byKey(FloatingDestinationBar.rowKey), ), + findsNothing, ); - expect(widePill.right, 1000 - 16); - expect(widePill.bottom, 844 - 16); - expect(widePill.width, lessThan(1000 * 0.6)); - // Beside the bar the content takes taps: the body fills the pane. expect(tester.getRect(body).left, 0); expect(tester.getRect(body).width, 1000); + expect( + MediaQuery.paddingOf(tester.element(body)).top, + greaterThanOrEqualTo(wideTabs.bottom), + ); }); testWidgets('${platform.name} missing graph states the exact wording', ( 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 40130ff9..cf3def37 100644 --- a/app/test/features/runs/ui/run_list_row_test.dart +++ b/app/test/features/runs/ui/run_list_row_test.dart @@ -187,4 +187,30 @@ void main() { expect(tester.takeException(), isNull); }); } + + testWidgets('under a day heading a row shows only its time of day', ( + tester, + ) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: RunListRow( + run: _finished, + now: DateTime.utc(2026, 10, 22), + timeOfDay: true, + ), + ), + ), + ); + final created = DateTime.parse('${_finished['created_at']}'); + expect(find.byType(RelativeTimeLabel), findsNothing); + final time = tester.widget( + find.byKey(const ValueKey('run-row-time-42')), + ); + expect(time.data, runTimeOfDay(created)); + expect(time.data, matches(RegExp(r'^\d\d:\d\d$'))); + // The day the heading already names is not repeated on the row. + final local = created.toLocal(); + expect(find.textContaining('${local.day} Oct'), findsNothing); + }); } diff --git a/app/test/features/settings/settings_actions_test.dart b/app/test/features/settings/settings_actions_test.dart new file mode 100644 index 00000000..f6a3044c --- /dev/null +++ b/app/test/features/settings/settings_actions_test.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/settings/settings_controls.dart'; + +Widget _actions({required bool connected}) => MaterialApp( + home: Scaffold( + body: SettingsActions( + primaryLabel: connected ? 'Disconnect' : 'Connect', + secondaryLabel: 'Reconnect', + primaryKey: const Key('primary'), + secondaryKey: const Key('secondary'), + primaryOutlined: connected, + onPrimary: () {}, + onSecondary: () {}, + ), + ), +); + +void main() { + testWidgets('connected: Reconnect is tonal and leads, Disconnect outlined', ( + tester, + ) async { + await tester.pumpWidget(_actions(connected: true)); + final disconnect = find.byKey(const Key('primary')); + final reconnect = find.byKey(const Key('secondary')); + expect(tester.widget(disconnect), isA()); + expect(tester.widget(reconnect), isA()); + // Never the filled primary emphasis on the action that drops the link. + expect(find.byType(OutlinedButton), findsOneWidget); + expect( + tester.getTopLeft(reconnect).dx, + lessThan(tester.getTopLeft(disconnect).dx), + ); + }); + + testWidgets('disconnected: Connect is filled, Reconnect outlined', ( + tester, + ) async { + await tester.pumpWidget(_actions(connected: false)); + final connect = find.byKey(const Key('primary')); + final reconnect = find.byKey(const Key('secondary')); + expect(tester.widget(connect), isA()); + expect(tester.widget(reconnect), isA()); + expect( + tester.getTopLeft(connect).dx, + lessThan(tester.getTopLeft(reconnect).dx), + ); + }); +} diff --git a/app/test/ui/layout/app_list_row_test.dart b/app/test/ui/layout/app_list_row_test.dart index 3a771e19..40a923f0 100644 --- a/app/test/ui/layout/app_list_row_test.dart +++ b/app/test/ui/layout/app_list_row_test.dart @@ -147,11 +147,21 @@ void main() { AppListRow.selectedColor(context), ); final accent = Theme.of(context).colorScheme.primary; + // The one selection style every list shares: the tonal fill plus one + // leading bar in the accent. + final bar = tester.widget( + find.descendant(of: row, matching: find.byKey(appListRowSelectionKey)), + ); + final side = + ((bar.decoration as BoxDecoration).border as BorderDirectional).start; + expect(side.color, accent); + expect(side.width, kAppListRowBarWidth); expect(_paint(tester, 'Fixture run').fontWeight, FontWeight.w700); expect(_paint(tester, '9d ago').color, accent); await tester.pumpWidget(_host(_row())); expect(tester.widget(surface).color, const Color(0x00000000)); + expect(find.byKey(appListRowSelectionKey), findsNothing); expect(_paint(tester, '9d ago').color, isNot(accent)); });