fix: the summary panel's first paint no longer freezes or claims the sources are gone

Two halves of the same first paint. The panel showed «Source unavailable»
in every row until the lazy metrics chunk arrived, because value() could
not tell "not loaded yet" from "source is dead"; and metrics() ran inside
render, walking the HA registry and unioning the clean floor of every
space synchronously — 11 s on the large-house fixture.

- totalCleanFloorAreaM2 computes the space's masonry and junction
  topology once per SPACE and hands them to innerContourForRoom, which
  otherwise unions the whole space again for every room: 11 045 → 1 488 ms
  on that fixture, same 306.3 m². The card has always done this through
  its own _innerContour cache; the panel now does the same.
- Aggregates leave the render path: the first frame paints skeletons and
  the work starts right after the frame is shown (timeout → rAF →
  timeout, never requestIdleCallback, which under load would leave the
  skeleton up for seconds). Stale memo keeps the previous number on
  screen instead of flashing back to a skeleton.
- valueState() separates pending from unavailable; a pending row keeps
  the same plate, grid and height and carries a pulsing rectangle the
  height of the line, replaced by the value with a short fade. Reduced
  motion keeps the rectangle and drops the pulse.
- Panel enter/exit animation (#505, 190 ms) is now actually visible —
  the main thread is free — and the smoke witnesses it.

Mutants: summary-first-paint-shows-unavailable, summary-metrics-block-first-frame,
summary-area-recomputes-walls-per-room, summary-stale-metric-falls-back-to-skeleton.

Issue: #509
User-Visible: yes
This commit is contained in:
Codex
2026-09-10 11:24:10 +03:00
parent 9d375dcb40
commit 398281a93f
54 changed files with 951 additions and 463 deletions
+44
View File
@@ -8110,6 +8110,50 @@ const MUTANT_DEFINITIONS = [
replace: " return relevant.sort((a, b) => stamp(a) - stamp(b) || Number(a.id || 0) - Number(b.id || 0))[0] || null; // mutant: oldest",
}],
},
{
id: 'summary-first-paint-shows-unavailable',
guard: 'node demo/smoke_summary_first_paint.mjs',
because: 'до прихода ленивого чанка метрик значения ещё НЕ известны: текст «источник недоступен» '
+ 'здесь — ложь, которую человек видит в первый же кадр панели (#509 AC1)',
patches: [{
file: 'src/summary-panel-runtime-loaded.ts',
find: " if (!module) return { kind: 'pending' };",
replace: " if (!module) return { kind: 'unavailable' }; // mutant: loading looks like a dead source",
}],
},
{
id: 'summary-metrics-block-first-frame',
guard: 'node demo/smoke_summary_first_paint.mjs',
because: 'агрегаты по всей геометрии и реестру, посчитанные внутри render, замораживают первый '
+ 'показ панели на сотни миллисекунд — ровно симптом #509 (AC4)',
patches: [{
file: 'src/summary-panel-runtime-loaded.ts',
find: " const needsAggregate = value.source.key === 'device_count' || value.source.key === 'total_area';",
replace: " this.computeMetrics(); // mutant: aggregates back inside render\n const needsAggregate = value.source.key === 'device_count' || value.source.key === 'total_area';",
}],
},
{
id: 'summary-area-recomputes-walls-per-room',
guard: 'node --test test/summary-panel.test.mjs',
because: 'innerContourForRoom без общей геометрии объединяет кладку пространства заново для КАЖДОЙ '
+ 'комнаты: 176 мс на комнату и 11 с на большом плане (#509 AC3)',
patches: [{
file: 'src/summary-panel-metrics.ts',
find: " shared.roomGeom, shared.multiWallNodes,",
replace: " // mutant: no shared masonry",
}],
},
{
id: 'summary-stale-metric-falls-back-to-skeleton',
guard: 'node --test test/summary-panel-runtime.test.mjs',
because: 'правка конфигурации не должна возвращать панель в скелет: прежнее число остаётся до '
+ 'прихода нового, иначе мигание возвращается с другой стороны (#509 AC9)',
patches: [{
file: 'src/summary-panel-runtime-loaded.ts',
find: " if (needsAggregate && !known) {",
replace: " if (needsAggregate && (!known || !this.metricsFresh())) {",
}],
},
{
id: 'summary-dialog-drops-flex-content',
guard: 'node demo/smoke_summary_dialog_scroll.mjs',