Skip to content

The agent that grows with you

fix(desktop): remember dismissed agent tips

wangtaoc1f96e6c6526
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/desktop-bridge.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/desktop-bridge.ts
index b0a5d2c6225..e9af455c4ab 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/desktop-bridge.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/desktop-bridge.ts
@@ -3,7 +3,7 @@ import { closeAgentTerminalByProc } from '@/app/right-sidebar/terminal/terminals
import { applyDesktopLayoutPreset, revealDesktopPane } from '@/store/pane-focus'
import { recordAgentReaction } from '@/store/reactions-local'
import { setMessages } from '@/store/session'
-import { $tipsEnabled, type ActiveTip, showTip } from '@/store/tips'
+import { $tipsEnabled, type ActiveTip, agentTipId, showTip } from '@/store/tips'
import type { GatewayEventContext } from './types'
@@ -47,6 +47,7 @@ export function handleDesktopBridgeEvent(ctx: GatewayEventContext): boolean {
side: (payload?.side as ActiveTip['side']) ?? 'top',
targets: [selector],
text,
+ tipId: agentTipId(selector, text),
title: typeof payload?.title === 'string' ? payload.title : undefined
})
}
diff --git a/apps/desktop/src/store/tips.test.ts b/apps/desktop/src/store/tips.test.ts
new file mode 100644
index 00000000000..0b24a1f9237
--- /dev/null
+++ b/apps/desktop/src/store/tips.test.ts
@@ -0,0 +1,40 @@
+import { beforeEach, describe, expect, it } from 'vitest'
+
+import { $activeTip, $retiredTips, agentTipId, dismissTip, resetTips, retireActiveTip, showTip } from './tips'
+
+const showAgentTip = (selector: string, text: string) => {
+ showTip({
+ side: 'top',
+ targets: [selector],
+ text,
+ tipId: agentTipId(selector, text)
+ })
+}
+
+beforeEach(() => {
+ dismissTip()
+ resetTips()
+})
+
+describe('agent tip retirement', () => {
+ it('does not show the same agent tip again after the user retires it', () => {
+ showAgentTip('[data-tour="model-pill"]', 'Choose a model here.')
+ const tipId = $activeTip.get()?.tipId
+
+ retireActiveTip()
+ showAgentTip('[data-tour="model-pill"]', 'Choose a model here.')
+
+ expect(tipId).toBe(agentTipId('[data-tour="model-pill"]', 'Choose a model here.'))
+ expect($retiredTips.get()).toContain(tipId)
+ expect($activeTip.get()).toBeNull()
+ })
+
+ it('keeps distinct agent tips independently dismissible', () => {
+ showAgentTip('[data-tour="model-pill"]', 'Choose a model here.')
+ retireActiveTip()
+
+ showAgentTip('[data-tour="composer"]', 'Write your prompt here.')
+
+ expect($activeTip.get()?.tipId).toBe(agentTipId('[data-tour="composer"]', 'Write your prompt here.'))
+ })
+})
diff --git a/apps/desktop/src/store/tips.ts b/apps/desktop/src/store/tips.ts
index 072ad2e9102..3a58baf4d8f 100644
--- a/apps/desktop/src/store/tips.ts
+++ b/apps/desktop/src/store/tips.ts
@@ -49,7 +49,7 @@ export interface ActiveTip {
* tip follows an element that re-renders and leaves when it goes away. */
targets: readonly string[]
text: string
- /** Catalog id. Absent for an agent-authored tip, which has nothing to retire. */
+ /** Stable id used by the seen and retirement ledgers. */
tipId?: string
title?: string
}
@@ -69,6 +69,11 @@ export const $nextTipAt = persistentAtom<null | number>(
)
export const $activeTip = atom<ActiveTip | null>(null)
+/** Agent tips have no catalog entry, so their content is their durable identity. */
+export function agentTipId(selector: string, text: string): string {
+ return `agent:${JSON.stringify([selector, text])}`
+}
+
// Off has to reach the agent, not just the renderer: the `tip` tool leaves the
// model's schema entirely rather than staying on offer and being dropped.
mirrorDisplayToggle('display.in_app_tips', ENABLED_KEY, $tipsEnabled)
@@ -120,6 +125,10 @@ export const $spentTipCount = computed([$retiredTips, $tipShownAt], (retired, sh
/** Put a tip on screen, replacing whatever was there. */
export function showTip(tip: ActiveTip): void {
+ if (tip.tipId && $retiredTips.get().includes(tip.tipId)) {
+ return
+ }
+
if (tip.tipId) {
// The cursor belongs to the rotation's walk. A campaign tip (an id the
// catalog doesn't hold) records when it showed but must not move the
@@ -142,8 +151,7 @@ export function dismissTip(): void {
$activeTip.set(null)
}
-/** Hard close (the ✕): retire the catalog tip behind the bubble for good. An
- * agent tip has no catalog entry, so it just closes. */
+/** Hard close (the ✕): retire the identified tip behind the bubble for good. */
export function retireActiveTip(): void {
const tipId = $activeTip.get()?.tipId