ebe79ebed0
Run detail gains a Findings tab (open-count badge) listing the server's findings ledger with status and minimum-severity filters and expandable event history; visit grants show as an Extra visits summary fact. The resume retry prompt can grant 1-5 extra visits to the exhausted stage or a chosen graph stage (never sent on restart), suggested when the run failed on a visit limit. A loop-exhaustion decision waiting on a model stage is now decidable from its recorded options, with readable labels, targets and the visit count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
173 lines
6.0 KiB
Dart
173 lines
6.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
|
import '../../../ui/text/monospace.dart';
|
|
import '../domain/run_findings.dart';
|
|
|
|
/// The Findings tab: the run's recorded findings ledger, filtered by status
|
|
/// (open first when any are open) and by minimum severity. Each finding
|
|
/// expands to show who raised it and its recorded status changes.
|
|
class RunFindingsTab extends StatefulWidget {
|
|
const RunFindingsTab({super.key, required this.findings});
|
|
|
|
final List<RunFinding> findings;
|
|
|
|
@override
|
|
State<RunFindingsTab> createState() => _RunFindingsTabState();
|
|
}
|
|
|
|
class _RunFindingsTabState extends State<RunFindingsTab> {
|
|
late String? _status = defaultFindingStatus(widget.findings);
|
|
FindingSeverity? _minSeverity;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final shown = filterFindings(
|
|
widget.findings,
|
|
status: _status,
|
|
minSeverity: _minSeverity,
|
|
);
|
|
return ListView(
|
|
key: const Key('run-detail-tab-body-findings'),
|
|
padding: withBarClearance(context, const EdgeInsets.all(16)),
|
|
children: [
|
|
_filters(context),
|
|
const SizedBox(height: 8),
|
|
if (shown.isEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
child: Text(
|
|
'No findings match these filters.',
|
|
key: const Key('run-findings-empty'),
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
),
|
|
),
|
|
for (final finding in shown) RunFindingTile(finding: finding),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _filters(BuildContext context) {
|
|
int count(String? status) =>
|
|
filterFindings(widget.findings, status: status).length;
|
|
return Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
children: [
|
|
for (final status in <String?>[null, ...findingStatuses])
|
|
ChoiceChip(
|
|
key: ValueKey('run-findings-status-${status ?? 'all'}'),
|
|
label: Text('${_statusLabel(status)} (${count(status)})'),
|
|
selected: _status == status,
|
|
onSelected: (_) => setState(() => _status = status),
|
|
),
|
|
DropdownMenu<FindingSeverity?>(
|
|
key: const Key('run-findings-severity'),
|
|
label: const Text('Minimum severity'),
|
|
initialSelection: _minSeverity,
|
|
onSelected: (value) => setState(() => _minSeverity = value),
|
|
dropdownMenuEntries: [
|
|
const DropdownMenuEntry(value: null, label: 'All severities'),
|
|
for (final severity in FindingSeverity.values)
|
|
DropdownMenuEntry(value: severity, label: severity.name),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
String _statusLabel(String? status) => switch (status) {
|
|
null => 'All',
|
|
final text => '${text[0].toUpperCase()}${text.substring(1)}',
|
|
};
|
|
|
|
/// One finding: severity, id and summary, with origin, location, status and
|
|
/// the latest reason under it; expanding shows its recorded events.
|
|
class RunFindingTile extends StatelessWidget {
|
|
const RunFindingTile({super.key, required this.finding});
|
|
|
|
final RunFinding finding;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final meta = [
|
|
if (finding.severityText.isNotEmpty) finding.severityText,
|
|
if (finding.origin.isNotEmpty) finding.origin,
|
|
if (finding.status.isNotEmpty) finding.status,
|
|
].join(' · ');
|
|
final history = [
|
|
if (finding.raisedBy.isNotEmpty)
|
|
'Raised by ${finding.raisedBy}${_visit(finding.raisedSequence)}',
|
|
if (finding.updatedBy.isNotEmpty)
|
|
'Updated by ${finding.updatedBy}${_visit(finding.updatedSequence)}',
|
|
];
|
|
return ExpansionTile(
|
|
key: ValueKey('run-finding-${finding.id}'),
|
|
tilePadding: EdgeInsets.zero,
|
|
childrenPadding: const EdgeInsetsDirectional.only(start: 40, bottom: 8),
|
|
expandedCrossAxisAlignment: CrossAxisAlignment.start,
|
|
leading: Icon(
|
|
_severityIcon(finding.severity),
|
|
color: _severityColor(theme.colorScheme, finding.severity),
|
|
),
|
|
title: Text(
|
|
[
|
|
finding.id,
|
|
finding.summary,
|
|
].where((part) => part.isNotEmpty).join(' · '),
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(meta),
|
|
if (finding.location.isNotEmpty)
|
|
SelectableText(
|
|
finding.location,
|
|
style: const TextStyle(fontFamily: appMonospaceFamily),
|
|
),
|
|
if (finding.reason.isNotEmpty) Text(finding.reason),
|
|
],
|
|
),
|
|
children: [
|
|
for (final line in history)
|
|
Text(line, style: theme.textTheme.bodySmall),
|
|
for (final event in finding.events)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 4),
|
|
child: Text(
|
|
[
|
|
if (event.sequence != null) '#${event.sequence}',
|
|
if (event.stage.isNotEmpty) event.stage,
|
|
if (event.status.isNotEmpty) event.status,
|
|
].join(' · ') +
|
|
(event.reason.isEmpty ? '' : ': ${event.reason}'),
|
|
style: theme.textTheme.bodySmall,
|
|
),
|
|
),
|
|
if (history.isEmpty && finding.events.isEmpty)
|
|
Text('No recorded history.', style: theme.textTheme.bodySmall),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
String _visit(int? sequence) => sequence == null ? '' : ' (visit #$sequence)';
|
|
|
|
IconData _severityIcon(FindingSeverity? severity) => switch (severity) {
|
|
FindingSeverity.critical => Icons.error,
|
|
FindingSeverity.important => Icons.warning_amber,
|
|
FindingSeverity.minor => Icons.info_outline,
|
|
FindingSeverity.nit || null => Icons.label_outline,
|
|
};
|
|
|
|
Color _severityColor(ColorScheme scheme, FindingSeverity? severity) =>
|
|
switch (severity) {
|
|
FindingSeverity.critical => scheme.error,
|
|
FindingSeverity.important => scheme.tertiary,
|
|
FindingSeverity.minor => scheme.primary,
|
|
FindingSeverity.nit || null => scheme.onSurfaceVariant,
|
|
};
|