Merge branch 'main' into worktree-agent-aab11f4f1fe3dff6b
# Conflicts: # app/test/features/runs/ui/run_list_row_test.dart
This commit is contained in:
@@ -152,7 +152,8 @@ String fileChangesSummary(ChangeCapture capture) {
|
|||||||
var text = capture.status;
|
var text = capture.status;
|
||||||
if (capture.files.isNotEmpty) {
|
if (capture.files.isNotEmpty) {
|
||||||
if (text.isNotEmpty) text += ' ';
|
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 (capture.skipped > 0) {
|
||||||
if (text.isNotEmpty) text += ', ';
|
if (text.isNotEmpty) text += ', ';
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class StageCaptureSection extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(stage.stage, style: Theme.of(context).textTheme.titleMedium),
|
|
||||||
Text(meta, style: Theme.of(context).textTheme.bodySmall),
|
Text(meta, style: Theme.of(context).textTheme.bodySmall),
|
||||||
if (capture != null) ...[
|
if (capture != null) ...[
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import '../../../../core/api_gateway.dart';
|
import '../../../../core/api_gateway.dart';
|
||||||
|
import '../../../../ui/text/relative_time.dart';
|
||||||
import '../../domain/chat_sessions.dart';
|
import '../../domain/chat_sessions.dart';
|
||||||
|
|
||||||
/// Titles shared by more than one visible session, so row action labels can
|
/// 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';
|
: 'Chat actions for $title';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The web row's relative recency: `just now`, `N min ago`, `N hr ago`,
|
/// The shared list-row recency, or nothing for an unusable `updated_at`.
|
||||||
/// `N days ago`, then a short date (`22 Oct`). A row without a usable
|
|
||||||
/// `updated_at` reports nothing rather than inventing a time.
|
|
||||||
String relativeChatSessionTime(Object? updatedAt, {DateTime? now}) {
|
String relativeChatSessionTime(Object? updatedAt, {DateTime? now}) {
|
||||||
final millis = chatSessionMillis(updatedAt);
|
final millis = chatSessionMillis(updatedAt);
|
||||||
if (millis <= 0) return '';
|
if (millis <= 0) return '';
|
||||||
final then = DateTime.fromMillisecondsSinceEpoch(millis);
|
return formatRelativeTime(
|
||||||
var elapsed = (now ?? DateTime.now()).difference(then);
|
DateTime.fromMillisecondsSinceEpoch(millis),
|
||||||
if (elapsed.isNegative) elapsed = Duration.zero;
|
now: now,
|
||||||
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]}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The row's one muted line: the recorded model and the folder (home as `~`).
|
/// 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;
|
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';
|
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) {
|
String formatDuration(int totalSeconds) {
|
||||||
final seconds = totalSeconds < 0 ? 0 : totalSeconds;
|
final seconds = totalSeconds < 0 ? 0 : totalSeconds;
|
||||||
if (seconds < 60) return '${seconds}s';
|
if (seconds < 60) return '${seconds}s';
|
||||||
if (seconds < 3600) return '${seconds ~/ 60}m ${seconds % 60}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
|
/// 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;
|
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`.
|
/// `1 stage` / `n stages`.
|
||||||
String stageCountText(int count) => '$count ${count == 1 ? 'stage' : 'stages'}';
|
String stageCountText(int count) => '$count ${count == 1 ? 'stage' : 'stages'}';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'pipeline_format.dart';
|
import 'pipeline_format.dart';
|
||||||
|
import '../../ui/text/relative_time.dart';
|
||||||
import 'pipeline_models.dart';
|
import 'pipeline_models.dart';
|
||||||
|
|
||||||
export 'pipeline_filter.dart';
|
export 'pipeline_filter.dart';
|
||||||
@@ -27,7 +28,7 @@ class RunBadge {
|
|||||||
final String? ranAgo;
|
final String? ranAgo;
|
||||||
final String? duration;
|
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 => [
|
String get metaLine => [
|
||||||
ranAgo,
|
ranAgo,
|
||||||
duration,
|
duration,
|
||||||
@@ -42,7 +43,7 @@ RunBadge runBadge(PipelineRun run, DateTime now) {
|
|||||||
return RunBadge(
|
return RunBadge(
|
||||||
runId: run.id,
|
runId: run.id,
|
||||||
state: runStateOf(run.status),
|
state: runStateOf(run.status),
|
||||||
ranAgo: formatRanAgo(run.createdAt, now),
|
ranAgo: formatRelativeTimestamp(run.createdAt, now: now),
|
||||||
duration: duration,
|
duration: duration,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ typedef DetailMetric = ({String label, String value});
|
|||||||
typedef DetailVisit = ({
|
typedef DetailVisit = ({
|
||||||
String stage,
|
String stage,
|
||||||
int? sequence,
|
int? sequence,
|
||||||
|
int visit,
|
||||||
String title,
|
String title,
|
||||||
String subtitle,
|
String subtitle,
|
||||||
String status,
|
String status,
|
||||||
@@ -114,22 +115,42 @@ List<DetailMetric> detailUsageMetrics(dynamic raw) {
|
|||||||
/// Every recorded visit with its server sequence, in recorded order.
|
/// Every recorded visit with its server sequence, in recorded order.
|
||||||
List<DetailVisit> detailTimeline(dynamic steps) {
|
List<DetailVisit> detailTimeline(dynamic steps) {
|
||||||
if (steps is! List) return const [];
|
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 [
|
return [
|
||||||
for (final step in steps.whereType<Map>())
|
for (var index = 0; index < records.length; index += 1)
|
||||||
(
|
() {
|
||||||
stage: '${step['stage'] ?? ''}'.trim(),
|
final step = records[index];
|
||||||
sequence: step['sequence'] is num
|
final stage = '${step['stage'] ?? ''}'.trim();
|
||||||
? (step['sequence'] as num).toInt()
|
final visit = visits[index]!;
|
||||||
: null,
|
return (
|
||||||
title:
|
stage: stage,
|
||||||
'${_text(step['stage'], 'Stage unavailable')} · visit '
|
sequence: step['sequence'] is num
|
||||||
'${step['sequence'] is num ? (step['sequence'] as num).toInt() : 'unavailable'}',
|
? (step['sequence'] as num).toInt()
|
||||||
subtitle: _visitSubtitle(step),
|
: null,
|
||||||
status: '${step['status'] ?? ''}'.trim(),
|
visit: visit,
|
||||||
outcome: '${step['outcome'] ?? ''}'.trim(),
|
title: '${_text(step['stage'], 'Stage unavailable')} · Visit $visit',
|
||||||
target: '${step['target'] ?? ''}'.trim(),
|
subtitle: _visitSubtitle(step),
|
||||||
duration: _visitDuration(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(' · ');
|
].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.
|
/// The web's `stepDuration`: finished minus started, when both are recorded.
|
||||||
String? _visitDuration(Map step) {
|
String? _visitDuration(Map step) {
|
||||||
final started = DateTime.tryParse('${step['started_at'] ?? ''}');
|
final started = DateTime.tryParse('${step['started_at'] ?? ''}');
|
||||||
|
|||||||
@@ -90,13 +90,13 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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`).
|
/// it belongs to (`Visit 2 · Run 7 · Nightly report`).
|
||||||
String runVisitSubtitle(JsonMap run, DetailVisit visit) {
|
String runVisitSubtitle(JsonMap run, DetailVisit visit) {
|
||||||
final runId = '${run['id'] ?? ''}'.trim();
|
final runId = '${run['id'] ?? ''}'.trim();
|
||||||
final title = detailTitle(run);
|
final title = detailTitle(run);
|
||||||
return [
|
return [
|
||||||
if (visit.sequence != null) 'Visit ${visit.sequence}',
|
'Visit ${visit.visit}',
|
||||||
if (runId.isNotEmpty) 'Run $runId',
|
if (runId.isNotEmpty) 'Run $runId',
|
||||||
if (title.isNotEmpty && title != 'Run $runId') title,
|
if (title.isNotEmpty && title != 'Run $runId') title,
|
||||||
].join(' · ');
|
].join(' · ');
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import '../../attention/notify/notification_controller.dart';
|
|||||||
import '../../attention/runtime/attention_controller.dart';
|
import '../../attention/runtime/attention_controller.dart';
|
||||||
import '../../attention/runtime/attention_store.dart';
|
import '../../attention/runtime/attention_store.dart';
|
||||||
import '../../attention/ui/needs_you_runs_heading.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 '../domain/run_models.dart';
|
||||||
import '../../../shell/shell_bar.dart';
|
import '../../../shell/shell_bar.dart';
|
||||||
import 'run_more_menu.dart';
|
import 'run_more_menu.dart';
|
||||||
@@ -354,7 +354,7 @@ class RunListRow extends StatelessWidget {
|
|||||||
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
|
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
|
||||||
),
|
),
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
time: formatRanAgo('${run['created_at'] ?? ''}', now),
|
time: formatRelativeTimestamp('${run['created_at'] ?? ''}', now: now),
|
||||||
subtitle: Text(subtitle),
|
subtitle: Text(subtitle),
|
||||||
compactSubtitle: Text(compactSubtitle),
|
compactSubtitle: Text(compactSubtitle),
|
||||||
// A narrow list pane beside the open run leaves the row no room for a
|
// A narrow list pane beside the open run leaves the row no room for a
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import '../../domain/saved_schedule.dart';
|
import '../../domain/saved_schedule.dart';
|
||||||
|
import '../../../../ui/text/relative_time.dart';
|
||||||
|
|
||||||
/// User-facing values for one saved schedule row.
|
/// 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';
|
return total == 1 ? '1 schedule' : '$total schedules';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A row's short next-run word for its title line: `Paused`, `Not
|
/// A row's compact next-run label, using the shared relative-time vocabulary.
|
||||||
/// scheduled`, `Next time unavailable`, or the local time as `22 Oct 09:00`.
|
String scheduleNextDueShort(SavedSchedule schedule, {DateTime? now}) {
|
||||||
String scheduleNextDueShort(SavedSchedule schedule) {
|
|
||||||
if (!schedule.enabled) return 'Paused';
|
if (!schedule.enabled) return 'Paused';
|
||||||
final value = schedule.nextDue;
|
final value = schedule.nextDue;
|
||||||
if (value.isEmpty) return 'Not scheduled';
|
if (value.isEmpty) return 'Not scheduled';
|
||||||
final date = DateTime.tryParse(value);
|
final date = DateTime.tryParse(value);
|
||||||
if (date == null) return 'Next time unavailable';
|
if (date == null) return 'Next time unavailable';
|
||||||
final local = date.toLocal();
|
return formatRelativeTime(date, now: now) ?? 'Next time unavailable';
|
||||||
String two(int part) => part.toString().padLeft(2, '0');
|
|
||||||
return '${local.day} ${_shortMonths[local.month - 1]} '
|
|
||||||
'${two(local.hour)}:${two(local.minute)}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _shortMonths = [
|
|
||||||
'Jan',
|
|
||||||
'Feb',
|
|
||||||
'Mar',
|
|
||||||
'Apr',
|
|
||||||
'May',
|
|
||||||
'Jun',
|
|
||||||
'Jul',
|
|
||||||
'Aug',
|
|
||||||
'Sep',
|
|
||||||
'Oct',
|
|
||||||
'Nov',
|
|
||||||
'Dec',
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
|
import '../../../ui/text/relative_time.dart';
|
||||||
import 'search_format.dart';
|
import 'search_format.dart';
|
||||||
|
|
||||||
export 'search_format.dart' show humanBytes, formatSearchTimestamp;
|
export 'search_format.dart' show humanBytes, formatSearchTimestamp;
|
||||||
@@ -47,7 +48,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
|||||||
final field = _map(hit['field']);
|
final field = _map(hit['field']);
|
||||||
final artifact = _map(hit['artifact']);
|
final artifact = _map(hit['artifact']);
|
||||||
|
|
||||||
final recency = formatSearchTimestamp('${hit['recency'] ?? ''}');
|
final recency = formatRelativeTimestamp('${hit['recency'] ?? ''}');
|
||||||
final target = _serverTarget(hit);
|
final target = _serverTarget(hit);
|
||||||
|
|
||||||
if (pipeline != null) {
|
if (pipeline != null) {
|
||||||
@@ -68,10 +69,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
|||||||
title:
|
title:
|
||||||
'pipeline ${_num(version['pipeline_id'])}'
|
'pipeline ${_num(version['pipeline_id'])}'
|
||||||
' · v${_num(version['version'])}',
|
' · v${_num(version['version'])}',
|
||||||
secondary: _join([
|
secondary: hash == null ? '' : 'content $hash',
|
||||||
hash == null ? null : 'content $hash',
|
|
||||||
formatSearchTimestamp('${version['created_at'] ?? ''}'),
|
|
||||||
]),
|
|
||||||
kindLabel: 'Pipeline version',
|
kindLabel: 'Pipeline version',
|
||||||
snippetSpans: const [],
|
snippetSpans: const [],
|
||||||
recency: recency,
|
recency: recency,
|
||||||
@@ -81,12 +79,8 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
|||||||
if (run != null) {
|
if (run != null) {
|
||||||
final name = _nonBlank(run['pipeline_name']);
|
final name = _nonBlank(run['pipeline_name']);
|
||||||
return SearchRowView(
|
return SearchRowView(
|
||||||
title: 'run #${_num(run['id'])}${name == null ? '' : ' · $name'}',
|
title: 'Run ${_num(run['id'])}${name == null ? '' : ' · $name'}',
|
||||||
secondary: _join([
|
secondary: _join([_nonBlank(run['status']), _nonBlank(run['workspace'])]),
|
||||||
_nonBlank(run['status']),
|
|
||||||
_nonBlank(run['workspace']),
|
|
||||||
formatSearchTimestamp('${run['created_at'] ?? ''}'),
|
|
||||||
]),
|
|
||||||
kindLabel: 'Run',
|
kindLabel: 'Run',
|
||||||
snippetSpans: const [],
|
snippetSpans: const [],
|
||||||
recency: recency,
|
recency: recency,
|
||||||
@@ -97,7 +91,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
|||||||
final stage = _nonBlank(step['stage']) ?? 'step';
|
final stage = _nonBlank(step['stage']) ?? 'step';
|
||||||
return SearchRowView(
|
return SearchRowView(
|
||||||
title:
|
title:
|
||||||
'run #${_num(step['run_id'])} · $stage'
|
'Run ${_num(step['run_id'])} · $stage'
|
||||||
' visit ${_num(step['visit'])}',
|
' visit ${_num(step['visit'])}',
|
||||||
secondary: _stepSecondary(step),
|
secondary: _stepSecondary(step),
|
||||||
kindLabel: 'Step',
|
kindLabel: 'Step',
|
||||||
@@ -110,7 +104,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
|||||||
final snippet = '${field['snippet'] ?? ''}';
|
final snippet = '${field['snippet'] ?? ''}';
|
||||||
return SearchRowView(
|
return SearchRowView(
|
||||||
title:
|
title:
|
||||||
'run #${_num(field['run_id'])} · step ${_num(field['sequence'])}'
|
'Run ${_num(field['run_id'])} · step ${_num(field['sequence'])}'
|
||||||
' · ${_nonBlank(field['field']) ?? 'field'}',
|
' · ${_nonBlank(field['field']) ?? 'field'}',
|
||||||
secondary: snippet,
|
secondary: snippet,
|
||||||
kindLabel: 'Field',
|
kindLabel: 'Field',
|
||||||
@@ -124,7 +118,7 @@ SearchRowView searchRowView(JsonMap hit, String query) {
|
|||||||
return SearchRowView(
|
return SearchRowView(
|
||||||
title: _nonBlank(artifact['name']) ?? 'artifact',
|
title: _nonBlank(artifact['name']) ?? 'artifact',
|
||||||
secondary: _join([
|
secondary: _join([
|
||||||
'run #${_num(artifact['run_id'])}',
|
'Run ${_num(artifact['run_id'])}',
|
||||||
'step ${_num(artifact['sequence'])}',
|
'step ${_num(artifact['sequence'])}',
|
||||||
_nonBlank(artifact['content_type']),
|
_nonBlank(artifact['content_type']),
|
||||||
humanBytes(_num(artifact['size_bytes'])),
|
humanBytes(_num(artifact['size_bytes'])),
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
const _monthNames = <String>[
|
||||||
|
'Jan',
|
||||||
|
'Feb',
|
||||||
|
'Mar',
|
||||||
|
'Apr',
|
||||||
|
'May',
|
||||||
|
'Jun',
|
||||||
|
'Jul',
|
||||||
|
'Aug',
|
||||||
|
'Sep',
|
||||||
|
'Oct',
|
||||||
|
'Nov',
|
||||||
|
'Dec',
|
||||||
|
];
|
||||||
|
|
||||||
|
/// A compact local recency label for list rows.
|
||||||
|
///
|
||||||
|
/// Past instants use `just now`, `Nm`, `Nh`, or `Nd` for their first week,
|
||||||
|
/// then a short local date. Future instants use the same compact units with an
|
||||||
|
/// `in` prefix, which keeps scheduled rows truthful.
|
||||||
|
String? formatRelativeTime(DateTime? instant, {DateTime? now}) {
|
||||||
|
if (instant == null) return null;
|
||||||
|
final current = now ?? DateTime.now();
|
||||||
|
final seconds = instant.difference(current).inSeconds;
|
||||||
|
final future = seconds > 0;
|
||||||
|
final age = seconds.abs();
|
||||||
|
if (age < 60) return 'just now';
|
||||||
|
final prefix = future ? 'in ' : '';
|
||||||
|
if (age < 3600) return '$prefix${age ~/ 60}m';
|
||||||
|
if (age < 86400) return '$prefix${age ~/ 3600}h';
|
||||||
|
if (age < 7 * 86400) return '$prefix${age ~/ 86400}d';
|
||||||
|
final local = instant.toLocal();
|
||||||
|
return '${local.day} ${_monthNames[local.month - 1]}';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parses [text] as an RFC3339 timestamp before formatting it for a list row.
|
||||||
|
String? formatRelativeTimestamp(String? text, {DateTime? now}) {
|
||||||
|
final value = text?.trim() ?? '';
|
||||||
|
return formatRelativeTime(DateTime.tryParse(value), now: now);
|
||||||
|
}
|
||||||
@@ -351,7 +351,7 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump(const Duration(milliseconds: 400));
|
await tester.pump(const Duration(milliseconds: 400));
|
||||||
await tester.pump(const Duration(milliseconds: 400));
|
await tester.pump(const Duration(milliseconds: 400));
|
||||||
expectVisitHeading(tester, 'plan', 5);
|
expectVisitHeading(tester, 'plan', 2);
|
||||||
expect(provider.value.uri.path, '/runs/77/stage/plan');
|
expect(provider.value.uri.path, '/runs/77/stage/plan');
|
||||||
expect(provider.value.uri.query, 'visit=1');
|
expect(provider.value.uri.query, 'visit=1');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(find.text('run #7 · Preserved run'), findsOneWidget);
|
expect(find.text('Run 7 · Preserved run'), findsOneWidget);
|
||||||
await tester.tap(find.byKey(const ValueKey('search.result.run:7')));
|
await tester.tap(find.byKey(const ValueKey('search.result.run:7')));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump(const Duration(milliseconds: 400));
|
await tester.pump(const Duration(milliseconds: 400));
|
||||||
@@ -497,7 +497,7 @@ void main() {
|
|||||||
expect(provider.value.uri.path, '/runs/7');
|
expect(provider.value.uri.path, '/runs/7');
|
||||||
expect(find.byType(SearchScreen), findsNothing);
|
expect(find.byType(SearchScreen), findsNothing);
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
expectVisitHeading(tester, 'build', 2);
|
expectVisitHeading(tester, 'build', 1);
|
||||||
|
|
||||||
// Leave the visit page (it covers the shell), then a retired field hit
|
// Leave the visit page (it covers the shell), then a retired field hit
|
||||||
// opens the plain Summary with no visit.
|
// opens the plain Summary with no visit.
|
||||||
@@ -608,7 +608,7 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
expectVisitHeading(tester, 'build', 2);
|
expectVisitHeading(tester, 'build', 1);
|
||||||
|
|
||||||
await tester.pumpWidget(const SizedBox.shrink());
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|||||||
@@ -125,11 +125,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
// The run-wide aggregate still counts the file this visit recorded.
|
// The run-wide aggregate still counts the file this visit recorded.
|
||||||
expect(find.textContaining('1 file changed'), findsOneWidget);
|
expect(find.textContaining('1 file changed'), findsOneWidget);
|
||||||
expect(find.text('implementer'), findsOneWidget);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
find.text(
|
find.text(
|
||||||
'partial (1 files), 1 skipped, 2 omitted · Excluded protected files.',
|
'partial (1 file), 1 skipped, 2 omitted · Excluded protected files.',
|
||||||
),
|
),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
@@ -157,7 +157,7 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(find.text('implementer'), findsNothing);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
// The reviewer's first visit is Visit 1, not the run-wide step ordinal 2.
|
// The reviewer's first visit is Visit 1, not the run-wide step ordinal 2.
|
||||||
expect(find.text('Visit 1 · failed'), findsOneWidget);
|
expect(find.text('Visit 1 · failed'), findsOneWidget);
|
||||||
expect(find.text('Visit 2 · failed'), findsNothing);
|
expect(find.text('Visit 2 · failed'), findsNothing);
|
||||||
@@ -205,18 +205,18 @@ void main() {
|
|||||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
// The reviewer's first recorded visit is Visit 1 too.
|
// The reviewer's first recorded visit is Visit 1 too.
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('implementer'), findsOneWidget);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(find.text('Visit 2 · completed'), findsOneWidget);
|
expect(find.text('Visit 2 · completed'), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
// The resumed reviewer visit records control.visit 6.
|
// The resumed reviewer visit records control.visit 6.
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
expect(find.text('Visit 6 · completed'), findsOneWidget);
|
expect(find.text('Visit 6 · completed'), findsOneWidget);
|
||||||
expect(find.text('Visit 3 · completed'), findsNothing);
|
expect(find.text('Visit 3 · completed'), findsNothing);
|
||||||
expect(find.text('Visit 4 · completed'), findsNothing);
|
expect(find.text('Visit 4 · completed'), findsNothing);
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ void main() {
|
|||||||
expect(parsed.files.map((entry) => entry.path), ['x']);
|
expect(parsed.files.map((entry) => entry.path), ['x']);
|
||||||
expect(
|
expect(
|
||||||
fileChangesSummary(parsed),
|
fileChangesSummary(parsed),
|
||||||
'partial (1 files), 2 skipped, 1 omitted · Excluded protected files.',
|
'partial (1 file), 2 skipped, 1 omitted · Excluded protected files.',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void main() {
|
|||||||
// change as the operator pages.
|
// change as the operator pages.
|
||||||
expect(find.text('3 files changed'), findsOneWidget);
|
expect(find.text('3 files changed'), findsOneWidget);
|
||||||
expect(find.text('1 of 2'), findsOneWidget);
|
expect(find.text('1 of 2'), findsOneWidget);
|
||||||
expect(find.text('implementer'), findsOneWidget);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
expect(find.text('lib/a.dart'), findsOneWidget);
|
expect(find.text('lib/a.dart'), findsOneWidget);
|
||||||
expect(find.text('lib/c.dart'), findsNothing);
|
expect(find.text('lib/c.dart'), findsNothing);
|
||||||
@@ -52,7 +52,7 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
// The shown page keeps its own visit identity in the heading.
|
// The shown page keeps its own visit identity in the heading.
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
expect(find.text('lib/c.dart'), findsOneWidget);
|
expect(find.text('lib/c.dart'), findsOneWidget);
|
||||||
expect(find.text('lib/a.dart'), findsNothing);
|
expect(find.text('lib/a.dart'), findsNothing);
|
||||||
@@ -62,7 +62,7 @@ void main() {
|
|||||||
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
|
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(find.text('implementer'), findsOneWidget);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(find.text('lib/a.dart'), findsOneWidget);
|
expect(find.text('lib/a.dart'), findsOneWidget);
|
||||||
expect(find.text('lib/c.dart'), findsNothing);
|
expect(find.text('lib/c.dart'), findsNothing);
|
||||||
expect(find.text('1 of 2'), findsOneWidget);
|
expect(find.text('1 of 2'), findsOneWidget);
|
||||||
@@ -104,11 +104,11 @@ void main() {
|
|||||||
// The disabled Next is inert; the page stays on the last visit.
|
// The disabled Next is inert; the page stays on the last visit.
|
||||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
|
|
||||||
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
|
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('implementer'), findsOneWidget);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(previous().onPressed, isNull);
|
expect(previous().onPressed, isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ void main() {
|
|||||||
findsNothing,
|
findsNothing,
|
||||||
);
|
);
|
||||||
// The single visit still keeps its identity heading.
|
// The single visit still keeps its identity heading.
|
||||||
expect(find.text('implementer'), findsOneWidget);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
expect(find.text('lib/only.dart'), findsOneWidget);
|
expect(find.text('lib/only.dart'), findsOneWidget);
|
||||||
});
|
});
|
||||||
@@ -154,12 +154,12 @@ void main() {
|
|||||||
await tester.pumpWidget(materialHost(ChangesViewer(steps: first)));
|
await tester.pumpWidget(materialHost(ChangesViewer(steps: first)));
|
||||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
|
|
||||||
await tester.pumpWidget(materialHost(ChangesViewer(steps: second)));
|
await tester.pumpWidget(materialHost(ChangesViewer(steps: second)));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
expect(find.text('implementer'), findsOneWidget);
|
expect(find.text('implementer'), findsNothing);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
expect(find.byKey(ChangesVisitPager.previousKey), findsNothing);
|
expect(find.byKey(ChangesVisitPager.previousKey), findsNothing);
|
||||||
});
|
});
|
||||||
@@ -187,7 +187,7 @@ void main() {
|
|||||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
expect(find.text('lib/c.dart'), findsOneWidget);
|
expect(find.text('lib/c.dart'), findsOneWidget);
|
||||||
});
|
});
|
||||||
@@ -210,7 +210,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('reviewer'), findsOneWidget);
|
expect(find.text('reviewer'), findsNothing);
|
||||||
expect(
|
expect(
|
||||||
tester
|
tester
|
||||||
.widget<CupertinoButton>(find.byKey(ChangesVisitPager.nextKey))
|
.widget<CupertinoButton>(find.byKey(ChangesVisitPager.nextKey))
|
||||||
|
|||||||
@@ -54,61 +54,64 @@ TextStyle _styleOf(WidgetTester tester, String text) =>
|
|||||||
tester.renderObject<RenderParagraph>(find.textContaining(text)).text.style!;
|
tester.renderObject<RenderParagraph>(find.textContaining(text)).text.style!;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('relative recency uses the web wording and never invents a time', () {
|
test(
|
||||||
final now = DateTime(2026, 10, 22, 12);
|
'relative recency uses shared compact wording and never invents a time',
|
||||||
final from = now.subtract;
|
() {
|
||||||
|
final now = DateTime(2026, 10, 22, 12);
|
||||||
|
final from = now.subtract;
|
||||||
|
|
||||||
expect(relativeChatSessionTime(null, now: now), '');
|
expect(relativeChatSessionTime(null, now: now), '');
|
||||||
expect(relativeChatSessionTime(0, now: now), '');
|
expect(relativeChatSessionTime(0, now: now), '');
|
||||||
expect(
|
expect(
|
||||||
relativeChatSessionTime(now.millisecondsSinceEpoch, now: now),
|
relativeChatSessionTime(now.millisecondsSinceEpoch, now: now),
|
||||||
'just now',
|
'just now',
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
relativeChatSessionTime(
|
relativeChatSessionTime(
|
||||||
from(const Duration(minutes: 5)).millisecondsSinceEpoch,
|
from(const Duration(minutes: 5)).millisecondsSinceEpoch,
|
||||||
now: now,
|
now: now,
|
||||||
),
|
),
|
||||||
'5 min ago',
|
'5m',
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
relativeChatSessionTime(
|
relativeChatSessionTime(
|
||||||
from(const Duration(hours: 3)).millisecondsSinceEpoch,
|
from(const Duration(hours: 3)).millisecondsSinceEpoch,
|
||||||
now: now,
|
now: now,
|
||||||
),
|
),
|
||||||
'3 hr ago',
|
'3h',
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
relativeChatSessionTime(
|
relativeChatSessionTime(
|
||||||
from(const Duration(hours: 25)).millisecondsSinceEpoch,
|
from(const Duration(hours: 25)).millisecondsSinceEpoch,
|
||||||
now: now,
|
now: now,
|
||||||
),
|
),
|
||||||
'1 day ago',
|
'1d',
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
relativeChatSessionTime(
|
relativeChatSessionTime(
|
||||||
from(const Duration(days: 3)).millisecondsSinceEpoch,
|
from(const Duration(days: 3)).millisecondsSinceEpoch,
|
||||||
now: now,
|
now: now,
|
||||||
),
|
),
|
||||||
'3 days ago',
|
'3d',
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
relativeChatSessionTime(
|
relativeChatSessionTime(
|
||||||
DateTime(2026, 10, 1, 9).millisecondsSinceEpoch,
|
DateTime(2026, 10, 1, 9).millisecondsSinceEpoch,
|
||||||
now: now,
|
now: now,
|
||||||
),
|
),
|
||||||
'1 Oct',
|
'1 Oct',
|
||||||
);
|
);
|
||||||
// The web formats with `Intl.DateTimeFormat('en-GB', …)`, whose short
|
// The web formats with `Intl.DateTimeFormat('en-GB', …)`, whose short
|
||||||
// September is `Sept`; its own test asserts `12 Sept`.
|
// September is `Sept`; its own test asserts `12 Sept`.
|
||||||
expect(
|
expect(
|
||||||
relativeChatSessionTime(
|
relativeChatSessionTime(
|
||||||
DateTime(2026, 9, 12, 9).millisecondsSinceEpoch,
|
DateTime(2026, 9, 12, 9).millisecondsSinceEpoch,
|
||||||
now: now,
|
now: now,
|
||||||
),
|
),
|
||||||
'12 Sept',
|
'12 Sep',
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('the subtitle and status come only from the row', () {
|
test('the subtitle and status come only from the row', () {
|
||||||
expect(
|
expect(
|
||||||
@@ -173,7 +176,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final title = tester.getRect(find.textContaining('Unread chat'));
|
final title = tester.getRect(find.textContaining('Unread chat'));
|
||||||
final time = tester.getRect(find.text('5 min ago'));
|
final time = tester.getRect(find.text('5m'));
|
||||||
final subtitle = tester.getRect(find.text('model-a · /work'));
|
final subtitle = tester.getRect(find.text('model-a · /work'));
|
||||||
final avatar = tester.getRect(
|
final avatar = tester.getRect(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
@@ -197,10 +200,10 @@ void main() {
|
|||||||
expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w600);
|
expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w600);
|
||||||
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
|
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
|
||||||
final accent = CupertinoTheme.of(
|
final accent = CupertinoTheme.of(
|
||||||
tester.element(find.text('5 min ago')),
|
tester.element(find.text('5m')),
|
||||||
).primaryColor;
|
).primaryColor;
|
||||||
expect(_styleOf(tester, '5 min ago').color, accent);
|
expect(_styleOf(tester, '5m').color, accent);
|
||||||
expect(_styleOf(tester, '2 hr ago').color, isNot(accent));
|
expect(_styleOf(tester, '2h').color, isNot(accent));
|
||||||
|
|
||||||
// Starred shows a small star by the title; running a badge on the avatar.
|
// Starred shows a small star by the title; running a badge on the avatar.
|
||||||
expect(
|
expect(
|
||||||
@@ -265,7 +268,7 @@ void main() {
|
|||||||
expect(subtitle.didExceedMaxLines, isTrue);
|
expect(subtitle.didExceedMaxLines, isTrue);
|
||||||
|
|
||||||
// The time and the Closed word stay inside their row.
|
// The time and the Closed word stay inside their row.
|
||||||
for (final (row, word) in [('s1', '3 days ago'), ('c1', 'Closed')]) {
|
for (final (row, word) in [('s1', '3d'), ('c1', 'Closed')]) {
|
||||||
expect(
|
expect(
|
||||||
tester.getRect(find.textContaining(word)).right,
|
tester.getRect(find.textContaining(word)).right,
|
||||||
lessThanOrEqualTo(
|
lessThanOrEqualTo(
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void main() {
|
|||||||
], isUnseen: (session) => session['id'] == 's1');
|
], isUnseen: (session) => session['id'] == 's1');
|
||||||
|
|
||||||
final title = tester.getRect(find.text('Unread chat'));
|
final title = tester.getRect(find.text('Unread chat'));
|
||||||
final time = tester.getRect(find.text('5 min ago'));
|
final time = tester.getRect(find.text('5m'));
|
||||||
expect(time.left, greaterThan(title.right));
|
expect(time.left, greaterThan(title.right));
|
||||||
expect(time.center.dy, closeTo(title.center.dy, 2));
|
expect(time.center.dy, closeTo(title.center.dy, 2));
|
||||||
expect(
|
expect(
|
||||||
@@ -90,13 +90,10 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Unread: bold title, accent time and a dot; the read row stays muted.
|
// Unread: bold title, accent time and a dot; the read row stays muted.
|
||||||
final scheme = Theme.of(tester.element(find.text('5 min ago'))).colorScheme;
|
final scheme = Theme.of(tester.element(find.text('5m'))).colorScheme;
|
||||||
|
expect(tester.widget<Text>(find.text('5m')).style?.color, scheme.primary);
|
||||||
expect(
|
expect(
|
||||||
tester.widget<Text>(find.text('5 min ago')).style?.color,
|
tester.widget<Text>(find.text('2h')).style?.color,
|
||||||
scheme.primary,
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
tester.widget<Text>(find.text('2 hr ago')).style?.color,
|
|
||||||
scheme.onSurfaceVariant,
|
scheme.onSurfaceVariant,
|
||||||
);
|
);
|
||||||
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
|
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
|
||||||
@@ -183,7 +180,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(subtitle.maxLines, 1);
|
expect(subtitle.maxLines, 1);
|
||||||
expect(subtitle.didExceedMaxLines, isTrue);
|
expect(subtitle.didExceedMaxLines, isTrue);
|
||||||
for (final (row, word) in [('s1', '3 days ago'), ('c1', 'Closed')]) {
|
for (final (row, word) in [('s1', '3d'), ('c1', 'Closed')]) {
|
||||||
expect(
|
expect(
|
||||||
tester.getRect(find.textContaining(word)).right,
|
tester.getRect(find.textContaining(word)).right,
|
||||||
lessThanOrEqualTo(
|
lessThanOrEqualTo(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import 'fixtures.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('formatting', () {
|
group('formatting', () {
|
||||||
test('renders local timestamps, durations and ages', () {
|
test('renders local timestamps and bounded durations', () {
|
||||||
expect(formatLocalTimestamp('2026-10-17T21:26:00'), '17 Oct 21:26');
|
expect(formatLocalTimestamp('2026-10-17T21:26:00'), '17 Oct 21:26');
|
||||||
expect(formatLocalTimestamp(''), isNull);
|
expect(formatLocalTimestamp(''), isNull);
|
||||||
expect(formatLocalTimestamp('not a time'), isNull);
|
expect(formatLocalTimestamp('not a time'), isNull);
|
||||||
@@ -15,15 +15,10 @@ void main() {
|
|||||||
expect(formatDuration(45), '45s');
|
expect(formatDuration(45), '45s');
|
||||||
expect(formatDuration(125), '2m 5s');
|
expect(formatDuration(125), '2m 5s');
|
||||||
expect(formatDuration(3720), '1h 2m');
|
expect(formatDuration(3720), '1h 2m');
|
||||||
|
expect(formatDuration(840000), '9d 17h');
|
||||||
expect(formatDuration(-4), '0s');
|
expect(formatDuration(-4), '0s');
|
||||||
expect(stageCountText(1), '1 stage');
|
expect(stageCountText(1), '1 stage');
|
||||||
expect(stageCountText(2), '2 stages');
|
expect(stageCountText(2), '2 stages');
|
||||||
final now = DateTime(2026, 10, 17, 21, 30);
|
|
||||||
expect(formatRanAgo('2026-10-17T21:29:40', now), 'just now');
|
|
||||||
expect(formatRanAgo('2026-10-17T21:25:00', now), '5m ago');
|
|
||||||
expect(formatRanAgo('2026-10-17T19:30:00', now), '2h ago');
|
|
||||||
expect(formatRanAgo('2026-10-14T21:30:00', now), '3d ago');
|
|
||||||
expect(formatRanAgo('2026-10-17T22:00:00', now), 'just now');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('maps the server status vocabulary and unknown values', () {
|
test('maps the server status vocabulary and unknown values', () {
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ void main() {
|
|||||||
await pumpDeepLink(tester, RunDetailTestPlatform.material, stage: 'plan');
|
await pumpDeepLink(tester, RunDetailTestPlatform.material, stage: 'plan');
|
||||||
|
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
expectVisitHeading(tester, 'plan', 5);
|
expectVisitHeading(tester, 'plan', 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('a Graph click opens the same latest visit as the stage route', (
|
testWidgets('a Graph click opens the same latest visit as the stage route', (
|
||||||
@@ -195,7 +195,7 @@ void main() {
|
|||||||
// The web client's graph click takes the last visit in sequence order, not
|
// The web client's graph click takes the last visit in sequence order, not
|
||||||
// the last row in reply order, so both entry points agree.
|
// the last row in reply order, so both entry points agree.
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
expectVisitHeading(tester, 'plan', 5);
|
expectVisitHeading(tester, 'plan', 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('an out-of-range visit is clamped to the stage last visit', (
|
testWidgets('an out-of-range visit is clamped to the stage last visit', (
|
||||||
@@ -209,7 +209,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
expectVisitHeading(tester, 'plan', 5);
|
expectVisitHeading(tester, 'plan', 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('a declared but unvisited stage selects its graph node', (
|
testWidgets('a declared but unvisited stage selects its graph node', (
|
||||||
@@ -259,7 +259,7 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
expectVisitHeading(tester, 'plan', 5);
|
expectVisitHeading(tester, 'plan', 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('a route change applies its visit and a plain route closes it', (
|
testWidgets('a route change applies its visit and a plain route closes it', (
|
||||||
@@ -301,7 +301,7 @@ void main() {
|
|||||||
|
|
||||||
rebuild(() => visit = 1);
|
rebuild(() => visit = 1);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expectVisitHeading(tester, 'plan', 5);
|
expectVisitHeading(tester, 'plan', 2);
|
||||||
|
|
||||||
rebuild(() => stage = null);
|
rebuild(() => stage = null);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ Finder runDetailText(String text) => find.descendant(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// The stage page's bar names the stage over its visit (and run): the title
|
/// The stage page's bar names the stage over its visit (and run): the title
|
||||||
/// is keyed `run-visit-title` and the subtitle starts `Visit <sequence>`.
|
/// is keyed `run-visit-title` and the subtitle starts `Visit <stage visit>`.
|
||||||
void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
|
void expectVisitHeading(WidgetTester tester, String stage, num visit) {
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
final heading = find.byKey(const Key('run-visit-title'));
|
final heading = find.byKey(const Key('run-visit-title'));
|
||||||
expect(
|
expect(
|
||||||
@@ -25,7 +25,7 @@ void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
|
|||||||
expect(
|
expect(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
of: heading,
|
of: heading,
|
||||||
matching: find.textContaining(RegExp('^Visit $sequence( ·|\$)')),
|
matching: find.textContaining(RegExp('^Visit $visit( ·|\$)')),
|
||||||
),
|
),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ void main() {
|
|||||||
|
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
|
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
|
||||||
expect(find.byType(RunTimelineList), findsOneWidget);
|
expect(find.byType(RunTimelineList), findsOneWidget);
|
||||||
expect(find.text('plan · visit 1'), findsOneWidget);
|
expect(find.text('plan · Visit 1'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('${platform.name} visit pane at 320 with 2x dark text', (
|
testWidgets('${platform.name} visit pane at 320 with 2x dark text', (
|
||||||
|
|||||||
@@ -201,17 +201,17 @@ void main() {
|
|||||||
matching: find.byType(Scrollable),
|
matching: find.byType(Scrollable),
|
||||||
);
|
);
|
||||||
await tester.scrollUntilVisible(
|
await tester.scrollUntilVisible(
|
||||||
find.textContaining('build · visit 3'),
|
find.textContaining('build · Visit 1').last,
|
||||||
200,
|
200,
|
||||||
scrollable: timelineScroll,
|
scrollable: timelineScroll,
|
||||||
);
|
);
|
||||||
expect(find.textContaining('build · visit 3'), findsOneWidget);
|
expect(find.textContaining('build · Visit 1').last, findsOneWidget);
|
||||||
await tester.scrollUntilVisible(
|
await tester.scrollUntilVisible(
|
||||||
find.textContaining('test · visit 4'),
|
find.textContaining('test · Visit 1').last,
|
||||||
200,
|
200,
|
||||||
scrollable: timelineScroll,
|
scrollable: timelineScroll,
|
||||||
);
|
);
|
||||||
expect(find.textContaining('test · visit 4'), findsOneWidget);
|
expect(find.textContaining('test · Visit 1').last, findsOneWidget);
|
||||||
|
|
||||||
final before = tester
|
final before = tester
|
||||||
.state<ScrollableState>(timelineScroll)
|
.state<ScrollableState>(timelineScroll)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
Rect at(String text) => tester.getRect(find.text(text));
|
Rect at(String text) => tester.getRect(find.text(text));
|
||||||
final title = at('Ship the release notes');
|
final title = at('Ship the release notes');
|
||||||
final age = at('12h ago');
|
final age = at('12h');
|
||||||
final subtitle = at('release · 2m 5s · 3 steps');
|
final subtitle = at('release · 2m 5s · 3 steps');
|
||||||
|
|
||||||
expect(age.center.dy, moreOrLessEquals(title.center.dy));
|
expect(age.center.dy, moreOrLessEquals(title.center.dy));
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
expectVisitHeading(tester, 'build', 2);
|
expectVisitHeading(tester, 'build', 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ void main() {
|
|||||||
await _openVisitChanges(tester);
|
await _openVisitChanges(tester);
|
||||||
|
|
||||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||||
// The body keeps the landed viewer's own identity for that visit.
|
// The stage is already named in the page bar, so Changes does not repeat it.
|
||||||
expect(
|
expect(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
of: find.byType(ChangesViewer),
|
of: find.byType(ChangesViewer),
|
||||||
matching: find.text('plan'),
|
matching: find.text('plan'),
|
||||||
),
|
),
|
||||||
findsOneWidget,
|
findsNothing,
|
||||||
);
|
);
|
||||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||||
expect(find.text('lib/plan.dart'), findsOneWidget);
|
expect(find.text('lib/plan.dart'), findsOneWidget);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ void main() {
|
|||||||
// Two lines per row: the name with its next run, then the timer
|
// Two lines per row: the name with its next run, then the timer
|
||||||
// and pinned pipeline version. The editor holds the rest.
|
// and pinned pipeline version. The editor holds the rest.
|
||||||
expect(find.text('Research batteries'), findsOneWidget);
|
expect(find.text('Research batteries'), findsOneWidget);
|
||||||
expect(find.text('22 Oct 09:00'), findsOneWidget);
|
expect(find.text('22 Oct'), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
find.text('Every 24h · mon, wed · Pipeline 4 · v2'),
|
find.text('Every 24h · mon, wed · Pipeline 4 · v2'),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
|
|||||||
@@ -90,24 +90,23 @@ void main() {
|
|||||||
|
|
||||||
final version = searchRowView(versionHit(), 'release');
|
final version = searchRowView(versionHit(), 'release');
|
||||||
expect(version.title, 'pipeline 9 · v2');
|
expect(version.title, 'pipeline 9 · v2');
|
||||||
expect(version.secondary, startsWith('content abc · '));
|
expect(version.secondary, 'content abc');
|
||||||
expect(version.recency, isNotNull);
|
expect(version.recency, isNotNull);
|
||||||
|
|
||||||
final run = searchRowView(runHit(), 'release');
|
final run = searchRowView(runHit(), 'release');
|
||||||
expect(run.title, 'run #11 · release');
|
expect(run.title, 'Run 11 · release');
|
||||||
expect(run.secondary, startsWith('succeeded · '));
|
expect(run.secondary, 'succeeded');
|
||||||
expect(run.secondary.split(' · '), hasLength(2));
|
|
||||||
|
|
||||||
final unnamed = searchRowView(runHit({'pipeline_name': ''}), '');
|
final unnamed = searchRowView(runHit({'pipeline_name': ''}), '');
|
||||||
expect(unnamed.title, 'run #11');
|
expect(unnamed.title, 'Run 11');
|
||||||
|
|
||||||
final step = searchRowView(stepHit({'target': '#success'}), '');
|
final step = searchRowView(stepHit({'target': '#success'}), '');
|
||||||
expect(step.title, 'run #11 · builder visit 2');
|
expect(step.title, 'Run 11 · builder visit 2');
|
||||||
expect(step.secondary, 'success · → #success');
|
expect(step.secondary, 'success · → #success');
|
||||||
|
|
||||||
final artifact = searchRowView(artifactHit(), 'notes');
|
final artifact = searchRowView(artifactHit(), 'notes');
|
||||||
expect(artifact.title, 'notes.md');
|
expect(artifact.title, 'notes.md');
|
||||||
expect(artifact.secondary, 'run #11 · step 4 · text/markdown · 2.0 KiB');
|
expect(artifact.secondary, 'Run 11 · step 4 · text/markdown · 2.0 KiB');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('a field snippet marks the first case-insensitive query occurrence', () {
|
test('a field snippet marks the first case-insensitive query occurrence', () {
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/text/relative_time.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
final now = DateTime(2026, 10, 22, 12);
|
||||||
|
|
||||||
|
test('formats compact past and future list-row times', () {
|
||||||
|
expect(formatRelativeTime(now, now: now), 'just now');
|
||||||
|
expect(
|
||||||
|
formatRelativeTime(now.subtract(const Duration(minutes: 5)), now: now),
|
||||||
|
'5m',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
formatRelativeTime(now.subtract(const Duration(hours: 3)), now: now),
|
||||||
|
'3h',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
formatRelativeTime(now.subtract(const Duration(days: 3)), now: now),
|
||||||
|
'3d',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
formatRelativeTime(now.subtract(const Duration(days: 8)), now: now),
|
||||||
|
'14 Oct',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
formatRelativeTime(now.add(const Duration(hours: 2)), now: now),
|
||||||
|
'in 2h',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parses timestamps and omits unusable values', () {
|
||||||
|
expect(formatRelativeTimestamp('2026-10-22T11:55:00', now: now), '5m');
|
||||||
|
expect(formatRelativeTimestamp('', now: now), isNull);
|
||||||
|
expect(formatRelativeTimestamp('not a time', now: now), isNull);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user