App: run failure reasons, Run again, labelled tabs, actionable errors, nav fixes

- Run rows show a failed run's reason (else its diagnostic's first line,
  full text in a tooltip) or a short result preview; the Summary leads
  with "Why it failed".
- Run again for succeeded/canceled/interrupted runs opens the New run form
  pre-filled (prompt, workspace, report format) at the latest version with
  the original offered.
- Run detail and stage tabs show their names; touch shows captions on the
  Runs header and artifact viewer actions (desktop keeps tooltips).
- ErrorNotice maps not connected / server too old / permission / timeout
  to what to do, raw detail behind Details (Schedules, create chat, Runs,
  Pipelines banners).
- Settings has no Back arrow; Schedules keeps the rail on wide windows;
  phone Settings leads with Connection and Notifications and has a
  Jump to topic menu.
- Walkthrough: Open Connection (skipped when connected), labelled Copy.
- Pluralised counts; no duplicate status/rail names for screen readers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 20:16:22 +00:00
parent c441400f36
commit 545291e04a
68 changed files with 1719 additions and 156 deletions
@@ -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,
),
);
}