The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): avatar misses expire after 30s instead of caching forever (#85908)
Teknium17d6a7d42626
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-message.tsx b/apps/desktop/src/components/assistant-ui/thread/user-message.tsxindex ce9cd410455..22e918389a8 100644--- a/apps/desktop/src/components/assistant-ui/thread/user-message.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/user-message.tsx@@ -87,10 +87,14 @@ const PROCESS_NOTIFICATION_RE = /^\[IMPORTANT: Background process [\s\S]*\]$/export const AGENT_MESSAGE_RE =/^(?:Message from (?:π€\s*)?([^:\n(]{1,64}?)(?:\s*\(@([a-z0-9][a-z0-9_-]{0,63})\))?:\s*|\[Message from agent '([^']{1,64})'\]\s*)([\s\S]*)$/u-// sender handle -> avatar data URL (null = known absent). Module-level so a-// chat full of notices from one bot resolves once. Profiles change rarely;-// stale entries only persist for the window's lifetime.+// sender handle -> avatar data URL. Module-level so a chat full of notices+// from one bot resolves once. Hits are cached for the window's lifetime;+// misses only briefly (30s) β an avatar can appear at any moment (bot just+// created, art backfill still running), and a permanent negative cache+// froze the π€ glyph until an app restart.export const agentAvatarCache = new Map<string, null | string>()+const agentAvatarMissAt = new Map<string, number>()+const AVATAR_MISS_TTL_MS = 30_000const agentAvatarInflight = new Map<string, Promise<null | string>>()export async function resolveAgentAvatar(handle: string): Promise<null | string> {@@ -101,7 +105,18 @@ export async function resolveAgentAvatar(handle: string): Promise<null | string>}if (agentAvatarCache.has(key)) {- return agentAvatarCache.get(key) ?? null+ const hit = agentAvatarCache.get(key) ?? null++ if (hit !== null) {+ return hit+ }++ // Negative entry: honor it only within the TTL, then re-probe.+ if (Date.now() - (agentAvatarMissAt.get(key) ?? 0) < AVATAR_MISS_TTL_MS) {+ return null+ }++ agentAvatarCache.delete(key)}const inflight = agentAvatarInflight.get(key)@@ -153,6 +168,10 @@ export async function resolveAgentAvatar(handle: string): Promise<null | string>const out = await runagentAvatarCache.set(key, out)+ if (out === null) {+ agentAvatarMissAt.set(key, Date.now())+ }+return out}