Files
pipelines/app/lib/features/pipelines/pipeline_query.dart
T
alan a44f31b989 feat(app): add native pipelines list and detail screen
Read-only Pipelines screen for the Flutter client:

- list_pipelines and list_runs with a last-run join, plus get_pipeline
  with an explicit version (0 = latest); no mutation requests.
- Name, run-presence, last-run-status and schedule filters; six sort
  orders; clear filters; truthful loading, empty and error states.
- Detail Summary, selectable Source and version history with selection
  and return to latest.
- Sequenced list/detail requests so stale replies cannot replace a newer
  selection or open a cleared one; refresh keeps the selected pipeline
  and version.
- Material controls on Android/desktop and Cupertino on iOS; a
  per-label segmented tab row at narrow widths and scaled text, with the
  native control kept wherever an equal share fits.
- Fixture probe entry and Chrome scripts for the rendered evidence;
  widget tests cover filters, sorting, formatting, sequencing, layout
  and the tab row.

Graph rendering remains P2: the Graph tab states that it is pending and
exposes a host hook. PipelinesScreen is not yet registered in the shell.

Evidence and limits: app/notes/P1.md.
2026-10-21 19:09:29 +01:00

93 lines
2.5 KiB
Dart

import 'pipeline_format.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;
/// `2h ago · 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: formatRanAgo(run.createdAt, 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);
}
/// `id {id} · v{version} · {N stages}`.
String pipelineSubtitle(PipelineSummary pipeline) =>
'id ${pipeline.id} · v${pipeline.version} · '
'${stageCountText(pipeline.stages)}';
/// `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) ?? '',
),
];