Merge branch 'worktree-agent-aa9ed772f90c7c7b3'
This commit is contained in:
@@ -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: () => '');
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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]),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user