From fcd830ee1cbdbd35a24668e0b22fa4e0dac2ae95 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sun, 27 Sep 2026 11:19:53 -0700 Subject: [PATCH] feat: Desktop first-run consent answer records setup_completed --- .../tui_gateway/test_shared_metrics_consent_rpc.py | 13 +++++++++++++ tui_gateway/methods_shared_metrics.py | 9 ++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/tui_gateway/test_shared_metrics_consent_rpc.py b/tests/tui_gateway/test_shared_metrics_consent_rpc.py index 785e889ccc..31a61629d3 100644 --- a/tests/tui_gateway/test_shared_metrics_consent_rpc.py +++ b/tests/tui_gateway/test_shared_metrics_consent_rpc.py @@ -67,3 +67,16 @@ def test_status_is_undecided_until_a_key_is_written(tmp_path, monkeypatch): (worker / "config.yaml").write_text( yaml.safe_dump({"telemetry": {"shared_metrics": {"enabled": False}}}), encoding="utf-8") assert _call("shared_metrics.status", {"profile": "code"}) == {"enabled": False, "send": False, "decided": True} + + +def test_only_the_first_run_answer_records_desktop_setup_completed(tmp_path, monkeypatch): + _launch, _worker = _bind_homes(monkeypatch, tmp_path) + import hermes_cli.observability.shared_metrics_events as events + + calls: list[dict] = [] + monkeypatch.setattr(events, "record_setup_completed", lambda **kw: calls.append(kw)) + + _call("shared_metrics.set", {"profile": "code", "enabled": True, "send": False, "first_run": True}) + _call("shared_metrics.set", {"profile": "code", "enabled": True, "send": True}) + + assert calls == [{"surface": "desktop", "provider": "nous"}] diff --git a/tui_gateway/methods_shared_metrics.py b/tui_gateway/methods_shared_metrics.py index b1313358d4..6729a47d6e 100644 --- a/tui_gateway/methods_shared_metrics.py +++ b/tui_gateway/methods_shared_metrics.py @@ -36,11 +36,10 @@ def _shared_metrics_consent(cfg) -> dict: def _shared_metrics_record_setup_completed(cfg) -> None: - """Desktop's setup ends at this first-run answer. A no-op unless collection is on.""" - try: - from hermes_cli.observability.shared_metrics_events import record_setup_completed - except ImportError: # the events module lands with the shared-metrics v3 PR - return + """Desktop has no setup-finish RPC; this first-run answer is the one backend call made once, + right after onboarding settles. A no-op (inside the events API) unless collection is on.""" + from hermes_cli.observability.shared_metrics_events import record_setup_completed + model = cfg.get("model") if isinstance(cfg, dict) else None provider = model.get("provider") if isinstance(model, dict) else None record_setup_completed(surface="desktop", provider=provider if isinstance(provider, str) and provider else None)