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:
@@ -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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user