No reviewers
Labels
No labels
area/ai
area/backend
area/frontend
area/infra
area/scheduler
area/wled
good-first-issue
priority/high
priority/low
priority/medium
security
type/bug
type/chore
type/ci-cd
type/docs
type/feature
type/qa
v1.0.0
v1.1.0
v1.2.0
v2.0.0
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/Iris-WLED!180
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/153-energy-report"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #153 (except the power-meter calibration check, which is in #179). Closes #181.
This PR grew two fixes while its CI failures were being chased down. Both are real bugs that already existed on
main, and both were found by root cause, not by raising timeouts.1. Energy and cost report (#153), commit
dd4722fget_infoand oneget_stateper tick. With the watchdogoff, anenergy_samplerjob takes its place at the same interval. Sampling can never break the watchdog.plan_for_date.power_samples(30 days) andenergy_daily(kept forever, in mAh, so nights recorded before the voltage is set become usable once it is). Migration0012, with a single head.led_voltageis set. Everything is labelled as an estimate./api/v1/energy/summary,/export.csv, an/energypage (a header link and the fourth app shortcut), an Energy settings card, and theiris_wled_current_milliampsandiris_energy_wh_totalmetrics (tz-aware, unlike #176).2. The calendar's scheme list stalled every other request, commit
96bd1f2list_schemesre-read and re-validated the settings for each of about 108 schemes (an N+1). py-spy during a parallel E2E run put it at 77.8% of server CPU, and a settings PUT that takes 0.03 s when idle took 5–22 s. Settings are now read once per request, with a regression test that counts the reads. This is also the probable cause of the #177 flake.3. Settings edits were silently lost (#181), commit
6574b4cThe Settings page renders its cards before
GET /settingsreturns. When the response landed, auseEffectcopied every server value over the form, including fields the person had just edited.Instrumented under load:
So Save sent the old values, which is exactly CI run 11017's diff.
Fix:
useDrafts: an edited field is never overwritten by a load, and Save sends only the edited settings. One card's Save no longer rewrites the other cards with stale values, and it no longer pins every key into the database, which is the #181 ask.const { data: webhooks = [] }created a new array on every render, so the drafts effect re-rendered forever for a viewer. It's now a module constant.settingsDrafts.test.tsx(6 tests), shown to fail on the old page. The watchdog E2E now asserts the exact PUT body and that the form keeps its values after the save's refetch.Verification
uv lock --checkare clean.tsc, vitest 292 passed, and build.Still open
review-nudges.spec.ts:93failure in run 11017 ("Unapproved" pressed) couldn't be reproduced in 13 instrumented runs. It's probably the CPU-starved 5-second default timeout. It's tracked on #177, and the next recurrence's trace would settle it.🤖 Generated with Claude Code
Show what the lights used and cost this season (#153)to Show what the lights used and cost this season (#153), and keep Settings edits until saved (#181)