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
+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',
);