Files
pipelines/app/lib/ui/status/error_notice.dart
T
alan 545291e04a 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>
2026-12-02 20:16:22 +00:00

117 lines
3.6 KiB
Dart

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)),
),
],
),
],
);
}
}