Files
pipelines/app/lib/features/runs/ui/run_failure_banner.dart
T
alan e72bee3faa First run: empty states with a next step, harness setup instead of errors
- One shared EmptyState (icon on a tonal disc, title, one line, primary
  action) that follows the design tokens; used by Runs (Start your first
  run), Pipelines (Browse templates), Schedules and the chat list (Start a
  chat).
- Chat on a server without an agent harness showed "Bad state: No saved
  machine is connected.": the federated list now keeps the server's own
  refusal, treats an omitted empty list as no chats, and the list shows a
  "Set up an agent" state with the harness setup command and Refresh. New
  chat shows the same step instead of a form that can only be refused.
- A run that fails because no harness CLI exists names the setup command
  beside the raw reason; error advice gains a noHarness kind.
- Templates opened before the app connected stayed on "Not connected";
  it now reads again when the connection arrives. The Pipelines empty state
  links to Templates, which had no entry point in the UI.
- The first-launch walkthrough waits briefly for the connection, so a
  connected web app is no longer told to connect; the empty-server check
  treats omitted lists and no chat harness as empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:29:23 +00:00

95 lines
3.5 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../core/error_advice.dart';
import '../domain/run_outcome_line.dart';
import '../../../ui/theme/app_design_tokens.dart';
/// The setup step a run that failed for want of an agent harness shows.
const runFailureHarnessHintKey = ValueKey<String>('run-failure-harness-hint');
/// 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.
///
/// [actions] (the run's Retry, Run again… and Open in chat; see
/// `RunFailureActions`) sit under the reason, so what to do next is beside
/// why it failed.
class RunFailureBanner extends StatelessWidget {
const RunFailureBanner({super.key, required this.run, this.actions});
final JsonMap run;
final Widget? actions;
@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: AppDesignTokens.of(
context,
).corners(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,
),
),
// A server without an agent harness is a setup step:
// say which, beside the raw reason.
if (needsHarnessSetup(outcome.full)) ...[
const SizedBox(height: 8),
Text(
errorAdviceSentence(ErrorAdviceKind.noHarness),
key: runFailureHarnessHintKey,
style: theme.textTheme.bodyMedium?.copyWith(
color: scheme.onErrorContainer,
fontWeight: FontWeight.w600,
),
),
],
if (actions case final actions?) ...[
const SizedBox(height: 8),
actions,
],
],
),
),
],
),
),
),
);
}
}