Merge branch 'main' into run/artifacts-split
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/// The viewer's words for a preview that could not be fetched.
|
||||
///
|
||||
/// The operator sees what happened in plain language and can retry; the raw
|
||||
/// exception text (`TypeError: Failed to fetch`) and bare status lines
|
||||
/// (`The server answered 404.`) never reach the screen. [status] is the HTTP
|
||||
/// status the server answered, or null when no answer arrived at all.
|
||||
String artifactPreviewFailureMessage({int? status}) {
|
||||
if (status == null) {
|
||||
return 'The preview could not be loaded. Check the connection and try '
|
||||
'again.';
|
||||
}
|
||||
if (status == 404 || status == 410) {
|
||||
return 'This file is no longer on the server.';
|
||||
}
|
||||
if (status == 401 || status == 403) {
|
||||
return 'The server did not allow this file to be opened.';
|
||||
}
|
||||
if (status >= 500) {
|
||||
return 'The server could not send this file right now.';
|
||||
}
|
||||
return 'The preview could not be loaded (status $status).';
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import '../../../ui/layout/section_heading.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -41,18 +41,10 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
children: rows,
|
||||
);
|
||||
}
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
child: const Text('Turn documents'),
|
||||
),
|
||||
hasLeading: false,
|
||||
children: rows,
|
||||
);
|
||||
}
|
||||
// Flat rows under a quiet label on both hosts: the section sits inside
|
||||
// the visit's Session page, which is itself flat, so a Cupertino inset
|
||||
// group here would be a group nested in a group.
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -61,7 +53,10 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
child: Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
child: const Text('Turn documents'),
|
||||
child: Text(
|
||||
'Turn documents',
|
||||
style: cupertino ? SectionHeadingStyle.of(context).title : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
...rows,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -496,10 +495,9 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
);
|
||||
if (widget.embedded) return body;
|
||||
if (usesCupertinoHost(context)) {
|
||||
// Flat sections on the page colour, as in the run and stage details;
|
||||
// their pinned headings take the same colour.
|
||||
return CupertinoPageScaffold(
|
||||
// Sections paint the grouped background; the page must match it or a
|
||||
// white seam shows below the last section in light mode.
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
navigationBar: const SegmentedBar(
|
||||
cupertino: true,
|
||||
title: artifactGalleryTitle,
|
||||
|
||||
@@ -41,8 +41,12 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
this.bytes,
|
||||
this.error,
|
||||
this.status,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Loads the current page's preview again after a failure.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final PagedArtifact page;
|
||||
final ArtifactPreviewPlan plan;
|
||||
final int index;
|
||||
@@ -76,6 +80,7 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
text: text,
|
||||
bytes: bytes,
|
||||
error: error,
|
||||
onRetry: onRetry,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
import '../domain/artifact_preview.dart';
|
||||
import 'artifact_html_view.dart';
|
||||
import 'artifact_table_view.dart';
|
||||
@@ -35,8 +38,12 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
this.error,
|
||||
this.videoControllerFactory = defaultArtifactVideoController,
|
||||
this.htmlBuilder = defaultArtifactHtml,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Offered under a fetch failure; absent, the message stands alone.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final ArtifactPreviewPlan plan;
|
||||
final bool loading;
|
||||
final ArtifactMarkdownBuilder markdownBuilder;
|
||||
@@ -60,7 +67,7 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
return const _Loading();
|
||||
}
|
||||
if (error != null) {
|
||||
return _Message(error!);
|
||||
return _Message(error!, onRetry: onRetry);
|
||||
}
|
||||
switch (plan.kind) {
|
||||
case ArtifactPreviewKind.image:
|
||||
@@ -201,17 +208,42 @@ class _PreviewPadding extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const artifactPreviewRetryKey = Key('artifact-preview-retry');
|
||||
|
||||
class _Message extends StatelessWidget {
|
||||
const _Message(this.message);
|
||||
const _Message(this.message, {this.onRetry});
|
||||
|
||||
final String message;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final retry = onRetry;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(message, textAlign: TextAlign.center),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(message, textAlign: TextAlign.center),
|
||||
if (retry != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
cupertino
|
||||
? CupertinoButton.tinted(
|
||||
key: artifactPreviewRetryKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: artifactPreviewRetryKey,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'artifact_selection_facts.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_preview.dart';
|
||||
import '../domain/artifact_preview_failure.dart';
|
||||
import '../domain/artifact_url.dart';
|
||||
import '../domain/gallery_navigation.dart';
|
||||
import 'artifact_external_open.dart';
|
||||
@@ -157,7 +158,7 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
if (!result.ok) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'The server answered ${result.status}.';
|
||||
_error = artifactPreviewFailureMessage(status: result.status);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -168,11 +169,11 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
_fetched = fetched;
|
||||
});
|
||||
},
|
||||
onError: (Object error) {
|
||||
onError: (Object _) {
|
||||
if (!mounted || generation != _generation) return;
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'Could not load preview: $error';
|
||||
_error = artifactPreviewFailureMessage();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -259,6 +260,8 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
fileBridge: widget.fileBridge,
|
||||
onPrevious: () => _step(-1),
|
||||
onNext: () => _step(1),
|
||||
// A failure is never cached, so loading again fetches afresh.
|
||||
onRetry: _beginLoad,
|
||||
onOpen: plan.resolved == null ? () {} : () => _open(plan.resolved!),
|
||||
onCopy: plan.resolved == null ? () {} : () => _copy(plan.resolved!),
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../../../ui/layout/section_heading.dart';
|
||||
import '../../../ui/layout/sticky_section.dart';
|
||||
import 'artifact_document_section.dart';
|
||||
import 'artifact_record_row.dart';
|
||||
@@ -104,7 +105,14 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
|
||||
final slivers = <Widget>[
|
||||
if (header != null) SliverToBoxAdapter(child: header),
|
||||
// The grid/list switch stays reachable while the gallery scrolls.
|
||||
StickyBar(child: _modeSwitch(context)),
|
||||
PinnedHeaderSliver(
|
||||
// On the page colour (that of the pinned section headings), not a
|
||||
// grouped band.
|
||||
child: ColoredBox(
|
||||
color: SectionHeadingStyle.of(context).background,
|
||||
child: _modeSwitch(context),
|
||||
),
|
||||
),
|
||||
];
|
||||
for (final group in widget.groups) {
|
||||
final identity = '${group.stageKey}\u0000${group.visit}';
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
|
||||
/// The server-shared "I have seen this" state (`attention_acks` on the wire):
|
||||
/// dismissed Needs-you identities (`{runId}:{kind}`) and per-chat-session
|
||||
/// read watermarks in epoch milliseconds.
|
||||
///
|
||||
/// The set only grows — dismissals are added and watermarks only advance — so
|
||||
/// merging is a union/maximum and applying a frame twice or out of order is
|
||||
/// harmless. The same shape is used for the whole set, a pushed delta and the
|
||||
/// offline queue of acknowledgements not yet accepted by the server.
|
||||
class AttentionAcks {
|
||||
const AttentionAcks({this.dismissed = const {}, this.chatSeen = const {}});
|
||||
|
||||
final Set<String> dismissed;
|
||||
final Map<String, int> chatSeen;
|
||||
|
||||
bool get isEmpty => dismissed.isEmpty && chatSeen.isEmpty;
|
||||
|
||||
int get length => dismissed.length + chatSeen.length;
|
||||
|
||||
/// The union of both sets, keeping the larger watermark per session.
|
||||
/// Returns this instance when [other] adds nothing.
|
||||
AttentionAcks merge(AttentionAcks other) {
|
||||
final addsDismissal = !dismissed.containsAll(other.dismissed);
|
||||
final advances = other.chatSeen.entries.any(
|
||||
(entry) => entry.value > (chatSeen[entry.key] ?? 0),
|
||||
);
|
||||
if (!addsDismissal && !advances) return this;
|
||||
final seen = {...chatSeen};
|
||||
other.chatSeen.forEach((id, at) {
|
||||
if (at > (seen[id] ?? 0)) seen[id] = at;
|
||||
});
|
||||
return AttentionAcks(
|
||||
dismissed: {...dismissed, ...other.dismissed},
|
||||
chatSeen: seen,
|
||||
);
|
||||
}
|
||||
|
||||
/// What remains of this queue after [sent] was accepted: a dismissal is
|
||||
/// gone once sent, a watermark only when no newer value was queued since.
|
||||
AttentionAcks without(AttentionAcks sent) => AttentionAcks(
|
||||
dismissed: dismissed.difference(sent.dismissed),
|
||||
chatSeen: {
|
||||
for (final entry in chatSeen.entries)
|
||||
if (entry.value > (sent.chatSeen[entry.key] ?? 0))
|
||||
entry.key: entry.value,
|
||||
},
|
||||
);
|
||||
|
||||
/// The wire body of `ack_attention` / the stored queue.
|
||||
JsonMap toJson() {
|
||||
final keys = dismissed.toList()..sort();
|
||||
return {'dismissed': keys, 'chat_seen': chatSeen};
|
||||
}
|
||||
|
||||
String encode() => jsonEncode(toJson());
|
||||
|
||||
/// Total decode of a wire or stored value: unreadable members are skipped
|
||||
/// and a malformed value is the empty set, never an exception.
|
||||
static AttentionAcks fromJson(Object? value) {
|
||||
if (value is! Map) return const AttentionAcks();
|
||||
final dismissed = value['dismissed'];
|
||||
final chatSeen = value['chat_seen'];
|
||||
return AttentionAcks(
|
||||
dismissed: {
|
||||
if (dismissed is List)
|
||||
for (final key in dismissed)
|
||||
if (key is String && key.isNotEmpty) key,
|
||||
},
|
||||
chatSeen: {
|
||||
if (chatSeen is Map)
|
||||
for (final entry in chatSeen.entries)
|
||||
if (entry.key is String &&
|
||||
entry.value is num &&
|
||||
(entry.value as num) > 0)
|
||||
entry.key as String: (entry.value as num).toInt(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static AttentionAcks decode(String? stored) {
|
||||
final text = (stored ?? '').trim();
|
||||
if (text.isEmpty) return const AttentionAcks();
|
||||
try {
|
||||
return fromJson(jsonDecode(text));
|
||||
} catch (_) {
|
||||
return const AttentionAcks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The server's bound on one `ack_attention`; a larger queue is sent in parts.
|
||||
const maxAttentionAckItems = 500;
|
||||
|
||||
/// The first [limit] items of [acks], dismissals first, for one request.
|
||||
AttentionAcks attentionAckBatch(
|
||||
AttentionAcks acks, {
|
||||
int limit = maxAttentionAckItems,
|
||||
}) {
|
||||
if (acks.length <= limit) return acks;
|
||||
final keys = acks.dismissed.toList()..sort();
|
||||
final dismissed = keys.take(limit).toSet();
|
||||
final room = limit - dismissed.length;
|
||||
return AttentionAcks(
|
||||
dismissed: dismissed,
|
||||
chatSeen: Map.fromEntries(acks.chatSeen.entries.take(room)),
|
||||
);
|
||||
}
|
||||
@@ -67,6 +67,9 @@ const notificationRationale =
|
||||
const notificationSectionTitle = 'Notifications';
|
||||
const notificationRequestLabel = 'Enable notifications';
|
||||
|
||||
/// The compact row's visible action; [notificationRequestLabel] is its name.
|
||||
const notificationEnableShortLabel = 'Enable';
|
||||
|
||||
/// The honest wording for every state, verbatim from `web/src/notify.js`; each
|
||||
/// says plainly that the in-app `Needs you` surface is the only channel when the
|
||||
/// platform cannot notify.
|
||||
@@ -100,13 +103,21 @@ class NotificationPermissionView {
|
||||
const NotificationPermissionView({
|
||||
required this.state,
|
||||
required this.body,
|
||||
required this.headline,
|
||||
required this.helper,
|
||||
required this.canRequest,
|
||||
required this.actionLabel,
|
||||
required this.asked,
|
||||
});
|
||||
|
||||
final NotificationPermissionState state;
|
||||
|
||||
/// The browser's full sentence for the state (read out with the row).
|
||||
final String body;
|
||||
|
||||
/// The compact Settings row: a short state line and one short helper.
|
||||
final String headline;
|
||||
final String helper;
|
||||
final bool canRequest;
|
||||
final String? actionLabel;
|
||||
final bool asked;
|
||||
@@ -126,9 +137,39 @@ NotificationPermissionView notificationPermissionView(
|
||||
NotificationPermissionState.notRequested =>
|
||||
asked ? notificationDefaultAskedCopy : notificationDefaultCopy,
|
||||
};
|
||||
final (headline, helper) = switch (state) {
|
||||
NotificationPermissionState.unsupported => (
|
||||
'Not supported in this browser',
|
||||
'Runs that need you still appear in Needs you.',
|
||||
),
|
||||
NotificationPermissionState.needsSecureContext => (
|
||||
'Needs a secure page',
|
||||
'Open the app over https or localhost to turn them on.',
|
||||
),
|
||||
NotificationPermissionState.granted => (
|
||||
'Alerts are on',
|
||||
'Failed and waiting runs raise a notification.',
|
||||
),
|
||||
NotificationPermissionState.denied => (
|
||||
'Blocked by the browser',
|
||||
'Allow them in the site settings; Needs you still works.',
|
||||
),
|
||||
NotificationPermissionState.notRequested =>
|
||||
asked
|
||||
? (
|
||||
'Alerts are still off',
|
||||
'Permission was not granted. Ask again, or use Needs you.',
|
||||
)
|
||||
: (
|
||||
'Alerts are off',
|
||||
'Get told when a run fails or needs your decision.',
|
||||
),
|
||||
};
|
||||
return NotificationPermissionView(
|
||||
state: state,
|
||||
body: body,
|
||||
headline: headline,
|
||||
helper: helper,
|
||||
canRequest: canRequest,
|
||||
actionLabel: canRequest ? notificationRequestLabel : null,
|
||||
asked: asked,
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../core/servers/server_scope.dart';
|
||||
|
||||
/// Persistence for acknowledgements made while the server could not take
|
||||
/// them (offline, or a server without `ack_attention`). The value is the
|
||||
/// opaque string from `AttentionAcks.encode`; both directions may fail, and a
|
||||
/// failure only means the queue lives in memory for this session.
|
||||
abstract interface class AttentionAckQueueStore {
|
||||
Future<String?> read();
|
||||
|
||||
Future<bool> write(String value);
|
||||
}
|
||||
|
||||
/// `shared_preferences` storage scoped to the server, like the other device
|
||||
/// caches. An unavailable plugin returns null/false instead of throwing.
|
||||
class SharedPreferencesAttentionAckQueue implements AttentionAckQueueStore {
|
||||
const SharedPreferencesAttentionAckQueue({this.serverId = ''});
|
||||
|
||||
static const key = 'pipelines.next.attention.pending_acks.v1';
|
||||
|
||||
final String serverId;
|
||||
String get _key => scopedServerKey(key, serverId);
|
||||
|
||||
Future<SharedPreferences?> _preferences() async {
|
||||
try {
|
||||
return await SharedPreferences.getInstance();
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> read() async {
|
||||
try {
|
||||
return (await _preferences())?.getString(_key);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> write(String value) async {
|
||||
try {
|
||||
return await (await _preferences())?.setString(_key, value) ?? false;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An in-memory queue for tests and isolated fixtures.
|
||||
class MemoryAttentionAckQueue implements AttentionAckQueueStore {
|
||||
MemoryAttentionAckQueue({this.stored});
|
||||
|
||||
String? stored;
|
||||
|
||||
@override
|
||||
Future<String?> read() async => stored;
|
||||
|
||||
@override
|
||||
Future<bool> write(String value) async {
|
||||
stored = value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/transport/connection_state.dart';
|
||||
import '../domain/attention_acks.dart';
|
||||
import 'attention_ack_queue.dart';
|
||||
|
||||
/// Keeps this device's attention acknowledgements in step with the server so
|
||||
/// clearing on one device clears everywhere.
|
||||
///
|
||||
/// [acks] is everything known to be acknowledged: the server's set, every
|
||||
/// pushed `attention_acks_changed` delta and this device's own acknowledgements
|
||||
/// (applied at once, before the server answers). Listeners — the Needs-you
|
||||
/// controller and the chat list — fold it into their own state.
|
||||
///
|
||||
/// An acknowledgement the server has not accepted yet stays in a persisted
|
||||
/// queue and is re-sent on the next [connected]. A server refusal drops the
|
||||
/// refused batch (it can never succeed); a server that does not know
|
||||
/// `ack_attention` keeps the queue for a later upgrade and this device falls
|
||||
/// back to its local state.
|
||||
///
|
||||
/// With [sendOnly] (the app passes the socket's own send-only path, as the
|
||||
/// run watch does) requests are not queued behind the transport's serialized
|
||||
/// request/reply calls, so a connect-time read never delays the first screen's
|
||||
/// list; the reply is matched by id from the pushed frames.
|
||||
class AttentionAckSync extends ChangeNotifier {
|
||||
AttentionAckSync({
|
||||
required this.gateway,
|
||||
required this.queue,
|
||||
this.sendOnly,
|
||||
this.replyTimeout = const Duration(seconds: 30),
|
||||
}) {
|
||||
_frames = gateway.frames.listen(_onFrame);
|
||||
}
|
||||
|
||||
final ApiGateway gateway;
|
||||
final AttentionAckQueueStore queue;
|
||||
final String Function(String type, JsonMap fields)? sendOnly;
|
||||
final Duration replyTimeout;
|
||||
late final StreamSubscription<JsonMap> _frames;
|
||||
final Map<String, Completer<JsonMap>> _replies = {};
|
||||
|
||||
AttentionAcks _acks = const AttentionAcks();
|
||||
AttentionAcks _pending = const AttentionAcks();
|
||||
Future<void>? _loading;
|
||||
Future<void>? _flushing;
|
||||
bool _supported = true;
|
||||
bool _disposed = false;
|
||||
|
||||
/// Everything acknowledged on any device, as far as this device knows.
|
||||
AttentionAcks get acks => _acks;
|
||||
|
||||
/// Acknowledgements made here that the server has not accepted yet.
|
||||
AttentionAcks get pending => _pending;
|
||||
|
||||
/// False after the server answered `attention_acks` with something else
|
||||
/// (an older server); reset on the next [connected].
|
||||
bool get supported => _supported;
|
||||
|
||||
/// Reads the persisted offline queue once.
|
||||
Future<void> load() => _loading ??= _load();
|
||||
|
||||
Future<void> _load() async {
|
||||
String? stored;
|
||||
try {
|
||||
stored = await queue.read();
|
||||
} catch (_) {
|
||||
stored = null;
|
||||
}
|
||||
if (_disposed) return;
|
||||
final queued = AttentionAcks.decode(stored);
|
||||
_pending = queued.merge(_pending);
|
||||
_apply(queued);
|
||||
}
|
||||
|
||||
/// Records an acknowledgement made on this device: it applies here at once
|
||||
/// and is sent to the server (now, or on the next [connected]).
|
||||
Future<void> acknowledge({
|
||||
Iterable<String> dismissed = const [],
|
||||
Map<String, int> chatSeen = const {},
|
||||
}) async {
|
||||
final ack = AttentionAcks(
|
||||
dismissed: {
|
||||
for (final key in dismissed)
|
||||
if (key.trim().isNotEmpty) key,
|
||||
},
|
||||
chatSeen: {
|
||||
for (final entry in chatSeen.entries)
|
||||
if (entry.key.isNotEmpty && entry.value > 0) entry.key: entry.value,
|
||||
},
|
||||
);
|
||||
if (_disposed || ack.isEmpty) return;
|
||||
await load();
|
||||
if (_disposed) return;
|
||||
_pending = _pending.merge(ack);
|
||||
_apply(ack);
|
||||
await _persist();
|
||||
await flush();
|
||||
}
|
||||
|
||||
/// Called on every connected transition of the shared socket: send what was
|
||||
/// queued while disconnected, then read the server's whole set.
|
||||
Future<void> connected() async {
|
||||
if (_disposed) return;
|
||||
_supported = true;
|
||||
// Replies still awaited belong to the replaced socket and never arrive;
|
||||
// fail them now so a stalled flush does not hold up this connection.
|
||||
_failReplies(StateError('Connection replaced'));
|
||||
await load();
|
||||
await flush();
|
||||
if (_disposed || !_supported) return;
|
||||
try {
|
||||
final reply = await _request('attention_acks');
|
||||
_accept(reply);
|
||||
} catch (_) {
|
||||
// Offline or refused: the local state still applies; the next
|
||||
// connection reads again.
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends the queue in bounded batches, one request at a time.
|
||||
Future<void> flush() => _flushing ??= _flush().whenComplete(() {
|
||||
_flushing = null;
|
||||
});
|
||||
|
||||
Future<void> _flush() async {
|
||||
while (!_disposed && _supported && !_pending.isEmpty) {
|
||||
final batch = attentionAckBatch(_pending);
|
||||
try {
|
||||
final reply = await _request('ack_attention', {
|
||||
'attention_acks': batch.toJson(),
|
||||
});
|
||||
if (!_accept(reply)) return;
|
||||
} on ProtocolError {
|
||||
// The server refused this batch; it will never be accepted.
|
||||
} catch (_) {
|
||||
return; // Not connected or timed out: keep it for the next connection.
|
||||
}
|
||||
_pending = _pending.without(batch);
|
||||
await _persist();
|
||||
}
|
||||
}
|
||||
|
||||
/// Folds an `attention_acks` reply; false when the server answered with
|
||||
/// another type, i.e. it does not support shared acknowledgements.
|
||||
bool _accept(JsonMap reply) {
|
||||
if (reply['type'] != 'attention_acks') {
|
||||
_supported = false;
|
||||
return false;
|
||||
}
|
||||
_apply(AttentionAcks.fromJson(reply['attention_acks']));
|
||||
return true;
|
||||
}
|
||||
|
||||
void _onFrame(JsonMap frame) {
|
||||
final id = frame['id'];
|
||||
final reply = id is String ? _replies.remove(id) : null;
|
||||
if (reply != null) {
|
||||
if (frame['type'] == 'error') {
|
||||
final reason = '${frame['error'] ?? ''}'.trim();
|
||||
reply.completeError(
|
||||
ProtocolError(reason.isEmpty ? 'server error' : reason),
|
||||
);
|
||||
} else {
|
||||
reply.complete(frame);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (frame['type'] != 'attention_acks_changed') return;
|
||||
_apply(AttentionAcks.fromJson(frame['attention_acks']));
|
||||
}
|
||||
|
||||
/// One request: through [sendOnly] when available (reply matched by id),
|
||||
/// else the gateway's ordinary request/reply call.
|
||||
Future<JsonMap> _request(String type, [JsonMap fields = const {}]) {
|
||||
final send = sendOnly;
|
||||
if (send == null) return gateway.call(type, fields);
|
||||
final String id;
|
||||
try {
|
||||
id = send(type, fields);
|
||||
} catch (error) {
|
||||
return Future.error(error);
|
||||
}
|
||||
final reply = Completer<JsonMap>();
|
||||
_replies[id] = reply;
|
||||
return reply.future.timeout(
|
||||
replyTimeout,
|
||||
onTimeout: () {
|
||||
_replies.remove(id);
|
||||
throw TimeoutException('$type timed out', replyTimeout);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _apply(AttentionAcks incoming) {
|
||||
if (_disposed) return;
|
||||
final next = _acks.merge(incoming);
|
||||
if (identical(next, _acks)) return;
|
||||
_acks = next;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> _persist() async {
|
||||
try {
|
||||
await queue.write(_pending.encode());
|
||||
} catch (_) {
|
||||
// The queue still lives in memory for this session.
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_disposed = true;
|
||||
unawaited(_frames.cancel());
|
||||
_failReplies(StateError('Attention sync disposed'));
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _failReplies(Object error) {
|
||||
final waiting = _replies.values.toList();
|
||||
_replies.clear();
|
||||
for (final reply in waiting) {
|
||||
reply.completeError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final _syncs = Expando<AttentionAckSync>('attention acknowledgement sync');
|
||||
|
||||
/// Makes [sync] the acknowledgement channel of [gateway], so feature
|
||||
/// controllers created later for the same socket (the chat list) share it.
|
||||
void bindAttentionAckSync(ApiGateway gateway, AttentionAckSync? sync) {
|
||||
_syncs[gateway] = sync;
|
||||
}
|
||||
|
||||
/// The acknowledgement channel bound to [gateway], if the app bound one.
|
||||
AttentionAckSync? attentionAckSyncOf(ApiGateway gateway) => _syncs[gateway];
|
||||
@@ -6,6 +6,7 @@ import '../../../core/api_gateway.dart';
|
||||
import '../../runs/domain/run_events.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import '../domain/attention_transitions.dart';
|
||||
import 'attention_ack_sync.dart';
|
||||
import 'attention_store.dart';
|
||||
|
||||
/// The live `Needs you` state behind the Runs-list bell.
|
||||
@@ -20,11 +21,22 @@ import 'attention_store.dart';
|
||||
/// [AttentionStore] without blocking the caller. A failed read or write leaves
|
||||
/// the in-memory set in force for this session; neither direction can throw into
|
||||
/// the UI.
|
||||
///
|
||||
/// With a [sync], dismissals are shared with every device: Dismiss and Clear
|
||||
/// all are also acknowledged to the server, and identities dismissed elsewhere
|
||||
/// (the server's set and pushed deltas) are folded in and cached locally, so
|
||||
/// the local store doubles as the offline copy.
|
||||
class AttentionController extends ChangeNotifier {
|
||||
AttentionController({required this.store, DateTime Function()? now})
|
||||
: _now = now ?? DateTime.now;
|
||||
AttentionController({
|
||||
required this.store,
|
||||
this.sync,
|
||||
DateTime Function()? now,
|
||||
}) : _now = now ?? DateTime.now {
|
||||
sync?.addListener(_syncChanged);
|
||||
}
|
||||
|
||||
final AttentionStore store;
|
||||
final AttentionAckSync? sync;
|
||||
final DateTime Function() _now;
|
||||
final AttentionTransitionDetector _detector = AttentionTransitionDetector();
|
||||
final List<AttentionTransition> _transitions = [];
|
||||
@@ -75,6 +87,16 @@ class AttentionController extends ChangeNotifier {
|
||||
// older stored value; the in-memory set is the operator's latest intent.
|
||||
if (!_dirty) _dismissed = stored;
|
||||
notifyListeners();
|
||||
_syncChanged();
|
||||
}
|
||||
|
||||
/// Folds identities acknowledged on any device into this set. A change is
|
||||
/// cached in the local store; nothing is sent back to the server.
|
||||
void _syncChanged() {
|
||||
final shared = sync?.acks.dismissed;
|
||||
if (_disposed || !_loaded || shared == null) return;
|
||||
if (_dismissed.containsAll(shared)) return;
|
||||
unawaited(_commit({..._dismissed, ...shared}));
|
||||
}
|
||||
|
||||
/// Replaces the drawn rows with an authoritative read.
|
||||
@@ -149,12 +171,25 @@ class AttentionController extends ChangeNotifier {
|
||||
/// The in-memory set and the bell update before the store is touched, so a
|
||||
/// slow or failed write never blocks the sheet. The returned future reports
|
||||
/// whether the write succeeded; callers that do not need it may ignore it.
|
||||
Future<bool> dismiss(AttentionEntry entry) =>
|
||||
_commit(attentionDismiss(_dismissed, entry.key));
|
||||
Future<bool> dismiss(AttentionEntry entry) {
|
||||
_share([entry.key]);
|
||||
return _commit(attentionDismiss(_dismissed, entry.key));
|
||||
}
|
||||
|
||||
/// Applies only the identities captured when the sheet opened.
|
||||
Future<bool> clearAll(Iterable<AttentionEntry> snapshot) =>
|
||||
_commit(attentionDismissAll(_dismissed, snapshot));
|
||||
Future<bool> clearAll(Iterable<AttentionEntry> snapshot) {
|
||||
final entries = snapshot.toList();
|
||||
_share([for (final entry in entries) entry.key]);
|
||||
return _commit(attentionDismissAll(_dismissed, entries));
|
||||
}
|
||||
|
||||
/// Acknowledges [keys] to every device. The sync queues them while offline,
|
||||
/// and sending never blocks or fails the local dismissal.
|
||||
void _share(List<String> keys) {
|
||||
final shared = sync;
|
||||
if (_disposed || shared == null || keys.isEmpty) return;
|
||||
unawaited(shared.acknowledge(dismissed: keys));
|
||||
}
|
||||
|
||||
Future<bool> _commit(Set<String> next) async {
|
||||
final unchanged =
|
||||
@@ -174,6 +209,7 @@ class AttentionController extends ChangeNotifier {
|
||||
@override
|
||||
void dispose() {
|
||||
_disposed = true;
|
||||
sync?.removeListener(_syncChanged);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import '../domain/attention_models.dart';
|
||||
const attentionSheetTitle = 'Needs you';
|
||||
const attentionEmptyCopy = 'Nothing needs you right now.';
|
||||
const attentionClearAllCopy = 'Clear all';
|
||||
const attentionCloseCopy = 'Close';
|
||||
|
||||
/// One row's dismissal name.
|
||||
///
|
||||
|
||||
@@ -12,6 +12,9 @@ const attentionSheetKey = ValueKey<String>('attention-sheet');
|
||||
/// The honest empty line shown when the open snapshot has no entries.
|
||||
const attentionEmptyKey = ValueKey<String>('attention-empty');
|
||||
|
||||
/// The header's Done action, which closes the sheet on both hosts.
|
||||
const attentionDoneKey = ValueKey<String>('attention-done');
|
||||
|
||||
/// The bulk dismissal action, present only while the snapshot has entries.
|
||||
const attentionClearAllKey = ValueKey<String>('attention-clear-all');
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import 'attention_status_icon.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_copy.dart';
|
||||
@@ -65,25 +66,12 @@ class CupertinoNeedsYouSheet extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(20, 16, 8, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(
|
||||
attentionSheetTitle,
|
||||
style: theme.textTheme.navTitleTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => _close(context),
|
||||
child: const Text(attentionCloseCopy),
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: AppSheetHeader(
|
||||
title: attentionSheetTitle,
|
||||
cupertino: true,
|
||||
doneKey: attentionDoneKey,
|
||||
onDone: () => _close(context),
|
||||
),
|
||||
),
|
||||
if (rows.isEmpty)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import 'attention_status_icon.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_copy.dart';
|
||||
@@ -57,28 +58,18 @@ class MaterialNeedsYouSheet extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 12, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(
|
||||
attentionSheetTitle,
|
||||
style: theme.textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
AppSheetHeader(
|
||||
title: attentionSheetTitle,
|
||||
cupertino: false,
|
||||
doneKey: attentionDoneKey,
|
||||
actions: [
|
||||
if (rows.isNotEmpty)
|
||||
TextButton(
|
||||
key: attentionClearAllKey,
|
||||
onPressed: () => onClearAll(snapshot),
|
||||
child: const Text(attentionClearAllCopy),
|
||||
),
|
||||
if (rows.isNotEmpty)
|
||||
TextButton(
|
||||
key: attentionClearAllKey,
|
||||
onPressed: () => onClearAll(snapshot),
|
||||
child: const Text(attentionClearAllCopy),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (rows.isEmpty)
|
||||
Padding(
|
||||
|
||||
@@ -55,48 +55,68 @@ class NotificationPermissionTile extends StatelessWidget {
|
||||
final action = view.canRequest && onRequest != null
|
||||
? _action(native, view.actionLabel!, onRequest!)
|
||||
: null;
|
||||
final bodyStyle = native
|
||||
final titleStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyLarge;
|
||||
final helperStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
// The Settings section supplies the `Notifications` heading and the page
|
||||
// inset, as for every other section, so the body starts at that edge.
|
||||
return Column(
|
||||
// One compact row: the state, one short helper line and Enable at the
|
||||
// end. The full sentence for the state is what a screen reader hears.
|
||||
// The Settings section supplies the `Notifications` heading.
|
||||
return Row(
|
||||
key: notificationTileKey,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(notificationRationale, style: bodyStyle),
|
||||
const SizedBox(height: 8),
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(view.body, key: notificationStateKey, style: bodyStyle),
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
liveRegion: true,
|
||||
label: view.body,
|
||||
excludeSemantics: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
view.headline,
|
||||
key: notificationStateKey,
|
||||
style: titleStyle,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(view.helper, style: helperStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// The action sits on its own row, as the browser's settings section
|
||||
// does: its label is too long to share a row at large text.
|
||||
if (action != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Align(alignment: AlignmentDirectional.centerStart, child: action),
|
||||
],
|
||||
if (action != null) ...[const SizedBox(width: 12), action],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A short `Enable`, named in full for assistive technology.
|
||||
Widget _action(bool native, String label, VoidCallback onRequest) {
|
||||
if (native) {
|
||||
return CupertinoButton(
|
||||
key: notificationEnableKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRequest,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: Text(label),
|
||||
const text = Text(notificationEnableShortLabel);
|
||||
final Widget button = native
|
||||
? CupertinoButton.tinted(
|
||||
key: notificationEnableKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
excludeSemantics: true,
|
||||
onTap: onRequest,
|
||||
child: button,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,8 @@ String fileChangesSummary(ChangeCapture capture) {
|
||||
var text = capture.status;
|
||||
if (capture.files.isNotEmpty) {
|
||||
if (text.isNotEmpty) text += ' ';
|
||||
text += '(${capture.files.length} files)';
|
||||
final count = capture.files.length;
|
||||
text += '($count ${count == 1 ? 'file' : 'files'})';
|
||||
}
|
||||
if (capture.skipped > 0) {
|
||||
if (text.isNotEmpty) text += ', ';
|
||||
|
||||
@@ -45,7 +45,6 @@ class StageCaptureSection extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(stage.stage, style: Theme.of(context).textTheme.titleMedium),
|
||||
Text(meta, style: Theme.of(context).textTheme.bodySmall),
|
||||
if (capture != null) ...[
|
||||
Text(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../../shell/destination.dart';
|
||||
import '../../shell/detail_page.dart';
|
||||
import '../../shell/empty_detail_pane.dart';
|
||||
import '../../shell/list_detail.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -257,7 +257,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
return ListDetailPanes(
|
||||
list: list,
|
||||
detail: selected == null
|
||||
? const _NoChatSelected()
|
||||
? const EmptyDetailPane(
|
||||
destination: AppDestination.chat,
|
||||
message: 'Select a chat to open it here.',
|
||||
)
|
||||
: DetailPane(
|
||||
key: const ValueKey('chat-detail-pane'),
|
||||
destination: AppDestination.chat,
|
||||
@@ -267,27 +270,3 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The open-chat pane before any chat is chosen.
|
||||
class _NoChatSelected extends StatelessWidget {
|
||||
const _NoChatSelected();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.chat_bubble_2
|
||||
: Icons.chat_bubble_outline,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Text('Select a chat to open it here.'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../core/servers/server_scope.dart';
|
||||
import '../../../../core/transport/connection_state.dart';
|
||||
import '../../../attention/runtime/attention_ack_sync.dart';
|
||||
import '../../data/chat_repository.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_session_local.dart';
|
||||
@@ -16,18 +18,40 @@ import 'session_attention.dart';
|
||||
/// discarded, so a slow reply can never replace fresher state. Accepted
|
||||
/// mutations always re-read the server list; only this device's hidden ids and
|
||||
/// read watermark are local.
|
||||
///
|
||||
/// With an [AttentionAckSync] (bound to the gateway by the app, or passed in),
|
||||
/// reading is shared: opening a chat acknowledges a `chat_seen` watermark to
|
||||
/// every device, and a watermark acknowledged elsewhere that is newer than this
|
||||
/// device's own clears the chat's New badge here. The local store remains the
|
||||
/// offline cache of both.
|
||||
class ChatSessionsController extends ChangeNotifier {
|
||||
ChatSessionsController(this.repository, {ChatSessionLocalStore? localStore})
|
||||
: _localStore =
|
||||
localStore ??
|
||||
SharedPreferencesChatSessionLocalStore(
|
||||
serverId: serverStorageScope(serverIdentity(repository.gateway)),
|
||||
) {
|
||||
ChatSessionsController(
|
||||
this.repository, {
|
||||
ChatSessionLocalStore? localStore,
|
||||
AttentionAckSync? ackSync,
|
||||
int Function()? nowMillis,
|
||||
this.activeAckDelay = const Duration(milliseconds: 1500),
|
||||
}) : _localStore =
|
||||
localStore ??
|
||||
SharedPreferencesChatSessionLocalStore(
|
||||
serverId: serverStorageScope(serverIdentity(repository.gateway)),
|
||||
),
|
||||
_nowMillis = nowMillis ?? _wallClockMillis {
|
||||
_listenFrames();
|
||||
_bindAckSync(ackSync ?? attentionAckSyncOf(repository.gateway));
|
||||
}
|
||||
|
||||
static int _wallClockMillis() => DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
/// How long the open chat stays quiet before its new content is
|
||||
/// acknowledged to the other devices; streaming text arrives in many frames.
|
||||
final Duration activeAckDelay;
|
||||
|
||||
ChatRepository repository;
|
||||
final ChatSessionLocalStore _localStore;
|
||||
final int Function() _nowMillis;
|
||||
AttentionAckSync? _ackSync;
|
||||
Timer? _activeAck;
|
||||
ChatSessionLocal _local = const ChatSessionLocal();
|
||||
final Map<String, String> _actionErrors = {};
|
||||
List<JsonMap> _sessions = const [];
|
||||
@@ -59,6 +83,59 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
if (row['closed_at'] != null || row['closed'] == true) return;
|
||||
if (effect.running != null) _setRunning(id, effect.running!);
|
||||
if (effect.attention && id != activeSessionId) unawaited(_markUnseen(id));
|
||||
if (effect.attention && id == activeSessionId) _scheduleActiveAck(id);
|
||||
}
|
||||
|
||||
void _bindAckSync(AttentionAckSync? sync) {
|
||||
if (identical(sync, _ackSync)) return;
|
||||
_ackSync?.removeListener(_ackChanged);
|
||||
_ackSync = sync;
|
||||
sync?.addListener(_ackChanged);
|
||||
_ackChanged();
|
||||
}
|
||||
|
||||
/// Content arriving in the chat this device has open is read here, so it is
|
||||
/// acknowledged to the other devices once the stream goes quiet.
|
||||
void _scheduleActiveAck(String id) {
|
||||
if (_ackSync == null) return;
|
||||
_activeAck?.cancel();
|
||||
_activeAck = Timer(activeAckDelay, () {
|
||||
if (_disposed || id != activeSessionId) return;
|
||||
unawaited(_acknowledgeSeen(id, 0));
|
||||
});
|
||||
}
|
||||
|
||||
/// Applies watermarks acknowledged on any device: one newer than this
|
||||
/// device's own marks the chat read here (clearing its New badge) and raises
|
||||
/// the local watermark, so a later badge is not cleared by the same ack.
|
||||
void _ackChanged() {
|
||||
final seen = _ackSync?.acks.chatSeen;
|
||||
if (_disposed || !_localLoaded || seen == null) return;
|
||||
var next = _local;
|
||||
seen.forEach((id, at) {
|
||||
if (at > next.watermark(id)) next = next.read(id, at);
|
||||
});
|
||||
if (identical(next, _local)) return;
|
||||
_local = next;
|
||||
_notify();
|
||||
unawaited(_persist());
|
||||
}
|
||||
|
||||
/// Marks [id] read up to now here and acknowledges it to every device. The
|
||||
/// value is at least the row's own recency; the server lifts it further to
|
||||
/// the session's registry recency.
|
||||
Future<void> _acknowledgeSeen(String id, int updatedAt) async {
|
||||
await _ensureLocal();
|
||||
if (_disposed) return;
|
||||
final at = max(updatedAt, _nowMillis());
|
||||
final next = _local.read(id, at);
|
||||
if (!identical(next, _local)) {
|
||||
_local = next;
|
||||
_notify();
|
||||
await _persist();
|
||||
}
|
||||
if (_disposed) return;
|
||||
await _ackSync?.acknowledge(chatSeen: {id: at});
|
||||
}
|
||||
|
||||
void _setRunning(String id, bool running) {
|
||||
@@ -126,6 +203,7 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
repository = next;
|
||||
_runningFrames.clear();
|
||||
_listenFrames();
|
||||
_bindAckSync(attentionAckSyncOf(next.gateway) ?? _ackSync);
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -242,7 +320,9 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
activeSessionId = id;
|
||||
await _ensureLocal();
|
||||
if (_disposed) return;
|
||||
final next = _local.read(id, chatSessionMillis(session['updated_at']));
|
||||
final updatedAt = chatSessionMillis(session['updated_at']);
|
||||
if (_ackSync != null) return _acknowledgeSeen(id, updatedAt);
|
||||
final next = _local.read(id, updatedAt);
|
||||
if (identical(next, _local)) return;
|
||||
_local = next;
|
||||
_notify();
|
||||
@@ -313,6 +393,7 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
}
|
||||
_localLoaded = true;
|
||||
_seedLocal();
|
||||
_ackChanged();
|
||||
_notify();
|
||||
}
|
||||
|
||||
@@ -351,6 +432,8 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
_disposed = true;
|
||||
_generation++;
|
||||
unawaited(_frameSubscription?.cancel());
|
||||
_activeAck?.cancel();
|
||||
_ackSync?.removeListener(_ackChanged);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../ui/text/relative_time.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
|
||||
/// Titles shared by more than one visible session, so row action labels can
|
||||
@@ -20,24 +21,15 @@ String sessionActionsLabel(JsonMap session, Set<String> duplicateTitles) {
|
||||
: 'Chat actions for $title';
|
||||
}
|
||||
|
||||
/// The web row's relative recency: `just now`, `N min ago`, `N hr ago`,
|
||||
/// `N days ago`, then a short date (`22 Oct`). A row without a usable
|
||||
/// `updated_at` reports nothing rather than inventing a time.
|
||||
/// The shared list-row recency, or nothing for an unusable `updated_at`.
|
||||
String relativeChatSessionTime(Object? updatedAt, {DateTime? now}) {
|
||||
final millis = chatSessionMillis(updatedAt);
|
||||
if (millis <= 0) return '';
|
||||
final then = DateTime.fromMillisecondsSinceEpoch(millis);
|
||||
var elapsed = (now ?? DateTime.now()).difference(then);
|
||||
if (elapsed.isNegative) elapsed = Duration.zero;
|
||||
final seconds = elapsed.inSeconds;
|
||||
if (seconds < 45) return 'just now';
|
||||
final minutes = seconds ~/ 60 < 1 ? 1 : seconds ~/ 60;
|
||||
if (minutes < 60) return '$minutes min ago';
|
||||
final hours = minutes ~/ 60;
|
||||
if (hours < 24) return '$hours hr ago';
|
||||
final days = hours ~/ 24;
|
||||
if (days < 7) return days == 1 ? '1 day ago' : '$days days ago';
|
||||
return '${then.day} ${_shortMonths[then.month - 1]}';
|
||||
return formatRelativeTime(
|
||||
DateTime.fromMillisecondsSinceEpoch(millis),
|
||||
now: now,
|
||||
) ??
|
||||
'';
|
||||
}
|
||||
|
||||
/// The row's one muted line: the recorded model and the folder (home as `~`).
|
||||
@@ -60,20 +52,3 @@ String? chatSessionRowStatus(JsonMap session, {required bool unseen}) {
|
||||
}
|
||||
return unseen ? 'New' : null;
|
||||
}
|
||||
|
||||
const _shortMonths = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
// `Intl.DateTimeFormat('en-GB', { month: 'short' })`, which the web row
|
||||
// uses, abbreviates September as `Sept`, not `Sep`.
|
||||
'Sept',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec',
|
||||
];
|
||||
|
||||
@@ -38,12 +38,13 @@ String? formatLocalTimestamp(String? text) {
|
||||
return '${local.day} ${_monthNames[local.month - 1]} $hour:$minute';
|
||||
}
|
||||
|
||||
/// `45s`, `2m 5s`, `1h 2m`. Negative values clamp to `0s`.
|
||||
/// `45s`, `2m 5s`, `1h 2m`, `9d 16h`. Negative values clamp to `0s`.
|
||||
String formatDuration(int totalSeconds) {
|
||||
final seconds = totalSeconds < 0 ? 0 : totalSeconds;
|
||||
if (seconds < 60) return '${seconds}s';
|
||||
if (seconds < 3600) return '${seconds ~/ 60}m ${seconds % 60}s';
|
||||
return '${seconds ~/ 3600}h ${(seconds % 3600) ~/ 60}m';
|
||||
if (seconds < 86400) return '${seconds ~/ 3600}h ${(seconds % 3600) ~/ 60}m';
|
||||
return '${seconds ~/ 86400}d ${(seconds % 86400) ~/ 3600}h';
|
||||
}
|
||||
|
||||
/// Whole non-negative seconds between two timestamps, or null when either is
|
||||
@@ -56,18 +57,6 @@ int? durationSeconds(String? start, String? end) {
|
||||
return seconds >= 0 ? seconds : null;
|
||||
}
|
||||
|
||||
/// `just now`, `Nm ago`, `Nh ago`, `Nd ago`; a future timestamp reads as
|
||||
/// `just now`, never a negative age.
|
||||
String? formatRanAgo(String? createdAt, DateTime now) {
|
||||
final start = parseInstant(createdAt);
|
||||
if (start == null) return null;
|
||||
final seconds = now.difference(start).inSeconds;
|
||||
if (seconds < 60) return 'just now';
|
||||
if (seconds < 3600) return '${seconds ~/ 60}m ago';
|
||||
if (seconds < 86400) return '${seconds ~/ 3600}h ago';
|
||||
return '${seconds ~/ 86400}d ago';
|
||||
}
|
||||
|
||||
/// `1 stage` / `n stages`.
|
||||
String stageCountText(int count) => '$count ${count == 1 ? 'stage' : 'stages'}';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'pipeline_format.dart';
|
||||
import '../../ui/text/relative_time.dart';
|
||||
import 'pipeline_models.dart';
|
||||
|
||||
export 'pipeline_filter.dart';
|
||||
@@ -27,7 +28,7 @@ class RunBadge {
|
||||
final String? ranAgo;
|
||||
final String? duration;
|
||||
|
||||
/// `2h ago · 1m 5s · run 42`; missing fragments are omitted.
|
||||
/// `2h · 1m 5s · run 42`; missing fragments are omitted.
|
||||
String get metaLine => [
|
||||
ranAgo,
|
||||
duration,
|
||||
@@ -42,7 +43,7 @@ RunBadge runBadge(PipelineRun run, DateTime now) {
|
||||
return RunBadge(
|
||||
runId: run.id,
|
||||
state: runStateOf(run.status),
|
||||
ranAgo: formatRanAgo(run.createdAt, now),
|
||||
ranAgo: formatRelativeTimestamp(run.createdAt, now: now),
|
||||
duration: duration,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../shell/destination.dart';
|
||||
import '../../../shell/empty_detail_pane.dart';
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/layout/reading_width.dart';
|
||||
import '../../graph/domain/graph_definition.dart';
|
||||
import '../../graph/widgets/stage_definition_view.dart';
|
||||
import '../pipeline_models.dart';
|
||||
@@ -124,8 +127,8 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
final panel = LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final headerLimit = _headerLimit(constraints);
|
||||
// The tabs float over the tab body: at the bottom on a phone page,
|
||||
// under the pane's top bar beside a list (never on the shell's bar).
|
||||
// The tabs float over the bottom of the tab body, on a phone page
|
||||
// and beside a list alike (the shell's bar stays over the list).
|
||||
final edge = PageTabsEdge.of(context);
|
||||
final tabs = PipelineDetailTabs(
|
||||
selected: _tab,
|
||||
@@ -302,16 +305,26 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _scrolling(Widget child) =>
|
||||
ListView(children: [child, const SizedBox(height: 24)]);
|
||||
/// A scrolling reading body: the whole pane scrolls, the content keeps
|
||||
/// [kReadingMaxWidth] from the leading edge.
|
||||
Widget _scrolling(Widget child) => ListView(
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: kReadingMaxWidth),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _withoutDetail(BuildContext context) {
|
||||
if (!_controller.hasSelection) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Text('Select a pipeline.', style: pipelineMutedStyle(context)),
|
||||
),
|
||||
return const EmptyDetailPane(
|
||||
destination: AppDestination.pipelines,
|
||||
message: 'Select a pipeline to open it here.',
|
||||
);
|
||||
}
|
||||
return ListView(
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/layout/app_list_row.dart';
|
||||
import '../../../ui/layout/facts_grid.dart';
|
||||
import '../../../ui/layout/section_heading.dart';
|
||||
import '../../schedules/ui/pipeline/schedule_pipeline_section.dart';
|
||||
import '../pipeline_format.dart';
|
||||
import '../pipeline_models.dart';
|
||||
@@ -11,9 +13,14 @@ import '../pipelines_controller.dart';
|
||||
import 'pipeline_controls.dart';
|
||||
import 'pipeline_detail_styles.dart';
|
||||
|
||||
/// Summary tab: key/value facts, the pipeline's saved schedules and the version
|
||||
/// history. Version rows are selectable; the latest version's row is marked and
|
||||
/// a historical selection offers an explicit return to latest.
|
||||
/// The Summary's facts grid.
|
||||
const pipelineSummaryFactsKey = Key('pipeline-summary-facts');
|
||||
|
||||
/// Summary tab: the recorded facts as a compact grid, the pipeline's saved
|
||||
/// schedules and the version history, flat on the page on both hosts (the
|
||||
/// same structure as the run Summary). Version rows are the app's shared list
|
||||
/// row; the shown version is the selected row, and a historical selection
|
||||
/// offers an explicit return to latest.
|
||||
class PipelineSummaryView extends StatelessWidget {
|
||||
const PipelineSummaryView({
|
||||
super.key,
|
||||
@@ -67,60 +74,62 @@ class PipelineSummaryView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Only recorded values are facts: a blank one is omitted, not drawn empty.
|
||||
Widget _fields(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final field in pipelineSummaryFields(detail))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(field.key, style: pipelineMutedStyle(context)),
|
||||
SelectableText(
|
||||
field.value,
|
||||
style: pipelineValueStyle(
|
||||
context,
|
||||
monospace: field.monospace,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
final fields = [
|
||||
for (final field in pipelineSummaryFields(detail))
|
||||
if (field.value.trim().isNotEmpty) field,
|
||||
];
|
||||
if (fields.isEmpty) return const SizedBox.shrink();
|
||||
return FactsGrid(
|
||||
key: pipelineSummaryFactsKey,
|
||||
cupertino: useCupertinoControls(context),
|
||||
items: [
|
||||
for (final field in fields)
|
||||
FactsGridItem(
|
||||
key: ValueKey('pipeline-summary-${_slug(field.key)}'),
|
||||
label: field.key,
|
||||
value: field.value,
|
||||
// A hash gets its own line; the host font is kept (the pipeline
|
||||
// detail does not switch identifiers to monospace).
|
||||
wide: field.monospace,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _versions(BuildContext context) {
|
||||
final cupertino = useCupertinoControls(context);
|
||||
final effective = detail.resolvedVersion;
|
||||
final showingLatest = effective == detail.latestVersion;
|
||||
final versions = detail.versions;
|
||||
final rows = <Widget>[
|
||||
if (!showingLatest)
|
||||
_versionTile(
|
||||
context,
|
||||
AppListRow(
|
||||
key: const Key('pipeline-latest-version'),
|
||||
subtitle: 'Return to the latest version',
|
||||
selected: false,
|
||||
label: 'View latest v${detail.latestVersion}',
|
||||
cupertino: cupertino,
|
||||
title: Text('View latest v${detail.latestVersion}'),
|
||||
subtitle: const Text('Return to the latest version'),
|
||||
divider: versions.isNotEmpty,
|
||||
onTap: () => controller.selectVersion(0),
|
||||
),
|
||||
for (final version in detail.versions)
|
||||
_versionTile(
|
||||
context,
|
||||
key: Key('pipeline-version-${version.version}'),
|
||||
subtitle: [
|
||||
stageCountText(version.stages),
|
||||
?formatLocalTimestamp(version.createdAt),
|
||||
].join(' · '),
|
||||
selected: version.version == effective,
|
||||
label: 'v${version.version}',
|
||||
onTap: () => controller.selectVersion(version.version),
|
||||
for (var index = 0; index < versions.length; index += 1)
|
||||
AppListRow(
|
||||
key: Key('pipeline-version-${versions[index].version}'),
|
||||
cupertino: cupertino,
|
||||
selected: versions[index].version == effective,
|
||||
title: Text('v${versions[index].version}'),
|
||||
time: formatLocalTimestamp(versions[index].createdAt),
|
||||
subtitle: Text(
|
||||
[
|
||||
stageCountText(versions[index].stages),
|
||||
if (versions[index].version == detail.latestVersion) 'latest',
|
||||
].join(' · '),
|
||||
),
|
||||
divider: index < versions.length - 1,
|
||||
onTap: () => controller.selectVersion(versions[index].version),
|
||||
),
|
||||
if (detail.versions.isEmpty)
|
||||
if (versions.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Text(
|
||||
@@ -129,49 +138,18 @@ class PipelineSummaryView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
];
|
||||
if (useCupertinoControls(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: const Text('VERSIONS'),
|
||||
children: rows,
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||
child: Text('Versions', style: pipelineSectionStyle(context)),
|
||||
const SectionHeading(
|
||||
title: 'Versions',
|
||||
header: true,
|
||||
padding: EdgeInsetsDirectional.only(start: 16, end: 8),
|
||||
),
|
||||
...rows,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _versionTile(
|
||||
BuildContext context, {
|
||||
required Key key,
|
||||
required String subtitle,
|
||||
required bool selected,
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
if (useCupertinoControls(context)) {
|
||||
return CupertinoListTile(
|
||||
key: key,
|
||||
title: Text(label),
|
||||
subtitle: Text(subtitle),
|
||||
trailing: selected ? const Icon(CupertinoIcons.check_mark) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
return ListTile(
|
||||
key: key,
|
||||
selected: selected,
|
||||
title: Text(label),
|
||||
subtitle: Text(subtitle),
|
||||
trailing: selected ? const Icon(Icons.check) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _slug(String label) => label.toLowerCase().replaceAll(' ', '-');
|
||||
|
||||
@@ -7,8 +7,9 @@ import 'pipeline_detail_tab.dart';
|
||||
|
||||
export 'pipeline_detail_tab.dart';
|
||||
|
||||
/// The pipeline detail's tabs: the app's floating glass tab bar, full width on
|
||||
/// a phone page; beside a list, sized to its tabs under the pane's top bar.
|
||||
/// The pipeline detail's tabs: the app's floating glass tab bar at the bottom,
|
||||
/// full width on a phone page; beside a list, sized to its tabs at the bottom
|
||||
/// of the detail pane (the shell's tab bar stays over the list pane).
|
||||
///
|
||||
/// Float it over the tab body with `FloatingBarOverlay`. The whole bar is
|
||||
/// keyed `pipeline-detail-tabs`, each tab `pipeline-detail-tab-<name>`.
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import '../domain/run_decisions.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import 'action_refusal.dart';
|
||||
import 'decision_option_row.dart';
|
||||
import 'decision_wording.dart';
|
||||
|
||||
/// Sends the draft to the server. Returns null on success, or an
|
||||
@@ -172,39 +173,20 @@ class _DecisionPromptState extends State<_DecisionPrompt> {
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
options: RadioGroup<String>(
|
||||
groupValue: _draft.selected,
|
||||
onChanged: (value) {
|
||||
if (value != null) _select(value);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final option in widget.decision.options)
|
||||
CupertinoButton(
|
||||
onPressed: _sending ? null : () => _select(option.key),
|
||||
child: Row(
|
||||
children: [
|
||||
CupertinoRadio<String>(
|
||||
value: option.key,
|
||||
useCheckmarkStyle: true,
|
||||
enabled: !_sending,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(option.key),
|
||||
if (_targetText(option) case final target?)
|
||||
Text(target),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
options: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final (index, option) in widget.decision.options.indexed)
|
||||
DecisionOptionRow(
|
||||
key: decisionOptionKey(option.key),
|
||||
label: option.key,
|
||||
target: _targetText(option),
|
||||
selected: _draft.selected == option.key,
|
||||
divider: index > 0,
|
||||
onTap: _sending ? null : () => _select(option.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
feedback: CupertinoTextField(
|
||||
key: decisionFeedbackKey,
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
/// One option row in the Cupertino decision prompt, keyed by the option.
|
||||
ValueKey<String> decisionOptionKey(String option) =>
|
||||
ValueKey<String>('human-decision-option-$option');
|
||||
|
||||
/// One choice of the Cupertino decision prompt: a check-list row.
|
||||
///
|
||||
/// The option reads as text in the label colour, not as a blue link, with its
|
||||
/// target underneath in the secondary colour. An empty circle marks an
|
||||
/// unpicked row and a filled check circle the picked one, so the choice is
|
||||
/// visible before Confirm. The whole row is the tap target; semantics report
|
||||
/// it as a selectable member of one exclusive group. A null [onTap] (while
|
||||
/// sending) dims the row.
|
||||
class DecisionOptionRow extends StatelessWidget {
|
||||
const DecisionOptionRow({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.selected,
|
||||
required this.onTap,
|
||||
this.target,
|
||||
this.divider = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String? target;
|
||||
final bool selected;
|
||||
final bool divider;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final enabled = onTap != null;
|
||||
final labelColor = enabled
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context);
|
||||
final mark = selected
|
||||
? Icon(
|
||||
CupertinoIcons.checkmark_circle_fill,
|
||||
color: enabled
|
||||
? theme.primaryColor
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Icon(
|
||||
CupertinoIcons.circle,
|
||||
color: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
);
|
||||
final row = Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
mark,
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
color: labelColor,
|
||||
fontWeight: selected ? FontWeight.w600 : null,
|
||||
),
|
||||
),
|
||||
if (target case final target?)
|
||||
Text(
|
||||
target,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return Semantics(
|
||||
inMutuallyExclusiveGroup: true,
|
||||
selected: selected,
|
||||
checked: selected,
|
||||
button: true,
|
||||
enabled: enabled,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: divider
|
||||
? Border(
|
||||
top: BorderSide(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
width: 0,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: row,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart';
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../shell/destination.dart';
|
||||
import '../../shell/detail_page.dart';
|
||||
import '../../shell/empty_detail_pane.dart';
|
||||
import '../../shell/list_detail.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import '../attention/notify/notification_controller.dart';
|
||||
@@ -262,15 +263,15 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
animation: controller,
|
||||
builder: (context, _) => ContentWidth(
|
||||
child: RunsList(
|
||||
active: narrow ? !selected : true,
|
||||
controller: controller,
|
||||
onSelected: _select,
|
||||
syncToken: widget.syncToken,
|
||||
attentionStore: widget.attentionStore,
|
||||
attentionNow: widget.attentionNow,
|
||||
notifications: widget.notifications,
|
||||
attention: widget.attention,
|
||||
),
|
||||
active: narrow ? !selected : true,
|
||||
controller: controller,
|
||||
onSelected: _select,
|
||||
syncToken: widget.syncToken,
|
||||
attentionStore: widget.attentionStore,
|
||||
attentionNow: widget.attentionNow,
|
||||
notifications: widget.notifications,
|
||||
attention: widget.attention,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (narrow) return list;
|
||||
@@ -283,7 +284,10 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
implyBack: false,
|
||||
builder: (_) => _detail(_back),
|
||||
)
|
||||
: const Center(child: Text('Select a run to open it here.')),
|
||||
: const EmptyDetailPane(
|
||||
destination: AppDestination.runs,
|
||||
message: 'Select a run to open it here.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ class RunDecisionNotice extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final pending = pendingDecision(run);
|
||||
if (pending == null) return const SizedBox.shrink();
|
||||
// As the web's `.decision-card`: one full-width banner in the waiting
|
||||
// colour, with the glyph, the title over its meta line, and the action on
|
||||
// the trailing edge. The same banner on both hosts.
|
||||
// One full-width line of the header strip: the glyph in the waiting
|
||||
// colour, the title over its meta line, and the action on the trailing
|
||||
// edge. The strip is already the frame, so the banner draws no card,
|
||||
// border or tint of its own. The same banner on both hosts.
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final color = CupertinoColors.systemTeal.resolveFrom(context);
|
||||
final metaStyle = cupertino
|
||||
@@ -36,13 +37,7 @@ class RunDecisionNotice extends StatelessWidget {
|
||||
return Container(
|
||||
key: const Key('run-decision-banner'),
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.12),
|
||||
border: Border.all(color: color),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
|
||||
@@ -16,6 +16,7 @@ typedef DetailMetric = ({String label, String value});
|
||||
typedef DetailVisit = ({
|
||||
String stage,
|
||||
int? sequence,
|
||||
int visit,
|
||||
String title,
|
||||
String subtitle,
|
||||
String status,
|
||||
@@ -114,22 +115,42 @@ List<DetailMetric> detailUsageMetrics(dynamic raw) {
|
||||
/// Every recorded visit with its server sequence, in recorded order.
|
||||
List<DetailVisit> detailTimeline(dynamic steps) {
|
||||
if (steps is! List) return const [];
|
||||
final records = steps.whereType<Map>().toList(growable: false);
|
||||
final ordered = List<int>.generate(records.length, (index) => index)
|
||||
..sort((a, b) {
|
||||
final bySequence = (_int(records[a]['sequence']) ?? 0).compareTo(
|
||||
_int(records[b]['sequence']) ?? 0,
|
||||
);
|
||||
return bySequence != 0 ? bySequence : a.compareTo(b);
|
||||
});
|
||||
final positions = <String, int>{};
|
||||
final visits = <int, int>{};
|
||||
for (final index in ordered) {
|
||||
final stage = '${records[index]['stage'] ?? ''}'.trim();
|
||||
final position = (positions[stage] ?? 0) + 1;
|
||||
positions[stage] = position;
|
||||
visits[index] = _displayVisit(records[index], position);
|
||||
}
|
||||
return [
|
||||
for (final step in steps.whereType<Map>())
|
||||
(
|
||||
stage: '${step['stage'] ?? ''}'.trim(),
|
||||
sequence: step['sequence'] is num
|
||||
? (step['sequence'] as num).toInt()
|
||||
: null,
|
||||
title:
|
||||
'${_text(step['stage'], 'Stage unavailable')} · visit '
|
||||
'${step['sequence'] is num ? (step['sequence'] as num).toInt() : 'unavailable'}',
|
||||
subtitle: _visitSubtitle(step),
|
||||
status: '${step['status'] ?? ''}'.trim(),
|
||||
outcome: '${step['outcome'] ?? ''}'.trim(),
|
||||
target: '${step['target'] ?? ''}'.trim(),
|
||||
duration: _visitDuration(step),
|
||||
),
|
||||
for (var index = 0; index < records.length; index += 1)
|
||||
() {
|
||||
final step = records[index];
|
||||
final stage = '${step['stage'] ?? ''}'.trim();
|
||||
final visit = visits[index]!;
|
||||
return (
|
||||
stage: stage,
|
||||
sequence: step['sequence'] is num
|
||||
? (step['sequence'] as num).toInt()
|
||||
: null,
|
||||
visit: visit,
|
||||
title: '${_text(step['stage'], 'Stage unavailable')} · Visit $visit',
|
||||
subtitle: _visitSubtitle(step),
|
||||
status: '${step['status'] ?? ''}'.trim(),
|
||||
outcome: '${step['outcome'] ?? ''}'.trim(),
|
||||
target: '${step['target'] ?? ''}'.trim(),
|
||||
duration: _visitDuration(step),
|
||||
);
|
||||
}(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -166,6 +187,15 @@ String _visitSubtitle(Map step) {
|
||||
].join(' · ');
|
||||
}
|
||||
|
||||
/// The stage's own recorded visit number, falling back to its position among
|
||||
/// visits to that stage rather than the run-wide step sequence.
|
||||
int _displayVisit(Map step, int position) {
|
||||
final control = step['control'];
|
||||
final recorded = control is Map ? control['visit'] : null;
|
||||
if (recorded is num && recorded > 0) return recorded.toInt();
|
||||
return position;
|
||||
}
|
||||
|
||||
/// The web's `stepDuration`: finished minus started, when both are recorded.
|
||||
String? _visitDuration(Map step) {
|
||||
final started = DateTime.tryParse('${step['started_at'] ?? ''}');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -8,11 +7,12 @@ import 'run_detail_summary_fields.dart';
|
||||
import 'run_detail_visit_facts.dart';
|
||||
import 'run_field_body.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/layout/facts_grid.dart';
|
||||
import '../../../ui/layout/sticky_section.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
|
||||
/// The Summary tab: the run's identity, the recorded facts as key/value rows,
|
||||
/// The Summary tab: the run's identity, the recorded facts as one grid,
|
||||
/// the stored original prompt with its copy control and the collapsible Input
|
||||
/// and Output sections.
|
||||
///
|
||||
@@ -34,9 +34,12 @@ Widget runDetailSummaryTab({
|
||||
final rows = detailSummaryRows(run);
|
||||
final identity = detailSummaryIdentity(run);
|
||||
// No separate "Original prompt": the run's Input carries it, as data.
|
||||
// The top bar's subtitle already names the run's pipeline (and its title
|
||||
// opens it), so a Pipeline fact would only repeat it.
|
||||
final pipelineInBar = '${run['name'] ?? ''}'.trim().isNotEmpty;
|
||||
final facts = [
|
||||
for (final row in rows)
|
||||
if (!row.block) row,
|
||||
if (!row.block && !(pipelineInBar && row.label == 'Pipeline')) row,
|
||||
];
|
||||
return CustomScrollView(
|
||||
key: const Key('run-detail-tab-body-summary'),
|
||||
@@ -58,14 +61,22 @@ Widget runDetailSummaryTab({
|
||||
),
|
||||
),
|
||||
),
|
||||
// The facts sit on the page as one grid, the same on both hosts: no
|
||||
// grouped card, so a single fact starts at the leading edge.
|
||||
if (facts.isNotEmpty)
|
||||
SliverToBoxAdapter(
|
||||
child: cupertino
|
||||
? CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [_summaryFacts(context, facts, cupertino: true)],
|
||||
)
|
||||
: _summaryFacts(context, facts, cupertino: false),
|
||||
child: FactsGrid(
|
||||
key: const Key('run-detail-summary-facts'),
|
||||
items: [
|
||||
for (final row in facts)
|
||||
FactsGridItem(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
label: row.label,
|
||||
value: row.value,
|
||||
monospace: row.monospace,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Long blocks (the Diagnostic), Input and Output are sticky
|
||||
// collapsibles: each title stays pinned while its content scrolls.
|
||||
@@ -200,18 +211,7 @@ Widget runDetailFieldTab({
|
||||
cupertino: cupertino,
|
||||
textBuilder: cupertino ? _CupertinoSelectableText.new : null,
|
||||
);
|
||||
if (cupertino) {
|
||||
return ListView(
|
||||
key: Key('run-detail-tab-body-$tabKey'),
|
||||
// Clear of a floating tab bar (the list pads its media insets itself).
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [Padding(padding: const EdgeInsets.all(16), child: body)],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
// Flat on the page on both hosts, like the Summary.
|
||||
return Builder(
|
||||
builder: (context) => ListView(
|
||||
key: Key('run-detail-tab-body-$tabKey'),
|
||||
@@ -223,76 +223,6 @@ Widget runDetailFieldTab({
|
||||
|
||||
// --- Material --------------------------------------------------------------
|
||||
|
||||
/// The recorded facts as a compact grid: two short facts per line on a phone,
|
||||
/// three when wider; a long or monospace value (a path, a hash) takes a whole
|
||||
/// line so it is never squeezed.
|
||||
Widget _summaryFacts(
|
||||
BuildContext context,
|
||||
List<DetailSummaryRow> rows, {
|
||||
required bool cupertino,
|
||||
}) {
|
||||
final labelStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
final TextStyle valueStyle =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium) ??
|
||||
const TextStyle();
|
||||
return Padding(
|
||||
key: const Key('run-detail-summary-facts'),
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const gap = 16.0;
|
||||
final columns = constraints.maxWidth >= 600 ? 3 : 2;
|
||||
final cell = (constraints.maxWidth - gap * (columns - 1)) / columns;
|
||||
return Wrap(
|
||||
spacing: gap,
|
||||
runSpacing: 12,
|
||||
children: [
|
||||
for (final row in rows)
|
||||
SizedBox(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
width: row.monospace || row.value.length > 28
|
||||
? constraints.maxWidth
|
||||
: cell,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(row.label, style: labelStyle),
|
||||
const SizedBox(height: 2),
|
||||
cupertino
|
||||
? Text(
|
||||
row.value,
|
||||
style: row.monospace
|
||||
? valueStyle.copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
)
|
||||
: valueStyle,
|
||||
)
|
||||
: SelectableText(
|
||||
row.value,
|
||||
style: row.monospace
|
||||
? valueStyle.copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
)
|
||||
: valueStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// A long recorded block (the Diagnostic) starts collapsed under its label.
|
||||
Widget _materialBlock(BuildContext context, DetailSummaryRow row) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
@@ -18,8 +18,8 @@ const List<RunDetailTab> renderedRunDetailTabs = [
|
||||
];
|
||||
|
||||
/// The run detail's tabs: the app's floating glass tab bar, full width at the
|
||||
/// bottom of a phone page; beside a list, under the pane's top bar (sized to
|
||||
/// its tabs) so it never stacks on the shell's own tab bar.
|
||||
/// 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).
|
||||
///
|
||||
/// 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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/adaptive/top_glass_strip.dart';
|
||||
import '../../../ui/layout/reading_width.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -19,6 +20,7 @@ import 'run_detail_tab_bodies.dart';
|
||||
import 'run_detail_tab_strip.dart';
|
||||
import 'run_detail_timeline.dart';
|
||||
import 'run_detail_visit.dart';
|
||||
import 'run_detail_wide_chrome.dart';
|
||||
import 'run_detail_visit_facts.dart';
|
||||
import 'run_search_selection.dart';
|
||||
|
||||
@@ -360,10 +362,50 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final headerLimit = _headerLimit(constraints);
|
||||
final header = ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: headerLimit),
|
||||
child: SingleChildScrollView(
|
||||
key: ValueKey('run-detail-header-${widget.run['id']}'),
|
||||
child: widget.header,
|
||||
),
|
||||
);
|
||||
final tabStrip = RunDetailTabStrip(
|
||||
tabs: tabs,
|
||||
edge: edge,
|
||||
selected: shown,
|
||||
onSelected: (tab) => setState(() => _tab = tab),
|
||||
);
|
||||
final body = KeyedSubtree(
|
||||
key: ValueKey('run-detail-body-${widget.run['id']}'),
|
||||
// Reading tabs keep a readable width on a wide window; canvases,
|
||||
// viewers and the gallery keep the whole pane.
|
||||
child: switch (shown) {
|
||||
RunDetailTab.summary ||
|
||||
RunDetailTab.input ||
|
||||
RunDetailTab.output ||
|
||||
RunDetailTab.timeline => ReadingWidth(child: _body(shown)),
|
||||
_ => _body(shown),
|
||||
},
|
||||
);
|
||||
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.
|
||||
return FloatingBarOverlay(
|
||||
edge: FloatingBarEdge.top,
|
||||
bar: RunDetailWideChrome(
|
||||
cupertino: widget.cupertino,
|
||||
tabs: tabStrip,
|
||||
header: header,
|
||||
),
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
// 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
|
||||
// the tab, at its bottom on a page or at its top beside a list, and
|
||||
// the bottom of the tab (on a page and beside a list alike), and
|
||||
// the tab learns their height as its padding on that edge too. Every
|
||||
// tab gets the whole height: the scrolling tabs own their content and
|
||||
// the Graph tab fills the slot, so its canvas is never asked for an
|
||||
@@ -374,27 +416,9 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
key: const Key('run-detail-header'),
|
||||
cupertino: widget.cupertino,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: headerLimit),
|
||||
child: SingleChildScrollView(
|
||||
key: ValueKey('run-detail-header-${widget.run['id']}'),
|
||||
child: widget.header,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: KeyedSubtree(
|
||||
key: ValueKey('run-detail-body-${widget.run['id']}'),
|
||||
child: FloatingBarOverlay(
|
||||
edge: edge,
|
||||
bar: RunDetailTabStrip(
|
||||
tabs: tabs,
|
||||
edge: edge,
|
||||
selected: shown,
|
||||
onSelected: (tab) => setState(() => _tab = tab),
|
||||
),
|
||||
child: _body(shown),
|
||||
),
|
||||
child: header,
|
||||
),
|
||||
child: FloatingBarOverlay(edge: edge, bar: tabStrip, child: body),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/layout/app_list_avatar.dart';
|
||||
import '../../../ui/layout/app_list_row.dart';
|
||||
import '../../../ui/status/outcome_palette.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
|
||||
/// The Timeline tab's recorded visits, one native row per visit.
|
||||
/// The Timeline tab's recorded visits, one shared list row per visit.
|
||||
///
|
||||
/// The list is flat on the page on both hosts, like the runs list and the
|
||||
/// Summary, with inset dividers between rows (no grouped card).
|
||||
///
|
||||
/// [onSelected] receives the row's index in [visits], so the caller opens
|
||||
/// exactly the recorded step it was built from. [selectedSequence] highlights a
|
||||
@@ -38,37 +42,29 @@ class RunTimelineList extends StatelessWidget {
|
||||
children: const [Text('No visits recorded.')],
|
||||
);
|
||||
}
|
||||
final rows = [
|
||||
for (var index = 0; index < visits.length; index += 1)
|
||||
RunTimelineRow(
|
||||
key: ValueKey(
|
||||
'run-timeline-visit-${visits[index].sequence ?? index}',
|
||||
),
|
||||
visit: visits[index],
|
||||
selected: visits[index].sequence == selectedSequence,
|
||||
cupertino: cupertino,
|
||||
onTap: onSelected == null ? null : () => onSelected!(index),
|
||||
),
|
||||
];
|
||||
if (cupertino) {
|
||||
return ListView(
|
||||
key: const Key('run-detail-tab-body-timeline'),
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: const Text('Timeline'),
|
||||
children: rows,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
// One colour per distinct outcome name across the whole run, so the same
|
||||
// outcome reads the same on every row and different ones never match.
|
||||
final palette = OutcomePalette(visits.map((visit) => visit.outcome));
|
||||
return ListView(
|
||||
key: const Key('run-detail-tab-body-timeline'),
|
||||
padding: withBarClearance(
|
||||
context,
|
||||
const EdgeInsets.symmetric(vertical: 8),
|
||||
),
|
||||
children: rows,
|
||||
children: [
|
||||
for (var index = 0; index < visits.length; index += 1)
|
||||
RunTimelineRow(
|
||||
key: ValueKey(
|
||||
'run-timeline-visit-${visits[index].sequence ?? index}',
|
||||
),
|
||||
visit: visits[index],
|
||||
selected: visits[index].sequence == selectedSequence,
|
||||
cupertino: cupertino,
|
||||
divider: index < visits.length - 1,
|
||||
palette: palette,
|
||||
onTap: onSelected == null ? null : () => onSelected!(index),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -82,14 +78,21 @@ class RunTimelineRow extends StatelessWidget {
|
||||
required this.visit,
|
||||
required this.selected,
|
||||
required this.cupertino,
|
||||
this.divider = false,
|
||||
this.onTap,
|
||||
this.palette,
|
||||
});
|
||||
|
||||
final DetailVisit visit;
|
||||
final bool selected;
|
||||
final bool cupertino;
|
||||
final bool divider;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
/// The run's outcome colours; without one the row colours its own outcome
|
||||
/// as the first (and only) name.
|
||||
final OutcomePalette? palette;
|
||||
|
||||
/// The visit's state for its glyph: the outcome when it has one (a completed
|
||||
/// step can still have failed), else the step status.
|
||||
String get _state {
|
||||
@@ -100,17 +103,18 @@ class RunTimelineRow extends StatelessWidget {
|
||||
return runStateOf(visit.status);
|
||||
}
|
||||
|
||||
/// One line under the title: where the visit went and how long it took.
|
||||
String get _detail => [
|
||||
if (visit.target.isNotEmpty) '→ ${visit.target}',
|
||||
?visit.duration,
|
||||
].join(' · ');
|
||||
|
||||
Widget _outcome(BuildContext context) {
|
||||
final label = visit.outcome.isNotEmpty
|
||||
? visit.outcome
|
||||
: (visit.status.isEmpty ? 'unknown' : visit.status);
|
||||
final color = runStatusColor(_state).resolveFrom(context);
|
||||
// An outcome is coloured by its name (no word is wired to a colour); a
|
||||
// visit with no outcome yet keeps its status colour.
|
||||
final color = visit.outcome.isNotEmpty
|
||||
? (palette ?? OutcomePalette([visit.outcome])).colorFor(
|
||||
context,
|
||||
visit.outcome,
|
||||
)
|
||||
: runStatusColor(_state).resolveFrom(context);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
@@ -130,48 +134,25 @@ class RunTimelineRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final leading = RunStatusIcon(
|
||||
state: _state,
|
||||
label: visit.status.isEmpty ? 'Status unavailable' : visit.status,
|
||||
size: 22,
|
||||
);
|
||||
final title = Text(
|
||||
visit.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
final detail = _detail;
|
||||
// The outcome chip leads the second line, so the title keeps the width.
|
||||
final subtitle = Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [_outcome(context), if (detail.isNotEmpty) Text(detail)],
|
||||
);
|
||||
if (cupertino) {
|
||||
return Semantics(
|
||||
selected: selected,
|
||||
child: CupertinoListTile(
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
backgroundColor: selected
|
||||
? CupertinoDynamicColor.resolve(
|
||||
CupertinoColors.secondarySystemFill,
|
||||
context,
|
||||
)
|
||||
: null,
|
||||
onTap: onTap,
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListTile(
|
||||
final state = _state;
|
||||
// The outcome chip leads the second line, then where the visit went; the
|
||||
// duration is the row's time.
|
||||
return AppListRow(
|
||||
cupertino: cupertino,
|
||||
selected: selected,
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
divider: divider,
|
||||
onTap: onTap,
|
||||
leading: AppListAvatar(
|
||||
foreground: runStatusColor(state).resolveFrom(context),
|
||||
child: RunStatusIcon(
|
||||
state: state,
|
||||
label: visit.status.isEmpty ? 'Status unavailable' : visit.status,
|
||||
),
|
||||
),
|
||||
title: Text(visit.title),
|
||||
time: visit.duration,
|
||||
subtitleLeading: _outcome(context),
|
||||
subtitle: visit.target.isEmpty ? null : Text('→ ${visit.target}'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/layout/reading_width.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_visit_facts_view.dart';
|
||||
import 'run_detail_visit_sections.dart';
|
||||
@@ -72,31 +73,40 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
||||
selected: _section,
|
||||
onSelected: (section) => setState(() => _section = section),
|
||||
),
|
||||
child: runVisitSectionBody(
|
||||
section: _section,
|
||||
run: widget.run,
|
||||
step: widget.step,
|
||||
visitIndex: widget.visitIndex,
|
||||
stageKey: widget.visit.stage,
|
||||
runSteps: widget.runSteps,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.onRunChanged,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
cupertino: widget.cupertino,
|
||||
facts: RunVisitFactsView(step: widget.step),
|
||||
// Reading sections keep a readable width on a wide window; the
|
||||
// gallery and the changes viewer keep the whole page.
|
||||
child: _capped(
|
||||
runVisitSectionBody(
|
||||
section: _section,
|
||||
run: widget.run,
|
||||
step: widget.step,
|
||||
visitIndex: widget.visitIndex,
|
||||
stageKey: widget.visit.stage,
|
||||
runSteps: widget.runSteps,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.onRunChanged,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
cupertino: widget.cupertino,
|
||||
facts: RunVisitFactsView(step: widget.step),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _capped(Widget body) => switch (_section) {
|
||||
RunVisitSection.artifacts || RunVisitSection.changes => body,
|
||||
_ => ReadingWidth(child: body),
|
||||
};
|
||||
}
|
||||
|
||||
/// The page bar's subtitle for a recorded visit: its sequence, then the run
|
||||
/// The page bar's subtitle for a recorded visit: its per-stage visit, then the run
|
||||
/// it belongs to (`Visit 2 · Run 7 · Nightly report`).
|
||||
String runVisitSubtitle(JsonMap run, DetailVisit visit) {
|
||||
final runId = '${run['id'] ?? ''}'.trim();
|
||||
final title = detailTitle(run);
|
||||
return [
|
||||
if (visit.sequence != null) 'Visit ${visit.sequence}',
|
||||
'Visit ${visit.visit}',
|
||||
if (runId.isNotEmpty) 'Run $runId',
|
||||
if (title.isNotEmpty && title != 'Run $runId') title,
|
||||
].join(' · ');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -113,25 +112,8 @@ class _RunVisitSessionState extends State<RunVisitSession> {
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
),
|
||||
];
|
||||
if (usesCupertinoHost(context)) {
|
||||
return ListView(
|
||||
key: const Key('run-visit-body-session'),
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _spaced(children),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
// Flat on the page on both hosts; the turn documents below are a flat
|
||||
// titled list too, so nothing is a group nested in a group.
|
||||
return ListView(
|
||||
key: const Key('run-visit-body-session'),
|
||||
padding: withBarClearance(context, const EdgeInsets.all(16)),
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
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.
|
||||
const double kRunDetailWideChromeMinWidth = kFloatingBarWideWidth;
|
||||
|
||||
/// The most of the row the tabs take, leaving the rest to the header.
|
||||
const double kRunDetailWideTabsShare = 0.6;
|
||||
|
||||
/// 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.
|
||||
///
|
||||
/// 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`.
|
||||
class RunDetailWideChrome extends StatelessWidget {
|
||||
const RunDetailWideChrome({
|
||||
super.key,
|
||||
required this.cupertino,
|
||||
required this.tabs,
|
||||
required this.header,
|
||||
});
|
||||
|
||||
final bool cupertino;
|
||||
|
||||
/// The tab strip at [FloatingBarEdge.top]; it brings its own 12px margins.
|
||||
final Widget tabs;
|
||||
|
||||
/// The header's content, already bounded in height.
|
||||
final Widget header;
|
||||
|
||||
@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'),
|
||||
cupertino: cupertino,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(kTopGlassStripRadius),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: header,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,14 @@ import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../graph/domain/graph_definition.dart';
|
||||
import '../../graph/widgets/run_graph_view.dart';
|
||||
|
||||
const runGraphPreviewKey = ValueKey<String>('run-graph-preview');
|
||||
|
||||
/// The muted line shown in place of the preview when the run has no graph.
|
||||
const runGraphPreviewMissingKey = ValueKey<String>('run-graph-preview-missing');
|
||||
|
||||
/// The run graph as a still picture on top of Summary. Tapping it opens the
|
||||
/// interactive graph full screen; picking a stage there closes it and hands
|
||||
/// the stage to [onStageSelected].
|
||||
@@ -31,6 +35,23 @@ class RunGraphPreview extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// No graph to draw: one muted line, with no frame and nothing to open.
|
||||
if (graphNodes(graph).isEmpty) {
|
||||
return Padding(
|
||||
key: runGraphPreviewMissingKey,
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Text(
|
||||
runGraphMissing,
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final border = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../actions/retry_eligibility.dart';
|
||||
import '../actions/retry_wording.dart';
|
||||
import '../actions/title_action.dart';
|
||||
import '../actions/title_wording.dart';
|
||||
import '../domain/run_models.dart' show runIdentity;
|
||||
|
||||
const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
||||
|
||||
@@ -16,6 +17,13 @@ const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
||||
bool showRunMoreMenu(JsonMap run) =>
|
||||
runTitleId(run) != null || canScheduleRun(run) || _canRetry(run);
|
||||
|
||||
/// The run's own name for its action sheet: its title or pipeline, else
|
||||
/// `Run <id>`, as its list row shows it.
|
||||
String runMoreMenuTitle(JsonMap run) {
|
||||
final label = runIdentity(run['title'], run['name']).label;
|
||||
return label.isEmpty ? 'Run ${run['id']}' : label;
|
||||
}
|
||||
|
||||
bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run);
|
||||
|
||||
enum _RunMoreItem { retry, rename, schedule }
|
||||
@@ -97,6 +105,8 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
|
||||
return AppOverflowMenu<_RunMoreItem>(
|
||||
key: widget.menuKey,
|
||||
cupertino: widget.cupertino,
|
||||
// The Cupertino action sheet names the run it acts on.
|
||||
sheetTitle: runMoreMenuTitle(run),
|
||||
actions: [
|
||||
for (final (item, label) in _items)
|
||||
AppMenuAction(key: _keyOf(item), value: item, label: label),
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'runs_controller.dart';
|
||||
|
||||
/// The Runs toolbar's choices and their labels, shared by the applied-filter
|
||||
/// chips, the filter sheet and the sort sheet. No widgets here.
|
||||
|
||||
const runSorts = [
|
||||
('newest_first', 'Newest first'),
|
||||
('oldest_first', 'Oldest first'),
|
||||
('longest_duration', 'Longest duration'),
|
||||
('shortest_duration', 'Shortest duration'),
|
||||
('pipeline_name', 'Pipeline name'),
|
||||
('status', 'Status'),
|
||||
];
|
||||
const runSchedules = [
|
||||
('any', 'Any trigger'),
|
||||
('scheduled', 'Scheduled runs'),
|
||||
('unscheduled', 'Not scheduled'),
|
||||
];
|
||||
const runTimeRanges = [
|
||||
('any_time', 'Any time'),
|
||||
('today', 'Today'),
|
||||
('last_7_days', 'Last 7 days'),
|
||||
('last_30_days', 'Last 30 days'),
|
||||
];
|
||||
|
||||
/// The pipelines the loaded runs belong to, by name then id.
|
||||
List<({int id, String name})> runFilterPipelines(RunsController controller) {
|
||||
final names = <int, String>{};
|
||||
final ids = <int>{};
|
||||
for (final run in controller.runs) {
|
||||
final id = run['pipeline_id'];
|
||||
if (id is! int) continue;
|
||||
ids.add(id);
|
||||
final name = '${run['name'] ?? ''}'.trim();
|
||||
if (name.isNotEmpty && !names.containsKey(id)) names[id] = name;
|
||||
}
|
||||
final options = ids
|
||||
.map((id) => (id: id, name: names[id] ?? 'Pipeline $id'))
|
||||
.toList();
|
||||
options.sort((a, b) {
|
||||
final nameOrder = a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
||||
return nameOrder != 0 ? nameOrder : a.id.compareTo(b.id);
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
/// Whether some loaded run carries no scheduling provenance at all.
|
||||
bool runsHaveUnclassified(RunsController controller) =>
|
||||
controller.runs.any((run) {
|
||||
final id = run['schedule_id'];
|
||||
return run['scheduled'] is! bool && !(id is num && id > 0);
|
||||
});
|
||||
|
||||
String runTimeRangeLabel(String value) => runTimeRanges
|
||||
.firstWhere((entry) => entry.$1 == value, orElse: () => runTimeRanges.first)
|
||||
.$2;
|
||||
String runSortLabel(String value) =>
|
||||
runSorts.firstWhere((e) => e.$1 == value, orElse: () => runSorts.first).$2;
|
||||
String runScheduleLabel(String value) => runSchedules
|
||||
.firstWhere((e) => e.$1 == value, orElse: () => runSchedules.first)
|
||||
.$2;
|
||||
@@ -0,0 +1,215 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
||||
import '../domain/run_models.dart';
|
||||
import 'runs_controller.dart';
|
||||
import 'runs_filter_options.dart';
|
||||
|
||||
const runsFilterTitle = 'Filter runs';
|
||||
const runsFilterDoneKey = ValueKey<String>('runs.filter.done');
|
||||
const runsFilterClearKey = ValueKey<String>('runs.filter.clear');
|
||||
|
||||
/// The filter sheet: a header (title, Clear, Done), the text filter, then
|
||||
/// status (several may be picked), pipeline, time range and trigger (one
|
||||
/// each), every choice applied as it is picked.
|
||||
Future<void> showRunsFilterSheet(
|
||||
BuildContext context,
|
||||
RunsController controller,
|
||||
) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final sheet = _RunsFilterSheet(controller: controller, cupertino: cupertino);
|
||||
if (cupertino) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
useSafeArea: true,
|
||||
builder: (_) => sheet,
|
||||
);
|
||||
}
|
||||
|
||||
class _RunsFilterSheet extends StatefulWidget {
|
||||
const _RunsFilterSheet({required this.controller, required this.cupertino});
|
||||
|
||||
final RunsController controller;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_RunsFilterSheet> createState() => _RunsFilterSheetState();
|
||||
}
|
||||
|
||||
class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
||||
late final TextEditingController _text = TextEditingController(
|
||||
text: widget.controller.query,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _clear() {
|
||||
_text.clear();
|
||||
widget.controller.setQuery('');
|
||||
widget.controller.clearFilters();
|
||||
}
|
||||
|
||||
Widget _section(BuildContext context, String title) {
|
||||
final style = widget.cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Semantics(header: true, child: Text(title, style: style)),
|
||||
);
|
||||
}
|
||||
|
||||
/// One status: several may be on at once, so Material uses a checkbox.
|
||||
Widget _multiChoice(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) return _checkRow(label, checked, onTap);
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
title: Text(label),
|
||||
value: checked,
|
||||
onChanged: (_) => onTap(),
|
||||
);
|
||||
}
|
||||
|
||||
/// One choice of a single-choice group: a check mark on the picked row.
|
||||
Widget _singleChoice(String label, bool checked, VoidCallback onTap) =>
|
||||
Semantics(
|
||||
inMutuallyExclusiveGroup: true,
|
||||
child: _checkRow(label, checked, onTap),
|
||||
);
|
||||
|
||||
Widget _checkRow(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) {
|
||||
return CupertinoListTile(
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(CupertinoIcons.check_mark) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
return ListTile(
|
||||
dense: true,
|
||||
selected: checked,
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(Icons.check) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = widget.controller;
|
||||
final field = AppSearchField(
|
||||
fieldKey: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
cupertino: widget.cupertino,
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
);
|
||||
return ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) {
|
||||
final active =
|
||||
controller.activeFilterCount > 0 || controller.query.isNotEmpty;
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AppSheetHeader(
|
||||
title: runsFilterTitle,
|
||||
cupertino: widget.cupertino,
|
||||
doneKey: runsFilterDoneKey,
|
||||
actions: [if (active) _clearButton()],
|
||||
),
|
||||
Flexible(child: _list(context, controller, field)),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _clearButton() => widget.cupertino
|
||||
? CupertinoButton(
|
||||
key: runsFilterClearKey,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: _clear,
|
||||
child: const Text('Clear'),
|
||||
)
|
||||
: TextButton(
|
||||
key: runsFilterClearKey,
|
||||
onPressed: _clear,
|
||||
child: const Text('Clear'),
|
||||
);
|
||||
|
||||
Widget _list(BuildContext context, RunsController controller, Widget field) {
|
||||
return ListView(
|
||||
key: const ValueKey('runs.filter.sheet'),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
Padding(padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), child: field),
|
||||
_section(context, 'Status'),
|
||||
for (final status in runStates)
|
||||
_multiChoice(
|
||||
runStateLabel(status),
|
||||
controller.statuses.contains(status),
|
||||
() => controller.setStatus(status),
|
||||
),
|
||||
_section(context, 'Pipeline'),
|
||||
_singleChoice(
|
||||
'Any pipeline',
|
||||
controller.pipelineId == null,
|
||||
() => controller.setPipeline(null),
|
||||
),
|
||||
for (final pipeline in runFilterPipelines(controller))
|
||||
_singleChoice(
|
||||
pipeline.name,
|
||||
controller.pipelineId == pipeline.id,
|
||||
() => controller.setPipeline(pipeline.id),
|
||||
),
|
||||
_section(context, 'Time range'),
|
||||
for (final range in runTimeRanges)
|
||||
_singleChoice(
|
||||
range.$2,
|
||||
controller.timeRange == range.$1,
|
||||
() => controller.setTimeRange(range.$1),
|
||||
),
|
||||
_section(context, 'Trigger'),
|
||||
for (final schedule in runSchedules)
|
||||
_singleChoice(
|
||||
schedule.$2,
|
||||
controller.scheduled == schedule.$1,
|
||||
() => controller.setScheduled(schedule.$1),
|
||||
),
|
||||
if (runsHaveUnclassified(controller))
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 0),
|
||||
child: Text(
|
||||
'Some records have no scheduling provenance; they stay '
|
||||
'unclassified.',
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,17 @@
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
||||
import 'runs_controller.dart';
|
||||
import 'runs_filter_options.dart';
|
||||
import 'runs_filter_sheet.dart';
|
||||
|
||||
export 'runs_filter_sheet.dart' show showRunsFilterSheet;
|
||||
|
||||
const runsSortTitle = 'Sort runs';
|
||||
const runsSortDoneKey = ValueKey<String>('runs.sort.done');
|
||||
|
||||
/// The runs list's compact native filter/sort toolbar and applied-filter chips.
|
||||
///
|
||||
@@ -62,17 +69,20 @@ class RunsFilters extends StatelessWidget {
|
||||
applied.add((label: pipeline, clear: () => controller.setPipeline(null)));
|
||||
}
|
||||
for (final status in controller.statuses) {
|
||||
applied.add((label: status, clear: () => controller.setStatus(status)));
|
||||
applied.add((
|
||||
label: runStateLabel(status),
|
||||
clear: () => controller.setStatus(status),
|
||||
));
|
||||
}
|
||||
if (controller.timeRange != 'any_time') {
|
||||
applied.add((
|
||||
label: _timeRangeLabel(controller.timeRange),
|
||||
label: runTimeRangeLabel(controller.timeRange),
|
||||
clear: () => controller.setTimeRange('any_time'),
|
||||
));
|
||||
}
|
||||
if (controller.scheduled != 'any') {
|
||||
applied.add((
|
||||
label: _scheduleLabel(controller.scheduled),
|
||||
label: runScheduleLabel(controller.scheduled),
|
||||
clear: () => controller.setScheduled('any'),
|
||||
));
|
||||
}
|
||||
@@ -128,61 +138,6 @@ class RunsFilters extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const _sorts = [
|
||||
('newest_first', 'Newest first'),
|
||||
('oldest_first', 'Oldest first'),
|
||||
('longest_duration', 'Longest duration'),
|
||||
('shortest_duration', 'Shortest duration'),
|
||||
('pipeline_name', 'Pipeline name'),
|
||||
('status', 'Status'),
|
||||
];
|
||||
const _schedules = [
|
||||
('any', 'Any trigger'),
|
||||
('scheduled', 'Scheduled runs'),
|
||||
('unscheduled', 'Not scheduled'),
|
||||
];
|
||||
const _timeRanges = [
|
||||
('any_time', 'Any time'),
|
||||
('today', 'Today'),
|
||||
('last_7_days', 'Last 7 days'),
|
||||
('last_30_days', 'Last 30 days'),
|
||||
];
|
||||
|
||||
List<({int id, String name})> _pipelines(RunsController controller) {
|
||||
final names = <int, String>{};
|
||||
final ids = <int>{};
|
||||
for (final run in controller.runs) {
|
||||
final id = run['pipeline_id'];
|
||||
if (id is! int) continue;
|
||||
ids.add(id);
|
||||
final name = '${run['name'] ?? ''}'.trim();
|
||||
if (name.isNotEmpty && !names.containsKey(id)) names[id] = name;
|
||||
}
|
||||
final options = ids
|
||||
.map((id) => (id: id, name: names[id] ?? 'Pipeline $id'))
|
||||
.toList();
|
||||
options.sort((a, b) {
|
||||
final nameOrder = a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
||||
return nameOrder != 0 ? nameOrder : a.id.compareTo(b.id);
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
bool _hasUnclassifiedRuns(RunsController controller) =>
|
||||
controller.runs.any((run) {
|
||||
final id = run['schedule_id'];
|
||||
return run['scheduled'] is! bool && !(id is num && id > 0);
|
||||
});
|
||||
|
||||
String _timeRangeLabel(String value) => _timeRanges
|
||||
.firstWhere((entry) => entry.$1 == value, orElse: () => _timeRanges.first)
|
||||
.$2;
|
||||
String _sortLabel(String value) =>
|
||||
_sorts.firstWhere((e) => e.$1 == value, orElse: () => _sorts.first).$2;
|
||||
String _scheduleLabel(String value) => _schedules
|
||||
.firstWhere((e) => e.$1 == value, orElse: () => _schedules.first)
|
||||
.$2;
|
||||
|
||||
/// The Runs list's app-bar actions: usage and charts, filter (with the search
|
||||
/// field inside) and sort, as icons.
|
||||
class RunsBarActions {
|
||||
@@ -252,7 +207,7 @@ class RunsBarActions {
|
||||
const ValueKey('runs.sort'),
|
||||
Icons.sort,
|
||||
CupertinoIcons.arrow_up_arrow_down,
|
||||
'Sort runs: ${_sortLabel(controller.sort)}',
|
||||
'Sort runs: ${runSortLabel(controller.sort)}',
|
||||
() => _chooseSort(context),
|
||||
),
|
||||
];
|
||||
@@ -265,10 +220,12 @@ class RunsBarActions {
|
||||
value = await showCupertinoModalPopup<String>(
|
||||
context: context,
|
||||
builder: (sheet) => CupertinoActionSheet(
|
||||
title: const Text('Sort runs'),
|
||||
title: const Text(runsSortTitle),
|
||||
actions: [
|
||||
for (final option in _sorts)
|
||||
for (final option in runSorts)
|
||||
CupertinoActionSheetAction(
|
||||
// The current order is the sheet's default (bold) action.
|
||||
isDefaultAction: controller.sort == option.$1,
|
||||
onPressed: () => Navigator.pop(sheet, option.$1),
|
||||
child: Text(
|
||||
'${controller.sort == option.$1 ? '✓ ' : ''}${option.$2}',
|
||||
@@ -286,18 +243,31 @@ class RunsBarActions {
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
builder: (sheet) => SafeArea(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const ListTile(title: Text('Sort runs')),
|
||||
for (final option in _sorts)
|
||||
ListTile(
|
||||
title: Text(option.$2),
|
||||
trailing: controller.sort == option.$1
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => Navigator.pop(sheet, option.$1),
|
||||
const AppSheetHeader(
|
||||
title: runsSortTitle,
|
||||
cupertino: false,
|
||||
doneKey: runsSortDoneKey,
|
||||
),
|
||||
Flexible(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
for (final option in runSorts)
|
||||
ListTile(
|
||||
selected: controller.sort == option.$1,
|
||||
title: Text(option.$2),
|
||||
trailing: controller.sort == option.$1
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => Navigator.pop(sheet, option.$1),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -306,162 +276,3 @@ class RunsBarActions {
|
||||
if (value != null && value != controller.sort) controller.setSort(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// The filter sheet: the text filter first, then status, pipeline, time range
|
||||
/// and trigger, each choice applied as it is picked.
|
||||
Future<void> showRunsFilterSheet(
|
||||
BuildContext context,
|
||||
RunsController controller,
|
||||
) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final sheet = _RunsFilterSheet(controller: controller, cupertino: cupertino);
|
||||
if (cupertino) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
useSafeArea: true,
|
||||
builder: (_) => sheet,
|
||||
);
|
||||
}
|
||||
|
||||
class _RunsFilterSheet extends StatefulWidget {
|
||||
const _RunsFilterSheet({required this.controller, required this.cupertino});
|
||||
|
||||
final RunsController controller;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_RunsFilterSheet> createState() => _RunsFilterSheetState();
|
||||
}
|
||||
|
||||
class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
||||
late final TextEditingController _text = TextEditingController(
|
||||
text: widget.controller.query,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _section(String title) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Text(title, style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
);
|
||||
|
||||
Widget _choice(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) {
|
||||
return CupertinoListTile(
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(CupertinoIcons.check_mark) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
title: Text(label),
|
||||
value: checked,
|
||||
onChanged: (_) => onTap(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = widget.controller;
|
||||
final field = AppSearchField(
|
||||
fieldKey: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
cupertino: widget.cupertino,
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
);
|
||||
return ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) => ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
|
||||
),
|
||||
child: ListView(
|
||||
key: const ValueKey('runs.filter.sheet'),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: field,
|
||||
),
|
||||
_section('Status'),
|
||||
for (final status in runStates)
|
||||
_choice(
|
||||
status,
|
||||
controller.statuses.contains(status),
|
||||
() => controller.setStatus(status),
|
||||
),
|
||||
_section('Pipeline'),
|
||||
_choice(
|
||||
'Any pipeline',
|
||||
controller.pipelineId == null,
|
||||
() => controller.setPipeline(null),
|
||||
),
|
||||
for (final pipeline in _pipelines(controller))
|
||||
_choice(
|
||||
pipeline.name,
|
||||
controller.pipelineId == pipeline.id,
|
||||
() => controller.setPipeline(pipeline.id),
|
||||
),
|
||||
_section('Time range'),
|
||||
for (final range in _timeRanges)
|
||||
_choice(
|
||||
range.$2,
|
||||
controller.timeRange == range.$1,
|
||||
() => controller.setTimeRange(range.$1),
|
||||
),
|
||||
_section('Trigger'),
|
||||
for (final schedule in _schedules)
|
||||
_choice(
|
||||
schedule.$2,
|
||||
controller.scheduled == schedule.$1,
|
||||
() => controller.setScheduled(schedule.$1),
|
||||
),
|
||||
if (_hasUnclassifiedRuns(controller))
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 0),
|
||||
child: Text(
|
||||
'Some records have no scheduling provenance; they stay '
|
||||
'unclassified.',
|
||||
),
|
||||
),
|
||||
if (controller.activeFilterCount > 0 || controller.query.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: widget.cupertino
|
||||
? CupertinoButton(
|
||||
onPressed: () {
|
||||
_text.clear();
|
||||
controller.setQuery('');
|
||||
controller.clearFilters();
|
||||
},
|
||||
child: const Text('Clear filters'),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: () {
|
||||
_text.clear();
|
||||
controller.setQuery('');
|
||||
controller.clearFilters();
|
||||
},
|
||||
child: const Text('Clear filters'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../../attention/notify/notification_controller.dart';
|
||||
import '../../attention/runtime/attention_controller.dart';
|
||||
import '../../attention/runtime/attention_store.dart';
|
||||
import '../../attention/ui/needs_you_runs_heading.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show formatRanAgo;
|
||||
import '../../../ui/text/relative_time.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import 'run_more_menu.dart';
|
||||
@@ -354,7 +354,7 @@ class RunListRow extends StatelessWidget {
|
||||
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
|
||||
),
|
||||
title: Text(title),
|
||||
time: formatRanAgo('${run['created_at'] ?? ''}', now),
|
||||
time: formatRelativeTimestamp('${run['created_at'] ?? ''}', now: now),
|
||||
subtitle: Text(subtitle),
|
||||
compactSubtitle: Text(compactSubtitle),
|
||||
// A narrow list pane beside the open run leaves the row no room for a
|
||||
|
||||
@@ -9,7 +9,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show parseInstant;
|
||||
import '../../pipelines/pipeline_format.dart' show parseInstant, runStateLabel;
|
||||
import 'run_detail_content.dart';
|
||||
import 'runs_controller.dart';
|
||||
|
||||
@@ -72,10 +72,13 @@ class RunsStatsPage extends StatelessWidget {
|
||||
key: const ValueKey('runs.stats.page'),
|
||||
padding: withBarClearance(context, const EdgeInsets.all(16)),
|
||||
children: [
|
||||
Text('Usage', style: heading),
|
||||
const SizedBox(height: 8),
|
||||
// The bar already says Usage: the totals lead the page untitled.
|
||||
if (metrics.isEmpty)
|
||||
Text('No usage reported.', style: TextStyle(color: secondary))
|
||||
Text(
|
||||
'No usage has been reported for these runs.',
|
||||
key: const ValueKey('runs.stats.usage.empty'),
|
||||
style: TextStyle(color: secondary),
|
||||
)
|
||||
else
|
||||
Wrap(
|
||||
spacing: 24,
|
||||
@@ -124,11 +127,11 @@ class RunsStatsPage extends StatelessWidget {
|
||||
children: [
|
||||
RunStatusIcon(
|
||||
state: entry.key,
|
||||
label: entry.key,
|
||||
label: runStateLabel(entry.key),
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(entry.key)),
|
||||
Expanded(child: Text(runStateLabel(entry.key))),
|
||||
Text('${entry.value}'),
|
||||
],
|
||||
),
|
||||
@@ -141,49 +144,14 @@ class RunsStatsPage extends StatelessWidget {
|
||||
const SizedBox(height: 24),
|
||||
Text('Runs in the last 7 days', style: heading),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
height: 140,
|
||||
child: Row(
|
||||
key: const ValueKey('runs.stats.days'),
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'${day.count}',
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Flexible(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: day.count == 0
|
||||
? 0.02
|
||||
: day.count /
|
||||
days.map((d) => d.count).reduce(math.max),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(day.label, style: TextStyle(color: secondary)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (days.every((day) => day.count == 0))
|
||||
Text(
|
||||
'No runs started in the last 7 days.',
|
||||
key: const ValueKey('runs.stats.days.empty'),
|
||||
style: TextStyle(color: secondary),
|
||||
)
|
||||
else
|
||||
_DaysChart(days: days, cupertino: cupertino, secondary: secondary),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -231,3 +199,92 @@ class _PiePainter extends CustomPainter {
|
||||
@override
|
||||
bool shouldRepaint(_PiePainter oldDelegate) => true;
|
||||
}
|
||||
|
||||
/// Runs per day as bars over a baseline axis, each bar labelled with its
|
||||
/// count and its weekday underneath. Only drawn when some day has a run.
|
||||
class _DaysChart extends StatelessWidget {
|
||||
const _DaysChart({
|
||||
required this.days,
|
||||
required this.cupertino,
|
||||
required this.secondary,
|
||||
});
|
||||
|
||||
final List<({String label, int count})> days;
|
||||
final bool cupertino;
|
||||
final Color secondary;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final most = days.map((d) => d.count).reduce(math.max);
|
||||
final bar = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final axis = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
return Column(
|
||||
key: const ValueKey('runs.stats.days'),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: axis)),
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 140,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (day.count > 0) ...[
|
||||
Text(
|
||||
'${day.count}',
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Flexible(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: day.count / most,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: bar,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Text(
|
||||
day.label,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../domain/saved_schedule.dart';
|
||||
import '../../../../ui/text/relative_time.dart';
|
||||
|
||||
/// User-facing values for one saved schedule row.
|
||||
///
|
||||
@@ -91,31 +92,12 @@ String scheduleCountLabel(int visible, int total) {
|
||||
return total == 1 ? '1 schedule' : '$total schedules';
|
||||
}
|
||||
|
||||
/// A row's short next-run word for its title line: `Paused`, `Not
|
||||
/// scheduled`, `Next time unavailable`, or the local time as `22 Oct 09:00`.
|
||||
String scheduleNextDueShort(SavedSchedule schedule) {
|
||||
/// A row's compact next-run label, using the shared relative-time vocabulary.
|
||||
String scheduleNextDueShort(SavedSchedule schedule, {DateTime? now}) {
|
||||
if (!schedule.enabled) return 'Paused';
|
||||
final value = schedule.nextDue;
|
||||
if (value.isEmpty) return 'Not scheduled';
|
||||
final date = DateTime.tryParse(value);
|
||||
if (date == null) return 'Next time unavailable';
|
||||
final local = date.toLocal();
|
||||
String two(int part) => part.toString().padLeft(2, '0');
|
||||
return '${local.day} ${_shortMonths[local.month - 1]} '
|
||||
'${two(local.hour)}:${two(local.minute)}';
|
||||
return formatRelativeTime(date, now: now) ?? 'Next time unavailable';
|
||||
}
|
||||
|
||||
const _shortMonths = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec',
|
||||
];
|
||||
|
||||
@@ -9,6 +9,10 @@ const scheduleSearchFieldKey = ValueKey<String>('schedule-search-field');
|
||||
const scheduleFilterKey = ValueKey<String>('schedule-filter');
|
||||
const scheduleRefreshKey = ValueKey<String>('schedule-refresh');
|
||||
|
||||
/// The strip width (inside its padding) from which the field, filter and
|
||||
/// count share one row.
|
||||
const double kScheduleToolbarRowWidth = 520;
|
||||
|
||||
/// Refresh for the list, as a bar action: the platform's activity indicator
|
||||
/// in the same touch target while a read is in flight.
|
||||
class ScheduleRefreshAction extends StatelessWidget {
|
||||
@@ -36,9 +40,12 @@ class ScheduleRefreshAction extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Search and the enabled filter, and the count; the refresh control too when
|
||||
/// no bar above carries it ([onRefresh] null leaves it to the bar). The list
|
||||
/// floats it as a glass strip under the page's bar.
|
||||
/// Search and the enabled filter, with the count as a muted label; the
|
||||
/// refresh control too when no bar above carries it ([onRefresh] null leaves
|
||||
/// it to the bar). The list floats it as a glass strip under the page's bar.
|
||||
///
|
||||
/// On a strip at least [kScheduleToolbarRowWidth] wide everything shares one
|
||||
/// row; narrower, the field takes its own row above the filter and count.
|
||||
class ScheduleListToolbar extends StatelessWidget {
|
||||
const ScheduleListToolbar({
|
||||
super.key,
|
||||
@@ -55,57 +62,60 @@ class ScheduleListToolbar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 8),
|
||||
child: _search(context),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 480),
|
||||
child: _filter(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (onRefresh case final refresh?) ...[
|
||||
const SizedBox(width: 8),
|
||||
ScheduleRefreshAction(
|
||||
controller: controller,
|
||||
cupertino: cupertino,
|
||||
onRefresh: refresh,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (controller.hasLoaded)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 8, 12, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(controller.countLabel, style: _metaStyle(context)),
|
||||
Text(
|
||||
'Saved run configurations, not pipeline definitions.',
|
||||
style: _metaStyle(context),
|
||||
),
|
||||
],
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final refresh = switch (onRefresh) {
|
||||
final refresh? => ScheduleRefreshAction(
|
||||
controller: controller,
|
||||
cupertino: cupertino,
|
||||
onRefresh: refresh,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
null => null,
|
||||
};
|
||||
if (constraints.maxWidth >= kScheduleToolbarRowWidth) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: _search(context)),
|
||||
const SizedBox(width: 12),
|
||||
_filter(context),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(child: _count(context)),
|
||||
if (refresh != null) ...[const SizedBox(width: 8), refresh],
|
||||
],
|
||||
);
|
||||
}
|
||||
// Narrow: the count follows the filter, and wraps under it when
|
||||
// large text leaves no room beside it.
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_search(context),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 8,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [_filter(context), _count(context), ?refresh],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The count, muted; empty space until the first read lands so the
|
||||
/// strip keeps its size.
|
||||
Widget _count(BuildContext context) => Text(
|
||||
controller.hasLoaded ? controller.countLabel : '',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: _metaStyle(context),
|
||||
);
|
||||
|
||||
Widget _search(BuildContext context) => AppSearchField(
|
||||
fieldKey: scheduleSearchFieldKey,
|
||||
controller: searchController,
|
||||
@@ -150,10 +160,11 @@ class ScheduleListToolbar extends StatelessWidget {
|
||||
}
|
||||
|
||||
TextStyle? _metaStyle(BuildContext context) => cupertino
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,13 @@ const scheduleListKey = ValueKey<String>('schedule-list');
|
||||
const scheduleRetryKey = ValueKey<String>('schedule-retry');
|
||||
const scheduleToolbarKey = ValueKey<String>('schedule-toolbar');
|
||||
|
||||
/// The widest the search and filter strip grows on a wide window.
|
||||
/// The widest the search and filter strip grows on a wide window. The rows
|
||||
/// share its width, so a row's time ends under the strip's trailing edge.
|
||||
const double kScheduleToolbarMaxWidth = 720;
|
||||
|
||||
/// The widest a row grows: the strip plus its 12px leading inset.
|
||||
const double kScheduleListMaxWidth = kScheduleToolbarMaxWidth + 12;
|
||||
|
||||
/// Platform-adaptive list body. It owns no navigation chrome; the shell frames
|
||||
/// it as the Schedules destination.
|
||||
///
|
||||
@@ -74,7 +78,12 @@ class SchedulesListView extends StatelessWidget {
|
||||
return BelowTopBar(child: _loadingState(context));
|
||||
}
|
||||
if (controller.schedules.isEmpty) {
|
||||
return BelowTopBar(child: _emptyState('No schedules yet.'));
|
||||
return BelowTopBar(
|
||||
child: _emptyState(
|
||||
'No schedules yet.',
|
||||
detail: 'Saved run configurations, not pipeline definitions.',
|
||||
),
|
||||
);
|
||||
}
|
||||
final content = controller.visibleSchedules.isEmpty
|
||||
? BelowTopBar(child: _emptyState(controller.emptyMessage))
|
||||
@@ -100,14 +109,20 @@ class SchedulesListView extends StatelessWidget {
|
||||
itemCount: schedules.length,
|
||||
itemBuilder: (context, index) {
|
||||
final schedule = schedules[index];
|
||||
return ScheduleListRow(
|
||||
key: ValueKey<String>(
|
||||
'schedule-row-$index-${schedule.id ?? 'unknown'}',
|
||||
return Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: kScheduleListMaxWidth),
|
||||
child: ScheduleListRow(
|
||||
key: ValueKey<String>(
|
||||
'schedule-row-$index-${schedule.id ?? 'unknown'}',
|
||||
),
|
||||
schedule: schedule,
|
||||
cupertino: cupertino,
|
||||
divider: index < schedules.length - 1,
|
||||
onOpen: () => onOpen(schedule),
|
||||
),
|
||||
),
|
||||
schedule: schedule,
|
||||
cupertino: cupertino,
|
||||
divider: index < schedules.length - 1,
|
||||
onOpen: () => onOpen(schedule),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -132,11 +147,28 @@ class SchedulesListView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _emptyState(String message) {
|
||||
Widget _emptyState(String message, {String? detail}) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Text(message, textAlign: TextAlign.center),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(message, textAlign: TextAlign.center),
|
||||
if (detail != null)
|
||||
Builder(
|
||||
builder: (context) => Text(
|
||||
detail,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../../../ui/layout/section_heading.dart';
|
||||
import '../../domain/saved_schedule.dart';
|
||||
import '../list/schedule_list_controller.dart';
|
||||
import 'schedule_pipeline_controller.dart';
|
||||
@@ -40,17 +42,7 @@ class SchedulePipelineListBody extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 4),
|
||||
child: _header(context),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
scheduleSectionNote,
|
||||
style: schedulePipelineMutedStyle(context),
|
||||
),
|
||||
),
|
||||
_header(context),
|
||||
if (controller.isInitialLoading)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
|
||||
@@ -68,8 +60,10 @@ class SchedulePipelineListBody extends StatelessWidget {
|
||||
else if (controller.hasLoaded && schedules.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
|
||||
// The empty state also says what a schedule is, so the section
|
||||
// needs no standing paragraph.
|
||||
child: Text(
|
||||
scheduleSectionEmpty,
|
||||
'$scheduleSectionEmpty $scheduleSectionNote',
|
||||
style: schedulePipelineMutedStyle(context),
|
||||
),
|
||||
),
|
||||
@@ -84,35 +78,36 @@ class SchedulePipelineListBody extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// The section's quiet heading (the same as Versions and the run Summary's
|
||||
/// sections) with Add as its one trailing action. There is no Refresh:
|
||||
/// the section reloads after every accepted change and offers Retry when a
|
||||
/// load fails.
|
||||
Widget _header(BuildContext context) {
|
||||
return Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Semantics(
|
||||
header: true,
|
||||
container: true,
|
||||
child: Text(
|
||||
controller.hasLoaded && controller.failure == null
|
||||
? '$scheduleSectionTitle (${controller.schedules.length})'
|
||||
: scheduleSectionTitle,
|
||||
style: schedulePipelineHeadingStyle(context),
|
||||
),
|
||||
),
|
||||
schedulePipelineTextButton(
|
||||
context,
|
||||
key: scheduleRefreshKey,
|
||||
label: scheduleRefreshLabel,
|
||||
onPressed: controller.isLoading ? null : controller.refresh,
|
||||
),
|
||||
schedulePipelineTextButton(
|
||||
context,
|
||||
key: scheduleAddKey,
|
||||
label: scheduleAddLabel,
|
||||
onPressed: onAdd,
|
||||
),
|
||||
],
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final add = cupertino
|
||||
? CupertinoButton(
|
||||
key: scheduleAddKey,
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size.square(44),
|
||||
onPressed: onAdd,
|
||||
child: const Icon(
|
||||
CupertinoIcons.add,
|
||||
semanticLabel: scheduleAddLabel,
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
key: scheduleAddKey,
|
||||
tooltip: scheduleAddLabel,
|
||||
onPressed: onAdd,
|
||||
icon: const Icon(Icons.add),
|
||||
);
|
||||
return SectionHeading(
|
||||
title: controller.hasLoaded && controller.failure == null
|
||||
? '$scheduleSectionTitle (${controller.schedules.length})'
|
||||
: scheduleSectionTitle,
|
||||
header: true,
|
||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
|
||||
trailing: [add],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ const scheduleSectionEmpty =
|
||||
'No schedules yet. Add one for each topic or recurring task.';
|
||||
const scheduleSectionLoading = 'Loading schedules…';
|
||||
const scheduleAddLabel = 'Add schedule';
|
||||
const scheduleRefreshLabel = 'Refresh';
|
||||
const scheduleEditLabel = 'Edit';
|
||||
const schedulePauseLabel = 'Pause';
|
||||
const scheduleEnableLabel = 'Enable';
|
||||
@@ -25,7 +24,6 @@ String scheduleDeleteTitle(String name) => 'Delete $name?';
|
||||
|
||||
const scheduleSectionKey = ValueKey<String>('schedule-pipeline-section');
|
||||
const scheduleAddKey = ValueKey<String>('schedule-pipeline-add');
|
||||
const scheduleRefreshKey = ValueKey<String>('schedule-pipeline-refresh');
|
||||
const scheduleDeleteKeepKey = ValueKey<String>('schedule-delete-keep');
|
||||
const scheduleDeleteConfirmKey = ValueKey<String>('schedule-delete-confirm');
|
||||
const scheduleDeleteErrorKey = ValueKey<String>('schedule-delete-error');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/text/relative_time.dart';
|
||||
import 'search_format.dart';
|
||||
|
||||
export 'search_format.dart' show humanBytes, formatSearchTimestamp;
|
||||
@@ -47,7 +48,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
||||
final field = _map(hit['field']);
|
||||
final artifact = _map(hit['artifact']);
|
||||
|
||||
final recency = formatSearchTimestamp('${hit['recency'] ?? ''}');
|
||||
final recency = formatRelativeTimestamp('${hit['recency'] ?? ''}');
|
||||
final target = _serverTarget(hit);
|
||||
|
||||
if (pipeline != null) {
|
||||
@@ -68,10 +69,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
||||
title:
|
||||
'pipeline ${_num(version['pipeline_id'])}'
|
||||
' · v${_num(version['version'])}',
|
||||
secondary: _join([
|
||||
hash == null ? null : 'content $hash',
|
||||
formatSearchTimestamp('${version['created_at'] ?? ''}'),
|
||||
]),
|
||||
secondary: hash == null ? '' : 'content $hash',
|
||||
kindLabel: 'Pipeline version',
|
||||
snippetSpans: const [],
|
||||
recency: recency,
|
||||
@@ -81,12 +79,8 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
||||
if (run != null) {
|
||||
final name = _nonBlank(run['pipeline_name']);
|
||||
return SearchRowView(
|
||||
title: 'run #${_num(run['id'])}${name == null ? '' : ' · $name'}',
|
||||
secondary: _join([
|
||||
_nonBlank(run['status']),
|
||||
_nonBlank(run['workspace']),
|
||||
formatSearchTimestamp('${run['created_at'] ?? ''}'),
|
||||
]),
|
||||
title: 'Run ${_num(run['id'])}${name == null ? '' : ' · $name'}',
|
||||
secondary: _join([_nonBlank(run['status']), _nonBlank(run['workspace'])]),
|
||||
kindLabel: 'Run',
|
||||
snippetSpans: const [],
|
||||
recency: recency,
|
||||
@@ -97,7 +91,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
||||
final stage = _nonBlank(step['stage']) ?? 'step';
|
||||
return SearchRowView(
|
||||
title:
|
||||
'run #${_num(step['run_id'])} · $stage'
|
||||
'Run ${_num(step['run_id'])} · $stage'
|
||||
' visit ${_num(step['visit'])}',
|
||||
secondary: _stepSecondary(step),
|
||||
kindLabel: 'Step',
|
||||
@@ -110,7 +104,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
||||
final snippet = '${field['snippet'] ?? ''}';
|
||||
return SearchRowView(
|
||||
title:
|
||||
'run #${_num(field['run_id'])} · step ${_num(field['sequence'])}'
|
||||
'Run ${_num(field['run_id'])} · step ${_num(field['sequence'])}'
|
||||
' · ${_nonBlank(field['field']) ?? 'field'}',
|
||||
secondary: snippet,
|
||||
kindLabel: 'Field',
|
||||
@@ -124,7 +118,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
||||
return SearchRowView(
|
||||
title: _nonBlank(artifact['name']) ?? 'artifact',
|
||||
secondary: _join([
|
||||
'run #${_num(artifact['run_id'])}',
|
||||
'Run ${_num(artifact['run_id'])}',
|
||||
'step ${_num(artifact['sequence'])}',
|
||||
_nonBlank(artifact['content_type']),
|
||||
humanBytes(_num(artifact['size_bytes'])),
|
||||
|
||||
@@ -106,7 +106,10 @@ class SettingsController extends ChangeNotifier {
|
||||
_connection.kind == transport.ConnectionKind.connecting;
|
||||
|
||||
String get primaryActionLabel => connectionActive ? 'Disconnect' : 'Connect';
|
||||
String get secondaryActionLabel => connectionActive ? 'Connect' : 'Reconnect';
|
||||
|
||||
/// Connecting again to the URL in the field; while connected that is a
|
||||
/// reconnect, so it never reads `Connect` beside `Disconnect`.
|
||||
String get secondaryActionLabel => 'Reconnect';
|
||||
|
||||
List<String> get connectionLines => connectionCardLines(
|
||||
_connection,
|
||||
|
||||
@@ -151,9 +151,12 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: <Widget>[
|
||||
if (usesCupertinoControls(context))
|
||||
CupertinoButton(
|
||||
// A tinted button keeps its shape when disabled, so an
|
||||
// unsaved-nothing state reads as a disabled button,
|
||||
// not as stray grey text.
|
||||
CupertinoButton.tinted(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
padding: EdgeInsets.zero,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
)
|
||||
|
||||
@@ -195,7 +195,10 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
onBack: _back,
|
||||
onCreate: () => _openCreate(selected),
|
||||
);
|
||||
final barTitle = selected == null ? null : templateBarTitle(selected);
|
||||
final framed = TemplatesFrame(
|
||||
title: barTitle?.title ?? templatesTitle,
|
||||
subtitle: barTitle?.subtitle,
|
||||
body: _withFailure(context, body),
|
||||
embedded: widget.embedded,
|
||||
canGoBack: selected != null,
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
import 'template_gallery.dart' show templatesColumn;
|
||||
|
||||
/// Browser wording for the gallery and the selected template, kept verbatim.
|
||||
const templateSourceLabel = 'Definition source';
|
||||
@@ -15,6 +16,17 @@ const templateDetailKey = ValueKey<String>('template-detail');
|
||||
const templateSourceKey = ValueKey<String>('template-source');
|
||||
const templateCreateActionKey = ValueKey<String>('template-create-action');
|
||||
const templateDetailBackKey = ValueKey<String>('template-detail-back');
|
||||
const templateKeyKey = ValueKey<String>('template-key');
|
||||
|
||||
/// What the bar's title pill shows for an open template: its name, and its
|
||||
/// description (when it has one) as the one-line subtitle.
|
||||
({String title, String? subtitle}) templateBarTitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim();
|
||||
return (
|
||||
title: templateDetailName(entry),
|
||||
subtitle: description.isEmpty ? null : description,
|
||||
);
|
||||
}
|
||||
|
||||
/// A gallery card's name: a blank name is the explicit unnamed placeholder.
|
||||
String templateGalleryName(TemplateEntry entry) {
|
||||
@@ -52,64 +64,92 @@ class TemplateDetail extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final muted = templateMutedStyle(context);
|
||||
final description = entry.description.trim();
|
||||
return ListView(
|
||||
key: templateDetailKey,
|
||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
|
||||
children: [
|
||||
if (showBack) _backRow(context, cupertino),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_createButton(context, cupertino),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
templateDetailName(entry),
|
||||
style: templateTitleStyle(context),
|
||||
),
|
||||
if (entry.description.trim().isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(entry.description),
|
||||
templatesColumn(
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// With a bar above, its title pill carries the name and the
|
||||
// description; only a bar-less page names the template here.
|
||||
if (showBack) ...[
|
||||
Text(
|
||||
templateDetailName(entry),
|
||||
style: templateTitleStyle(context),
|
||||
),
|
||||
if (description.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(entry.description),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_createButton(cupertino),
|
||||
const SizedBox(height: 16),
|
||||
// The key and the schedule on one quiet line, not a
|
||||
// label/value document.
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
SelectableText(
|
||||
entry.key,
|
||||
key: templateKeyKey,
|
||||
semanticsLabel: 'Key ${entry.key}',
|
||||
style: muted,
|
||||
),
|
||||
if (entry.scheduled) ...[
|
||||
Text('·', style: muted),
|
||||
Text(templateIncludesScheduleLabel, style: muted),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('Key', style: templateMutedStyle(context)),
|
||||
SelectableText(entry.key, style: templateBodyStyle(context)),
|
||||
if (entry.scheduled)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(templateIncludesScheduleLabel),
|
||||
const SizedBox(height: 20),
|
||||
Text(templateSourceLabel, style: templateSectionStyle(context)),
|
||||
const SizedBox(height: 8),
|
||||
// The server's source, byte-for-byte: no trim, re-indent or
|
||||
// re-encoding, so selecting it copies exactly what was
|
||||
// received.
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: SelectableText(
|
||||
entry.source,
|
||||
key: templateSourceKey,
|
||||
style: templateBodyStyle(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(templateSourceLabel, style: templateSectionStyle(context)),
|
||||
const SizedBox(height: 8),
|
||||
// The server's source, byte-for-byte: no trim, re-indent or
|
||||
// re-encoding, so selecting it copies exactly what was received.
|
||||
SelectableText(
|
||||
entry.source,
|
||||
key: templateSourceKey,
|
||||
style: templateBodyStyle(context),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _createButton(BuildContext context, bool cupertino) {
|
||||
/// A compact button at its own width: the page's one action, never a bar
|
||||
/// spanning a wide window.
|
||||
Widget _createButton(bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton.filled(
|
||||
key: templateCreateActionKey,
|
||||
sizeStyle: CupertinoButtonSize.medium,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
return FilledButton(
|
||||
return FilledButton.icon(
|
||||
key: templateCreateActionKey,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,7 +200,11 @@ TextStyle? templateBodyStyle(BuildContext context) {
|
||||
|
||||
TextStyle? templateMutedStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
// The list rows' secondary size, not the tab bar's 10pt caption.
|
||||
// SelectableText needs an explicit baseline when it inherits no style.
|
||||
return CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
inherit: true,
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/layout/app_list_avatar.dart';
|
||||
import '../../../ui/layout/app_list_row.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
import 'template_detail.dart';
|
||||
import 'templates_failure.dart';
|
||||
@@ -16,8 +18,23 @@ const _loadingMessage = 'Loading templates…';
|
||||
const _emptyMessage = 'No templates are available on this server.';
|
||||
|
||||
Key templateRowKey(String key) => ValueKey<String>('template-row-$key');
|
||||
Key templateAvatarKey(String key) => ValueKey<String>('template-avatar-$key');
|
||||
|
||||
/// The gallery's truthful states and native catalogue rows.
|
||||
/// The widest the gallery and an open template grow on a wide window: the
|
||||
/// Settings column's reading width, so the page opened from Settings lines up
|
||||
/// with it.
|
||||
const double templatesContentMaxWidth = 720;
|
||||
|
||||
/// Caps [child] at [templatesContentMaxWidth], start-aligned under the bar.
|
||||
Widget templatesColumn(Widget child) => Align(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: templatesContentMaxWidth),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
/// The gallery's truthful states and the app's shared list rows.
|
||||
///
|
||||
/// It owns no requests: loading, failure and the actual rows all come from the
|
||||
/// screen, so opening a row only selects an already-read template.
|
||||
@@ -44,9 +61,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
final ValueChanged<String> onOpen;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _body(context);
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
Widget build(BuildContext context) {
|
||||
if (!loaded) {
|
||||
if (error != null) {
|
||||
return TemplatesFailureState(
|
||||
@@ -58,9 +73,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
return _loadingState(context);
|
||||
}
|
||||
if (templates.isEmpty) return _emptyState(context);
|
||||
return usesCupertinoHost(context)
|
||||
? _cupertinoList(context)
|
||||
: _materialList(context);
|
||||
return _list(context);
|
||||
}
|
||||
|
||||
Widget _loadingState(BuildContext context) {
|
||||
@@ -93,82 +106,62 @@ class TemplateGallery extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialList(BuildContext context) {
|
||||
return ListView.separated(
|
||||
Widget _list(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// The rows scroll behind the bar and the floating tab bar.
|
||||
return ListView.builder(
|
||||
key: templatesGalleryKey,
|
||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 8)),
|
||||
itemCount: templates.length,
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final entry = templates[index];
|
||||
return ListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
subtitle: _materialSubtitle(entry),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => onOpen(entry.key),
|
||||
return templatesColumn(
|
||||
AppListRow(
|
||||
key: templateRowKey(entry.key),
|
||||
cupertino: cupertino,
|
||||
divider: index < templates.length - 1,
|
||||
onTap: () => onOpen(entry.key),
|
||||
leading: ExcludeSemantics(
|
||||
child: AppListAvatar.initial(
|
||||
templateDetailName(entry),
|
||||
key: templateAvatarKey(entry.key),
|
||||
color: _avatarColor(context, entry.key, cupertino),
|
||||
),
|
||||
),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
subtitle: _subtitle(entry),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoList(BuildContext context) {
|
||||
return ListView(
|
||||
key: templatesGalleryKey,
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final entry in templates)
|
||||
CupertinoListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: _cupertinoText(templateGalleryName(entry)),
|
||||
subtitle: _cupertinoSubtitle(entry),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
onTap: () => onOpen(entry.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The native tile is single-line by default. Let its content wrap at larger
|
||||
/// text sizes instead of ellipsizing a template's own name; the row grows
|
||||
/// with the content and nothing else about the tile is restyled.
|
||||
Widget _cupertinoText(String text) =>
|
||||
DefaultTextStyle.merge(maxLines: 3, child: Text(text));
|
||||
|
||||
Widget _materialSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: Text(entry.description);
|
||||
final count = Text(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: _cupertinoText(entry.description);
|
||||
final count = _cupertinoText(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
String _stageCountLabel(String key) {
|
||||
if (!stageCounts.containsKey(key) || stageCounts[key] == null) {
|
||||
return 'stage count unavailable';
|
||||
/// One of the theme's accents, picked by the template key so a row keeps
|
||||
/// its colour across reloads (the Pipelines list's palette).
|
||||
Color _avatarColor(BuildContext context, String key, bool cupertino) {
|
||||
final List<Color> colors;
|
||||
if (cupertino) {
|
||||
colors = [
|
||||
CupertinoTheme.of(context).primaryColor,
|
||||
CupertinoColors.systemIndigo.resolveFrom(context),
|
||||
CupertinoColors.systemTeal.resolveFrom(context),
|
||||
];
|
||||
} else {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
colors = [scheme.primary, scheme.secondary, scheme.tertiary];
|
||||
}
|
||||
final count = stageCounts[key]!;
|
||||
return '$count ${count == 1 ? 'stage' : 'stages'}';
|
||||
final hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
|
||||
return colors[hash % colors.length];
|
||||
}
|
||||
|
||||
/// The description, then the stage count when the server could parse the
|
||||
/// source. An unknown count is left out rather than announced on every row.
|
||||
Widget? _subtitle(TemplateEntry entry) {
|
||||
final count = stageCounts[entry.key];
|
||||
final parts = [
|
||||
if (entry.description.trim().isNotEmpty) entry.description.trim(),
|
||||
if (count != null) '$count ${count == 1 ? 'stage' : 'stages'}',
|
||||
];
|
||||
return parts.isEmpty ? null : Text(parts.join(' · '));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../ui/theme/app_theme.dart';
|
||||
|
||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||
const templatesBackKey = ValueKey<String>('templates-back');
|
||||
const templatesTitle = 'Templates';
|
||||
|
||||
/// The screen's native chrome.
|
||||
///
|
||||
@@ -26,8 +27,14 @@ class TemplatesFrame extends StatelessWidget {
|
||||
required this.refreshing,
|
||||
required this.onBack,
|
||||
required this.onRefresh,
|
||||
this.title = templatesTitle,
|
||||
this.subtitle,
|
||||
});
|
||||
|
||||
/// The bar's title pill: `Templates` on the gallery, the open template's
|
||||
/// name (with its description as [subtitle]) on a detail.
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final Widget body;
|
||||
final bool embedded;
|
||||
final bool canGoBack;
|
||||
@@ -41,7 +48,8 @@ class TemplatesFrame extends StatelessWidget {
|
||||
if (embedded) {
|
||||
if (ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
title: 'Templates',
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
onBack: canGoBack ? onBack : null,
|
||||
actions: [_refreshButton()],
|
||||
child: body,
|
||||
@@ -70,14 +78,16 @@ class TemplatesFrame extends StatelessWidget {
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
title: 'Templates',
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
actions: [_refreshButton()],
|
||||
);
|
||||
// The body reaches the top edge and scrolls behind the bar.
|
||||
final page = SafeArea(top: false, bottom: false, child: body);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// Plain list rows on the page background, like the other lists.
|
||||
backgroundColor: AppColors.background,
|
||||
navigationBar: bar,
|
||||
child: page,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user