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:
@@ -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(
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
|
||||
typedef RunTabCounts = ({int running, int failed});
|
||||
|
||||
/// Independent status counts from known, unfiltered server summaries.
|
||||
/// Dismissing a notification does not change a run's failed status.
|
||||
RunTabCounts runTabCounts(Iterable<JsonMap> runs) {
|
||||
var running = 0;
|
||||
var failed = 0;
|
||||
for (final run in runs) {
|
||||
if (run['status'] == 'failed') failed++;
|
||||
if (const {
|
||||
'succeeded',
|
||||
'failed',
|
||||
'canceled',
|
||||
'interrupted',
|
||||
}.contains(run['status'])) {
|
||||
continue;
|
||||
}
|
||||
// Older summaries omit the execution flag but still name the live state.
|
||||
if (run['executing'] == true ||
|
||||
(!run.containsKey('executing') && run['status'] == 'running')) {
|
||||
running++;
|
||||
}
|
||||
}
|
||||
return (running: running, failed: failed);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import '../../attention/runtime/attention_controller.dart';
|
||||
import '../../attention/runtime/attention_store.dart';
|
||||
import '../../attention/ui/needs_you_runs_heading.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../domain/run_tab_counts.dart';
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import '../../../shell/shell_list_shortcuts.dart';
|
||||
import 'run_list_row.dart';
|
||||
@@ -102,14 +103,19 @@ class RunsList extends StatelessWidget {
|
||||
if (!ShellBar.available(context)) {
|
||||
return _ownBar(context, [const Spacer(), ...actions]);
|
||||
}
|
||||
final counts = runTabCounts(controller.runs);
|
||||
return ShellBar(
|
||||
active: active,
|
||||
actions: actions,
|
||||
// The Runs tab counts runs still executing.
|
||||
child: ShellBadge(
|
||||
kind: ShellBadgeKind.running,
|
||||
count: controller.runs.where((run) => run['executing'] == true).length,
|
||||
child: _shortcutList(context),
|
||||
count: counts.running,
|
||||
child: ShellBadge(
|
||||
kind: ShellBadgeKind.failed,
|
||||
count: counts.failed,
|
||||
child: _shortcutList(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ class AdaptiveShell extends StatefulWidget {
|
||||
this.onClosePage,
|
||||
this.onSearch,
|
||||
this.attentionCount = 0,
|
||||
this.runningRunCount,
|
||||
this.failedRunCount,
|
||||
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
|
||||
this.barActions = const [],
|
||||
});
|
||||
@@ -46,10 +48,13 @@ class AdaptiveShell extends StatefulWidget {
|
||||
/// shell tests and compositions without routing keep their tab set only.
|
||||
final VoidCallback? onSearch;
|
||||
|
||||
/// Runs needing the operator today, mirrored on the Runs tab in every mount
|
||||
/// so it stays visible from any destination. Zero shows no badge.
|
||||
/// Runs needing the operator today, retained in the tab's accessible label.
|
||||
final int attentionCount;
|
||||
|
||||
/// App-wide counts when available; standalone screens publish their own.
|
||||
final int? runningRunCount;
|
||||
final int? failedRunCount;
|
||||
|
||||
@override
|
||||
State<AdaptiveShell> createState() => _AdaptiveShellState();
|
||||
}
|
||||
@@ -109,7 +114,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
});
|
||||
}
|
||||
|
||||
/// The destination's icon; only Runs carries the attention count.
|
||||
/// Runs has independent status counts; Chat has its unread count.
|
||||
Widget _icon(AppDestination destination, IconData data) {
|
||||
Widget icon = Icon(data);
|
||||
if (destination == AppDestination.chat) {
|
||||
@@ -121,17 +126,15 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
);
|
||||
}
|
||||
if (destination != AppDestination.runs) return icon;
|
||||
// One indicator: runs that need you outrank runs in progress, so the
|
||||
// tab never wears two counts at once.
|
||||
final attention = widget.attentionCount > 0;
|
||||
return AttentionDestinationIcon(
|
||||
count: widget.attentionCount,
|
||||
child: ActivityBadge(
|
||||
key: const ValueKey('shell.badge.runs.running'),
|
||||
count: attention ? 0 : _bar.badge(destination, ShellBadgeKind.running),
|
||||
label: 'runs in progress',
|
||||
child: icon,
|
||||
),
|
||||
return RunsDestinationIcon(
|
||||
running:
|
||||
widget.runningRunCount ??
|
||||
_bar.badge(destination, ShellBadgeKind.running),
|
||||
failed:
|
||||
widget.failedRunCount ??
|
||||
_bar.badge(destination, ShellBadgeKind.failed),
|
||||
attention: widget.attentionCount,
|
||||
child: icon,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../features/attention/domain/attention_models.dart';
|
||||
import '../ui/motion/motion.dart';
|
||||
|
||||
/// Mirrors the Runs-heading bell count onto the Runs destination icon.
|
||||
/// A generic attention count, separate from the Runs tab's status counts.
|
||||
///
|
||||
/// The bell itself lives in the Runs heading, so without this the count would
|
||||
/// be visible only on that destination; the web mirrors it on the rail and
|
||||
@@ -44,7 +44,57 @@ class AttentionDestinationIcon extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// A small count on a tab icon: blue for activity (runs in progress, unread
|
||||
/// Both status counts remain visible: failures never hide executing work.
|
||||
class RunsDestinationIcon extends StatelessWidget {
|
||||
const RunsDestinationIcon({
|
||||
super.key,
|
||||
required this.running,
|
||||
required this.failed,
|
||||
required this.child,
|
||||
this.attention = 0,
|
||||
});
|
||||
|
||||
final int running;
|
||||
final int failed;
|
||||
final int attention;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final labels = [
|
||||
if (running > 0) '$running runs in progress',
|
||||
if (failed > 0) '$failed failed runs',
|
||||
if (attention > 0) attentionBadgeLabel(attention),
|
||||
];
|
||||
return Semantics(
|
||||
label: labels.join(', '),
|
||||
child: ExcludeSemantics(
|
||||
child: Tooltip(
|
||||
message: labels.isEmpty ? 'Runs' : 'Runs: ${labels.join(', ')}',
|
||||
excludeFromSemantics: true,
|
||||
child: Badge.count(
|
||||
key: const ValueKey('shell.badge.runs.failed'),
|
||||
count: failed,
|
||||
maxCount: 99,
|
||||
isLabelVisible: failed > 0,
|
||||
backgroundColor: colors.error,
|
||||
textColor: colors.onError,
|
||||
child: ActivityBadge(
|
||||
key: const ValueKey('shell.badge.runs.running'),
|
||||
count: running,
|
||||
label: 'runs in progress',
|
||||
bottom: true,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A small primary-theme count on a tab icon for activity (runs in progress, unread
|
||||
/// chats), so it reads apart from the red needs-you count.
|
||||
class ActivityBadge extends StatelessWidget {
|
||||
const ActivityBadge({
|
||||
|
||||
@@ -357,6 +357,9 @@ enum ShellBadgeKind {
|
||||
/// Runs still executing.
|
||||
running,
|
||||
|
||||
/// Runs whose server status is failed, independent of attention dismissal.
|
||||
failed,
|
||||
|
||||
/// Chats with messages not yet seen.
|
||||
unread,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user