Skip to content

The agent that grows with you

feat: Desktop first-run consent answer records setup_completed

teknium1fcd830ee1cbd
diff --git a/tests/tui_gateway/test_shared_metrics_consent_rpc.py b/tests/tui_gateway/test_shared_metrics_consent_rpc.py
index 785e889ccc8..31a61629d38 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 b1313358d40..6729a47d6e6 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)