Merge branch 'worktree-agent-aa9ed772f90c7c7b3'

This commit is contained in:
2026-12-02 20:20:08 +00:00
68 changed files with 1719 additions and 156 deletions
+9 -1
View File
@@ -961,6 +961,7 @@ class _PipelinesAppState extends State<PipelinesApp>
server: widget.server,
onBack: _delegate.closeSchedules,
onOpenPipeline: (id) => _delegate.goTo(AppRoute.pipeline(id)),
onSelectDestination: _selectDestination,
);
Widget _buildTemplates(BuildContext context) => TemplatesDestination(
@@ -1137,6 +1138,7 @@ class _PipelinesAppState extends State<PipelinesApp>
connection: _session,
connected: () => _session.connected,
gateway: _session.client,
onOpenConnection: () => _delegate.goTo(AppRoute.settings),
child: PipelinesDestination(
session: _session,
server: widget.server,
@@ -1242,7 +1244,13 @@ class _PipelinesAppState extends State<PipelinesApp>
deliveryServiceController: _deliveryController,
// The Help and about row replays the first-run walkthrough. It only
// shows it; the device's seen record is left alone.
onShowWalkthrough: () => unawaited(showFirstRunWalkthrough(context)),
onShowWalkthrough: () => unawaited(
showFirstRunWalkthrough(
context,
connected: _session.connected,
onOpenConnection: () => _delegate.goTo(AppRoute.settings),
),
),
),
},
);
+37 -1
View File
@@ -8,6 +8,8 @@ import '../features/schedules/ui/list/schedule_list_controller.dart';
import '../features/schedules/ui/list/schedule_list_toolbar.dart'
show ScheduleRefreshAction;
import '../features/schedules/ui/list/schedule_list_view.dart';
import '../shell/destination.dart';
import '../shell/navigation_rail.dart';
import 'app_session.dart';
import 'server_endpoint.dart';
@@ -26,8 +28,13 @@ class SchedulesDestination extends StatefulWidget {
required this.server,
required this.onBack,
required this.onOpenPipeline,
this.onSelectDestination,
});
/// Selects a destination from the rail this page keeps on a wide window,
/// so Schedules does not hide the app's navigation. Null draws no rail.
final ValueChanged<AppDestination>? onSelectDestination;
final AppSession session;
final ServerEndpoint server;
final VoidCallback onBack;
@@ -97,7 +104,36 @@ class _SchedulesDestinationState extends State<SchedulesDestination> {
// finished read would otherwise stay on `Loading schedules…`.
return AnimatedBuilder(
animation: Listenable.merge([widget.session, _controller]),
builder: (context, _) => _page(),
builder: (context, _) => _withRail(context, _page()),
);
}
/// On a window wide enough for the rail, the page keeps it at its leading
/// edge (Settings selected, since Schedules sits under it).
Widget _withRail(BuildContext context, Widget page) {
final select = widget.onSelectDestination;
if (select == null || !showsNavigationRail(context)) return page;
final padding = MediaQuery.paddingOf(context);
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Material(
child: ShellNavigationRail(
selected: AppDestination.settings,
icon: (destination) => Icon(destinationDetails(destination).icon),
onSelected: select,
padding: EdgeInsets.only(top: padding.top, bottom: padding.bottom),
),
),
const VerticalDivider(width: 1, thickness: 1),
Expanded(
child: MediaQuery.removePadding(
context: context,
removeLeft: true,
child: page,
),
),
],
);
}
+66
View File
@@ -0,0 +1,66 @@
import 'dart:async' show TimeoutException;
import 'error_reason.dart';
import 'transport/connection_state.dart';
/// The common kinds of failure an operator can act on.
enum ErrorAdviceKind { notConnected, serverTooOld, permission, timeout }
/// What to do about a failure, as one sentence, and the raw detail it came
/// from (kept available behind the sentence, never replaced by it).
typedef ErrorAdvice = ({ErrorAdviceKind kind, String sentence, String detail});
/// Maps a request failure (an exception or the message a controller kept) to
/// a sentence saying what to do, or null when it is none of the common kinds
/// (the raw message then stands on its own).
ErrorAdvice? errorAdvice(Object? error) {
if (error == null) return null;
final detail = describeErrorReason(error, fallback: 'Unknown error');
final kind = errorAdviceKind(error);
if (kind == null) return null;
return (kind: kind, sentence: errorAdviceSentence(kind), detail: detail);
}
/// The failure's kind, from its type or its words.
ErrorAdviceKind? errorAdviceKind(Object error) {
if (error is NotConnectedError) return ErrorAdviceKind.notConnected;
if (error is TimeoutException) return ErrorAdviceKind.timeout;
if (error is ProtocolError && error.code == 'elevation_required') {
return ErrorAdviceKind.permission;
}
final text = '$error'.toLowerCase();
if (_tooOld.hasMatch(text)) return ErrorAdviceKind.serverTooOld;
if (_permission.hasMatch(text)) return ErrorAdviceKind.permission;
if (_timeout.hasMatch(text)) return ErrorAdviceKind.timeout;
if (_notConnected.hasMatch(text)) return ErrorAdviceKind.notConnected;
return null;
}
String errorAdviceSentence(ErrorAdviceKind kind) => switch (kind) {
ErrorAdviceKind.notConnected =>
'Not connected to the server. Check the connection in Settings, then '
'try again.',
ErrorAdviceKind.serverTooOld =>
'This server is too old for this feature. Update the Pipelines server, '
'then try again.',
ErrorAdviceKind.permission =>
'The server refused this for lack of permission. Sign in again in '
'Settings › Connection, then try again.',
ErrorAdviceKind.timeout =>
'The server did not answer in time. Check the connection, then try '
'again.',
};
final _tooOld = RegExp(
r'unknown (command|message|request)|unsupported (command|message|request)',
);
final _permission = RegExp(
r'permission denied|unauthori[sz]ed|forbidden|not signed in|'
r'sign-in required|authentication (required|failed)|elevation_required|'
r'\b401\b|\b403\b',
);
final _timeout = RegExp(r'timed out|timeout');
final _notConnected = RegExp(
r'not connected|connection (closed|replaced|refused|lost|failed)|'
r'websocket|failed host lookup|network is unreachable|no saved machine',
);
@@ -7,6 +7,7 @@ import '../ui/artifact_viewer_fetch.dart';
import 'artifact_file.dart';
import 'artifact_file_bridge.dart';
import 'artifact_file_controller.dart';
import '../../../ui/navigation/labelled_icon_button.dart';
/// Download and Share for one selected artifact, backed by its exact bytes.
///
@@ -222,9 +223,13 @@ class ArtifactIconAction extends StatelessWidget {
required this.icon,
required this.onPressed,
this.busy = false,
this.caption,
});
final String label;
/// The short visible word on touch; defaults to [label].
final String? caption;
final IconData icon;
final VoidCallback? onPressed;
@@ -232,6 +237,22 @@ class ArtifactIconAction extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (showsActionCaptions(context)) {
// Touch has no hover tooltip: the action is captioned.
return LabelledIconButton(
icon: icon,
label: label,
caption: caption,
onPressed: onPressed,
child: busy
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: null,
);
}
return IconButton(
tooltip: label,
constraints: GlassBarMetrics.materialConstraints(),
@@ -2,6 +2,7 @@ import '../../../core/api_gateway.dart';
import 'artifact_capture.dart';
import 'artifact_groups.dart';
import 'artifact_selection.dart';
import '../../../ui/text/plural.dart';
/// The "capture pending" wording shared by a running visit's summary and the
/// run-level empty state, so the two never spell it differently.
@@ -72,10 +73,15 @@ List<String> artifactCaptureNotes(JsonMap step) {
if (presentedArtifacts(artifactsOf(step)).isEmpty) return notes;
final capture = ArtifactCapture.fromStep(step);
if (capture.skipped > 0) {
notes.add('${capture.skipped} files excluded from artifact capture.');
notes.add(
'${countLabel(capture.skipped, 'file')} excluded from artifact capture.',
);
}
if (capture.truncated > 0) {
notes.add('${capture.truncated} files omitted by artifact capture limits.');
notes.add(
'${countLabel(capture.truncated, 'file')} omitted by artifact '
'capture limits.',
);
}
return notes;
}
@@ -130,12 +130,14 @@ class ArtifactViewerBar extends StatelessWidget {
ArtifactIconAction(
key: const Key('artifact-open'),
label: 'Open in browser',
caption: 'Open',
icon: Icons.open_in_new,
onPressed: onOpen,
),
ArtifactIconAction(
key: const Key('artifact-copy-link'),
label: 'Copy link',
caption: 'Link',
icon: Icons.link,
onPressed: onCopy,
),
@@ -144,6 +146,7 @@ class ArtifactViewerBar extends StatelessWidget {
ArtifactIconAction(
key: artifactFullscreenKey,
label: fullscreen ? 'Exit full screen' : 'Full screen',
caption: fullscreen ? 'Exit' : 'Expand',
icon: fullscreen ? Icons.fullscreen_exit : Icons.fullscreen,
onPressed: toggle,
),
@@ -151,6 +154,7 @@ class ArtifactViewerBar extends StatelessWidget {
ArtifactIconAction(
key: const Key('artifact-send-to-chat'),
label: 'Send to chat…',
caption: 'To chat',
icon: Icons.chat_outlined,
onPressed: onSendToChat!,
),
@@ -2,6 +2,7 @@ import 'change_capture.dart';
import 'file_change.dart';
import 'run_changes.dart';
import 'unified_patch.dart';
import '../../../ui/text/plural.dart';
/// The honest messages the viewer and its tests share. Spelled once, matching
/// the web client's `web/src/changes.js`.
@@ -62,7 +63,9 @@ String runChangesNote(RunChanges changes) {
if (changes.partial) {
out = partialCaptureDetail;
final caveats = <String>[];
if (changes.skipped > 0) caveats.add('${changes.skipped} files skipped');
if (changes.skipped > 0) {
caveats.add('${countLabel(changes.skipped, 'file')} skipped');
}
if (changes.omitted > 0) caveats.add('${changes.omitted} omitted');
final truncated = changes.files.where((file) => file.truncated).length;
if (truncated > 0) caveats.add('$truncated truncated');
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import '../../../../core/error_advice.dart';
import '../../../../ui/status/error_notice.dart';
import '../../domain/chat_default_name.dart';
@@ -63,8 +65,12 @@ class ChatCatalogFields extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (loading) return const Text('Loading directories…');
if (error != null) {
return _message('Unable to load chat options: $error');
if (error case final error?) {
// A common failure says what to do; its raw detail stays behind
// Details. Anything else reads as before.
return errorAdvice(error) == null
? _message(Text('Unable to load chat options: $error'))
: _message(ErrorNotice(error: error));
}
final choices = chatDirectoryChoices(directories);
String directoryLabel(String choice) =>
@@ -113,11 +119,11 @@ class ChatCatalogFields extends StatelessWidget {
);
}
Widget _message(String text) {
Widget _message(Widget text) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(text),
text,
Align(
alignment: AlignmentDirectional.centerStart,
child: TextButton(onPressed: onRetry, child: const Text('Retry')),
@@ -14,6 +14,7 @@ import '../folder_picker/folder_picker_route.dart';
import 'chat_create_dialog_frame.dart';
import 'chat_create_fields.dart';
import 'chat_prompt_chooser.dart';
import '../../../../ui/status/error_notice.dart';
/// The instructions field's helper and the creation-time model behavior.
const String chatCreateInstructionsHelper =
@@ -419,12 +420,9 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
key: const Key('chat-create-start-in'),
),
],
if (_formError != null) ...[
if (_formError case final error?) ...[
const SizedBox(height: 8),
Text(
_formError!,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
ErrorNotice(error: error),
],
],
),
@@ -0,0 +1,34 @@
import 'run_pipeline_intent.dart';
/// What a Run again pre-fills in the start-a-run form: the earlier run's
/// prompt, workspace and report requirement, and the version it ran.
///
/// The form defaults to the pipeline's latest version and offers
/// [originalVersion] as the other choice when it differs.
class RunPipelineSeed {
const RunPipelineSeed({
required this.prompt,
required this.workspace,
this.originalVersion,
this.outputFormat = RunOutputFormat.none,
});
final String prompt;
final String workspace;
final int? originalVersion;
final RunOutputFormat outputFormat;
}
/// The report requirement a run recorded (`html`, `markdown`), else none.
RunOutputFormat runOutputFormatOf(Object? wire) =>
RunOutputFormat.values.firstWhere(
(format) => format.wireValue == '${wire ?? ''}'.trim(),
orElse: () => RunOutputFormat.none,
);
/// The version choices the form offers: the latest first, then the
/// original when it is a different, real version.
List<int> runPipelineVersionChoices(int latest, int? original) => [
latest,
if (original != null && original > 0 && original != latest) original,
];
@@ -8,7 +8,9 @@ import '../../../core/api_gateway.dart';
import '../../settings/settings_store.dart';
import '../pipeline_models.dart';
import '../run_pipeline_intent.dart';
import '../run_pipeline_seed.dart';
import 'run_pipeline_fields.dart';
import 'run_pipeline_version_field.dart';
import 'run_pipeline_wording.dart';
/// Opens the native start-a-run prompt; resolves when it closes.
@@ -16,6 +18,7 @@ import 'run_pipeline_wording.dart';
/// Opening, typing and Cancel send nothing. Only the confirm action validates
/// and submits. [pending] restores an intent whose admission is still unknown,
/// so its fields are locked and the same request key is offered for check/retry.
/// [seed] pre-fills a Run again from an earlier run.
Future<void> showRunPipelineDialog({
required BuildContext context,
required PipelineDetail detail,
@@ -25,6 +28,7 @@ Future<void> showRunPipelineDialog({
onSubmit,
required ValueChanged<RunPipelineIntent?> onPendingChanged,
required ValueChanged<JsonMap> onAccepted,
RunPipelineSeed? seed,
}) {
// Schedule instead: the editor opens as the next page from the screen that
// opened this dialog, seeded with what was typed here.
@@ -47,6 +51,7 @@ Future<void> showRunPipelineDialog({
onPendingChanged: onPendingChanged,
onAccepted: onAccepted,
onSchedule: schedule,
seed: seed,
);
return showDialog<void>(
context: context,
@@ -64,8 +69,11 @@ class _RunPipelineDialog extends StatefulWidget {
required this.onPendingChanged,
required this.onAccepted,
required this.onSchedule,
this.seed,
});
final RunPipelineSeed? seed;
final Future<void> Function(ScheduleDraft draft) onSchedule;
final PipelineDetail detail;
@@ -85,6 +93,11 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
late RunNotifyMode _notify;
late RunOutputFormat _outputFormat;
late RunPipelineIntent? _intent;
late int _version = widget.detail.resolvedVersion;
late final List<int> _versions = runPipelineVersionChoices(
widget.detail.resolvedVersion,
widget.seed?.originalVersion,
);
bool _sending = false;
bool _directoriesLoading = true;
List<String> _directories = const [];
@@ -101,9 +114,13 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
: null;
_intent = restored;
_notify = restored?.notifyMode ?? RunNotifyMode.pipelineDefault;
_outputFormat = restored?.outputFormat ?? RunOutputFormat.none;
_prompt = TextEditingController(text: restored?.prompt ?? '');
_workspace = TextEditingController(text: restored?.workspace ?? '');
final seed = restored == null ? widget.seed : null;
_outputFormat =
restored?.outputFormat ?? seed?.outputFormat ?? RunOutputFormat.none;
_prompt = TextEditingController(text: restored?.prompt ?? seed?.prompt);
_workspace = TextEditingController(
text: restored?.workspace ?? seed?.workspace,
);
_error = restored == null ? null : runPipelineUnknownAdmission;
_loadDirectories(restored);
}
@@ -174,15 +191,12 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
_intent ??
RunPipelineIntent(
pipelineId: widget.detail.id,
version: widget.detail.resolvedVersion,
version: _version,
prompt: prompt,
workspace: workspace.trim(),
notifyMode: _notify,
outputFormat: _outputFormat,
requestKey: newRunPipelineRequestKey(
widget.detail.id,
widget.detail.resolvedVersion,
),
requestKey: newRunPipelineRequestKey(widget.detail.id, _version),
);
setState(() {
_sending = true;
@@ -241,7 +255,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
void _schedule() {
final draft = ScheduleDraft.create(
pipelineId: widget.detail.id,
version: '${widget.detail.resolvedVersion}',
version: '$_version',
workspace: _workspace.text.trim(),
)..prompt = _prompt.text;
final schedule = widget.onSchedule;
@@ -262,6 +276,13 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (_versions.length > 1)
RunPipelineVersionField(
choices: _versions,
value: _version,
locked: _locked,
onChanged: (version) => setState(() => _version = version),
),
RunPipelineFields(
prompt: _prompt,
workspace: _workspace,
@@ -6,6 +6,7 @@ import '../../runs/data/runs_repository.dart';
import '../pipeline_models.dart';
import '../pipelines_controller.dart';
import '../run_pipeline_intent.dart';
import '../run_pipeline_seed.dart';
import 'run_pipeline_dialog.dart';
import 'run_pipeline_wording.dart';
@@ -22,6 +23,7 @@ Future<void> openRunPipelineFlow({
required PipelineDetail detail,
required ApiGateway gateway,
ValueChanged<int>? onRunStarted,
RunPipelineSeed? seed,
}) async {
final pipelineId = detail.id;
final version = detail.resolvedVersion;
@@ -32,6 +34,7 @@ Future<void> openRunPipelineFlow({
detail: detail,
gateway: gateway,
pending: pending,
seed: seed,
onSubmit: (intent) => _submit(controller, gateway, intent),
onPendingChanged: (intent) {
if (intent == null) {
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
const runPipelineVersionKey = Key('run-pipeline-version');
/// Run again's version choice: the pipeline's latest version (the default)
/// or the version the earlier run used. [choices] lists the latest first.
class RunPipelineVersionField extends StatelessWidget {
const RunPipelineVersionField({
super.key,
required this.choices,
required this.value,
required this.locked,
required this.onChanged,
});
final List<int> choices;
final int value;
final bool locked;
final ValueChanged<int> onChanged;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: DropdownButtonFormField<int>(
key: runPipelineVersionKey,
initialValue: value,
decoration: const InputDecoration(
labelText: 'Version',
border: OutlineInputBorder(),
),
items: [
for (final (index, version) in choices.indexed)
DropdownMenuItem(
value: version,
child: Text(
index == 0 ? 'Latest (v$version)' : 'Original run (v$version)',
),
),
],
onChanged: locked
? null
: (version) {
if (version != null) onChanged(version);
},
),
);
}
}
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../pipeline_query.dart';
import '../../../ui/status/error_notice.dart';
/// Standard Material activity indicator with an accessible status label.
class PipelineProgress extends StatelessWidget {
@@ -110,19 +111,15 @@ class PipelineErrorBanner extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = Theme.of(context).colorScheme.error;
return Semantics(
liveRegion: true,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(message, style: TextStyle(color: color)),
if (onRetry != null)
PipelineTextButton(label: retryLabel, onPressed: onRetry),
],
),
// The notice announces itself; a common failure says what to do.
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: ErrorNotice(
error: message,
actions: [
if (onRetry != null)
PipelineTextButton(label: retryLabel, onPressed: onRetry),
],
),
);
}
@@ -9,6 +9,21 @@ bool canRetryRun(JsonMap? run) {
return run['executing'] != true && run['status'] == 'failed';
}
/// Whether [run] can be started again with its inputs: a finished run that
/// succeeded, was canceled or was interrupted, and names its pipeline. A
/// failed run has Retry instead.
bool canRunAgain(JsonMap? run) {
if (run == null || run['executing'] == true) return false;
final pipeline = run['pipeline_id'];
return const {
'succeeded',
'canceled',
'interrupted',
}.contains(run['status']) &&
pipeline is num &&
pipeline > 0;
}
/// The run id used by the retry request, or null for a malformed run.
num? retryRunId(JsonMap run) {
final id = run['id'];
@@ -0,0 +1,43 @@
import '../../../core/api_gateway.dart';
import 'run_models.dart' show runStateOf;
/// The longest result preview a succeeded run's row shows; a longer one is
/// left to the run's detail rather than cut into a misleading fragment.
const int runResultPreviewRowLimit = 140;
/// Why a run ended, in one line for its list row, with the full recorded text
/// for a tooltip. [failed] says the line explains a failure (drawn in the
/// error colour); otherwise it is a succeeded run's short result.
typedef RunOutcomeLine = ({String line, String full, bool failed});
/// The row's outcome line, or null when the run recorded nothing to show.
///
/// A failed run shows its failure reason, else its diagnostic's first
/// non-blank line. A succeeded run shows its result preview only when it is
/// short (at most [runResultPreviewRowLimit] characters on one line).
RunOutcomeLine? runOutcomeLine(JsonMap run) {
final state = runStateOf(run['status']);
if (state == 'failed' && run['executing'] != true) {
final reason = '${run['failure_reason'] ?? ''}'.trim();
final diagnostic = '${run['diagnostic'] ?? ''}'.trim();
final full = reason.isNotEmpty ? reason : diagnostic;
if (full.isEmpty) return null;
return (line: firstLine(full), full: full, failed: true);
}
if (state == 'succeeded') {
final preview = '${run['result_preview'] ?? ''}'.trim();
if (preview.isEmpty ||
preview.contains('\n') ||
preview.length > runResultPreviewRowLimit) {
return null;
}
return (line: preview, full: preview, failed: false);
}
return null;
}
/// The first non-blank line of [text], trimmed.
String firstLine(String text) => text
.split('\n')
.map((line) => line.trim())
.firstWhere((line) => line.isNotEmpty, orElse: () => '');
+2 -1
View File
@@ -1,4 +1,5 @@
import '../../../core/api_gateway.dart';
import '../../../ui/text/plural.dart';
/// Reported token and cost usage of a run or one stage. No widgets here.
///
@@ -151,7 +152,7 @@ String tokenUsageDetail(TokenUsage usage) => [
'${formatTokenCount(usage.input!)} in, '
'${formatTokenCount(usage.output!)} out',
if (usage.partial && usage.stages != null)
'${usage.tokenStages} of ${usage.stages} stages reported',
'${usage.tokenStages} of ${countLabel(usage.stages!, 'stage')} reported',
].join(' · ');
/// The wording for a cost no stage reported as a positive amount.
+14
View File
@@ -20,6 +20,7 @@ import 'data/runs_sort_store.dart';
import 'domain/run_decisions.dart';
import 'ui/new_run_button.dart';
import 'ui/new_run_flow.dart';
import 'ui/run_again_flow.dart';
import 'ui/run_pipeline_link.dart';
import 'ui/run_detail_view.dart';
import 'ui/run_search_selection.dart';
@@ -270,6 +271,17 @@ class _RunsScreenState extends State<RunsScreen> {
),
);
/// Run again: the New run form pre-filled from a finished [run].
void _runAgain(JsonMap run) => unawaited(
startRunAgainFlow(
context: context,
run: run,
controller: _launches,
gateway: widget.gateway,
onRunStarted: _newRunStarted,
),
);
/// An accepted launch re-reads the list so its row appears, then opens the
/// run the same way a row tap does.
void _newRunStarted(int id) {
@@ -305,6 +317,7 @@ class _RunsScreenState extends State<RunsScreen> {
onRunOpened: _select,
onOpenPipeline: widget.onOpenPipeline,
onOpenInChat: widget.onOpenInChat,
onRunAgain: _runAgain,
onSendToChat: widget.onSendToChat == null
? null
: (context, run, draft) => widget.onSendToChat!(context, run, draft),
@@ -363,6 +376,7 @@ class _RunsScreenState extends State<RunsScreen> {
notifications: widget.notifications,
attention: widget.attention,
onOpenInChat: widget.onOpenInChat,
onRunAgain: _runAgain,
),
),
);
+2 -1
View File
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../../pipelines/pipeline_models.dart';
import '../../pipelines/pipeline_repository.dart';
import '../../pipelines/ui/run_pipeline_wording.dart';
import '../../../ui/text/plural.dart';
/// Whether an active pipeline matches a picker search by name. An empty query
/// matches every pipeline.
@@ -119,7 +120,7 @@ class _PipelinePickerState extends State<_PipelinePicker> {
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
'v${pipeline.version} · ${pipeline.stages} stages',
'v${pipeline.version} · ${countLabel(pipeline.stages, 'stage')}',
),
onTap: () => Navigator.of(context).pop(pipeline.id),
),
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../pipelines/pipeline_models.dart';
import '../../pipelines/pipeline_repository.dart';
import '../../pipelines/pipelines_controller.dart';
import '../../pipelines/run_pipeline_seed.dart';
import '../../pipelines/ui/run_pipeline_flow.dart';
import '../../pipelines/ui/run_pipeline_wording.dart';
import '../actions/retry_eligibility.dart';
import '../data/runs_repository.dart';
import 'run_detail_content.dart' show detailPrompt;
const runAgainActionLabel = 'Run again…';
const runAgainActionKey = ValueKey<String>('run-again-action');
/// The seed a Run again pre-fills from [run]: its stored prompt, workspace,
/// report requirement and the version it ran.
RunPipelineSeed runAgainSeed(JsonMap run) {
final version = run['version'];
return RunPipelineSeed(
prompt: detailPrompt(run) ?? '',
workspace: '${run['workspace'] ?? ''}'.trim(),
originalVersion: version is num ? version.toInt() : null,
outputFormat: runOutputFormatOf(run['output_format']),
);
}
/// Run again: opens the New run form for [run]'s pipeline at its latest
/// version (the original offered), pre-filled with the run's inputs.
///
/// A list row carries no input, so the run is read first. Nothing starts until
/// the form's own confirm, exactly as New run.
Future<void> startRunAgainFlow({
required BuildContext context,
required JsonMap run,
required PipelinesController controller,
required ApiGateway gateway,
ValueChanged<int>? onRunStarted,
}) async {
if (!canRunAgain(run)) return;
final pipelineId = (run['pipeline_id'] as num).toInt();
final JsonMap full;
final PipelineDetail detail;
try {
full = run['input'] is Map
? run
: await RunsRepository(gateway).getRun(run['id'] as num);
detail = await PipelinesRepository(gateway).getPipeline(pipelineId, 0);
} catch (error) {
if (!context.mounted) return;
ScaffoldMessenger.maybeOf(
context,
)?.showSnackBar(SnackBar(content: Text(describeRunPipelineError(error))));
return;
}
if (!context.mounted) return;
await openRunPipelineFlow(
context: context,
controller: controller,
detail: detail,
gateway: gateway,
onRunStarted: onRunStarted,
seed: runAgainSeed(full),
);
}
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import 'run_detail_summary_fields.dart';
import 'run_failure_banner.dart';
import 'run_detail_visit_facts.dart';
import 'run_field_body.dart';
import '../../../ui/layout/facts_grid.dart';
@@ -60,6 +61,7 @@ Widget runDetailSummaryTab({
),
),
),
SliverToBoxAdapter(child: RunFailureBanner(run: run)),
SliverToBoxAdapter(
child: WarningsSection(messages: warningMessages(run['warnings'])),
),
@@ -46,6 +46,9 @@ class RunDetailTabStrip extends StatelessWidget {
return KeyedSubtree(
key: const Key('run-detail-tabs'),
child: FloatingDestinationBar(
// Named on screen: a phone has no tooltip to name an icon.
showLabels: true,
maxLabelScale: 1.3,
currentIndex: index < 0 ? 0 : index,
edge: edge,
onTap: (value) => onSelected(tabs[value]),
+10 -1
View File
@@ -13,6 +13,8 @@ import 'run_pipeline_link.dart';
import 'run_detail_content.dart';
import 'run_detail_material.dart';
import 'runs_controller.dart';
import '../../../core/error_advice.dart';
import '../../../ui/status/error_notice.dart';
class RunDetailView extends StatefulWidget {
const RunDetailView({
@@ -26,8 +28,12 @@ class RunDetailView extends StatefulWidget {
this.initialVisit,
this.onOpenInChat,
this.onSendToChat,
this.onRunAgain,
});
/// Opens the New run form pre-filled from this run.
final ValueChanged<JsonMap>? onRunAgain;
final RunsController controller;
/// The app's shared gateway; the rename action sends through it.
@@ -122,6 +128,7 @@ class _RunDetailViewState extends State<RunDetailView> {
onRunOpened: widget.onRunOpened,
onDeleted: widget.controller.applyDeletion,
onOpenInChat: widget.onOpenInChat,
onRunAgain: widget.onRunAgain,
);
if (inShellBar) {
return ShellBar(
@@ -193,7 +200,9 @@ class _RunDetailViewState extends State<RunDetailView> {
],
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(message, textAlign: TextAlign.center),
child: loading || errorAdvice(message) == null
? Text(message, textAlign: TextAlign.center)
: ErrorNotice(error: message, textAlign: TextAlign.center),
),
const SizedBox(height: 12),
FilledButton(
@@ -53,6 +53,9 @@ class RunVisitSectionStrip extends StatelessWidget {
return KeyedSubtree(
key: const Key('run-visit-tabs'),
child: FloatingDestinationBar(
// Named on screen: a phone has no tooltip to name an icon.
showLabels: true,
maxLabelScale: 1.3,
currentIndex: index < 0 ? 0 : index,
onTap: (value) => onSelected(shownVisitSections[value]),
items: [
@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../domain/run_outcome_line.dart';
/// The run Summary's prominent "Why it failed" note: a failed run's recorded
/// failure reason (else its diagnostic), selectable, at the top of the
/// Summary so the reason is read before the facts. Nothing for other runs.
class RunFailureBanner extends StatelessWidget {
const RunFailureBanner({super.key, required this.run});
final JsonMap run;
@override
Widget build(BuildContext context) {
final outcome = runOutcomeLine(run);
if (outcome == null || !outcome.failed) return const SizedBox.shrink();
final theme = Theme.of(context);
final scheme = theme.colorScheme;
return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: DecoratedBox(
key: const Key('run-failure-banner'),
decoration: ShapeDecoration(
color: scheme.errorContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.error_outline, color: scheme.onErrorContainer),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Why it failed',
style: theme.textTheme.titleSmall?.copyWith(
color: scheme.onErrorContainer,
),
),
const SizedBox(height: 4),
SelectableText(
outcome.full,
maxLines: 6,
minLines: 1,
style: theme.textTheme.bodyMedium?.copyWith(
color: scheme.onErrorContainer,
),
),
],
),
),
],
),
),
),
);
}
}
@@ -9,6 +9,7 @@ import '../../../ui/text/live_elapsed_builder.dart';
import '../../../ui/text/relative_time_label.dart';
import '../domain/run_deletion.dart';
import '../domain/run_models.dart';
import '../domain/run_outcome_line.dart';
import '../domain/run_tokens.dart';
import 'run_more_menu.dart';
@@ -36,8 +37,11 @@ class RunListRow extends StatelessWidget {
this.onToggle,
this.onLongPress,
this.onOpenInChat,
this.onRunAgain,
});
final ValueChanged<JsonMap>? onRunAgain;
final JsonMap run;
final DateTime now;
final bool selected;
@@ -136,6 +140,7 @@ class RunListRow extends StatelessWidget {
: RelativeTimeLabel(instant: createdAt, now: now),
subtitle: line(subtitle),
compactSubtitle: line(compactSubtitle),
detail: _outcome(context),
// Kept in a narrow list pane too, so every run's actions stay one tap
// away from the list.
menu:
@@ -146,6 +151,7 @@ class RunListRow extends StatelessWidget {
run,
deletable: onDeleted != null,
canOpenInChat: onOpenInChat != null,
canRunAgainHere: onRunAgain != null,
)
? RunMoreMenu(
run: run,
@@ -154,12 +160,33 @@ class RunListRow extends StatelessWidget {
onRunOpened: onRunOpened,
onDeleted: onDeleted,
onOpenInChat: onOpenInChat,
onRunAgain: onRunAgain,
menuKey: ValueKey('run-list-more-menu-$id'),
)
: null,
);
}
/// Why a failed run ended (or a succeeded run's short result): one line,
/// the full recorded text in its tooltip.
Widget? _outcome(BuildContext context) {
final outcome = runOutcomeLine(run);
if (outcome == null) return null;
final scheme = Theme.of(context).colorScheme;
return Tooltip(
key: ValueKey('run-row-outcome-${run['id']}'),
message: outcome.full,
excludeFromSemantics: true,
child: Text(
outcome.line,
style: outcome.failed ? TextStyle(color: scheme.error) : null,
semanticsLabel: outcome.failed
? 'Failed: ${outcome.full}'
: 'Result: ${outcome.full}',
),
);
}
Widget _checkbox(BuildContext context) {
final id = run['id'];
final enabled = runIsDeletable(run);
+17 -2
View File
@@ -12,6 +12,7 @@ import '../actions/title_action.dart';
import '../actions/title_wording.dart';
import '../domain/run_deletion.dart';
import '../domain/run_models.dart' show runIdentity;
import 'run_again_flow.dart';
const runMoreMenuKey = ValueKey<String>('run-more-menu');
const deleteRunActionKey = ValueKey<String>('run-delete-action');
@@ -25,8 +26,10 @@ bool showRunMoreMenu(
JsonMap run, {
bool deletable = false,
bool canOpenInChat = false,
bool canRunAgainHere = false,
}) =>
runTitleId(run) != null ||
(canRunAgainHere && canRunAgain(run)) ||
canScheduleRun(run) ||
_canRetry(run) ||
(deletable && runIsDeletable(run)) ||
@@ -41,18 +44,20 @@ String runMoreMenuTitle(JsonMap run) {
bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run);
enum _RunMoreItem { retry, rename, schedule, delete, openInChat }
enum _RunMoreItem { retry, runAgain, rename, schedule, delete, openInChat }
/// Each item keeps the key its standalone button had.
Key _keyOf(_RunMoreItem item) => switch (item) {
_RunMoreItem.retry => retryActionKey,
_RunMoreItem.runAgain => runAgainActionKey,
_RunMoreItem.rename => runTitleActionKey,
_RunMoreItem.schedule => scheduleRunActionKey,
_RunMoreItem.delete => deleteRunActionKey,
_RunMoreItem.openInChat => openRunInChatActionKey,
};
/// The run detail's more menu: Retry (failed runs only), Rename and Schedule
/// The run detail's more menu: Retry (failed runs only), Run again (other
/// finished runs), Rename and Schedule
/// this run, kept out of the header.
/// This widget stays mounted while a picked flow runs, so the flow's result
/// still reaches the current run.
@@ -65,9 +70,14 @@ class RunMoreMenu extends StatefulWidget {
this.onRunOpened,
this.onDeleted,
this.onOpenInChat,
this.onRunAgain,
this.menuKey = runMoreMenuKey,
});
/// Opens the New run form pre-filled from this run (finished runs that
/// did not fail); without it the menu offers no Run again.
final ValueChanged<JsonMap>? onRunAgain;
final JsonMap run;
final ApiGateway gateway;
final ValueChanged<JsonMap> onRunChanged;
@@ -92,6 +102,8 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
List<(_RunMoreItem, String)> get _items => [
// Retry is offered only for a failed run that is no longer executing.
if (_canRetry(run)) (_RunMoreItem.retry, retryActionLabel),
if (widget.onRunAgain != null && canRunAgain(run))
(_RunMoreItem.runAgain, runAgainActionLabel),
if (runTitleId(run) != null) (_RunMoreItem.rename, runTitleActionLabel),
if (canScheduleRun(run)) (_RunMoreItem.schedule, scheduleRunActionLabel),
if (widget.onDeleted != null && runIsDeletable(run))
@@ -111,6 +123,8 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
onRunOpened: widget.onRunOpened,
owns: (owned) => mounted && retryRunId(widget.run) == owned,
);
case _RunMoreItem.runAgain:
widget.onRunAgain!(run);
case _RunMoreItem.rename:
openRunTitleEditor(
context,
@@ -147,6 +161,7 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
label: label,
icon: switch (item) {
_RunMoreItem.retry => Icons.replay,
_RunMoreItem.runAgain => Icons.replay,
_RunMoreItem.rename => Icons.edit_outlined,
_RunMoreItem.schedule => Icons.schedule,
_RunMoreItem.delete => Icons.delete_outline,
+9 -3
View File
@@ -6,6 +6,7 @@ import '../../pipelines/pipeline_format.dart' show runStateLabel;
import 'runs_controller.dart';
import 'runs_filter_options.dart';
import 'runs_filter_sheet.dart';
import '../../../ui/navigation/labelled_icon_button.dart';
export 'runs_filter_sheet.dart' show showRunsFilterSheet;
@@ -131,17 +132,19 @@ class RunsBarActions {
Key key,
IconData material,
String label,
String caption,
VoidCallback onPressed, {
bool active = false,
bool anchorPopup = false,
}) {
final button = Builder(
builder: (buttonContext) => IconButton(
builder: (buttonContext) => LabelledIconButton(
key: key,
tooltip: label,
label: label,
caption: caption,
isSelected: active,
onPressed: anchorPopup ? () => _chooseSort(buttonContext) : onPressed,
icon: Icon(material),
icon: material,
),
);
// A narrow bar moves it into its More menu.
@@ -160,12 +163,14 @@ class RunsBarActions {
const ValueKey('runs.stats'),
Icons.insert_chart_outlined,
'Usage and charts',
'Charts',
onStats,
),
icon(
const ValueKey('runs.filter'),
count > 0 ? Icons.filter_alt : Icons.filter_alt_outlined,
filterLabel,
'Filter',
() => showRunsFilterSheet(context, controller),
active: count > 0,
),
@@ -173,6 +178,7 @@ class RunsBarActions {
const ValueKey('runs.sort'),
Icons.sort,
'Sort runs: ${runSortLabel(controller.sort)}',
'Sort',
() => _chooseSort(context),
anchorPopup: true,
),
+8 -2
View File
@@ -18,6 +18,7 @@ import 'runs_filter_options.dart';
import 'runs_selection_bar.dart';
import 'runs_stats_page.dart';
import 'runs_filters.dart';
import '../../../ui/status/error_notice.dart';
export 'run_list_row.dart';
@@ -33,12 +34,16 @@ class RunsList extends StatelessWidget {
this.attention,
this.active = true,
this.onOpenInChat,
this.onRunAgain,
});
/// False while a run detail covers the list; the bar is then the run's.
final bool active;
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
/// Opens the New run form pre-filled from a finished run.
final ValueChanged<JsonMap>? onRunAgain;
final RunsController controller;
final ValueChanged<num> onSelected;
@@ -256,7 +261,7 @@ class RunsList extends StatelessWidget {
children: [
const Icon(Icons.error_outline),
const SizedBox(height: 8),
Text(controller.error!),
ErrorNotice(error: controller.error!, textAlign: TextAlign.center),
const SizedBox(height: 8),
FilledButton(onPressed: controller.load, child: const Text('Retry')),
],
@@ -299,7 +304,7 @@ class RunsList extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Expanded(child: Text(controller.error!)),
Expanded(child: ErrorNotice(error: controller.error!)),
TextButton(onPressed: controller.load, child: const Text('Retry')),
],
),
@@ -344,6 +349,7 @@ class RunsList extends StatelessWidget {
onRunChanged: controller.acceptRunDetail,
onRunOpened: onSelected,
onOpenInChat: onOpenInChat,
onRunAgain: onRunAgain,
);
}
}
@@ -6,6 +6,7 @@ import '../../../ui/layout/section_heading.dart';
import '../actions/delete_runs_action.dart';
import '../domain/run_deletion.dart';
import 'runs_controller.dart';
import '../../../ui/navigation/labelled_icon_button.dart';
const runsSelectKey = ValueKey<String>('runs.select');
const runsSelectDoneKey = ValueKey<String>('runs.select.done');
@@ -30,11 +31,11 @@ Widget runsSelectAction(BuildContext context, RunsController controller) {
icon: Icons.checklist,
onPressed: enter,
),
child: IconButton(
child: LabelledIconButton(
key: runsSelectKey,
tooltip: 'Select',
label: 'Select',
onPressed: enter,
icon: const Icon(Icons.checklist),
icon: Icons.checklist,
),
);
}
@@ -7,6 +7,7 @@ import '../../domain/saved_schedule.dart';
import 'schedule_list_controller.dart';
import 'schedule_list_row.dart';
import 'schedule_list_toolbar.dart';
import '../../../../ui/status/error_notice.dart';
const scheduleListKey = ValueKey<String>('schedule-list');
const scheduleRetryKey = ValueKey<String>('schedule-retry');
@@ -194,6 +195,11 @@ class SchedulesListView extends StatelessWidget {
}
Widget _failureText(BuildContext context, ScheduleListFailure failure) {
// A common failure (not connected, permission, timeout) says what to do,
// its raw detail behind Details; an older server already has guidance.
if (!failure.unsupported) {
return ErrorNotice(error: failure.message, textAlign: TextAlign.center);
}
final color = Theme.of(context).colorScheme.error;
return Semantics(
liveRegion: true,
@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'settings_section.dart';
/// The sections a phone shows first, in this order: how to reach the server
/// (Connection, Servers, Sign in) and then how it reaches you (the
/// notification sections). The rest keep their order after them.
const settingsPhoneFirstIds = [
'managed-connection',
'connection',
'servers',
'sign-in',
'notifications',
'device-delivery',
'phone-notifications',
];
/// [sections] reordered for a phone: [settingsPhoneFirstIds] first.
List<SettingsSection> settingsPhoneOrder(List<SettingsSection> sections) {
int rank(SettingsSection section) {
final index = settingsPhoneFirstIds.indexOf(section.id);
return index < 0 ? settingsPhoneFirstIds.length : index;
}
final indexed = sections.indexed.toList()
..sort((a, b) {
final byRank = rank(a.$2).compareTo(rank(b.$2));
return byRank != 0 ? byRank : a.$1.compareTo(b.$1);
});
return [for (final (_, section) in indexed) section];
}
const settingsTopicMenuKey = ValueKey<String>('settings.topics');
/// The phone's "Jump to topic" menu beside the search field: every shown
/// section by title; picking one scrolls to it (the wide layout has an index
/// column instead).
class SettingsTopicMenu extends StatelessWidget {
const SettingsTopicMenu({
super.key,
required this.sections,
required this.onJump,
});
final List<SettingsSection> sections;
final ValueChanged<String> onJump;
@override
Widget build(BuildContext context) => PopupMenuButton<String>(
key: settingsTopicMenuKey,
tooltip: 'Jump to topic',
icon: const Icon(Icons.toc),
onSelected: onJump,
itemBuilder: (_) => [
for (final section in sections)
PopupMenuItem(value: section.id, child: Text(section.title)),
],
);
}
@@ -6,6 +6,7 @@ import 'settings_layout.dart';
import 'settings_page_chrome.dart';
import 'settings_section.dart';
import 'settings_skeleton.dart';
import 'settings_phone_order.dart';
/// The one Settings page: a pinned search field over a scrolling column of
/// grouped sections, with a jump index beside it on wide layouts.
@@ -130,10 +131,11 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
@override
Widget build(BuildContext context) {
final insets = MediaQuery.paddingOf(context);
final visible = _visible;
return LayoutBuilder(
builder: (context, constraints) {
final wide = constraints.maxWidth >= settingsIndexMinWidth;
// A phone leads with Connection and Notifications and jumps by menu.
final visible = wide ? _visible : settingsPhoneOrder(_visible);
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
@@ -154,9 +156,20 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SettingsSearchField(
controller: _search,
onChanged: _onQueryChanged,
Row(
children: [
Expanded(
child: SettingsSearchField(
controller: _search,
onChanged: _onQueryChanged,
),
),
if (!wide && visible.length > 1)
SettingsTopicMenu(
sections: visible,
onJump: _jumpTo,
),
],
),
const SizedBox(height: settingsSectionGap),
Expanded(child: _list(visible, insets)),
@@ -3,6 +3,7 @@ import '../settings_group.dart';
import 'storage_controls.dart';
import 'storage_models.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/text/plural.dart';
class StorageUsage extends StatelessWidget {
const StorageUsage({super.key, required this.data});
@@ -46,7 +47,7 @@ class StorageUsage extends StatelessWidget {
),
],
),
Text('${storageInt(category['files'])} files'),
Text(countLabel(storageInt(category['files']), 'file')),
if (category['path'] case final String path when path.isNotEmpty)
Text(path, softWrap: true),
if (category['error'] case final String error
@@ -7,16 +7,31 @@ import 'walkthrough_steps.dart';
/// Opens the walkthrough as a Material details sheet on phones and a dialog on
/// wide windows. [onClosed] runs once however it closes (Skip, Done, the close
/// button or a tap outside), so the caller can record it as seen.
///
/// [connected] skips the connect directions; [onOpenConnection] (Settings'
/// Connection) closes the walkthrough and opens it.
Future<void> showFirstRunWalkthrough(
BuildContext context, {
Future<void> Function()? onClosed,
bool connected = false,
VoidCallback? onOpenConnection,
}) async {
var openConnection = false;
await showAppDetails<void>(
context,
maxWidth: 560,
builder: (sheet) =>
FirstRunWalkthrough(onClose: () => Navigator.of(sheet).pop()),
builder: (sheet) => FirstRunWalkthrough(
onClose: () => Navigator.of(sheet).pop(),
steps: walkthroughStepsFor(connected: connected),
onOpenConnection: onOpenConnection == null
? null
: () {
openConnection = true;
Navigator.of(sheet).pop();
},
),
);
if (openConnection) onOpenConnection?.call();
await onClosed?.call();
}
@@ -28,8 +43,12 @@ class FirstRunWalkthrough extends StatefulWidget {
super.key,
required this.onClose,
this.steps = walkthroughSteps,
this.onOpenConnection,
});
/// Opens Settings' Connection from the connect page; null hides it.
final VoidCallback? onOpenConnection;
/// Called by Skip, Done and the close button.
final VoidCallback onClose;
final List<WalkthroughStep> steps;
@@ -90,6 +109,19 @@ class _FirstRunWalkthroughState extends State<FirstRunWalkthrough> {
const SizedBox(height: 8),
_Point(text: point),
],
if (step.showsConnectAction &&
widget.onOpenConnection != null) ...<Widget>[
const SizedBox(height: 16),
Align(
alignment: AlignmentDirectional.centerStart,
child: FilledButton.tonalIcon(
key: const ValueKey<String>('walkthrough.open-connection'),
onPressed: widget.onOpenConnection,
icon: const Icon(Icons.link),
label: const Text('Open Connection'),
),
),
],
if (step.showsHarnessCommand) ...<Widget>[
const SizedBox(height: 16),
const WalkthroughHarnessCommand(),
@@ -54,8 +54,12 @@ class FirstRunWalkthroughGate extends StatefulWidget {
required this.connection,
required this.connected,
this.gateway,
this.onOpenConnection,
});
/// Opens Settings' Connection from the walkthrough's connect page.
final VoidCallback? onOpenConnection;
final Widget child;
final WalkthroughStore store;
@@ -192,7 +196,12 @@ class _FirstRunWalkthroughGateState extends State<FirstRunWalkthroughGate> {
}
Future<void> _show() async {
await showFirstRunWalkthrough(context, onClosed: widget.store.markSeen);
await showFirstRunWalkthrough(
context,
onClosed: widget.store.markSeen,
connected: widget.connected(),
onOpenConnection: widget.onOpenConnection,
);
}
@override
@@ -60,26 +60,25 @@ class _WalkthroughHarnessCommandState extends State<WalkthroughHarnessCommand> {
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: const EdgeInsets.only(left: 12, right: 4),
child: Row(
children: <Widget>[
Expanded(
child: SelectableText(
command,
key: const ValueKey<String>('walkthrough.command'),
style: Theme.of(context).textTheme.bodyLarge,
),
),
IconButton(
key: const ValueKey<String>('walkthrough.copy'),
tooltip: _copied ? 'Command copied' : 'Copy command',
onPressed: () => _copy(command),
icon: Icon(_copied ? Icons.check : Icons.copy_outlined),
),
],
padding: const EdgeInsets.all(12),
child: SelectableText(
command,
key: const ValueKey<String>('walkthrough.command'),
style: Theme.of(context).textTheme.bodyLarge,
),
),
),
const SizedBox(height: 8),
// A labelled action, not a bare icon: the step says what to do.
Align(
alignment: AlignmentDirectional.centerStart,
child: FilledButton.tonalIcon(
key: const ValueKey<String>('walkthrough.copy'),
onPressed: () => _copy(command),
icon: Icon(_copied ? Icons.check : Icons.copy_outlined),
label: Text(_copied ? 'Command copied' : 'Copy command'),
),
),
],
);
}
@@ -9,6 +9,7 @@ class WalkthroughStep {
required this.body,
this.points = const <String>[],
this.showsHarnessCommand = false,
this.showsConnectAction = false,
});
final IconData icon;
@@ -20,6 +21,9 @@ class WalkthroughStep {
/// Whether this page shows the harness setup command picker.
final bool showsHarnessCommand;
/// Whether this page offers the Open Connection button.
final bool showsConnectAction;
}
/// The agents `pipelines harness setup` accepts, in the order they are offered.
@@ -28,6 +32,26 @@ const harnessAgents = <String>['claude', 'codex', 'opencode', 'pi'];
/// The command for [agent], exactly as a terminal should run it.
String harnessSetupCommand(String agent) => 'pipelines harness setup $agent';
/// The welcome page for an app already connected to its server: nothing to
/// connect, so no connect directions or Open Connection.
const connectedWelcomeStep = WalkthroughStep(
icon: Icons.hub_outlined,
title: 'Welcome to Pipelines',
body:
'Pipelines runs reusable AI workflows and holds chats with coding '
'agents. Both live on your server, and this app is connected to it.',
points: <String>[
'Pipelines: workflows you define once and run again.',
'Chats: conversations with coding agents on the server.',
],
);
/// The pages for this app: the connect step is skipped when [connected].
List<WalkthroughStep> walkthroughStepsFor({required bool connected}) =>
connected
? [connectedWelcomeStep, ...walkthroughSteps.skip(1)]
: walkthroughSteps;
/// The four walkthrough pages, in order.
const walkthroughSteps = <WalkthroughStep>[
WalkthroughStep(
@@ -43,6 +67,7 @@ const walkthroughSteps = <WalkthroughStep>[
'Connect: open Settings, then Connection, enter the Server URL and '
'choose Connect.',
],
showsConnectAction: true,
),
WalkthroughStep(
icon: Icons.build_circle_outlined,
+4 -30
View File
@@ -91,11 +91,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
late AppDestination _selected;
final Set<AppDestination> _visited = {};
final TabHistory _history = TabHistory();
// The destination a shell control (rail, bar, floating bar) asked for and
// that is not shown yet. Settings reached this way is a destination; any
// other way in (a route, a deep link, the Pipelines gear) is a page to Back.
AppDestination? _navigatingTo;
bool _settingsPushed = false;
// Whether a navigator inside each destination (an open item's pane) has a
// page of its own for the system Back to close first.
final Map<AppDestination, bool> _nestedCanPop = {};
@@ -120,9 +115,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
super.initState();
_bar.onNavigate = _select;
_selected = widget.destination ?? AppDestination.pipelines;
// A first load that opens Settings (a deep link, a restored page) was not
// reached from a shell control, so its Back closes the page.
_settingsPushed = _selected == AppDestination.settings;
_visited.add(_selected);
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
}
@@ -132,23 +124,12 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
super.didUpdateWidget(oldWidget);
final destination = widget.destination;
if (destination != null) {
if (destination != _selected) _noteShown(destination);
_history.record(_selected, destination);
_selected = destination;
_visited.add(destination);
}
}
/// Records that [destination] is becoming the shown one. Settings opened by
/// a shell control is a destination (no Back); opened any other way it is a
/// page that Back closes.
void _noteShown(AppDestination destination) {
if (destination == AppDestination.settings) {
_settingsPushed = _navigatingTo != AppDestination.settings;
}
_navigatingTo = null;
}
/// The entry every tab control calls when tapped: a destination shown
/// already is re-selected (see [AdaptiveShell.onDestinationReselected]), any
/// other is selected.
@@ -158,13 +139,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
reselected(destination);
return;
}
if (destination != _selected) {
_navigatingTo = destination;
// A selection the route never applies must not mark a later route.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted && _navigatingTo == destination) _navigatingTo = null;
});
}
_select(destination);
}
@@ -175,7 +149,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
return;
}
setState(() {
if (destination != _selected) _noteShown(destination);
_history.record(_selected, destination);
_selected = destination;
_visited.add(destination);
@@ -515,9 +488,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
String label, {
required bool page,
}) {
// Settings reached from a shell control has no Back: it is a destination.
final onBack =
spec?.onBack ?? (page && _settingsPushed ? _closePage : null);
// Settings is a top-level destination however it was reached (a shell
// control, a route, a deep link or the Pipelines gear): it has no Back
// arrow. The system Back still leaves it for the previous destination.
final onBack = spec?.onBack;
final published = spec?.actions ?? const <Widget>[];
final onSearch = widget.onSearch;
final windows = widget.windowManager;
+3
View File
@@ -104,8 +104,11 @@ class ShellNavigationRail extends StatelessWidget {
icon: KeyedSubtree(
key: ValueKey('shell.destination.${destination.name}'),
// The bar it replaces named each tab in a tooltip too.
// The destination's label already names it for assistive
// technology; the tooltip must not repeat it.
child: Tooltip(
message: destinationDetails(destination).label,
excludeFromSemantics: true,
child: icon(destination),
),
),
@@ -39,8 +39,14 @@ class FloatingDestinationBar extends StatefulWidget {
this.edge = FloatingBarEdge.bottom,
this.alignment,
this.showLabels = false,
this.maxLabelScale,
});
/// The largest text scale [showLabels] captions follow; null follows the
/// system's. A page's own tabs cap it so large text cannot stack them over
/// the content they switch.
final double? maxLabelScale;
/// Main app navigation keeps names visible; dense page tabs can stay icons.
final bool showLabels;
@@ -188,13 +194,20 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
Widget _row(BuildContext context, double width) {
if (widget.showLabels) {
return FloatingDestinationLabels(
final labels = FloatingDestinationLabels(
key: FloatingDestinationBar.rowKey,
labels: [for (final item in items) item.label],
selected: currentIndex,
buttonBuilder: (index) => _button(context, index),
onTap: widget.onTap,
);
final max = widget.maxLabelScale;
return max == null
? labels
: MediaQuery.withClampedTextScaling(
maxScaleFactor: max,
child: labels,
);
}
final gap = _gap(width);
// As tall as the selected (largest) button; the others are centred on
+17
View File
@@ -53,6 +53,7 @@ class AppListRow extends StatelessWidget {
this.timeWidget,
this.subtitle,
this.compactSubtitle,
this.detail,
this.subtitleLeading,
this.subtitleTrailing,
this.menu,
@@ -88,6 +89,10 @@ class AppListRow extends StatelessWidget {
/// Replaces [subtitle] in a compact row, which has less room for facts.
final Widget? compactSubtitle;
/// An optional third line under the subtitle (a failed run's reason), one
/// ellipsised line in the subtitle style unless the widget styles itself.
final Widget? detail;
final Widget? subtitleLeading;
final Widget? subtitleTrailing;
final Widget? menu;
@@ -271,6 +276,17 @@ class AppListRow extends StatelessWidget {
// A compact row has no room beside its title: the time takes a line of
// its own under the subtitle.
final timeLine = compact ? time : null;
final detailLine = detail == null
? null
: Padding(
padding: const EdgeInsets.only(top: _lineGap),
child: DefaultTextStyle(
style: styles.subtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
child: detail!,
),
);
if (line == null && subtitleLeading == null && subtitleTrailing == null) {
if (timeLine == null) return titleLine;
return Column(
@@ -311,6 +327,7 @@ class AppListRow extends StatelessWidget {
),
],
),
?detailLine,
?timeLine,
],
);
@@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
import '../adaptive/platform.dart';
/// Whether icon-only actions show a visible caption: on touch devices, which
/// have no hover to reveal a tooltip. Desktop keeps icons with tooltips.
bool showsActionCaptions(BuildContext context) =>
!prefersCompactHitTargets(context);
/// A toolbar action that is an [IconButton] with its tooltip on desktop and,
/// on touch, the icon over a short visible [caption] in the same 48 dp tall
/// target, so a phone user can read what it does without long-pressing.
///
/// [label] is the full accessible name (and desktop tooltip); [caption] is
/// the short word drawn under the icon, defaulting to [label].
class LabelledIconButton extends StatelessWidget {
const LabelledIconButton({
super.key,
required this.icon,
required this.label,
required this.onPressed,
this.caption,
this.isSelected = false,
this.iconSize,
this.child,
});
final IconData icon;
final String label;
final String? caption;
final VoidCallback? onPressed;
final bool isSelected;
final double? iconSize;
/// Replaces the icon glyph (a progress indicator or a badged icon).
final Widget? child;
@override
Widget build(BuildContext context) {
final glyph = child ?? Icon(icon, size: iconSize);
if (!showsActionCaptions(context)) {
return IconButton(
tooltip: label,
isSelected: isSelected,
constraints: const BoxConstraints(
minWidth: kMinInteractiveDimension,
minHeight: kMinInteractiveDimension,
),
onPressed: onPressed,
icon: glyph,
);
}
final theme = Theme.of(context);
final color = onPressed == null
? theme.disabledColor
: isSelected
? theme.colorScheme.primary
: theme.colorScheme.onSurfaceVariant;
return Semantics(
button: true,
enabled: onPressed != null,
selected: isSelected,
label: label,
excludeSemantics: true,
child: InkResponse(
onTap: onPressed,
radius: kMinInteractiveDimension * 0.75,
child: ConstrainedBox(
constraints: const BoxConstraints(
minWidth: kMinInteractiveDimension,
minHeight: kMinInteractiveDimension,
maxHeight: kMinInteractiveDimension,
// A long caption scales down rather than widening the toolbar.
maxWidth: kMinInteractiveDimension + 8,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
IconTheme.merge(
data: IconThemeData(color: color, size: 22),
child: glyph,
),
const SizedBox(height: 2),
Text(
caption ?? label,
maxLines: 1,
style: theme.textTheme.labelSmall?.copyWith(color: color),
),
],
),
),
),
),
),
);
}
}
+116
View File
@@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../core/error_advice.dart';
import '../../core/error_reason.dart';
const errorNoticeDetailsKey = ValueKey<String>('error-notice-details');
const errorNoticeCopyKey = ValueKey<String>('error-notice-copy');
/// A failure as the operator should read it: a sentence saying what to do
/// for the common kinds (not connected, server too old, permission, timeout)
/// with the raw detail behind "Details" (selectable, with Copy); any other
/// failure shows its own message.
///
/// [error] is the exception or the message a controller kept.
class ErrorNotice extends StatefulWidget {
const ErrorNotice({
super.key,
required this.error,
this.textAlign = TextAlign.start,
this.actions = const <Widget>[],
});
final Object error;
/// Buttons for the failure (Retry), on one wrapping row with Details.
final List<Widget> actions;
final TextAlign textAlign;
@override
State<ErrorNotice> createState() => _ErrorNoticeState();
}
class _ErrorNoticeState extends State<ErrorNotice> {
bool _open = false;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final color = theme.colorScheme.error;
final advice = errorAdvice(widget.error);
final error = widget.error;
// Any other failure reads exactly as it was reported.
final message =
advice?.sentence ??
(error is String
? error
: describeErrorReason(error, fallback: 'Something went wrong.'));
final center = widget.textAlign == TextAlign.center;
final text = Semantics(
liveRegion: true,
child: Text(
message,
textAlign: widget.textAlign,
style: TextStyle(color: color),
),
);
final alignment = center ? WrapAlignment.center : WrapAlignment.start;
if (advice == null) {
if (widget.actions.isEmpty) return text;
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: center
? CrossAxisAlignment.center
: CrossAxisAlignment.start,
children: [
text,
Wrap(alignment: alignment, children: widget.actions),
],
);
}
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: center
? CrossAxisAlignment.center
: CrossAxisAlignment.start,
children: [
text,
Wrap(
alignment: alignment,
children: [
...widget.actions,
TextButton.icon(
key: errorNoticeDetailsKey,
onPressed: () => setState(() => _open = !_open),
icon: Icon(_open ? Icons.expand_less : Icons.expand_more),
label: Text(_open ? 'Hide details' : 'Details'),
),
],
),
if (_open)
Row(
mainAxisSize: center ? MainAxisSize.min : MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: SelectableText(
advice.detail,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
IconButton(
key: errorNoticeCopyKey,
tooltip: 'Copy details',
icon: const Icon(Icons.copy, size: 18),
onPressed: () =>
Clipboard.setData(ClipboardData(text: advice.detail)),
),
],
),
],
);
}
}
+2
View File
@@ -21,8 +21,10 @@ class RunStatusIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = runStatusColor(state, Theme.of(context).colorScheme);
// The label is the glyph's accessible name; the tooltip must not repeat it.
return Tooltip(
message: label,
excludeFromSemantics: true,
child: Semantics(
label: label,
image: true,
+4
View File
@@ -0,0 +1,4 @@
/// `1 stage`, `2 stages`: [count] with [one], or [many] (default `${one}s`)
/// for any count but one.
String countLabel(num count, String one, [String? many]) =>
'$count ${count == 1 ? one : many ?? '${one}s'}';
@@ -0,0 +1,27 @@
# Review findings: run outcomes, Run again, labels, errors, navigation
- Run rows show why a failed run ended (failure reason, else the diagnostic's
first line; full text in a tooltip) and a succeeded run's short result
preview. The run Summary leads with a "Why it failed" note.
- Run again (succeeded, canceled, interrupted) opens the New run form for the
run's pipeline at its latest version (the original offered), pre-filled with
the prompt, workspace and report format.
- Run detail and stage page tabs show their names; on touch, the Runs header
and artifact viewer actions show captions (desktop keeps tooltips).
- Common failures (not connected, server too old, permission, timeout) read
as what to do, with the raw detail behind Details (`ErrorNotice`): Schedules,
the create-chat dialog, the Runs list/detail and Pipelines banners.
- Settings has no Back arrow however it was reached (the system Back still
leaves it); Schedules keeps the rail on wide windows; a phone's Settings
leads with Connection and Notifications and has a "Jump to topic" menu.
- Walkthrough: Open Connection on the connect page (skipped when connected),
a labelled Copy command.
- Pluralised counts (`countLabel`); the status glyph and rail tabs no longer
repeat their names to screen readers.
Evidence: capture kit at 560x1000 and 1440x900, light and dark (runs list,
failed run Summary, more menu, Run again form, Settings, Schedules, the
walkthrough), plus Android touch captures of the Runs header, artifact viewer
and Settings topics. Not captured: the disconnected walkthrough page and an
ErrorNotice with advice (the fixture has neither state); both are covered by
widget tests.
@@ -7,6 +7,7 @@ import 'package:pipelines_app/application/schedules_destination.dart';
import 'package:pipelines_app/application/server_endpoint.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
@@ -80,4 +81,41 @@ void main() {
expect(find.byKey(scheduleRefreshKey), findsOneWidget);
expect(find.byType(SegmentedBackButton), findsOneWidget);
});
testWidgets('a wide window keeps the navigation rail beside Schedules; a '
'narrow one does not', (tester) async {
final client = PipelinesClient(channelFactory: (_) => FakeChannel());
final server = ServerEndpoint.resolve(
base: Uri.parse('http://127.0.0.1:8096/'),
web: true,
);
final session = AppSession(endpoint: server.uri, client: client);
addTearDown(session.dispose);
final selected = <AppDestination>[];
Future<void> pumpAt(double width) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
await tester.pumpWidget(
MaterialApp(
home: SchedulesDestination(
session: session,
server: server,
onBack: () {},
onOpenPipeline: (_) {},
onSelectDestination: selected.add,
),
),
);
await tester.pump();
}
addTearDown(tester.view.reset);
await pumpAt(1300);
expect(find.byType(NavigationRail), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
expect(selected, [AppDestination.runs]);
await pumpAt(500);
expect(find.byType(NavigationRail), findsNothing);
});
}
+7 -6
View File
@@ -38,9 +38,9 @@ void main() {
androidSupported: false,
server: webServer(),
client: PipelinesClient(
replaceSilentSocket: false,
channelFactory: (_) => channel,
),
replaceSilentSocket: false,
channelFactory: (_) => channel,
),
routeInformationProvider: provider,
),
);
@@ -143,8 +143,8 @@ void main() {
await tester.pump();
});
testWidgets('the /settings deep link opens Settings as a pushed page with '
'Back, and the system Back closes it to Pipelines', (tester) async {
testWidgets('the /settings deep link opens Settings with no Back arrow, and '
'the system Back closes it to Pipelines', (tester) async {
final provider = await pumpApp(
tester,
location: '/settings',
@@ -152,7 +152,8 @@ void main() {
);
await tester.pump();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
// A top-level destination draws no Back arrow however it was reached.
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
expect(selectedTab(tester), 4);
final handled = await tester.binding.handlePopRoute();
@@ -313,8 +313,10 @@ void main() {
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/settings');
// A tab retap preserves Settings; explicit Back returns to Pipelines.
await tester.tap(find.byKey(const Key('shell.back')));
// Settings is a top-level destination with no Back arrow; the system
// Back still returns to Pipelines.
expect(find.byKey(const Key('shell.back')), findsNothing);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/pipelines');
expect(find.text('Probe release'), findsOneWidget);
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_fullscreen.dart';
@@ -76,7 +77,13 @@ Future<void> _enter(WidgetTester tester) async {
}
/// A bar control by its Material tooltip.
Finder _named(String name) => find.byTooltip(name);
/// A control named [name]: by its tooltip on desktop, or by its accessible
/// name where touch shows the name as a caption instead.
Finder _named(String name) => find.byWidgetPredicate(
(widget) =>
(widget is Tooltip && widget.message == name) ||
(widget is LabelledIconButton && widget.label == name),
);
void main() {
testWidgets('the bottom actions offer Full screen', (tester) async {
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_body.dart';
import 'package:pipelines_app/features/changes/widgets/diff_form_control.dart';
@@ -56,7 +57,14 @@ void main() {
),
),
);
await tester.tap(find.byTooltip('Details'));
// A tooltip on desktop; a caption under the icon on touch.
await tester.tap(
find.byWidgetPredicate(
(widget) =>
(widget is Tooltip && widget.message == 'Details') ||
(widget is LabelledIconButton && widget.label == 'Details'),
),
);
await tester.pumpAndSettle();
expect(find.text('Recorded artifact facts'), findsOneWidget);
expect(find.byType(Dialog), width >= 600 ? findsOneWidget : findsNothing);
@@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/pipelines/pending_run_store.dart';
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
import 'package:pipelines_app/features/pipelines/run_pipeline_intent.dart';
import 'package:pipelines_app/features/pipelines/run_pipeline_seed.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_version_field.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/features/runs/actions/retry_eligibility.dart';
import 'package:pipelines_app/features/runs/ui/run_again_flow.dart';
import '../../pipelines/fixtures.dart';
import '../../pipelines/ui/run_pipeline_launch_test.dart'
show acceptedRun, launchGateway;
/// Run again: a finished run that did not fail opens the New run form for its
/// pipeline, pre-filled with its prompt, workspace and report requirement,
/// at the latest version with the original offered.
void main() {
JsonMap finished({String status = 'succeeded', bool withInput = true}) => {
'id': 9,
'status': status,
'executing': false,
'pipeline_id': 1,
'version': 1,
'workspace': '/work/alpha',
'output_format': 'markdown',
if (withInput) 'input': {'prompt': 'Ship the release notes.'},
};
test('only finished runs that did not fail can run again', () {
expect(canRunAgain(finished()), isTrue);
expect(canRunAgain(finished(status: 'canceled')), isTrue);
expect(canRunAgain(finished(status: 'interrupted')), isTrue);
expect(canRunAgain(finished(status: 'failed')), isFalse);
expect(canRunAgain(finished()..['executing'] = true), isFalse);
expect(canRunAgain(finished()..remove('pipeline_id')), isFalse);
});
test('the seed carries the run inputs and its version', () {
final seed = runAgainSeed(finished());
expect(seed.prompt, 'Ship the release notes.');
expect(seed.workspace, '/work/alpha');
expect(seed.originalVersion, 1);
expect(seed.outputFormat, RunOutputFormat.markdown);
expect(runPipelineVersionChoices(2, 1), [2, 1]);
expect(runPipelineVersionChoices(2, 2), [2]);
});
testWidgets('the form opens pre-filled at the latest version and can '
'start the original one', (tester) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final launched = <JsonMap>[];
final fixture = PipelineFixture();
final gateway = launchGateway(
fixture,
onLaunch: (fields) {
launched.add(fields);
return acceptedRun(30);
},
onLookup: (_) => {'type': 'run', 'run_detail': finished()},
);
final controller = PipelinesController(
PipelinesRepository(gateway),
pendingRunStore: MemoryPendingRunStore(),
);
addTearDown(controller.dispose);
final started = <int>[];
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) => TextButton(
onPressed: () => startRunAgainFlow(
context: context,
// A list row carries no input: the run is read first.
run: finished(withInput: false),
controller: controller,
gateway: gateway,
onRunStarted: started.add,
),
child: const Text('again'),
),
),
),
);
await tester.tap(find.text('again'));
await tester.pumpAndSettle();
final prompt = tester.widget<TextField>(find.byKey(runPipelinePromptKey));
expect(prompt.controller!.text, 'Ship the release notes.');
final workspace = tester.widget<TextField>(
find.byKey(runPipelineWorkspaceKey),
);
expect(workspace.controller!.text, '/work/alpha');
expect(find.text('Latest (v2)'), findsOneWidget);
await tester.tap(find.byKey(runPipelineVersionKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Original run (v1)').last);
await tester.pumpAndSettle();
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
expect(launched, hasLength(1));
expect(launched.single['pipeline_id'], 1);
expect(launched.single['version'], 1);
expect(launched.single['workspace'], '/work/alpha');
expect(launched.single['input'], {'prompt': 'Ship the release notes.'});
expect(launched.single['output_format'], 'markdown');
expect(started, [30]);
});
}
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'run_detail_graph_support.dart';
@@ -81,7 +82,13 @@ void main() {
final rest = tester.getTopLeft(facts).dy;
expect(rest, greaterThanOrEqualTo(barBottom));
// The tabs float at the bottom over the section.
final tabs = pieceOf(tester, find.byKey(const Key('run-visit-tabs')));
// The labelled row (buttons over their captions) ends above the margin.
final tabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('run-visit-tabs')),
matching: find.byKey(FloatingDestinationBar.rowKey),
),
);
expect(tabs.bottom, 844 - 16);
expect(tester.getRect(summary).bottom, 844);
@@ -97,11 +97,8 @@ void main() {
),
);
final body = find.byKey(const Key('run-detail-tab-body-summary'));
// Sized to its tabs at the right, floating above the bottom.
expect(
pill.width,
FloatingDestinationBar.rowWidth(tabs: renderedRunDetailTabs.length),
);
// Sized to its labelled tabs at the right, floating above the bottom.
expect(pill.width, lessThan(390 * 0.85));
expect(pill.right, 390 - 16);
expect(pill.bottom, 844 - 16);
// The tab's content reaches the bottom edge, behind the bar.
@@ -294,8 +294,8 @@ void main() {
);
expect(pill.right, size.width - 16);
expect(pill.bottom, size.height - 16);
// Sized to its tabs at the right on every width.
expect(pill.width, lessThan(size.width * 0.7));
// Sized to its labelled tabs at the right on every width.
expect(pill.width, lessThan(size.width * 0.8));
},
);
}
@@ -0,0 +1,149 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show SemanticsNode;
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/domain/run_outcome_line.dart';
import 'package:pipelines_app/features/runs/ui/run_again_flow.dart';
import 'package:pipelines_app/features/runs/ui/run_failure_banner.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
JsonMap _run(String status, [JsonMap extra = const {}]) => {
'id': 7,
'title': 'Nightly release',
'name': 'release',
'status': status,
'executing': false,
'pipeline_id': 3,
'created_at': '2026-10-21T12:00:00Z',
'finished_at': '2026-10-21T12:02:05Z',
...extra,
};
class _FakeGateway implements ApiGateway {
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async => {};
@override
Stream<JsonMap> get frames => const Stream.empty();
}
/// A run row says why a run failed (its failure reason, else its
/// diagnostic's first line) in one line with the full text in a tooltip, and
/// a succeeded run's short result; its status is read once.
void main() {
test('the outcome line prefers the failure reason, then the diagnostic', () {
final reason = runOutcomeLine(
_run('failed', {
'failure_reason': 'Stage review timed out',
'diagnostic': 'trace\nmore',
}),
);
expect(reason?.line, 'Stage review timed out');
expect(reason?.failed, isTrue);
final diagnostic = runOutcomeLine(
_run('failed', {'diagnostic': '\n exit status 2\nstack trace'}),
);
expect(diagnostic?.line, 'exit status 2');
expect(diagnostic?.full, 'exit status 2\nstack trace');
expect(runOutcomeLine(_run('failed')), isNull);
expect(
runOutcomeLine(
_run('succeeded', {'result_preview': 'Released 1.2'}),
)?.line,
'Released 1.2',
);
// A long or multi-line preview is left to the detail.
expect(
runOutcomeLine(_run('succeeded', {'result_preview': 'x' * 200})),
isNull,
);
expect(
runOutcomeLine(_run('succeeded', {'result_preview': 'a\nb'})),
isNull,
);
expect(runOutcomeLine(_run('running', {'failure_reason': 'x'})), isNull);
});
Future<void> pumpRow(WidgetTester tester, JsonMap run) async {
tester.view.physicalSize = const Size(800, 400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunListRow(
run: run,
now: DateTime.utc(2026, 10, 22),
gateway: _FakeGateway(),
onRunChanged: (_) {},
onRunAgain: (_) {},
),
),
),
);
await tester.pumpAndSettle();
}
testWidgets('a failed row shows its reason with the full text in a '
'tooltip', (tester) async {
const reason = 'Stage review timed out after 30 minutes';
await pumpRow(tester, _run('failed', {'failure_reason': reason}));
expect(find.text(reason), findsOneWidget);
final tooltip = tester.widget<Tooltip>(
find.byKey(const ValueKey('run-row-outcome-7')),
);
expect(tooltip.message, reason);
});
testWidgets('the row reads its status once', (tester) async {
final semantics = tester.ensureSemantics();
await pumpRow(tester, _run('failed', {'failure_reason': 'Boom'}));
final labels = <String>[];
void collect(SemanticsNode node) {
final data = node.getSemanticsData();
labels.add('${data.label} ${data.tooltip}');
node.visitChildren((child) {
collect(child);
return true;
});
}
collect(tester.getSemantics(find.byType(RunListRow)));
final all = labels.join(' ');
expect(RegExp(r'\bfailed\b').allMatches(all), hasLength(1), reason: all);
semantics.dispose();
});
testWidgets('a succeeded run offers Run again; a failed one does not', (
tester,
) async {
await pumpRow(tester, _run('succeeded'));
await tester.tap(find.byKey(const ValueKey('run-list-more-menu-7')));
await tester.pumpAndSettle();
expect(find.byKey(runAgainActionKey), findsOneWidget);
await tester.tapAt(Offset.zero);
await tester.pumpAndSettle();
await pumpRow(tester, _run('failed', {'failure_reason': 'Boom'}));
await tester.tap(find.byKey(const ValueKey('run-list-more-menu-7')));
await tester.pumpAndSettle();
expect(find.byKey(runAgainActionKey), findsNothing);
});
testWidgets('the Summary leads with why a failed run failed', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunFailureBanner(
run: _run('failed', {'diagnostic': 'exit status 2'}),
),
),
),
);
expect(find.text('Why it failed'), findsOneWidget);
expect(find.text('exit status 2'), findsOneWidget);
await tester.pumpWidget(
MaterialApp(home: RunFailureBanner(run: _run('succeeded'))),
);
expect(find.text('Why it failed'), findsNothing);
});
}
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/settings/settings_phone_order.dart';
import 'package:pipelines_app/features/settings/settings_search_page.dart';
import 'package:pipelines_app/features/settings/settings_section.dart';
SettingsSection _section(String id, String title) => SettingsSection(
id: id,
title: title,
keywords: '',
builder: (_) => SizedBox(height: 400, child: Text('$title body')),
);
/// A phone's Settings lead with Connection and Notifications and offer a
/// "Jump to topic" menu; a wide window keeps its order and index column.
void main() {
final sections = [
_section('interface-size', 'Interface size'),
_section('font', 'Font'),
_section('notifications', 'Notifications'),
_section('connection', 'Connection'),
_section('help', 'Help and about'),
];
test('Connection, then Notifications, lead on a phone', () {
expect(settingsPhoneOrder(sections).map((section) => section.id), [
'connection',
'notifications',
'interface-size',
'font',
'help',
]);
});
Future<void> pumpAt(WidgetTester tester, double width) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(body: SettingsSearchPage(sections: sections)),
),
);
await tester.pumpAndSettle();
}
testWidgets('a phone jumps to a topic from its menu', (tester) async {
await pumpAt(tester, 390);
final connection = tester.getTopLeft(find.text('Connection body')).dy;
final size = tester.getTopLeft(find.text('Interface size body')).dy;
expect(connection, lessThan(size));
await tester.tap(find.byKey(settingsTopicMenuKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Help and about').last);
await tester.pumpAndSettle();
expect(
tester.getTopLeft(find.text('Help and about body')).dy,
lessThan(400),
);
});
testWidgets('a wide window keeps its order and has no topic menu', (
tester,
) async {
await pumpAt(tester, 1300);
expect(find.byKey(settingsTopicMenuKey), findsNothing);
final connection = tester.getTopLeft(find.text('Connection body')).dy;
final size = tester.getTopLeft(find.text('Interface size body')).dy;
expect(size, lessThan(connection));
});
}
@@ -232,6 +232,10 @@ void main() {
await tester.enterText(workspace, ' /srv/pipelines ');
await tester.pump();
// A phone leads with Connection and Notifications, so Save may sit
// below the fold.
await tester.ensureVisible(find.byKey(SettingsKeys.saveWorkspace));
await tester.pump();
await tester.tap(find.byKey(SettingsKeys.saveWorkspace));
await tester.pump();
await tester.pump();
@@ -359,7 +363,9 @@ void main() {
expect(row, findsOneWidget);
expect(
tester
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
.widget<ListTile>(
find.descendant(of: row, matching: find.byType(ListTile)),
)
.enabled,
isTrue,
);
@@ -391,7 +397,9 @@ void main() {
expect(row, findsOneWidget);
expect(
tester
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
.widget<ListTile>(
find.descendant(of: row, matching: find.byType(ListTile)),
)
.enabled,
isFalse,
);
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/walkthrough/first_run_walkthrough.dart';
import 'package:pipelines_app/features/walkthrough/walkthrough_steps.dart';
const _openConnectionKey = ValueKey<String>('walkthrough.open-connection');
/// The walkthrough acts as well as directs: Open Connection on the connect
/// page (skipped once connected) and a labelled Copy command.
void main() {
Future<void> launch(
WidgetTester tester, {
required bool connected,
required VoidCallback onOpenConnection,
}) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) => TextButton(
onPressed: () => showFirstRunWalkthrough(
context,
connected: connected,
onOpenConnection: onOpenConnection,
),
child: const Text('Open'),
),
),
),
),
);
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
}
testWidgets('Open Connection closes the walkthrough and opens it', (
tester,
) async {
var opened = 0;
await launch(tester, connected: false, onOpenConnection: () => opened++);
expect(find.textContaining('enter the Server URL'), findsOneWidget);
await tester.tap(find.byKey(_openConnectionKey));
await tester.pumpAndSettle();
expect(opened, 1);
expect(find.text('Step 1 of 4'), findsNothing);
});
testWidgets('a connected app skips the connect directions', (tester) async {
await launch(tester, connected: true, onOpenConnection: () {});
expect(find.text('Step 1 of 4'), findsOneWidget);
expect(find.textContaining('this app is connected'), findsOneWidget);
expect(find.textContaining('enter the Server URL'), findsNothing);
expect(find.byKey(_openConnectionKey), findsNothing);
expect(walkthroughStepsFor(connected: true), hasLength(4));
});
testWidgets('the harness page labels its copy action', (tester) async {
await launch(tester, connected: true, onOpenConnection: () {});
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.next')));
await tester.pumpAndSettle();
expect(
find.descendant(
of: find.byKey(const ValueKey<String>('walkthrough.copy')),
matching: find.text('Copy command'),
),
findsOneWidget,
);
});
}
@@ -62,8 +62,7 @@ class _HeldStore implements WalkthroughStore {
Future<void> markSeen() => inner.markSeen();
@override
Future<bool> wasOffered(String serverScope) =>
inner.wasOffered(serverScope);
Future<bool> wasOffered(String serverScope) => inner.wasOffered(serverScope);
@override
Future<void> markOffered(String serverScope) =>
@@ -98,7 +97,10 @@ Widget _host({
Future<void> _finishWalkthrough(WidgetTester tester) async {
for (var page = 0; page < 3; page++) {
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.next')));
final next = find.byKey(const ValueKey<String>('walkthrough.next'));
await tester.ensureVisible(next);
await tester.pumpAndSettle();
await tester.tap(next);
await tester.pumpAndSettle();
}
await tester.tap(find.text('Done'));
+14
View File
@@ -77,6 +77,20 @@ void main() {
expect(settings.bottom, closeTo(railRect.bottom, 1));
});
testWidgets('a rail tab is named once for assistive technology', (
tester,
) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: 1000);
final node = tester.getSemantics(
find.byKey(const ValueKey('shell.destination.pipelines')),
);
// The label and its tab position; the tooltip does not repeat the name.
expect(node.label, startsWith('Pipelines'));
expect(node.tooltip, isEmpty);
semantics.dispose();
});
testWidgets('the rail marks the selected tab and one tap selects another', (
tester,
) async {
+8 -24
View File
@@ -3,9 +3,9 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
/// Settings' Back: a destination reached from a shell control has none; a page
/// pushed by a route (a first load or a route change, such as a deep link or
/// the Pipelines gear) has one that returns to Pipelines.
/// Settings is a top-level destination: it draws no Back arrow however it was
/// reached (a shell control, a route change, a deep link or the Pipelines
/// gear); the system Back still leaves it for the previous destination.
void main() {
AdaptiveShell shellAt(AppDestination destination) => AdaptiveShell(
destination: destination,
@@ -48,8 +48,8 @@ void main() {
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
});
testWidgets('Settings pushed by a route change has Back, which returns to '
'Pipelines', (tester) async {
testWidgets('Settings reached by a route change has no Back arrow; the '
'system Back returns to Pipelines', (tester) async {
await pumpAt(tester, AppDestination.pipelines);
// The route moves to Settings (as a gear or a deep link does).
await tester.pumpWidget(
@@ -57,34 +57,18 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text('settings body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(find.text('pipelines body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
});
testWidgets('a first load on Settings (a deep link) has Back', (
testWidgets('a first load on Settings (a deep link) has no Back arrow', (
tester,
) async {
await pumpAt(tester, AppDestination.settings);
expect(find.text('settings body'), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
});
testWidgets('a nav selection after a pushed Settings clears its Back', (
tester,
) async {
await pumpAt(tester, AppDestination.settings);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('chat body'), findsOneWidget);
// Settings opened again from its rail item is a destination, not a page.
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
});
}
+4 -1
View File
@@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
@@ -46,7 +47,9 @@ Future<void> _setUp(WidgetTester tester, double scale) async {
List<Rect> _controls(WidgetTester tester, Finder pill) {
final found = find.descendant(
of: pill,
matching: find.byWidgetPredicate((widget) => widget is IconButton),
matching: find.byWidgetPredicate(
(widget) => widget is IconButton || widget is LabelledIconButton,
),
);
final rects = [
for (var i = 0; i < found.evaluate().length; i++)
@@ -9,7 +9,8 @@ import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
/// Every bottom tab bar shows icons only, yet each tab keeps its name for
/// The pipeline detail's bottom tabs show icons only and a run's show their
/// names under them; either way each tab keeps its name for
/// assistive technology (and a Material tooltip), its selected state and its
/// test key; the icons within a bar, and against the shell's tabs a detail's
/// bar floats above, are distinct.
@@ -50,6 +51,7 @@ void main() {
),
};
const labelled = {'run detail', 'stage page'};
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
testWidgets('$label tabs are icons named for assistive '
'technology', (tester) async {
@@ -61,10 +63,11 @@ void main() {
await tester.pumpAndSettle();
final floating = find.byType(FloatingDestinationBar);
// No label is drawn at all.
// A run's tabs name themselves on screen (a phone has no tooltip);
// the pipeline detail's stay icons.
expect(
find.descendant(of: floating, matching: find.byType(Text)),
findsNothing,
labelled.contains(label) ? findsNWidgets(tabs.length) : findsNothing,
);
for (final (index, (key, tabLabel)) in tabs.indexed) {
final finder = find.byKey(ValueKey(key));
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart';
/// Touch shows an action's caption under its icon (no hover tooltip there);
/// desktop keeps the icon with its tooltip. Both are named once for
/// assistive technology.
void main() {
Future<void> pump(WidgetTester tester) => tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: LabelledIconButton(
icon: Icons.sort,
label: 'Sort runs: Newest first',
caption: 'Sort',
onPressed: () {},
),
),
),
),
);
testWidgets(
'touch draws the caption and names the full action',
(tester) async {
final semantics = tester.ensureSemantics();
await pump(tester);
expect(find.text('Sort'), findsOneWidget);
expect(find.byType(Tooltip), findsNothing);
expect(find.bySemanticsLabel('Sort runs: Newest first'), findsOneWidget);
expect(tester.getSize(find.byType(LabelledIconButton)).height, 48);
semantics.dispose();
},
variant: TargetPlatformVariant.only(TargetPlatform.android),
);
testWidgets(
'desktop keeps the icon with its tooltip',
(tester) async {
await pump(tester);
expect(find.text('Sort'), findsNothing);
expect(find.byTooltip('Sort runs: Newest first'), findsOneWidget);
expect(find.byType(IconButton), findsOneWidget);
},
variant: TargetPlatformVariant.only(TargetPlatform.linux),
);
}
+80
View File
@@ -0,0 +1,80 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/error_advice.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/ui/status/error_notice.dart';
import 'package:pipelines_app/ui/text/plural.dart';
/// Common failures read as what to do, with the raw detail kept behind
/// Details; any other failure reads exactly as reported.
void main() {
test('common failures map to their kind', () {
expect(
errorAdviceKind(const NotConnectedError()),
ErrorAdviceKind.notConnected,
);
expect(
errorAdviceKind(StateError('Connection closed')),
ErrorAdviceKind.notConnected,
);
expect(
errorAdviceKind(const ProtocolError('unknown command: list_schedules')),
ErrorAdviceKind.serverTooOld,
);
expect(
errorAdviceKind(const ProtocolError('x', code: 'elevation_required')),
ErrorAdviceKind.permission,
);
expect(
errorAdviceKind('permission denied: /srv'),
ErrorAdviceKind.permission,
);
expect(
errorAdviceKind(TimeoutException('request timed out after 30000ms')),
ErrorAdviceKind.timeout,
);
expect(errorAdviceKind('pipeline 4 has no stage review'), isNull);
final advice = errorAdvice(StateError('Connection closed'));
expect(advice?.detail, 'Connection closed');
expect(advice?.sentence, contains('Settings'));
});
testWidgets('a common failure says what to do and keeps its detail', (
tester,
) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: ErrorNotice(error: 'unknown command: list_schedules'),
),
),
);
expect(
find.text(errorAdviceSentence(ErrorAdviceKind.serverTooOld)),
findsOneWidget,
);
expect(find.text('unknown command: list_schedules'), findsNothing);
await tester.tap(find.byKey(errorNoticeDetailsKey));
await tester.pump();
expect(find.text('unknown command: list_schedules'), findsOneWidget);
expect(find.byKey(errorNoticeCopyKey), findsOneWidget);
});
testWidgets('any other failure reads as reported', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: ErrorNotice(error: 'Bad state: pipeline gone')),
),
);
expect(find.text('Bad state: pipeline gone'), findsOneWidget);
expect(find.byKey(errorNoticeDetailsKey), findsNothing);
});
test('counts are pluralised', () {
expect(countLabel(1, 'stage'), '1 stage');
expect(countLabel(3, 'stage'), '3 stages');
expect(countLabel(0, 'file'), '0 files');
});
}
@@ -60,6 +60,8 @@ JsonMap probeRunDetail() => {
'id': 7,
'title': 'Release train run',
'name': 'release-train',
'pipeline_id': 24,
'version': 4,
'status': _liveRunStatus ?? 'succeeded',
'created_at': '2026-10-20T08:12:00Z',
'finished_at': '2026-10-20T08:42:00Z',
@@ -259,6 +261,7 @@ List<JsonMap> probeRuns() => [
'title': 'Release train run',
'name': 'release-train',
'status': _liveRunStatus ?? 'succeeded',
'result_preview': 'Release 2.4 shipped; notes published.',
'created_at': '2026-10-20T08:12:00Z',
'finished_at': '2026-10-20T08:42:00Z',
'pipeline_id': 24,
@@ -268,6 +271,10 @@ List<JsonMap> probeRuns() => [
'title': 'Nightly docs run',
'name': 'nightly-docs',
'status': 'failed',
'failure_reason':
'Stage publish failed: the docs host rejected the upload '
'(HTTP 413, bundle larger than 50 MB).',
'diagnostic': 'upload rejected\nHTTP 413 Payload Too Large',
'created_at': '2026-10-19T22:00:00Z',
'finished_at': '2026-10-19T22:03:00Z',
'pipeline_id': 22,
@@ -544,6 +551,21 @@ JsonMap? probeReply(JsonMap request) {
'usage': null,
};
case 'get_run':
if (request['run_id'] == 6) {
// The failed run: its summary row is its whole recorded detail.
final failed = probeRuns().firstWhere((run) => run['id'] == 6);
return {
'id': id,
'type': 'run',
'run_detail': {
...failed,
'version': 1,
'workspace': '/srv/probe/docs',
'input': {'prompt': 'Publish the nightly docs.'},
'steps': <JsonMap>[],
},
};
}
if (request['run_id'] != 7) {
return error('Fixture run ${request['run_id']} is unavailable');
}