Skip to content

The agent that grows with you

fix(telemetry): an Enter typed during startup no longer answers the CLI consent offer

Teknium57de31f8daa9
diff --git a/hermes_cli/observability/shared_metrics_consent.py b/hermes_cli/observability/shared_metrics_consent.py
index b8592e353b9..c3592a14928 100644
--- a/hermes_cli/observability/shared_metrics_consent.py
+++ b/hermes_cli/observability/shared_metrics_consent.py
@@ -98,8 +98,11 @@ def offer_consent(config: dict | None = None) -> bool:
"""Ask once, with the Desktop strip's three answers; "No thanks" is the default so Enter never
opts anyone in. Esc leaves the question open (asked again next time). True when answered."""
from hermes_cli.cli_output import print_info, print_success
- from hermes_cli.curses_ui import curses_radiolist
+ from hermes_cli.curses_ui import curses_radiolist, flush_stdin
+ # The offer appears seconds into startup; an Enter typed while Hermes booted would otherwise
+ # answer it ("No thanks") before it was ever on screen, so the user was never really asked.
+ flush_stdin()
idx = curses_radiolist(
"Help improve Hermes?", [label for label, _, _ in OFFER_CHOICES], selected=_NO_THANKS, cancel_returns=-1,
description=_OFFER_DESCRIPTION,
diff --git a/tests/hermes_cli/test_setup_telemetry.py b/tests/hermes_cli/test_setup_telemetry.py
index 5b70194345a..dd045f9b5fe 100644
--- a/tests/hermes_cli/test_setup_telemetry.py
+++ b/tests/hermes_cli/test_setup_telemetry.py
@@ -113,3 +113,16 @@ def test_chat_offer_asks_an_undecided_profile_once(monkeypatch):
assert len(asked) == 1
assert consent.consent_state(read_raw_config()) == {"enabled": True, "send": False, "decided": True}
+
+
+def test_offer_drops_keys_typed_before_it_appeared(monkeypatch):
+ """An Enter typed while Hermes booted answered "No thanks" before the offer was on screen."""
+ from hermes_cli.observability import shared_metrics_consent as consent
+
+ events = []
+ monkeypatch.setattr("hermes_cli.curses_ui.flush_stdin", lambda: events.append("flush"))
+ monkeypatch.setattr("hermes_cli.curses_ui.curses_radiolist", lambda *a, **k: events.append("ask") or -1)
+
+ consent.offer_consent()
+
+ assert events == ["flush", "ask"]