Skip to content

Sync card counters with backend schedule (regression fix)#130

Merged
partach merged 1 commit into
mainfrom
claude/add-from-grid-plus-mode-iqMQm
May 26, 2026
Merged

Sync card counters with backend schedule (regression fix)#130
partach merged 1 commit into
mainfrom
claude/add-from-grid-plus-mode-iqMQm

Conversation

@partach
Copy link
Copy Markdown
Owner

@partach partach commented May 26, 2026

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.

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.
@partach partach merged commit e0b2267 into main May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants