Merge branch 'worktree-agent-ac4392b2750312e98'

This commit is contained in:
2026-12-03 00:59:38 +00:00
37 changed files with 848 additions and 399 deletions
@@ -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<JsonMap> 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<int>(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);
@@ -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;
@@ -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<JsonMap>(
// A mouse drags at once (a click still opens the chat); the chip
// follows the pointer.
@@ -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;
}
@@ -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<JsonMap>(
// 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),
@@ -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<ChatCodeCopyRegion> createState() => _ChatCodeCopyRegionState();
}
class _ChatCodeCopyRegionState extends State<ChatCodeCopyRegion> {
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,
],
),
),
);
}
@@ -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<ChatHorizontalViewport> {
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<ScrollMetricsNotification>(
onNotification: (notification) {
if (notification.metrics.axis == Axis.horizontal) _scheduleMetrics();
@@ -127,35 +176,17 @@ class _ChatHorizontalViewportState extends State<ChatHorizontalViewport> {
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),
],
),
),
@@ -260,22 +260,19 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
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),
),
),
),
@@ -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,
@@ -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,
@@ -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';
@@ -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<RunDetailTab> 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-<name>`.
/// 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-<name>`.
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<RunDetailTab, String> disabledReasons;
final RunDetailTab selected;
final ValueChanged<RunDetailTab> onSelected;
final FloatingBarEdge edge;
@@ -40,9 +73,17 @@ class RunDetailTabStrip extends StatelessWidget {
/// The tabs this run offers, in [renderedRunDetailTabs] order.
final List<RunDetailTab> 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<RunDetailTab> 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,
),
],
),
+51 -24
View File
@@ -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<RunDetailTabs> {
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<RunDetailTabs> {
});
}
/// 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<RunDetailTab> _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<RunDetailTab> _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<RunDetailTabs> {
_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<RunDetailTabs> {
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
@@ -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-<name>`.
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<RunDetailTab> tabs;
final RunDetailTab selected;
final ValueChanged<RunDetailTab> onSelected;
final int? artifactCount;
final Set<RunDetailTab> disabled;
/// Why a disabled tab cannot open, as its tooltip.
final Map<RunDetailTab, String> 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<RunDetailTab>(
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<RunDetailTab>(
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);
},
),
),
);
}
}
@@ -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,
),
],
),
);
}
@@ -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<JsonMap>? 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),
+23 -4
View File
@@ -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,
@@ -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: <Widget>[
FilledButton(
key: primaryKey,
onPressed: onPrimary,
child: Text(primaryLabel),
),
OutlinedButton(
key: secondaryKey,
onPressed: onSecondary,
child: Text(secondaryLabel),
),
],
children: primaryOutlined
? <Widget>[secondary, primary]
: <Widget>[primary, secondary],
);
}
}
@@ -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,