Share one minute clock across time labels and narrow shell and runs rebuilds

Relative-time labels follow one wall-minute RelativeTimeClock instead of a
timer per row, skip ticks while their tab is offstage and rebuild only when
their text changes. The shell rebuilds its top bar only for the focused
destination's published bar and its tab bar only for badge changes. Run
events that repeat a row's state no longer notify, and the runs list filters
and sorts once per build. Adds a rebuild/timer benchmark.
This commit is contained in:
2026-11-01 23:29:20 +00:00
parent bdf70af7e8
commit 3b996bdbc7
9 changed files with 621 additions and 164 deletions
+15 -1
View File
@@ -187,12 +187,26 @@ JsonMap? newRunSummaryFromFrame(JsonMap frame) {
: (runs: [row, ...runs], needsResync: false);
}
final updated = _mergeRunFields(runs[index], frame);
if (identical(updated, runs[index])) return (runs: runs, needsResync: false);
// A frame that repeats the row's state (a busy run's progress stream)
// keeps the same list, so its holders can skip a rebuild.
if (identical(updated, runs[index]) || _sameFields(updated, runs[index])) {
return (runs: runs, needsResync: false);
}
final next = [...runs];
next[index] = updated;
return (runs: next, needsResync: false);
}
/// Shallow equality: nested values compare by identity, so a rebuilt nested
/// map counts as a change.
bool _sameFields(JsonMap a, JsonMap b) {
if (a.length != b.length) return false;
for (final entry in a.entries) {
if (!b.containsKey(entry.key) || b[entry.key] != entry.value) return false;
}
return true;
}
JsonMap? foldRunEventDetail(JsonMap? detail, JsonMap frame) {
if (detail == null || detail['id'] != frame['run_id']) return detail;
if (_stale(detail['status'], frame['status'], runLifecycleRank) &&
@@ -271,6 +271,7 @@ class RunsController extends ChangeNotifier {
void _event(JsonMap frame) {
if (_removed.contains(frame['run_id'])) return;
final folded = foldRunEvent(runs, frame);
final before = (runs: runs, detail: detail);
runs = folded.runs;
selection.retain(runs);
if (detail?['id'] == frame['run_id']) {
@@ -285,6 +286,11 @@ class RunsController extends ChangeNotifier {
(folded.needsResync || runDetailNeedsFullSync(frame))) {
_scheduleDetailRefresh(selected);
}
// A frame that changed neither the list nor the open detail shows
// nothing new; the refreshes above notify for themselves.
if (identical(before.runs, runs) && identical(before.detail, detail)) {
return;
}
notifyListeners();
}
+11 -7
View File
@@ -146,7 +146,9 @@ class RunsList extends StatelessWidget {
RunsDeleteReport(controller: controller),
RunsFilters(controller: controller),
];
if (controller.visibleRuns.isNotEmpty) return _groupedRuns(context, header);
// Filtered and sorted once per build: the getter recomputes every read.
final visible = controller.visibleRuns;
if (visible.isNotEmpty) return _groupedRuns(context, header, visible);
return BelowTopBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -169,15 +171,17 @@ class RunsList extends StatelessWidget {
);
}
Widget _groupedRuns(BuildContext context, List<Widget> header) {
Widget _groupedRuns(
BuildContext context,
List<Widget> header,
List<JsonMap> visible,
) {
final entries = <_Entry>[];
if (flatRunSorts.contains(controller.sort)) {
// An order by size is one flat list: day headings would split it.
entries.addAll(
controller.visibleRuns.map((run) => (day: null, run: run)),
);
entries.addAll(visible.map((run) => (day: null, run: run)));
} else {
final groups = groupRunsByDay(controller.visibleRuns, DateTime.now());
final groups = groupRunsByDay(visible, DateTime.now());
for (final group in groups) {
entries.add((day: group, run: null));
entries.addAll(group.runs.map((run) => (day: null, run: run)));
@@ -185,7 +189,7 @@ class RunsList extends StatelessWidget {
}
// Runs that start while the list is open enter with a short fade.
return ArrivalScope(
ids: [for (final run in controller.visibleRuns) '${run['id']}'],
ids: [for (final run in visible) '${run['id']}'],
child: _entriesList(entries, header),
);
}