Skip to content

Show the dominant state in a mixed history slot, not the last one seen - #4872

Open
chalfontchubby wants to merge 1 commit into
mainfrom
fix/history-mixed-slot-states-4843
Open

Show the dominant state in a mixed history slot, not the last one seen#4872
chalfontchubby wants to merge 1 commit into
mainfrom
fix/history-mixed-slot-states-4843

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

Summary

  • calculate_yesterday()'s History-view slot reconstruction now shows whichever state actually held the most of a 30-minute slot's trusted minutes (the genuinely dominant one), rather than whichever state a scan happened to visit last or ranked highest by an abstract "most active" precedence.
  • A slot that held more than one state is marked with an asterisk, and every state it passed through is listed in the cell's tooltip, in chronological order, so nothing is silently lost even when it isn't the headline state.
  • A slot's first/last 5 minutes are only trusted when they hold one state throughout - this guards against Predbat's reported status lagging a slot boundary by a minute or two while it catches up to a replan, without discarding a state that genuinely occupies the full edge window.
  • Also fixes a pre-existing bug where a slot's per-minute status was read from the wrong (mirrored) offset within the slot.

Addresses #4843.

Test plan

  • ./run_all --test calculate_yesterday - full suite including new edge-window regression tests
  • ./run_all --quick - full quick suite
  • ./run_pre_commit

🤖 Generated with Claude Code

#4843)

calculate_yesterday() rebuilds each 30-minute History slot from Predbat's
per-minute status, but a slot can genuinely hold more than one state - a
force export that hits its target part way through drops to freeze export,
a manual override can land on any minute. The reconstruction used to assign
unconditionally as it scanned each slot, so whichever state it visited last
won and an earlier, more significant state silently vanished (#4840's force
export erased by the freeze export that followed it). The scan also read
each minute's status from the wrong offset within the slot, mirrored around
the midpoint, which changed which state "won" depending on where in the
slot a transition happened to land.

A slot's cell now shows whichever state actually held the most of its
trusted minutes - the genuinely dominant one, not just whichever the old
last-wins scan reached last or ranked highest in the abstract - marked with
an asterisk when the slot held more than one, with every state it passed
through listed in the cell's tooltip so nothing is silently lost. A slot's
first/last 5 minutes are only trusted when they hold one state throughout:
that guards against Predbat's reported status lagging a slot boundary by a
minute or two while it catches up to a replan, without discarding a state
that genuinely occupies the full edge window.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant