Show running and failed run counts independently

Give the Runs tab separate activity and failure indicators so neither suppresses the other. Reuse known summaries and pushed updates, keep failed states separate from decisions and dismissal counts, and update across tabs even when total attention is unchanged.
This commit is contained in:
2026-11-11 22:10:37 +00:00
parent 9551eceaed
commit efca56e4e4
13 changed files with 415 additions and 99 deletions
+21 -7
View File
@@ -3,6 +3,7 @@ import '../core/servers/server_context.dart';
import '../core/servers/elevation/elevation_dialog.dart';
import '../core/servers/elevation/machine_elevation.dart';
import 'dart:async';
import '../features/runs/domain/run_tab_counts.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
@@ -70,6 +71,8 @@ bool shouldReconnectOnForeground(ConnectionKind kind) =>
///
/// Tests may inject the client and route-information provider; the session
/// owns the socket either way, so there is never a second app-level connection.
typedef _RunIndicators = ({int attention, int running, int failed});
class PipelinesApp extends StatefulWidget {
const PipelinesApp({
super.key,
@@ -203,7 +206,11 @@ class _PipelinesAppState extends State<PipelinesApp>
int _attentionEpoch = 0;
/// The count the shell's Runs tab shows; only a changed count rebuilds it.
final ValueNotifier<int> _attentionCount = ValueNotifier<int>(0);
final _attentionCount = ValueNotifier<_RunIndicators>((
attention: 0,
running: 0,
failed: 0,
));
/// Android background delivery (no service elsewhere).
final NotificationServiceBridge _deliveryService =
@@ -552,13 +559,18 @@ class _PipelinesAppState extends State<PipelinesApp>
if (_session.connected) unawaited(_ackSync.connected());
}
/// Mirrors the controller's entry count for the shell. The Runs list seeds
/// Mirrors attention and independent status counts for the shell. The Runs list seeds
/// the rows from inside its own build, and the shell sits above that layout
/// scope, so a count that changes mid-build lands after the frame; a pushed
/// frame arrives outside any build and applies at once.
void _attentionChanged() {
if (!mounted) return;
final count = _attention.entries.length;
final statuses = runTabCounts(_attention.rows);
final count = (
attention: _attention.entries.length,
running: statuses.running,
failed: statuses.failed,
);
if (count == _attentionCount.value) return;
if (SchedulerBinding.instance.schedulerPhase ==
SchedulerPhase.persistentCallbacks) {
@@ -777,10 +789,10 @@ class _PipelinesAppState extends State<PipelinesApp>
void _chatSyncChanged() => _chatRuntime.syncToken.value =
widget.chatPool?.revision ?? _session.connectionEpoch;
/// The shell rebuilds its Runs tab badge from the attention count alone; the
/// The shell rebuilds its Runs tab badges from the shared status counts; the
/// destination bodies keep their state through it.
Widget _buildShell(BuildContext context, AppRoute route) =>
ValueListenableBuilder<int>(
ValueListenableBuilder<_RunIndicators>(
valueListenable: _attentionCount,
builder: (context, count, _) => _terminals.surround(
_shellFor(route, count),
@@ -789,7 +801,7 @@ class _PipelinesAppState extends State<PipelinesApp>
),
);
Widget _shellFor(AppRoute route, int attentionCount) {
Widget _shellFor(AppRoute route, _RunIndicators counts) {
// Each tab is built from the route it last showed, so switching tabs keeps
// an open run, pipeline or chat instead of resetting it.
AppRoute tab(AppDestination destination) {
@@ -812,7 +824,9 @@ class _PipelinesAppState extends State<PipelinesApp>
if (_destinationOf(route.kind) == AppDestination.chat)
_terminals.toggle(),
],
attentionCount: attentionCount,
attentionCount: counts.attention,
runningRunCount: counts.running,
failedRunCount: counts.failed,
destination: _destinationOf(route.kind),
onDestinationSelected: _selectDestination,
onClosePage: () => _delegate.goTo(