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'}';