The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): pace the tip rotation in hours, not minutes
Brooklyn Nicholson198a69421cc3
diff --git a/apps/desktop/src/components/tips/use-tip-rotation.ts b/apps/desktop/src/components/tips/use-tip-rotation.tsindex 5bb315b0a60..20834a5e68b 100644--- a/apps/desktop/src/components/tips/use-tip-rotation.ts+++ b/apps/desktop/src/components/tips/use-tip-rotation.ts@@ -1,15 +1,23 @@/**- * The rotation's clock: when the app is quiet, offer a tip.+ * The rotation's clock: a few minutes into a launch, then hours apart, offer a+ * tip if the app happens to be quiet.** Off unless the user turned it on (Settings → Appearance) — this is the half* of the feature that talks unprompted, so it is the half that has to be asked* for. An agent tip doesn't come through here at all.*- * "Quiet" is doing the rest of the work. A tip is the app interrupting, so it- * waits for a moment that is genuinely idle — nothing streaming, no dialog,- * menu or tour on screen, the window focused, and a few seconds since the last- * keystroke. Fail any of those and the tick simply passes; a tip is never- * queued up to ambush the user the instant they stop typing.+ * The pacing is a loading-screen tip's, not a notification's. Two clocks have+ * to agree: a per-launch settling delay, so opening the app is never met with a+ * bubble, and a six-hour cooldown persisted across launches, so quitting and+ * reopening isn't a way to farm them. In practice that lands around one tip per+ * day of use and takes weeks to walk the catalog, which is the point — ten tips+ * in an afternoon is how a nicety turns into a thing people switch off.+ *+ * Then "quiet" does the rest. A tip is still the app interrupting, so it waits+ * for a moment that is genuinely idle — nothing streaming, no dialog, menu or+ * tour on screen, the window focused, and a few seconds since the last+ * keystroke. Fail any of those and the tick passes; being due only means the+ * next quiet moment is eligible, never that one gets taken.*/import { useEffect } from 'react'@@ -19,13 +27,14 @@ import { resolveTipAnchor } from '@/lib/tips/anchor'import { TIP_CATALOG } from '@/lib/tips/catalog'import { nextTip } from '@/lib/tips/rotation'import { $awaitingResponse, $busy } from '@/store/session'-import { $activeTip, $lastTipId, $retiredTips, $tipRotationEnabled, showTip } from '@/store/tips'--const TICK_MS = 5_000-/** Long enough that the first tip lands after you've settled in, not on boot. */-const FIRST_TIP_MS = 45_000-/** And rare enough afterwards to stay a nicety rather than a nag. */-const BETWEEN_TIPS_MS = 6 * 60_000+import { $activeTip, $lastTipId, $nextTipAt, $retiredTips, $tipRotationEnabled, showTip } from '@/store/tips'++const TICK_MS = 30_000+/** Nothing in the first stretch of a launch, however long the cooldown says+ * it's been: you opened the app to do a thing, and the tip can wait until+ * you've done it. Jittered so it isn't the same beat every time. */+const SETTLE_MIN_MS = 5 * 60_000+const SETTLE_SPREAD_MS = 5 * 60_000/** Typing is the clearest "I'm busy" signal the renderer gets for free. */const TYPING_GRACE_MS = 5_000@@ -54,25 +63,24 @@ function appIsQuiet(lastTypedAt: number): boolean {export function useTipRotation(copy: Translations['tips']) {useEffect(() => {let lastTypedAt = 0- let dueAt = Date.now() + FIRST_TIP_MS+ let settledAt = Date.now() + SETTLE_MIN_MS + Math.random() * SETTLE_SPREAD_MSconst noteTyping = () => {lastTypedAt = Date.now()}- const offer = () => {- if (!$tipRotationEnabled.get()) {- return- }+ const isDue = () => {+ const nextAt = $nextTipAt.get()- if ($activeTip.get()) {- // One is up; the next comes due a good while after it goes away.- dueAt = Date.now() + BETWEEN_TIPS_MS+ return Date.now() >= settledAt && (nextAt === null || Date.now() >= nextAt)+ }+ const offer = () => {+ if (!$tipRotationEnabled.get() || $activeTip.get()) {return}- if (Date.now() < dueAt || !appIsQuiet(lastTypedAt)) {+ if (!isDue() || !appIsQuiet(lastTypedAt)) {return}@@ -102,11 +110,22 @@ export function useTipRotation(copy: Translations['tips']) {})}+ // Turning the rotation on is its own kind of settled: the delay guards a+ // launch you came into with a purpose, and has nothing to say about someone+ // who just asked for tips and is owed the sight of one working.+ const unbindSwitch = $tipRotationEnabled.listen(enabled => {+ if (enabled) {+ settledAt = Date.now()+ offer()+ }+ })+const timer = window.setInterval(offer, TICK_MS)window.addEventListener('keydown', noteTyping, true)return () => {+ unbindSwitch()window.clearInterval(timer)window.removeEventListener('keydown', noteTyping, true)}diff --git a/apps/desktop/src/store/tips.ts b/apps/desktop/src/store/tips.tsindex d9fe6f07237..4451ece223e 100644--- a/apps/desktop/src/store/tips.ts+++ b/apps/desktop/src/store/tips.ts@@ -17,9 +17,9 @@* - `$activeTip` is what is on screen. Ephemeral by design: a tip is a nicety,* and one that survives a reload has overstayed.*- * `$lastTipId` is the rotation's cursor — where the next walk through the- * catalog resumes from. Persisted, because the alternative is that every- * relaunch reopens the tour at tip one.+ * `$lastTipId` is the rotation's cursor and `$nextTipAt` is its clock. Both are+ * persisted, because the alternative is that every relaunch reopens the tour at+ * tip one and re-arms a schedule measured in hours.*/import { atom } from 'nanostores'@@ -27,6 +27,9 @@ import { atom } from 'nanostores'import { Codecs, persistentAtom } from '@/lib/persisted'import type { TipSide } from '@/lib/tips/catalog'+/** Hours, not minutes. The catalog is ten tips and it should take weeks. */+const COOLDOWN_MS = 6 * 60 * 60_000+/** A tip as the bubble needs it: resolved copy, resolved anchor. */export interface ActiveTip {/** Keybind action id whose live combo the bubble prints. */@@ -44,6 +47,11 @@ export interface ActiveTip {export const $tipRotationEnabled = persistentAtom('hermes.desktop.tips.rotation.v1', false, Codecs.bool)export const $retiredTips = persistentAtom<string[]>('hermes.desktop.tips.retired.v1', [], Codecs.stringArray)export const $lastTipId = persistentAtom<null | string>('hermes.desktop.tips.last.v1', null, Codecs.nullableText)+export const $nextTipAt = persistentAtom<null | number>(+ 'hermes.desktop.tips.next.v1',+ null,+ Codecs.json(value => (typeof value === 'number' && Number.isFinite(value) ? value : null))+)export const $activeTip = atom<ActiveTip | null>(null)export function setTipRotationEnabled(enabled: boolean): void {@@ -56,9 +64,11 @@ export function setTipRotationEnabled(enabled: boolean): void {$tipRotationEnabled.set(enabled)}-/** Un-retire everything. The rotation starts over from a full deck. */+/** Un-retire everything, and let the rotation start over from a full deck+ * rather than from wherever a six-hour cooldown had left it. */export function resetTips(): void {$retiredTips.set([])+ $nextTipAt.set(null)}/** Put a tip on screen, replacing whatever was there. */@@ -67,6 +77,9 @@ export function showTip(tip: ActiveTip): void {$lastTipId.set(tip.tipId)}+ // Any tip starts the cooldown, an agent's included: whoever just pointed at+ // something, the user has had their one interruption for a good while.+ $nextTipAt.set(Date.now() + COOLDOWN_MS)$activeTip.set(tip)}diff --git a/website/docs/reference/tools-reference.md b/website/docs/reference/tools-reference.mdindex 24943617615..7431a0d50e1 100644--- a/website/docs/reference/tools-reference.md+++ b/website/docs/reference/tools-reference.md@@ -264,12 +264,15 @@ The `tip` tool takes the same selectors `tour(action='targets')` reports, sodiscovery is one call for both, and the durable `data-tour` handles above nametargets for either. One tip is on screen at a time; a new one replaces the last.-The app can also show its own, walking a built-in catalog of app features on a-slow rotation whenever things are quiet. That half is off until switched on in-Settings → Appearance, since it talks unprompted; closing one of its tips with-the ✕ retires that tip for good, and the same settings row brings them back. The-tool is not behind that switch — like `tour`, it runs in answer to the-conversation rather than at idle.+The app can also show its own, walking a built-in catalog of app features in+order. That half is off until switched on in Settings → Appearance, since it+talks unprompted, and it is paced like a game's loading-screen tips rather than+a notification: a few minutes into a launch at the earliest, then at most one+every six hours, and only at a genuinely idle moment. Closing one of its tips+with the ✕ retires that tip for good, and the same settings row brings them+back. The tool is not behind that switch — like `tour`, it runs in answer to the+conversation rather than at idle. It does share the cooldown, so a tip from+Hermes also buys the user six hours of quiet from the rotation.## `todo` toolset