Keep History figures with their selected period - #66
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ftw-webapp | be619aa | Commit Preview URL Branch Preview URL |
Sep 07 2026, 06:36 PM |
frahlg
marked this pull request as ready for review
September 7, 2026 18:41
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_1181de53-2082-474c-a1b3-61a69d555271) |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switching History from 7 days to Today used to keep the week's totals and bars under the Today heading until a new answer arrived, even after a failed read. A period change now clears those figures immediately and invalidates the previous period's pending reply. A refresh of the same period keeps its figures, and the existing retry restores a failed read.
Validation:
npm run verifypasses, including 1,027 tests (one skipped), type checks and the production build. Regression tests caught the old total under Today and late success/failure replies before the fix. They cover loading, failure, automatic recovery, same-period refresh and a previously empty period.Browser check on
be619aadce13e807cd4b9c026aaa7d34835ffb2e: a separate local SimBox fixture returned HTTP 503 only for/api/energy/daily. Switching from 341 kWh over seven days to Today removed the old figures and bars and showed the loading and retry messages. After two failed reads, the normal retry filled Today with 37 kWh and removed the error without a reload. Viewed at 1280×720 and 390×844; the mobile cards and message fit without horizontal overflow. These checks use simulated data.Note
Medium Risk
Changes async race handling and empty/loaded UX for energy history; wrong token logic could drop valid data or flash empty states, but scope is limited to the History energy store and existing retry paths.
Overview
Fixes History showing the previous range’s totals and chart under a new period label (e.g. week kWh under Today) while a fetch was in flight or after errors.
EnergyStore.selectnow no-ops on the same range; otherwise it bumps the request token, clearsdays, resetsloaded/loading/error, and only then switchesrange.loadstill uses tokens so late success/failure replies for an old range never repopulate the UI. Failed refreshes for the current period still keep that period’s figures and show “not up to date”; fetching on tap stays withaskWhenLive.Adds store tests (empty prior period, stale replies) and Energy integration tests (no mislabeling during load/retry, same-period refresh on visibility). Patch changeset for
ftw-webapp.Reviewed by Cursor Bugbot for commit be619aa. Bugbot is set up for automated code reviews on this repo. Configure here.