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. /// /// [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: 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, ), ), if (actions case final actions?) ...[ const SizedBox(height: 8), actions, ], ], ), ), ], ), ), ), ); } }