Skip to content

The agent that grows with you

fix(desktop): shared-metrics question is a composer offer strip, never a launch modal

teknium19edbf627f0a8
diff --git a/apps/desktop/src/app/chat/composer/status-stack/index.tsx b/apps/desktop/src/app/chat/composer/status-stack/index.tsx
index d994c687b62..eea94c3b05e 100644
--- a/apps/desktop/src/app/chat/composer/status-stack/index.tsx
+++ b/apps/desktop/src/app/chat/composer/status-stack/index.tsx
@@ -12,6 +12,7 @@ import { composerDockCard } from '@/components/chat/composer-dock'
import { StatusSection } from '@/components/chat/status-section'
import { FreeTierNoticeStrip, useFreeTierNoticeOwner } from '@/components/free-tier/notice-strip'
import { usePaneVisible } from '@/components/pane-shell/pane-visibility'
+import { SharedMetricsConsentStrip } from '@/components/shared-metrics/consent-strip'
import { Button } from '@/components/ui/button'
import { Codicon } from '@/components/ui/codicon'
import { GlyphSpinner } from '@/components/ui/glyph-spinner'
@@ -34,6 +35,7 @@ import { $freeTierRoute, $freeTierStatus, freeTierStripPending } from '@/store/f
import { $interfaceMode, shownInMode, type Tiered } from '@/store/interface-mode'
import { $previewStatusBySession, dismissPreviewArtifact } from '@/store/preview-status'
import { $sessionControlBySession, refreshSessionControl } from '@/store/session-control'
+import { $sharedMetricsConsent, sharedMetricsOfferPending } from '@/store/shared-metrics'
import { $threadScrolledUpBySession } from '@/store/thread-scroll'
import { $retainedTodosBySession } from '@/store/todos'
import { openSessionInNewWindow } from '@/store/windows'
@@ -142,6 +144,9 @@ export function ComposerStatusStack({ onSubmit, queue, sessionId }: ComposerStat
// notice once — and a non-owning stack adds no empty row to its card.
const ownsFreeTierNotice = useFreeTierNoticeOwner()
const freeTierNotice = ownsFreeTierNotice && freeTierStripPending(freeTierStatus, freeTierRoute)
+ // Same single owner, one offer at a time: the metrics question waits for the free-tier notice.
+ const sharedMetricsConsent = useStore($sharedMetricsConsent)
+ const sharedMetricsOffer = ownsFreeTierNotice && !freeTierNotice && sharedMetricsOfferPending(sharedMetricsConsent)
const isStructuredSupported = controlEntry?.capability === 'supported'
@@ -231,6 +236,10 @@ export function ComposerStatusStack({ onSubmit, queue, sessionId }: ComposerStat
sections.push({ key: 'free-tier', node: <FreeTierNoticeStrip /> })
}
+ if (sharedMetricsOffer) {
+ sections.push({ key: 'shared-metrics', node: <SharedMetricsConsentStrip /> })
+ }
+
const hasControlContent = Boolean(
controlEntry &&
(controlEntry.error ||
diff --git a/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsx b/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsx
index 4ed954d6cda..22f7cc674a4 100644
--- a/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsx
+++ b/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsx
@@ -3,7 +3,12 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { en } from '@/i18n/en'
import { $desktopOnboarding } from '@/store/onboarding'
-import type { SharedMetricsConsent } from '@/store/shared-metrics'
+import {
+ $sharedMetricsConsent,
+ $sharedMetricsDetailsOpen,
+ type SharedMetricsConsent,
+ sharedMetricsOfferPending
+} from '@/store/shared-metrics'
import { SharedMetricsConsentDialog } from './consent-dialog'
@@ -36,30 +41,50 @@ beforeEach(() => {
afterEach(() => {
cleanup()
$desktopOnboarding.set(initialOnboarding)
+ $sharedMetricsConsent.set(null)
+ $sharedMetricsDetailsOpen.set(false)
})
describe('SharedMetricsConsentDialog', () => {
- it('stays hidden when the profile already answered (e.g. in hermes setup)', async () => {
- const { calls, requestGateway } = backend({ enabled: false, send: false, decided: true })
-
- render(<SharedMetricsConsentDialog enabled profile="default" requestGateway={requestGateway} />)
-
- await waitFor(() => expect(calls.map(c => c.method)).toContain('shared_metrics.status'))
- expect(screen.queryByText(copy.consentTitle)).toBeNull()
+ it('never blocks launch: an undecided profile becomes a composer offer, not a modal', async () => {
+ const undecided = backend({ enabled: false, send: false, decided: false })
+
+ const { unmount } = render(
+ <SharedMetricsConsentDialog enabled profile="default" requestGateway={undecided.requestGateway} />
+ )
+
+ await waitFor(() => expect(sharedMetricsOfferPending($sharedMetricsConsent.get())).toBe(true))
+ expect(screen.queryByRole('dialog')).toBeNull()
+ unmount()
+
+ // An answer given in `hermes setup` is the same config keys: no offer at all.
+ const answered = backend({ enabled: false, send: false, decided: true })
+ render(<SharedMetricsConsentDialog enabled profile="work" requestGateway={answered.requestGateway} />)
+ await waitFor(() => expect($sharedMetricsConsent.get()?.decided).toBe(true))
+ expect(sharedMetricsOfferPending($sharedMetricsConsent.get())).toBe(false)
})
- it('asks an undecided profile once and records the answer as both opt-ins', async () => {
+ it('details decide nothing when closed and record a chosen answer as both opt-ins', async () => {
const { calls, requestGateway } = backend({ enabled: false, send: false, decided: false })
render(<SharedMetricsConsentDialog enabled profile="default" requestGateway={requestGateway} />)
+ await waitFor(() => expect(sharedMetricsOfferPending($sharedMetricsConsent.get())).toBe(true))
+ $sharedMetricsDetailsOpen.set(true)
+ await screen.findByRole('dialog')
+ fireEvent.keyDown(screen.getByRole('dialog'), { key: 'Escape' })
+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
+ expect(calls.some(c => c.method === 'shared_metrics.set')).toBe(false)
+ expect(sharedMetricsOfferPending($sharedMetricsConsent.get())).toBe(true)
+
+ $sharedMetricsDetailsOpen.set(true)
const keepLocal = await screen.findByRole('button', { name: copy.local })
- // Nothing is preselected: no choice holds focus when the dialog opens.
+ // Nothing is preselected: no choice holds focus when the details open.
expect(keepLocal.ownerDocument.activeElement).not.toBe(keepLocal)
-
fireEvent.click(keepLocal)
- await waitFor(() => expect(screen.queryByText(copy.consentTitle)).toBeNull())
+ await waitFor(() => expect(sharedMetricsOfferPending($sharedMetricsConsent.get())).toBe(false))
+ expect(screen.queryByRole('dialog')).toBeNull()
expect(calls.find(c => c.method === 'shared_metrics.set')?.params).toEqual({
enabled: true,
send: false,
diff --git a/apps/desktop/src/components/shared-metrics/consent-dialog.tsx b/apps/desktop/src/components/shared-metrics/consent-dialog.tsx
index 20a7a3a5b9b..a0b3d703584 100644
--- a/apps/desktop/src/components/shared-metrics/consent-dialog.tsx
+++ b/apps/desktop/src/components/shared-metrics/consent-dialog.tsx
@@ -19,12 +19,13 @@ import { notifyError } from '@/store/notifications'
import { $desktopOnboarding } from '@/store/onboarding'
import { $onboardingSurfaces } from '@/store/onboarding-presence'
import {
+ $sharedMetricsConsent,
+ $sharedMetricsDetailsOpen,
+ answerSharedMetricsOffer,
readSharedMetricsConsent,
- saveSharedMetricsConsent,
- SHARED_METRICS_CHOICES,
SHARED_METRICS_DOCS_URL,
type SharedMetricsChoice,
- type SharedMetricsConsent,
+ sharedMetricsOfferPending,
type SharedMetricsRequester
} from '@/store/shared-metrics'
@@ -39,12 +40,15 @@ interface SharedMetricsConsentDialogProps {
const CHOICE_ORDER: readonly SharedMetricsChoice[] = ['share', 'local', 'off']
/**
- * The one-time shared-metrics question, the Desktop twin of `hermes setup`'s
- * Shared Metrics section. It waits until first-run onboarding is out of the way
- * and asks only when the profile's config.yaml carries no answer yet — an
- * answer given in the CLI (or here, or in Settings) is the same config keys,
- * so nobody is asked twice. Three equal choices, none preselected or focused;
- * Esc is the refusal and is recorded like "No thanks".
+ * Owner of the one-time shared-metrics question, the Desktop twin of `hermes
+ * setup`'s Shared Metrics section. It reads the focused profile's answer once
+ * first-run onboarding is out of the way; an unanswered profile gets an OFFER in
+ * the composer status stack (`SharedMetricsConsentStrip`), never a modal — a
+ * healthy install opens straight to chat. An answer given in the CLI (or here,
+ * or in Settings) is the same config keys, so nobody is asked twice. This host
+ * also paints the "What is collected" details the strip opens on request:
+ * three equal choices, none preselected or focused, and closing it decides
+ * nothing (the strip stays until answered).
*/
export function SharedMetricsConsentDialog({ enabled, profile, requestGateway }: SharedMetricsConsentDialogProps) {
const { t } = useI18n()
@@ -53,8 +57,9 @@ export function SharedMetricsConsentDialog({ enabled, profile, requestGateway }:
const intro = useStore($introReveal)
const surfaces = useStore($onboardingSurfaces)
const detailsId = useId()
- const [consent, setConsent] = useState<SharedMetricsConsent | null>(null)
- const [expanded, setExpanded] = useState(false)
+ const consent = useStore($sharedMetricsConsent)
+ const detailsOpen = useStore($sharedMetricsDetailsOpen)
+ const [expanded, setExpanded] = useState(true)
const [saving, setSaving] = useState(false)
// Never over the provider picker, the free-tier welcome, the intro film or
@@ -69,23 +74,24 @@ export function SharedMetricsConsentDialog({ enabled, profile, requestGateway }:
const ready = enabled && onboardingSettled
useEffect(() => {
+ $sharedMetricsConsent.set(null)
+
if (!ready) {
return
}
let cancelled = false
- setConsent(null)
void readSharedMetricsConsent(requestGateway).then(next => {
if (!cancelled) {
- setConsent(next)
+ $sharedMetricsConsent.set(next)
}
})
return () => void (cancelled = true)
}, [ready, profile, requestGateway])
- if (!ready || !consent || consent.decided) {
+ if (!ready || !detailsOpen || !sharedMetricsOfferPending(consent)) {
return null
}
@@ -97,7 +103,7 @@ export function SharedMetricsConsentDialog({ enabled, profile, requestGateway }:
setSaving(true)
try {
- setConsent(await saveSharedMetricsConsent(requestGateway, SHARED_METRICS_CHOICES[choice], { firstRun: true }))
+ await answerSharedMetricsOffer(requestGateway, choice)
} catch (err) {
notifyError(err, copy.saveFailed)
} finally {
@@ -106,7 +112,7 @@ export function SharedMetricsConsentDialog({ enabled, profile, requestGateway }:
}
return (
- <Dialog onOpenChange={open => !open && void choose('off')} open>
+ <Dialog onOpenChange={open => $sharedMetricsDetailsOpen.set(open)} open>
<DialogContent className="max-w-md" onOpenAutoFocus={preventCloseButtonAutoFocus}>
<DialogHeader>
<DialogTitle>{copy.consentTitle}</DialogTitle>
diff --git a/apps/desktop/src/components/shared-metrics/consent-strip.tsx b/apps/desktop/src/components/shared-metrics/consent-strip.tsx
new file mode 100644
index 00000000000..f9b4c8b71b6
--- /dev/null
+++ b/apps/desktop/src/components/shared-metrics/consent-strip.tsx
@@ -0,0 +1,74 @@
+import { useState } from 'react'
+
+import { useGatewayRequest } from '@/app/gateway/hooks/use-gateway-request'
+import { StatusRow } from '@/components/chat/status-row'
+import { Button } from '@/components/ui/button'
+import { Codicon } from '@/components/ui/codicon'
+import { useI18n } from '@/i18n'
+import { notifyError } from '@/store/notifications'
+import { $sharedMetricsDetailsOpen, answerSharedMetricsOffer, type SharedMetricsChoice } from '@/store/shared-metrics'
+
+const CHOICES: readonly SharedMetricsChoice[] = ['share', 'local', 'off']
+
+/**
+ * The first-run shared-metrics offer, in the composer status stack beside the
+ * free-tier strip: it never blocks the composer or takes focus, and it stays
+ * until one of the three equal answers is saved (the backend's `decided` is
+ * the only latch). "Details" opens the full explainer the host paints.
+ */
+export function SharedMetricsConsentStrip() {
+ const { requestGateway } = useGatewayRequest()
+ const { t } = useI18n()
+ const copy = t.sharedMetrics
+ const [saving, setSaving] = useState(false)
+
+ const choose = async (choice: SharedMetricsChoice) => {
+ setSaving(true)
+
+ try {
+ await answerSharedMetricsOffer(requestGateway, choice)
+ } catch (err) {
+ notifyError(err, copy.saveFailed)
+ } finally {
+ setSaving(false)
+ }
+ }
+
+ return (
+ <StatusRow
+ leading={<Codicon aria-hidden className="text-(--ui-text-tertiary)" name="graph" size="0.8rem" />}
+ trailing={
+ <>
+ {CHOICES.map(choice => (
+ <Button
+ className="text-foreground/90 hover:text-foreground"
+ disabled={saving}
+ key={choice}
+ onClick={() => void choose(choice)}
+ size="micro"
+ type="button"
+ variant="text"
+ >
+ {copy.stripChoices[choice]}
+ </Button>
+ ))}
+ <Button
+ className="text-muted-foreground/75 hover:text-foreground/90"
+ onClick={() => $sharedMetricsDetailsOpen.set(true)}
+ size="micro"
+ type="button"
+ variant="text"
+ >
+ {copy.stripDetails}
+ </Button>
+ </>
+ }
+ trailingVisible
+ >
+ <span className="min-w-0 truncate text-[0.73rem] leading-4 text-foreground/92">
+ <span className="font-medium">{copy.consentTitle}</span>
+ <span className="text-muted-foreground/80"> {copy.stripBody}</span>
+ </span>
+ </StatusRow>
+ )
+}
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 5f895718a53..a59fdb7c611 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -26,7 +26,10 @@ export const ar = defineLocale({
sendLabel: 'إرسال إحصاءات الاستخدام إلى Nous',
sendDesc:
'رفع كل حزمة يومية إلى خدمة القياس عن بُعد لدى Nous. لا تُرسل إلا بيانات نافذة الموافقة. يتطلب تفعيل الجمع.',
- unavailable: 'حدّث واجهة Hermes الخلفية لتغيير هذا الإعداد.'
+ unavailable: 'حدّث واجهة Hermes الخلفية لتغيير هذا الإعداد.',
+ stripBody: 'عدّادات محدودة فقط، دون أي مطالبات أو ملفات.',
+ stripChoices: { share: 'إرسال إلى Nous', local: 'محليًا فقط', off: 'لا، شكرًا' },
+ stripDetails: 'التفاصيل'
},
externalOpenFailed: {
title: 'تعذّر فتح هذا الرابط',
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index d0069239941..65cd2185f60 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -29,7 +29,10 @@ export const deOverrides = {
sendLabel: 'Nutzungsstatistiken an Nous senden',
sendDesc:
'Jedes Tagespaket an den Nous-Telemetriedienst hochladen. Nur Daten aus einem Zustimmungsfenster werden gesendet. Erfordert aktive Erfassung.',
- unavailable: 'Aktualisieren Sie das Hermes-Backend, um diese Einstellung zu ändern.'
+ unavailable: 'Aktualisieren Sie das Hermes-Backend, um diese Einstellung zu ändern.',
+ stripBody: 'Nur begrenzte Zähler, niemals Prompts oder Dateien.',
+ stripChoices: { share: 'An Nous senden', local: 'Nur lokal', off: 'Nein danke' },
+ stripDetails: 'Details'
},
intro: introDe,
connectors: {
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 76705a2bc3c..ebb8f0da99a 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -38,7 +38,10 @@ export const en: Translations = {
sendLabel: 'Send usage stats to Nous',
sendDesc:
'Upload each daily package to the Nous telemetry service. Only data from inside a consent window is sent. Needs collection on.',
- unavailable: 'Update the Hermes backend to change this setting.'
+ unavailable: 'Update the Hermes backend to change this setting.',
+ stripBody: 'Bounded counters only, never prompts or files.',
+ stripChoices: { share: 'Send to Nous', local: 'Local only', off: 'No thanks' },
+ stripDetails: 'Details'
},
// English editorial copy stays in the shipped JSONL; other locales override it.
intro: { stock: {}, custom: () => [] },
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index 9666ad85ce8..00de181ff6b 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -30,7 +30,10 @@ export const esOverrides = {
sendLabel: 'Enviar estadísticas de uso a Nous',
sendDesc:
'Sube cada paquete diario al servicio de telemetría de Nous. Solo se envían datos de una ventana de consentimiento. Requiere la recopilación activada.',
- unavailable: 'Actualiza el backend de Hermes para cambiar este ajuste.'
+ unavailable: 'Actualiza el backend de Hermes para cambiar este ajuste.',
+ stripBody: 'Solo contadores acotados, nunca prompts ni archivos.',
+ stripChoices: { share: 'Enviar a Nous', local: 'Solo local', off: 'No, gracias' },
+ stripDetails: 'Detalles'
},
intro: introEs,
connectors: {
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index aa949bd9997..1cf67c2e093 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -30,7 +30,10 @@ export const frOverrides = {
sendLabel: 'Envoyer les statistiques d’utilisation à Nous',
sendDesc:
'Envoyer chaque paquet quotidien au service de télémétrie de Nous. Seules les données d’une fenêtre de consentement sont envoyées. Nécessite la collecte activée.',
- unavailable: 'Mettez à jour le backend Hermes pour modifier ce réglage.'
+ unavailable: 'Mettez à jour le backend Hermes pour modifier ce réglage.',
+ stripBody: 'Uniquement des compteurs bornés, jamais de prompts ni de fichiers.',
+ stripChoices: { share: 'Envoyer à Nous', local: 'Local uniquement', off: 'Non merci' },
+ stripDetails: 'Détails'
},
intro: introFr,
connectors: {
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index df8746af8f0..12dcef6a120 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -36,7 +36,10 @@ export const ja = defineLocale({
sendLabel: '利用統計を Nous に送信する',
sendDesc:
'日次パッケージを Nous のテレメトリサービスにアップロードします。同意期間内のデータだけが送信されます。収集がオンである必要があります。',
- unavailable: 'この設定を変更するには Hermes バックエンドを更新してください。'
+ unavailable: 'この設定を変更するには Hermes バックエンドを更新してください。',
+ stripBody: '上限付きのカウンターのみ。プロンプトやファイルは含みません。',
+ stripChoices: { share: 'Nous に送信', local: 'ローカルのみ', off: '今はしない' },
+ stripDetails: '詳細'
},
intro: introJa,
catalog: {
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 006323563a0..920cc2b3bf6 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -49,7 +49,10 @@ export const ru = defineLocale({
sendLabel: 'Отправлять статистику в Nous',
sendDesc:
'Загружать ежедневный пакет в сервис телеметрии Nous. Отправляются только данные из окна согласия. Требует включённого сбора.',
- unavailable: 'Обновите бэкенд Hermes, чтобы изменить этот параметр.'
+ unavailable: 'Обновите бэкенд Hermes, чтобы изменить этот параметр.',
+ stripBody: 'Только ограниченные счётчики, никаких промптов и файлов.',
+ stripChoices: { share: 'Отправлять в Nous', local: 'Только локально', off: 'Нет, спасибо' },
+ stripDetails: 'Подробнее'
},
catalog: {
add: 'Добавить',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index eadd36552c5..ad744cdbde8 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -82,6 +82,9 @@ export interface Translations {
sendLabel: string
sendDesc: string
unavailable: string
+ stripBody: string
+ stripChoices: { share: string; local: string; off: string }
+ stripDetails: string
}
externalOpenFailed: {
title: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index aa919006bdc..028fb1095f2 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -34,7 +34,10 @@ export const zhHant = defineLocale({
collectDesc: '在此裝置上保存有上限的計數。絕不包含提示詞、檔案、路徑或錯誤文字。',
sendLabel: '向 Nous 傳送使用統計',
sendDesc: '將每日資料包上傳到 Nous 遙測服務。只傳送同意時段內的資料。需要先開啟收集。',
- unavailable: '請更新 Hermes 後端以變更此設定。'
+ unavailable: '請更新 Hermes 後端以變更此設定。',
+ stripBody: '僅限有界計數器,絕不包含提示詞或檔案。',
+ stripChoices: { share: '傳送給 Nous', local: '僅限本機', off: '不用了' },
+ stripDetails: '詳細資訊'
},
intro: introZhHant,
catalog: {
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index a078cf5e17f..9220166cf7f 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -34,7 +34,10 @@ export const zh = defineLocale({
collectDesc: '在此设备上保存有上限的计数。绝不包含提示词、文件、路径或错误文本。',
sendLabel: '向 Nous 发送使用统计',
sendDesc: '将每日数据包上传到 Nous 遥测服务。只发送同意时段内的数据。需要先开启收集。',
- unavailable: '请更新 Hermes 后端以更改此设置。'
+ unavailable: '请更新 Hermes 后端以更改此设置。',
+ stripBody: '仅限有界计数器,绝不包含提示词或文件。',
+ stripChoices: { share: '发送给 Nous', local: '仅本地', off: '不用了' },
+ stripDetails: '详情'
},
intro: introZh,
catalog: {
diff --git a/apps/desktop/src/store/shared-metrics.ts b/apps/desktop/src/store/shared-metrics.ts
index a584179c172..5c066987864 100644
--- a/apps/desktop/src/store/shared-metrics.ts
+++ b/apps/desktop/src/store/shared-metrics.ts
@@ -1,4 +1,5 @@
import type { SharedMetricsConsentResult } from '@hermes/shared'
+import { atom } from 'nanostores'
/** Public page describing exactly what shared metrics contain and how consent windows work. */
export const SHARED_METRICS_DOCS_URL = 'https://hermes-agent.nousresearch.com/docs/developer-guide/relay-shared-metrics'
@@ -51,3 +52,27 @@ export async function saveSharedMetricsConsent(
return consent
}
+
+/**
+ * The focused profile's answer, as last read from the backend by the consent
+ * host. `null` = not asked yet or the backend could not say (never offer then).
+ * A cache of backend truth: the host re-reads it on every profile switch.
+ */
+export const $sharedMetricsConsent = atom<SharedMetricsConsent | null>(null)
+
+/** The "What is collected" details dialog, opened only by the user from the strip. */
+export const $sharedMetricsDetailsOpen = atom(false)
+
+/** The first-run offer is still unanswered for the focused profile. */
+export function sharedMetricsOfferPending(consent: SharedMetricsConsent | null): boolean {
+ return consent?.decided === false
+}
+
+/** Record a first-run answer; the strip and the dialog retire as soon as the backend reports it decided. */
+export async function answerSharedMetricsOffer(
+ request: SharedMetricsRequester,
+ choice: SharedMetricsChoice
+): Promise<void> {
+ $sharedMetricsConsent.set(await saveSharedMetricsConsent(request, SHARED_METRICS_CHOICES[choice], { firstRun: true }))
+ $sharedMetricsDetailsOpen.set(false)
+}
diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.md
index ee0984ed7e9..5593944ffbc 100644
--- a/website/docs/developer-guide/relay-shared-metrics.md
+++ b/website/docs/developer-guide/relay-shared-metrics.md
@@ -386,6 +386,14 @@ telemetry:
- Like `enabled`, `send` is profile-owned and is not overridden by
managed-scope configuration.
+Both keys are asked once per profile: by the Shared Metrics section of
+`hermes setup`, or in Hermes Desktop by an offer strip above the composer
+(Send to Nous / Local only / No thanks, with a Details view). The Desktop offer
+never blocks the composer or takes focus, appears only after first-run
+onboarding, and stays until answered. A profile whose `config.yaml` already
+carries either key is never asked again on any surface. Settings › Safety ›
+Privacy & network toggles both keys later.
+
**A package is only sent when its whole period falls inside a recorded
consent window.** Consent is stored as explicit intervals in the shared-
metrics SQLite store (`send_consent_windows`): a window opens when `send: