Sync card counters with backend schedule (regression fix)#130
Merged
Conversation
When the card displays the backend's slot_schedule (no slider overrides
active), the colored bars come from the backend but the counter text
("X charge / Y sell / Z kWh planned") was still being driven by the
client-side simulation result. The client sim can legitimately return
0 counts for cases the backend handles (e.g., 'both' mode sell selection
with profitability filter + SOC validation that the simplified card sim
doesn't replicate exactly).
The ?? fallback chain in the render path was supposed to catch this:
simR?.chargeCount ?? backend_attribute ?? 0
…but since the client sim explicitly returns chargeCount: 0 (a non-nullish
number, not undefined), the backend fallback never triggered.
Fix: when useBackendSchedule is true in _drawSlotTimeline, recompute
chargeCount, dischargeCount, plannedChargeKwh, plannedDischargeKwh, and
the today-view's tomorrow summary from the displayed slot data — which
IS the backend's authoritative schedule.
Symptom: chart shows orange sell bars at 18-23 but text reads
"0 sell / 0.0 kWh planned" alongside. Fixed.
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.
When the card displays the backend's slot_schedule (no slider overrides active), the colored bars come from the backend but the counter text ("X charge / Y sell / Z kWh planned") was still being driven by the client-side simulation result. The client sim can legitimately return 0 counts for cases the backend handles (e.g., 'both' mode sell selection with profitability filter + SOC validation that the simplified card sim doesn't replicate exactly).
The ?? fallback chain in the render path was supposed to catch this:
simR?.chargeCount ?? backend_attribute ?? 0
…but since the client sim explicitly returns chargeCount: 0 (a non-nullish number, not undefined), the backend fallback never triggered.
Fix: when useBackendSchedule is true in _drawSlotTimeline, recompute chargeCount, dischargeCount, plannedChargeKwh, plannedDischargeKwh, and the today-view's tomorrow summary from the displayed slot data — which IS the backend's authoritative schedule.
Symptom: chart shows orange sell bars at 18-23 but text reads "0 sell / 0.0 kWh planned" alongside. Fixed.