fix(cli): first repaint no longer swallowed when monotonic clock is small

time.monotonic() counts from an arbitrary epoch (boot on Linux). Two CLI
repaint throttles used 0.0 as the never-fired sentinel, so on a freshly
booted VM (CI runners, containers) now - 0.0 < min_interval suppressed
the FIRST repaint ever requested:

- _schedule_focus_regain_redraw: min_interval=60 suppressed the first
  focus-regain redraw whenever uptime < 60s — the exact failure in CI
  run 32494557030 (test_focus_regain_redraw_is_rate_limited, both
  attempts red on a fresh runner, green everywhere else).
- _invalidate: same 0.0 sentinel; a first spinner/stream repaint inside
  the first 250ms of uptime was droppable the same way.

Both now use None as the never-fired sentinel. Regression test pins
monotonic()=3.0 with min_interval=60 and asserts the first redraw fires.
This commit is contained in:
Teknium
2026-08-21 09:16:37 -07:00
parent 6467172db9
commit eab377a407
3 changed files with 31 additions and 3 deletions
+1 -1
View File
@@ -2837,7 +2837,7 @@ class HermesCLI(CLIProcessNotificationsMixin, CLIAgentSetupMixin, CLICommandsMix
getattr(self, "_write_terminal_breadcrumb", lambda: None)()
self._history_file = _hermes_home / ".hermes_history"
self._last_invalidate: float = 0.0 # throttles UI repaints
self._last_invalidate: float | None = None # throttles UI repaints (None = never; monotonic epoch is arbitrary)
self._init_ui_state()
def _init_session_store(self):