Files
pipelines/app/lib/features/pipelines/pipeline_query.dart
T
alan a6db4ba20e App: run tabs under the header on wide layouts, stable Artifacts tab, spelled-out pipeline status, shared list selection, code block header and edge fades
- Run detail: on a wide window (>= 840, pane >= 600) the tabs are Material
  segments under the run header; phones keep the floating bottom bar.
  Artifacts is always a tab, badged with its count and disabled with 0 (its
  tooltip says why), so Changes never moves.
- Pipelines list: 'Failed · last run 19 Oct' beside the status dot; facts on
  the next line; compact rows keep 'Failed · 19 Oct'.
- Settings: Disconnect is outlined beside a tonal Reconnect.
- Lists: one selection style (tonal fill plus one leading accent bar) for
  runs, pipelines and chats; chat's border, fill and pointer removed.
- Transcript: overflowing blocks fade at the edge with a chevron instead of
  a 'Scroll horizontally' line (semantics hint kept); code blocks get a
  header strip with language and Copy; lighter light-mode code fill.
- Runs list: rows under a day heading show only the time of day.
- Artifact search reveal re-centres once the lazy list's extent settles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:55:50 +00:00

113 lines
3.4 KiB
Dart

import 'pipeline_format.dart';
import '../../ui/text/relative_time.dart';
import 'pipeline_models.dart';
export 'pipeline_filter.dart';
export 'pipeline_sort.dart';
/// One Summary key/value row.
class PipelineField {
const PipelineField(this.key, this.value, {this.monospace = false});
final String key;
final String value;
final bool monospace;
}
/// The last-run values a row displays.
class RunBadge {
const RunBadge({
required this.runId,
required this.state,
required this.ranAgo,
required this.duration,
});
final int runId;
final String state;
final String? ranAgo;
final String? duration;
/// When the last run started, said as such for a list row: `last run
/// 19 Oct`, `last run 2h ago`, `last run just now`. Null without a time.
String? get lastRun {
final ago = ranAgo;
if (ago == null || ago.isEmpty) return null;
// `5m`, `2h`, `3d` are ages; a date or `just now` reads as it is.
final age = RegExp(r'^\d+[mhd]$').hasMatch(ago) ? '$ago ago' : ago;
return 'last run $age';
}
/// `2h · 1m 5s · run 42`; missing fragments are omitted.
String get metaLine => [
ranAgo,
duration,
'run $runId',
].whereType<String>().where((fragment) => fragment.isNotEmpty).join(' · ');
}
RunBadge runBadge(PipelineRun run, DateTime now) {
final duration = run.executing
? _liveDuration(run, now)
: _finishedDuration(run);
return RunBadge(
runId: run.id,
state: runStateOf(run.status),
ranAgo: formatRelativeTimestamp(run.createdAt, now: now),
duration: duration,
);
}
String? _liveDuration(PipelineRun run, DateTime now) {
final start = parseInstant(run.createdAt);
if (start == null) return null;
final seconds = now.difference(start).inSeconds;
return formatDuration(seconds < 0 ? 0 : seconds);
}
String? _finishedDuration(PipelineRun run) {
final seconds = durationSeconds(run.createdAt, run.finishedAt);
return seconds == null ? null : formatDuration(seconds);
}
/// The web's version label for a pipeline: `v{n}`.
String pipelineVersionLabel(PipelineSummary pipeline) => 'v${pipeline.version}';
/// The row's flow summary: the web's `{N stages}` label for the recorded stage
/// count. A summary without `stages` falls back to its recorded `shape` flow,
/// so a count is never taken from an unrecorded flow.
String pipelineStageSummary(PipelineSummary pipeline) =>
stageCountText(pipeline.rowStageCount);
/// `id {id} · v{version} · {N stages}`.
String pipelineSubtitle(PipelineSummary pipeline) =>
'id ${pipeline.id} · ${pipelineVersionLabel(pipeline)} · '
'${pipelineStageSummary(pipeline)}';
/// `updated d MMM HH:mm`, or null when the timestamp is unusable.
String? pipelineUpdatedLine(PipelineSummary pipeline) {
final formatted = formatLocalTimestamp(pipeline.updatedAt);
return formatted == null ? null : 'updated $formatted';
}
/// The Summary tab's rows in the app's order.
List<PipelineField> pipelineSummaryFields(PipelineDetail detail) => [
PipelineField('Content hash', detail.contentHash, monospace: true),
PipelineField(
'Latest version',
detail.latestVersion > 0 ? 'v${detail.latestVersion}' : '',
),
PipelineField(
'Version created',
formatLocalTimestamp(detail.versionCreatedAt) ?? '',
),
PipelineField(
'Pipeline created',
formatLocalTimestamp(detail.createdAt) ?? '',
),
PipelineField(
'Pipeline updated',
formatLocalTimestamp(detail.updatedAt) ?? '',
),
];