Fix elapsed showing --:-- at DONE, and energy not reset on restart

sud_elapsed_seconds is intentionally reset to None once a run leaves
a running state (it gates the forecast plot's dynamic-vs-static view
switch) - but the status bar/Progress tab reused it too, so they lost
the final total exactly when it mattered most: right as the run
finished. Added sud_elapsed_last, which only ever gets overwritten by
a real 'Elapsed' push and is reset on a fresh Start/Load, for those
two displays to use instead.

Separately, a fresh Start (restarting an already-loaded, now IDLE/
DONE schedule) never sent a new Load, so SudTask's energy bookkeeping
- previously only reset in the Load handler - kept showing the
previous run's banked totals until each step was revisited. Now also
reset on a fresh Start (not a Pause->resume, which should keep it).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019qvu5giu7gvRCyEWzf2Vpx
This commit is contained in:
2026-06-24 19:39:03 +02:00
co-authored by Claude Sonnet 4.6
parent 3c5b3053e9
commit 2913b41cab
2 changed files with 54 additions and 10 deletions
+8
View File
@@ -430,6 +430,14 @@ class SudTask(ATask):
# whatever temperature existed back at Load (time passed,
# possibly manual heating in between).
fresh_start = self.sud.state in (SudState.IDLE, SudState.DONE)
if fresh_start:
# Belongs to the run that just ended (Stop, or running
# the schedule through to DONE), not the one about to
# begin - a Pause->resume (fresh_start False) keeps it,
# same as the forecast above.
self.energy_step_accum_j = 0.0
self.energy_by_step = {}
self._energy_index = None
self.sud.start()
if fresh_start:
asyncio.create_task(self.send_forecast(self.sud.save()))