Files
pipelines/app/lib/features/runs/ui/run_detail_tab_strip.dart
T
alan ebe79ebed0 App: findings ledger tab, retry extra visits and exhaustion decisions
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>
2026-12-03 12:45:51 +00:00

140 lines
4.7 KiB
Dart

import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import 'run_detail_tab.dart';
/// The tabs the strip renders, in the web's order: Summary first so it is the
/// default, then the Timeline, the run's Artifacts and its Changes. Input and
/// Output are collapsible Summary sections now, so their stable enum keys stay
/// available for old routes but they are not separate tabs. The graph is a
/// preview on Summary that opens full screen, so it has no tab of its own.
const List<RunDetailTab> renderedRunDetailTabs = [
RunDetailTab.summary,
RunDetailTab.timeline,
RunDetailTab.artifacts,
RunDetailTab.changes,
];
/// The run's Artifacts count as a small badge: `0` on a run with none, so
/// the (disabled) tab still says why it cannot open.
class RunArtifactsCount extends StatelessWidget {
const RunArtifactsCount({super.key, required this.count, this.child});
final int count;
/// The icon the badge sits on; null draws the badge on its own.
final Widget? child;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return Badge(
key: const ValueKey('run-detail-artifacts-count'),
label: Text('$count'),
backgroundColor: count == 0
? scheme.surfaceContainerHighest
: scheme.secondary,
textColor: count == 0 ? scheme.onSurfaceVariant : scheme.onSecondary,
child: child,
);
}
}
/// The run's open findings as a badge on the Findings tab; nothing when none
/// are open.
class RunOpenFindingsCount extends StatelessWidget {
const RunOpenFindingsCount({super.key, required this.count, this.child});
final int count;
final Widget? child;
@override
Widget build(BuildContext context) {
if (count <= 0) return child ?? const SizedBox.shrink();
return Badge(
key: const ValueKey('run-detail-findings-count'),
label: Text('$count'),
child: child,
);
}
}
/// The run detail's tabs on a phone: the app's floating glass tab bar, full
/// width at the bottom of the page (a wide layout puts `RunDetailTopTabs`
/// under the run header instead).
///
/// Float it over the tab body with `FloatingBarOverlay` at the same [edge];
/// every tab is always visible, so a tab selected by the Graph is shown
/// selected without scrolling. Artifacts is always a tab, disabled with a
/// `0` count on a run with none, so the tabs after it never move between
/// runs. The whole bar is keyed `run-detail-tabs`, each tab
/// `run-detail-tab-<name>`.
class RunDetailTabStrip extends StatelessWidget {
const RunDetailTabStrip({
super.key,
required this.selected,
required this.onSelected,
this.tabs = renderedRunDetailTabs,
this.edge = FloatingBarEdge.bottom,
this.artifactCount,
this.openFindingCount,
this.disabled = const {},
this.disabledReasons = const {},
});
/// Why a disabled tab cannot open, as its tooltip.
final Map<RunDetailTab, String> disabledReasons;
final RunDetailTab selected;
final ValueChanged<RunDetailTab> onSelected;
final FloatingBarEdge edge;
/// The tabs this run offers, in [renderedRunDetailTabs] order.
final List<RunDetailTab> tabs;
/// The run's recorded artifacts, badged on the Artifacts tab; null draws
/// no badge.
final int? artifactCount;
/// The run's open findings, badged on the Findings tab when above zero.
final int? openFindingCount;
/// Tabs shown greyed out that take no taps.
final Set<RunDetailTab> disabled;
@override
Widget build(BuildContext context) {
final index = tabs.indexOf(selected);
final count = artifactCount;
return KeyedSubtree(
key: const Key('run-detail-tabs'),
child: FloatingDestinationBar(
// Named on screen: a phone has no tooltip to name an icon.
showLabels: true,
maxLabelScale: 1.3,
currentIndex: index < 0 ? 0 : index,
edge: edge,
onTap: (value) => onSelected(tabs[value]),
items: [
for (final tab in tabs)
FloatingDestinationItem(
key: ValueKey('run-detail-tab-${tab.name}'),
icon: tab == RunDetailTab.artifacts && count != null
? RunArtifactsCount(count: count, child: Icon(tab.icon))
: tab == RunDetailTab.findings
? RunOpenFindingsCount(
count: openFindingCount ?? 0,
child: Icon(tab.icon),
)
: Icon(tab.icon),
label: tab.label,
enabled: !disabled.contains(tab),
tooltip: disabled.contains(tab) ? disabledReasons[tab] : null,
),
],
),
);
}
}