Skip to content

The agent that grows with you

refactor(desktop): one identity chip behind every avatar

Brooklyn Nicholson9ed308f90120
diff --git a/apps/desktop/electron/favicon.ts b/apps/desktop/electron/favicon.ts
new file mode 100644
index 00000000000..920953345c2
--- /dev/null
+++ b/apps/desktop/electron/favicon.ts
@@ -0,0 +1,347 @@
+/**
+ * Favicon resolution, the thorough way.
+ *
+ * `<origin>/favicon.ico` answers for maybe half the web. Everyone else
+ * declares their marks in the page head (`<link rel="icon">`, apple-touch,
+ * SVG mask icons) or in a web app manifest, at paths that are frequently
+ * hashed build artifacts on a CDN — unguessable. So: read the page, collect
+ * every declared icon, rank them, and only then fall back to the well-known
+ * paths.
+ *
+ * Only ever the site's own marks. A public icon service would answer for the
+ * hosts that hide behind a bot wall, but asking one means telling a third
+ * party which connector a user is wiring up — so a site we can't read keeps
+ * its monogram instead.
+ *
+ * This lives in the main process because none of it is possible from the
+ * renderer: cross-origin HTML is unreadable under CORS, and the whole point
+ * is reading someone else's markup.
+ *
+ * Everything here is pure — URL math, parsing, ranking. The I/O is injected
+ * so the ladder can be tested without a network.
+ */
+
+export interface IconCandidate {
+ url: string
+ /** Rough pixel edge, or a synthetic rank for scalable/unsized marks. */
+ score: number
+}
+
+export interface FaviconIo {
+ /** Page/manifest text, or '' when it can't be read. */
+ fetchText: (url: string) => Promise<string>
+ /** Image bytes plus the server's content type, or null on any refusal. */
+ fetchImage: (url: string) => Promise<null | { bytes: Uint8Array; mime: string }>
+}
+
+/** Scalable beats every raster size; below it, bigger wins up to a point. */
+const SCORE_SVG = 1024
+/** `sizes="any"` — usually an SVG or a multi-res ICO. */
+const SCORE_ANY = 512
+/** Apple's spec size, which is what unsized apple-touch links almost always are. */
+const SCORE_APPLE_TOUCH = 180
+/** A declared icon with no size at all still beats a guessed path. */
+const SCORE_UNSIZED = 96
+/** Guessed well-known paths, tried only after everything declared. */
+const SCORE_GUESS = 48
+
+/** Past this the file is a download, not an icon. */
+const SCORE_CEILING = 512
+
+/**
+ * A host worth asking for an icon.
+ *
+ * Loopback and RFC1918 addresses serve MCP endpoints, not brands, and an
+ * icon service can't see them anyway. Refusing them here is also what keeps
+ * a private hostname from being handed to that service.
+ */
+export function isPublicHttpUrl(raw: string): boolean {
+ let url: URL
+
+ try {
+ url = new URL(raw)
+ } catch {
+ return false
+ }
+
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
+ return false
+ }
+
+ const host = url.hostname.toLowerCase()
+
+ return !(
+ host === 'localhost' ||
+ host === '::1' ||
+ host.endsWith('.local') ||
+ host.endsWith('.internal') ||
+ !host.includes('.') ||
+ /^127\./.test(host) ||
+ /^10\./.test(host) ||
+ /^192\.168\./.test(host) ||
+ /^169\.254\./.test(host) ||
+ /^172\.(1[6-9]|2\d|3[01])\./.test(host)
+ )
+}
+
+const absolute = (href: string, base: string): string => {
+ try {
+ const url = new URL(href.trim(), base)
+
+ return url.protocol === 'http:' || url.protocol === 'https:' ? url.toString() : ''
+ } catch {
+ return ''
+ }
+}
+
+/** "180x180 32x32" → 180. Takes the largest declared square edge. */
+export function largestDeclaredSize(sizes: string): number {
+ let best = 0
+
+ for (const token of sizes.toLowerCase().split(/\s+/)) {
+ if (token === 'any') {
+ best = Math.max(best, SCORE_ANY)
+
+ continue
+ }
+
+ const edge = Number(token.split('x')[0])
+
+ if (Number.isFinite(edge)) {
+ best = Math.max(best, edge)
+ }
+ }
+
+ return best
+}
+
+const attr = (tag: string, name: string): string =>
+ tag
+ .match(new RegExp(`\\b${name}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s"'>]+))`, 'i'))
+ ?.slice(2)
+ .find(Boolean) ?? ''
+
+const scoreFor = (rel: string, type: string, sizes: string): number => {
+ if (type.includes('svg') || rel.includes('mask-icon')) {
+ return SCORE_SVG
+ }
+
+ const declared = largestDeclaredSize(sizes)
+
+ if (declared > 0) {
+ return Math.min(declared, SCORE_CEILING)
+ }
+
+ return rel.includes('apple-touch-icon') ? SCORE_APPLE_TOUCH : SCORE_UNSIZED
+}
+
+/** Every icon the page declares, absolute and ranked. */
+export function iconCandidatesFromHtml(html: string, pageUrl: string): IconCandidate[] {
+ const base = absolute(attr(html.match(/<base\b[^>]*>/i)?.[0] ?? '', 'href'), pageUrl) || pageUrl
+ const candidates: IconCandidate[] = []
+
+ for (const tag of html.match(/<link\b[^>]*>/gi) ?? []) {
+ const rel = attr(tag, 'rel').toLowerCase()
+
+ if (!/\b(icon|shortcut icon|apple-touch-icon|apple-touch-icon-precomposed|fluid-icon|mask-icon)\b/.test(rel)) {
+ continue
+ }
+
+ const url = absolute(attr(tag, 'href'), base)
+
+ if (url) {
+ candidates.push({ score: scoreFor(rel, attr(tag, 'type').toLowerCase(), attr(tag, 'sizes')), url })
+ }
+ }
+
+ return candidates
+}
+
+/** The page's web app manifest, if it links one. */
+export function manifestUrlFromHtml(html: string, pageUrl: string): string {
+ for (const tag of html.match(/<link\b[^>]*>/gi) ?? []) {
+ if (/\bmanifest\b/i.test(attr(tag, 'rel'))) {
+ return absolute(attr(tag, 'href'), pageUrl)
+ }
+ }
+
+ return ''
+}
+
+/** PWA manifests carry the best assets a site has — 192px and 512px marks
+ * designed to stand alone on a home screen, which is exactly our use. */
+export function iconCandidatesFromManifest(raw: string, manifestUrl: string): IconCandidate[] {
+ let parsed: unknown
+
+ try {
+ parsed = JSON.parse(raw)
+ } catch {
+ return []
+ }
+
+ const icons = (parsed as { icons?: unknown })?.icons
+
+ if (!Array.isArray(icons)) {
+ return []
+ }
+
+ const candidates: IconCandidate[] = []
+
+ for (const icon of icons) {
+ const src = typeof icon?.src === 'string' ? absolute(icon.src, manifestUrl) : ''
+
+ if (!src) {
+ continue
+ }
+
+ const type = typeof icon?.type === 'string' ? icon.type.toLowerCase() : ''
+ const sizes = typeof icon?.sizes === 'string' ? icon.sizes : ''
+
+ candidates.push({ score: scoreFor('', type, sizes), url: src })
+ }
+
+ return candidates
+}
+
+/** The well-known paths, on the origin and on its apex — vendors routinely
+ * serve icons from `example.com` and nothing from `api.example.com`. */
+export function fallbackIconCandidates(pageUrl: string): IconCandidate[] {
+ let url: URL
+
+ try {
+ url = new URL(pageUrl)
+ } catch {
+ return []
+ }
+
+ const labels = url.hostname.split('.')
+ const apex = labels.length > 2 ? `${url.protocol}//${labels.slice(-2).join('.')}` : url.origin
+ const origins = [...new Set([url.origin, apex])]
+
+ return origins.flatMap(origin => [
+ { score: SCORE_GUESS + 2, url: `${origin}/apple-touch-icon.png` },
+ { score: SCORE_GUESS + 1, url: `${origin}/apple-touch-icon-precomposed.png` },
+ { score: SCORE_GUESS, url: `${origin}/favicon.ico` },
+ { score: SCORE_GUESS - 1, url: `${origin}/favicon.png` }
+ ])
+}
+
+/** Highest-ranked first, one entry per URL, capped so a page declaring
+ * twenty icons can't turn one card into twenty requests. */
+export function rankCandidates(candidates: IconCandidate[], limit = 6): IconCandidate[] {
+ const best = new Map<string, number>()
+
+ for (const candidate of candidates) {
+ best.set(candidate.url, Math.max(best.get(candidate.url) ?? 0, candidate.score))
+ }
+
+ return [...best.entries()]
+ .map(([url, score]) => ({ score, url }))
+ .sort((a, b) => b.score - a.score)
+ .slice(0, limit)
+}
+
+/** Magic bytes, because plenty of servers hand back an icon as
+ * `application/octet-stream` — and an HTML error page as `image/png`. */
+export function sniffImageMime(bytes: Uint8Array): string {
+ const at = (offset: number, ...signature: number[]) =>
+ signature.every((byte, index) => bytes[offset + index] === byte)
+
+ if (at(0, 0x89, 0x50, 0x4e, 0x47)) {
+ return 'image/png'
+ }
+
+ if (at(0, 0xff, 0xd8, 0xff)) {
+ return 'image/jpeg'
+ }
+
+ if (at(0, 0x47, 0x49, 0x46, 0x38)) {
+ return 'image/gif'
+ }
+
+ if (at(0, 0x00, 0x00, 0x01, 0x00)) {
+ return 'image/x-icon'
+ }
+
+ if (at(0, 0x52, 0x49, 0x46, 0x46) && at(8, 0x57, 0x45, 0x42, 0x50)) {
+ return 'image/webp'
+ }
+
+ const head = new TextDecoder().decode(bytes.subarray(0, 1024)).toLowerCase()
+
+ return head.includes('<svg') ? 'image/svg+xml' : ''
+}
+
+/**
+ * The mime to trust for these bytes, or '' if they aren't an image.
+ *
+ * The bytes decide, never the header. A blocked request answers 200 with an
+ * HTML challenge page under `content-type: image/png` often enough that
+ * believing the server is how you end up rendering a broken-image box.
+ */
+export function imageMime(declared: string, bytes: Uint8Array): string {
+ if (bytes.length < 48) {
+ return ''
+ }
+
+ const sniffed = sniffImageMime(bytes)
+
+ // An SVG that opens with a license comment long enough to push `<svg` past
+ // the sniff window is still an SVG if the server said so.
+ return sniffed || (declared.toLowerCase().includes('svg') ? 'image/svg+xml' : '')
+}
+
+export const toDataUrl = (mime: string, bytes: Uint8Array): string =>
+ `data:${mime};base64,${Buffer.from(bytes).toString('base64')}`
+
+/**
+ * Walk the ladder and return the first real image, as a data URL.
+ *
+ * Data URL rather than a link so the renderer paints without a second
+ * network trip, the icon survives a site going down, and one cached string
+ * covers every surface showing that connector.
+ */
+export async function resolveFavicon(pageUrl: string, io: FaviconIo): Promise<string> {
+ if (!isPublicHttpUrl(pageUrl)) {
+ return ''
+ }
+
+ const candidates: IconCandidate[] = []
+ const html = await io.fetchText(pageUrl).catch(() => '')
+
+ if (html) {
+ candidates.push(...iconCandidatesFromHtml(html, pageUrl))
+
+ const manifestUrl = manifestUrlFromHtml(html, pageUrl)
+
+ if (manifestUrl) {
+ const manifest = await io.fetchText(manifestUrl).catch(() => '')
+
+ if (manifest) {
+ candidates.push(...iconCandidatesFromManifest(manifest, manifestUrl))
+ }
+ }
+ }
+
+ candidates.push(...fallbackIconCandidates(pageUrl))
+
+ // Only the site's own marks. A third-party icon service would answer for
+ // the hosts that serve nothing readable, but asking it means naming a
+ // connector's host to someone else — so a site that won't show us its icon
+ // simply keeps its monogram.
+ for (const candidate of rankCandidates(candidates)) {
+ const image = await io.fetchImage(candidate.url).catch(() => null)
+
+ if (!image) {
+ continue
+ }
+
+ const mime = imageMime(image.mime, image.bytes)
+
+ if (mime) {
+ return toDataUrl(mime, image.bytes)
+ }
+ }
+
+ return ''
+}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 0a7b998d72b..eaf5ad99917 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -141,6 +141,7 @@ import {
terminalScriptExtension,
tuiResumeArgs
} from './external-terminal'
+import { type FaviconIo, resolveFavicon } from './favicon'
import { findGitBash as _findGitBash } from './find-git-bash'
import {
installFindShortcut,
@@ -5373,6 +5374,159 @@ function fetchLinkTitle(rawUrl) {
return pending
}
+// ─── Favicon resolution ──────────────────────────────────────────────────────
+// The ladder itself is electron/favicon.ts; this is its I/O, its cache, and
+// the one rule that belongs to the app rather than the algorithm: one icon
+// per host. A connector's mark doesn't vary by path, and hosting the cache on
+// the host key means Linear's docs page and Linear's MCP endpoint cost one
+// lookup between them.
+
+const FAVICON_CACHE_PATH = path.join(app.getPath('userData'), 'favicon-cache.json')
+const FAVICON_CACHE_LIMIT = 400
+const FAVICON_TTL_MS = 30 * 24 * 60 * 60 * 1000
+// A miss is cheap to re-check and expensive to be wrong about (a site that
+// was behind a captcha yesterday has a logo today), so it expires fast.
+const FAVICON_MISS_TTL_MS = 12 * 60 * 60 * 1000
+const FAVICON_TIMEOUT_MS = 6000
+const FAVICON_MAX_BYTES = 256 * 1024
+const FAVICON_WRITE_DEBOUNCE_MS = 3000
+
+let faviconCache: Map<string, { at: number; icon: string }> | null = null
+let faviconWriteTimer: null | ReturnType<typeof setTimeout> = null
+const faviconInflight = new Map<string, Promise<string>>()
+
+function faviconCacheKey(rawUrl: string): string {
+ try {
+ return new URL(rawUrl).hostname.replace(/^www\./i, '').toLowerCase()
+ } catch {
+ return ''
+ }
+}
+
+function loadFaviconCache(): Map<string, { at: number; icon: string }> {
+ if (faviconCache) {
+ return faviconCache
+ }
+
+ faviconCache = new Map()
+
+ try {
+ const raw = JSON.parse(fs.readFileSync(FAVICON_CACHE_PATH, 'utf8'))
+
+ for (const [host, entry] of Object.entries(raw?.icons ?? {})) {
+ const at = Number((entry as { at?: number })?.at)
+ const icon = String((entry as { icon?: string })?.icon ?? '')
+
+ if (Number.isFinite(at) && Date.now() - at < (icon ? FAVICON_TTL_MS : FAVICON_MISS_TTL_MS)) {
+ faviconCache.set(host, { at, icon })
+ }
+ }
+ } catch {
+ // No cache yet, or it's unreadable — resolving again is the whole cost.
+ }
+
+ return faviconCache
+}
+
+function saveFaviconCacheSoon() {
+ if (faviconWriteTimer) {
+ return
+ }
+
+ faviconWriteTimer = setTimeout(() => {
+ faviconWriteTimer = null
+
+ try {
+ const icons = Object.fromEntries(loadFaviconCache())
+
+ fs.writeFileSync(FAVICON_CACHE_PATH, JSON.stringify({ icons }), 'utf8')
+ } catch {
+ // Cache is an optimization; failing to persist it costs one refetch.
+ }
+ }, FAVICON_WRITE_DEBOUNCE_MS)
+
+ faviconWriteTimer.unref?.()
+}
+
+async function faviconFetch(url: string, accept: string) {
+ const controller = new AbortController()
+ const timer = setTimeout(() => controller.abort(), FAVICON_TIMEOUT_MS)
+
+ try {
+ return await electronNet.fetch(url, {
+ // Same browser-shaped identity the title fetcher uses: a plain Electron
+ // UA gets a challenge page from anything behind a bot wall.
+ headers: { Accept: accept, 'Accept-Language': 'en-US,en;q=0.7', 'User-Agent': TITLE_USER_AGENT },
+ redirect: 'follow',
+ signal: controller.signal
+ })
+ } finally {
+ clearTimeout(timer)
+ }
+}
+
+const faviconIo: FaviconIo = {
+ fetchImage: async url => {
+ const response = await faviconFetch(url, 'image/avif,image/webp,image/svg+xml,image/*;q=0.8,*/*;q=0.5')
+
+ if (!response.ok) {
+ return null
+ }
+
+ const buffer = await response.arrayBuffer()
+
+ if (buffer.byteLength === 0 || buffer.byteLength > FAVICON_MAX_BYTES) {
+ return null
+ }
+
+ return { bytes: new Uint8Array(buffer), mime: response.headers.get('content-type') ?? '' }
+ },
+ fetchText: async url => {
+ const response = await faviconFetch(url, 'text/html,application/xhtml+xml,application/json;q=0.9,*/*;q=0.5')
+
+ return response.ok ? (await response.text()).slice(0, TITLE_BYTE_BUDGET * 2) : ''
+ }
+}
+
+function resolveFaviconCached(rawUrl: string): Promise<string> {
+ const key = faviconCacheKey(String(rawUrl || '').trim())
+
+ if (!key) {
+ return Promise.resolve('')
+ }
+
+ const cache = loadFaviconCache()
+ const hit = cache.get(key)
+
+ if (hit && Date.now() - hit.at < (hit.icon ? FAVICON_TTL_MS : FAVICON_MISS_TTL_MS)) {
+ return Promise.resolve(hit.icon)
+ }
+
+ const inflight = faviconInflight.get(key)
+
+ if (inflight) {
+ return inflight
+ }
+
+ const pending = resolveFavicon(rawUrl, faviconIo)
+ .catch(() => '')
+ .then(icon => {
+ if (cache.size >= FAVICON_CACHE_LIMIT) {
+ cache.delete(cache.keys().next().value)
+ }
+
+ cache.set(key, { at: Date.now(), icon })
+ saveFaviconCacheSoon()
+ faviconInflight.delete(key)
+
+ return icon
+ })
+
+ faviconInflight.set(key, pending)
+
+ return pending
+}
+
async function resourceBufferFromUrl(rawUrl) {
if (!rawUrl) {
throw new Error('Missing URL')
@@ -14288,6 +14442,8 @@ ipcMain.handle('hermes:setting:defaultProjectDir:pick', async () => {
ipcMain.handle('hermes:fetchLinkTitle', (_event, url) => fetchLinkTitle(url))
+ipcMain.handle('hermes:resolveFavicon', (_event, url) => resolveFaviconCached(url))
+
ipcMain.handle('hermes:logs:reveal', async () => {
try {
await fs.promises.mkdir(path.dirname(DESKTOP_LOG_PATH), { recursive: true })
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index e95c5e389a4..7d8dac57af5 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -236,6 +236,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {
openPreviewInBrowser: url => ipcRenderer.invoke('hermes:openPreviewInBrowser', url),
reachPreviewUrl: url => ipcRenderer.invoke('hermes:preview:reach', url),
fetchLinkTitle: url => ipcRenderer.invoke('hermes:fetchLinkTitle', url),
+ resolveFavicon: url => ipcRenderer.invoke('hermes:resolveFavicon', url),
sanitizeWorkspaceCwd: cwd => ipcRenderer.invoke('hermes:workspace:sanitize', cwd),
settings: {
getDefaultProjectDir: () => ipcRenderer.invoke('hermes:setting:defaultProjectDir:get'),
diff --git a/apps/desktop/src/app/messaging/platform-icon.tsx b/apps/desktop/src/app/messaging/platform-icon.tsx
index 7102f848f52..13e8bfa6ffd 100644
--- a/apps/desktop/src/app/messaging/platform-icon.tsx
+++ b/apps/desktop/src/app/messaging/platform-icon.tsx
@@ -15,8 +15,8 @@ import {
import type { ComponentPropsWithoutRef, ComponentType, SVGProps } from 'react'
import { forwardRef, memo } from 'react'
+import { AvatarChip } from '@/components/ui/avatar-chip'
import { Globe, Link as LinkIcon, MessageSquareText } from '@/lib/icons'
-import { cn } from '@/lib/utils'
// ---------------------------------------------------------------------------
// Photon brand icon — three diagonal rounded bars (the Photon logo mark).
@@ -84,48 +84,18 @@ interface PlatformAvatarProps extends Omit<ComponentPropsWithoutRef<'span'>, 'ch
// silently — the tooltip renders but never opens (#67500).
export const PlatformAvatar = memo(
forwardRef<HTMLSpanElement, PlatformAvatarProps>(function PlatformAvatar(
- { className, platformId, platformName, style, ...rest },
+ { className, platformId, platformName, ...rest },
ref
) {
- const spec = PLATFORM_ICONS[platformId]
-
- const baseClass = cn(
- 'inline-grid size-6 shrink-0 place-items-center rounded-md text-[length:var(--conversation-caption-font-size)] font-medium',
- className
- )
-
- if (!spec) {
- return (
- <span
- aria-hidden="true"
- className={cn(baseClass, 'bg-(--ui-bg-tertiary) text-(--ui-text-tertiary)')}
- ref={ref}
- style={style}
- {...rest}
- >
- {platformName.charAt(0).toUpperCase()}
- </span>
- )
- }
-
- const { Icon, color } = spec
-
return (
- <span
+ <AvatarChip
aria-hidden="true"
- className={baseClass}
+ brand={PLATFORM_ICONS[platformId]}
+ className={className}
+ name={platformName}
ref={ref}
- style={{
- // 16% tint of the brand color so the glyph reads against any surface
- // without the avatar dominating the row.
- backgroundColor: `color-mix(in srgb, ${color} 16%, transparent)`,
- color,
- ...style
- }}
{...rest}
- >
- {Icon ? <Icon className="size-3.5" /> : spec.monogram || platformName.charAt(0).toUpperCase()}
- </span>
+ />
)
})
)
diff --git a/apps/desktop/src/app/skills/mcp-tab.tsx b/apps/desktop/src/app/skills/mcp-tab.tsx
index 93088c62582..7ef859479c7 100644
--- a/apps/desktop/src/app/skills/mcp-tab.tsx
+++ b/apps/desktop/src/app/skills/mcp-tab.tsx
@@ -6,6 +6,7 @@ import { type CodeEditorApi } from '@/components/chat/code-editor'
import { JsonDocumentEditor } from '@/components/chat/json-document-editor'
import { LogTail } from '@/components/chat/log-tail'
import { PageLoader } from '@/components/page-loader'
+import { AvatarChip } from '@/components/ui/avatar-chip'
import { Button } from '@/components/ui/button'
import { Codicon } from '@/components/ui/codicon'
import { ErrorBanner } from '@/components/ui/error-state'
@@ -33,7 +34,7 @@ import {
} from '@/hermes'
import { type Translations, useI18n } from '@/i18n'
import { compactNumber } from '@/lib/format'
-import { brandFor, brandGlyphStyle } from '@/lib/mcp-brands'
+import { brandFor } from '@/lib/mcp-brands'
import { estimateServerTokens, serverUsageCount } from '@/lib/mcp-cost'
import { completeMcpDesktopOAuth } from '@/lib/mcp-dashboard-oauth'
import { type McpImportEntry, parseMcpImport } from '@/lib/mcp-import'
@@ -1757,41 +1758,28 @@ function McpLogs({
// Avatars + list rows
// ---------------------------------------------------------------------------
-// Brand glyphs for well-known MCP providers, exactly the Messaging avatar
-// treatment (simpleicons on a 16% brand tint) — shared with the composer
-// suggestion pills and inline setup card via lib/mcp-brands. Unknown servers
-// fall back to the same letter monogram Messaging uses.
-
-// PlatformAvatar (messaging), copied 1:1 — same size, radius, type scale, and
-// brand-tint treatment — plus a status dot overlay. Identity ladder: curated
-// brand glyph → letter monogram. We deliberately do NOT fetch remote favicons:
-// a configured MCP URL can be a private/internal host, and hitting Google's
-// favicon service for it would leak that hostname off-box.
+// The shared identity chip (`ui/avatar-chip`) plus a status dot. Identity
+// ladder: curated brand glyph (lib/mcp-brands, shared with the composer
+// suggestion pills and the inline setup card) → letter monogram. Nothing here
+// reaches the network for a mark: a configured MCP URL can be a private host,
+// and the connector card's favicon rung only ever reads a public site's own
+// markup, never a third-party icon service.
function McpAvatar({ className, name, status }: { className?: string; name: string; status: ServerStatus }) {
- const brand = brandFor(name)
-
return (
- <span
- className={cn(
- 'relative inline-grid size-6 shrink-0 place-items-center rounded-md text-[length:var(--conversation-caption-font-size)] font-medium',
- !brand && 'bg-(--ui-bg-tertiary) text-(--ui-text-tertiary)',
- className
- )}
- style={brand ? { backgroundColor: `color-mix(in srgb, ${brand.color} 16%, transparent)` } : undefined}
- >
- {brand ? (
- <brand.Icon aria-hidden className="size-3.5" style={brandGlyphStyle(brand)} />
- ) : (
- name.charAt(0).toUpperCase()
- )}
- <span
- aria-hidden
- className={cn(
- 'absolute -bottom-0.5 -right-0.5 size-2 rounded-full ring-2 ring-(--ui-chat-surface-background)',
- STATUS_DOT[status]
- )}
- />
- </span>
+ <AvatarChip
+ brand={brandFor(name)}
+ className={className}
+ name={name}
+ overlay={
+ <span
+ aria-hidden
+ className={cn(
+ 'absolute -bottom-0.5 -right-0.5 size-2 rounded-full ring-2 ring-(--ui-chat-surface-background)',
+ STATUS_DOT[status]
+ )}
+ />
+ }
+ />
)
}
diff --git a/apps/desktop/src/components/ui/avatar-chip.test.tsx b/apps/desktop/src/components/ui/avatar-chip.test.tsx
new file mode 100644
index 00000000000..d0b78ba28c4
--- /dev/null
+++ b/apps/desktop/src/components/ui/avatar-chip.test.tsx
@@ -0,0 +1,66 @@
+import { cleanup, render, screen } from '@testing-library/react'
+import { afterEach, describe, expect, it } from 'vitest'
+
+import { AvatarChip, monogramFor } from './avatar-chip'
+
+afterEach(cleanup)
+
+const Glyph = () => <svg data-testid="glyph" />
+
+describe('the identity ladder', () => {
+ it('paints a brand glyph on a tint of its own color', () => {
+ render(<AvatarChip brand={{ Icon: Glyph, color: '#5E6AD2' }} data-testid="chip" name="Linear" />)
+
+ const background = screen.getByTestId('chip').style.backgroundColor
+
+ expect(screen.getByTestId('glyph')).toBeTruthy()
+ // jsdom normalises the hex, so assert the tint rather than the literal.
+ expect(background).toContain('rgb(94, 106, 210)')
+ expect(background).toContain('16%')
+ })
+
+ it('falls back to a letter when we have no mark for the name', () => {
+ render(<AvatarChip name="Zulip" />)
+
+ expect(screen.getByText('Z')).toBeTruthy()
+ })
+
+ it('prefers a brand-supplied monogram over the first letter', () => {
+ render(<AvatarChip brand={{ color: '#000', monogram: 'n8' }} name="n8n" />)
+
+ expect(screen.getByText('n8')).toBeTruthy()
+ })
+
+ it('lets a caller replace the mark entirely, which is how a resolved favicon gets in', () => {
+ render(
+ <AvatarChip brand={{ Icon: Glyph, color: '#000' }} name="Acme">
+ <img alt="" data-testid="favicon" src="data:image/png;base64,iVBOR" />
+ </AvatarChip>
+ )
+
+ expect(screen.getByTestId('favicon')).toBeTruthy()
+ expect(screen.queryByTestId('glyph')).toBeNull()
+ })
+
+ it('leaves a monochrome mark to follow the surrounding text color rather than vanish into the theme', () => {
+ render(<AvatarChip brand={{ Icon: Glyph, color: '#0E1128', monochrome: true }} data-testid="chip" name="Unreal" />)
+
+ expect(screen.getByTestId('chip').style.color).toBe('')
+ })
+
+ it('carries an overlay for a status dot', () => {
+ render(<AvatarChip name="Acme" overlay={<span data-testid="dot" />} />)
+
+ expect(screen.getByTestId('dot')).toBeTruthy()
+ })
+})
+
+describe('the monogram', () => {
+ it.each([
+ ['linear', 'L'],
+ [' spaced', 'S'],
+ ['', '']
+ ])('%s → %s', (name, expected) => {
+ expect(monogramFor(name)).toBe(expected)
+ })
+})
diff --git a/apps/desktop/src/components/ui/avatar-chip.tsx b/apps/desktop/src/components/ui/avatar-chip.tsx
new file mode 100644
index 00000000000..2ec9b1c1ca7
--- /dev/null
+++ b/apps/desktop/src/components/ui/avatar-chip.tsx
@@ -0,0 +1,73 @@
+import type { ComponentPropsWithoutRef, ComponentType, ReactNode, SVGProps } from 'react'
+import { forwardRef } from 'react'
+
+import { cn } from '@/lib/utils'
+
+/**
+ * The square identity chip: a brand glyph on a 16% tint of its own color, or
+ * a letter monogram when we have no mark for the thing.
+ *
+ * One treatment, three surfaces — messaging platforms, the MCP servers tab,
+ * connector cards — which is one more than it took for the copies to drift.
+ * They had already diverged on radius, on glyph size, and on what an unknown
+ * name looks like. Size and radius are the caller's call (`className`);
+ * everything else is fixed here so a Slack row and a Linear card wear the
+ * same chip.
+ */
+export interface AvatarChipBrand {
+ Icon?: ComponentType<SVGProps<SVGSVGElement>>
+ color: string
+ /** Marks that are black or white by design (GitHub, Notion, Unreal) follow
+ * the surrounding text color instead of vanishing into the theme. */
+ monochrome?: boolean
+ monogram?: string
+}
+
+interface AvatarChipProps extends Omit<ComponentPropsWithoutRef<'span'>, 'children'> {
+ brand?: AvatarChipBrand | null
+ /** Replaces the mark entirely — a resolved favicon, a spinner. */
+ children?: ReactNode
+ /** The monogram's source, and what a screen reader gets. */
+ name: string
+ /** Painted over the mark: a status dot, a badge. */
+ overlay?: ReactNode
+}
+
+/** Proportional to the chip so one glyph size serves every size the chip is
+ * used at — 14px inside the 24px row chip, matching what it replaced. */
+const GLYPH_CLASS = 'size-[58%]'
+
+export const AvatarChip = forwardRef<HTMLSpanElement, AvatarChipProps>(function AvatarChip(
+ { brand, children, className, name, overlay, style, ...rest },
+ ref
+) {
+ const Icon = brand?.Icon
+
+ return (
+ <span
+ className={cn(
+ // Not `overflow-hidden`: an overlay dot sits proud of the corner. A
+ // caller painting a raster mark clips at its own layer.
+ 'relative inline-grid size-6 shrink-0 place-items-center rounded-md text-[length:var(--conversation-caption-font-size)] font-medium',
+ !brand && 'bg-(--ui-bg-tertiary) text-(--ui-text-tertiary)',
+ className
+ )}
+ ref={ref}
+ style={
+ brand
+ ? {
+ backgroundColor: `color-mix(in srgb, ${brand.color} 16%, transparent)`,
+ color: brand.monochrome ? undefined : brand.color,
+ ...style
+ }
+ : style
+ }
+ {...rest}
+ >
+ {children ?? (Icon ? <Icon aria-hidden className={GLYPH_CLASS} /> : (brand?.monogram ?? monogramFor(name)))}
+ {overlay}
+ </span>
+ )
+})
+
+export const monogramFor = (name: string): string => name.trim().charAt(0).toUpperCase()
diff --git a/apps/desktop/src/components/ui/connector-logo.tsx b/apps/desktop/src/components/ui/connector-logo.tsx
new file mode 100644
index 00000000000..50d82c82063
--- /dev/null
+++ b/apps/desktop/src/components/ui/connector-logo.tsx
@@ -0,0 +1,40 @@
+import { brandFor } from '@/lib/mcp-brands'
+import { type Connector, connectorLogoSource } from '@/lib/mcp-connectors'
+import { cn } from '@/lib/utils'
+
+import { AvatarChip, monogramFor } from './avatar-chip'
+import { Favicon } from './favicon'
+
+/**
+ * A connector's mark, resolved as far as it goes.
+ *
+ * Curated brand glyph → the product's own favicon → the monogram every other
+ * unknown name in the app falls back to. The middle rung is what keeps the
+ * long tail from all looking alike: the catalog is a couple dozen names and
+ * the registry is thousands, so a connector we ship no icon for still arrives
+ * wearing its own logo. Which site to read that favicon from is
+ * `connectorLogoSource`'s call, not this component's.
+ */
+export function ConnectorLogo({
+ className,
+ connector
+}: {
+ className?: string
+ // Name and title are the identity; the URLs are what a favicon lookup needs
+ // and a settled transcript row no longer has.
+ connector: Partial<Pick<Connector, 'docs' | 'homepage' | 'url'>> & Pick<Connector, 'name' | 'title'>
+}) {
+ const brand = brandFor(connector.name)
+ const site = brand ? '' : connectorLogoSource(connector)
+
+ return (
+ <AvatarChip
+ brand={brand}
+ className={cn(site && 'overflow-hidden', className)}
+ name={connector.title || connector.name}
+ title={connector.title}
+ >
+ {site ? <Favicon fallback={monogramFor(connector.title || connector.name)} url={site} /> : undefined}
+ </AvatarChip>
+ )
+}
diff --git a/apps/desktop/src/components/ui/favicon.tsx b/apps/desktop/src/components/ui/favicon.tsx
new file mode 100644
index 00000000000..f59cd4f7e12
--- /dev/null
+++ b/apps/desktop/src/components/ui/favicon.tsx
@@ -0,0 +1,89 @@
+import { type ReactNode, useEffect, useState } from 'react'
+
+import { Loader2 } from '@/lib/icons'
+import { cn } from '@/lib/utils'
+
+/**
+ * A site's icon, resolved the thorough way.
+ *
+ * The work happens in the main process (`electron/favicon.ts`): read the
+ * page, collect every declared `<link rel="icon">` and web-app-manifest
+ * icon, rank them, then fall back to the well-known paths. None of that is
+ * reachable from here — cross-origin HTML is unreadable under CORS — so this
+ * component is just the request, the wait, and the placeholder.
+ *
+ * `fallback` holds the box before and after: a spinner marks the lookup, and
+ * a site with no readable icon keeps the caller's own glyph rather than
+ * flashing a broken image.
+ */
+
+/** url → data URL, or '' for a site we've already failed to read. The main
+ * process caches across restarts; this keeps a remount from crossing the
+ * IPC boundary at all. */
+const resolved = new Map<string, string>()
+
+export function Favicon({
+ className,
+ fallback,
+ title,
+ url
+}: {
+ className?: string
+ fallback: ReactNode
+ title?: string
+ url: null | string | undefined
+}) {
+ const [icon, setIcon] = useState(() => (url ? (resolved.get(url) ?? '') : ''))
+ const [pending, setPending] = useState(false)
+
+ useEffect(() => {
+ const resolveFavicon = window.hermesDesktop?.resolveFavicon
+
+ if (!url || !resolveFavicon) {
+ setIcon('')
+ setPending(false)
+
+ return
+ }
+
+ const cached = resolved.get(url)
+
+ if (cached !== undefined) {
+ setIcon(cached)
+ setPending(false)
+
+ return
+ }
+
+ let live = true
+
+ setPending(true)
+
+ void resolveFavicon(url)
+ .catch(() => '')
+ .then(found => {
+ resolved.set(url, found)
+
+ if (live) {
+ setIcon(found)
+ setPending(false)
+ }
+ })
+
+ return () => {
+ live = false
+ }
+ }, [url])
+
+ return (
+ <span className={cn('inline-grid size-full place-items-center', className)} title={title}>
+ {icon ? (
+ <img alt="" aria-hidden className="size-full object-contain" src={icon} />
+ ) : pending ? (
+ <Loader2 aria-hidden className="h-1/2 w-1/2 animate-spin opacity-60" />
+ ) : (
+ fallback
+ )}
+ </span>
+ )
+}
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index 100a28dfdd3..bf85c94f35f 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -262,6 +262,9 @@ declare global {
openExternal: (url: string) => Promise<void>
openPreviewInBrowser?: (url: string) => Promise<void>
fetchLinkTitle: (url: string) => Promise<string>
+ /** A site's icon as a data URL, or '' when it has none we can read.
+ * Resolved and cached in the main process (electron/favicon.ts). */
+ resolveFavicon?: (url: string) => Promise<string>
sanitizeWorkspaceCwd: (cwd?: null | string) => Promise<{ cwd: string; sanitized: boolean }>
settings: {
getDefaultProjectDir: () => Promise<{ defaultLabel: string; dir: null | string; resolvedCwd: string }>
diff --git a/apps/desktop/src/lib/external-link.test.tsx b/apps/desktop/src/lib/external-link.test.tsx
index 3f33f45680d..653769c4a62 100644
--- a/apps/desktop/src/lib/external-link.test.tsx
+++ b/apps/desktop/src/lib/external-link.test.tsx
@@ -11,6 +11,7 @@ import {
hostPathLabel,
isTitleFetchable,
LinkifiedText,
+ MarkdownLinkText,
PrettyLink,
urlSlugTitleLabel
} from './external-link'
@@ -134,6 +135,21 @@ describe('external link helpers', () => {
expect($previewTabs.get()).toHaveLength(0)
})
+ // A setup step sends you to a console you are signed into in your own
+ // browser, to fill in a form and copy a secret back. The in-app pane has
+ // none of that session and is the wrong destination even for web URLs.
+ it('sends a setup-step link straight to the OS browser', () => {
+ const openExternal = vi.fn().mockResolvedValue(undefined)
+ installDesktopBridge({ openExternal: openExternal as unknown as Window['hermesDesktop']['openExternal'] })
+
+ render(<MarkdownLinkText text="Enable the [Docs API](https://console.cloud.google.com/apis/library) first." />)
+
+ fireEvent.click(screen.getByRole('link', { name: 'Docs API' }))
+
+ expect(openExternal).toHaveBeenCalledWith('https://console.cloud.google.com/apis/library')
+ expect($previewTabs.get()).toHaveLength(0)
+ })
+
// A webview can't do anything useful with these, so they always hand off.
it('hands a non-web scheme to the OS', () => {
const openExternal = vi.fn().mockResolvedValue(undefined)
diff --git a/apps/desktop/src/lib/external-link.tsx b/apps/desktop/src/lib/external-link.tsx
index 54a6411d5dd..0af32238ecc 100644
--- a/apps/desktop/src/lib/external-link.tsx
+++ b/apps/desktop/src/lib/external-link.tsx
@@ -247,6 +247,9 @@ export function openLink(href: string, options: { native?: boolean } = {}): void
interface ExternalLinkProps extends Omit<ComponentProps<'a'>, 'href' | 'target'> {
href: string
children?: ReactNode
+ /** Skip the in-app pane. For links whose whole point is the session you are
+ * signed into over there — a cloud console, an account page. */
+ native?: boolean
showExternalIcon?: boolean
}
@@ -274,6 +277,7 @@ export function ExternalLink({
children,
className,
href,
+ native = false,
onClick,
showExternalIcon = false,
...rest
@@ -307,7 +311,7 @@ export function ExternalLink({
}
event.preventDefault()
- openLink(target, { native: wantsNativeBrowser(event.nativeEvent) })
+ openLink(target, { native: native || wantsNativeBrowser(event.nativeEvent) })
}}
rel="noopener noreferrer"
target="_blank"
@@ -381,6 +385,49 @@ export function LinkifiedText({ className, explicitOnly = false, pretty = true,
return <span className={className}>{nodes.length ? nodes : text}</span>
}
+const MD_LINK_RE = /\[([^\]]+)]\((https?:\/\/[^\s)]+)\)/g
+
+/**
+ * Inline `[label](url)` and nothing else.
+ *
+ * For short authored strings — a catalog entry's setup steps — where the
+ * label carries the meaning ("enable the Docs API") and the URL is a console
+ * page whose own title is useless or, behind a login wall, actively wrong.
+ * `LinkifiedText` can't serve this: it finds bare URLs and guesses a label.
+ * Full markdown is the other extreme, a block renderer inside a card row.
+ *
+ * These open in the real browser. The destination is a console the user is
+ * already signed into there, and the work is a form to fill in and a secret to
+ * copy back — none of which the in-app pane is for.
+ */
+export function MarkdownLinkText({ className, text }: { className?: string; text: string }) {
+ const nodes: ReactNode[] = []
+ let cursor = 0
+
+ for (const match of text.matchAll(MD_LINK_RE)) {
+ const [raw, label, href] = match
+ const index = match.index ?? 0
+
+ if (index > cursor) {
+ nodes.push(text.slice(cursor, index))
+ }
+
+ nodes.push(
+ <ExternalLink href={href} key={`${href}-${index}`} native title={href}>
+ {label}
+ </ExternalLink>
+ )
+
+ cursor = index + raw.length
+ }
+
+ if (cursor < text.length) {
+ nodes.push(text.slice(cursor))
+ }
+
+ return <span className={className}>{nodes.length ? nodes : text}</span>
+}
+
export function __resetLinkTitleCache(): void {
titleCache.clear()
titleInflight.clear()
diff --git a/apps/desktop/src/lib/mcp-brands.tsx b/apps/desktop/src/lib/mcp-brands.tsx
index 10a8e6136b2..4bfff908f59 100644
--- a/apps/desktop/src/lib/mcp-brands.tsx
+++ b/apps/desktop/src/lib/mcp-brands.tsx
@@ -1,10 +1,13 @@
/**
* Curated brand glyphs for MCP server names — extracted from the mcp-tab's
* avatar (its `MCP_BRAND_ICONS`) the moment a second surface (the composer
- * suggestion pills / inline setup card) needed the same identity ladder:
- * curated brand glyph → letter monogram. We deliberately do NOT fetch remote
- * favicons: a configured MCP URL can be a private/internal host, and hitting
- * a favicon service for it would leak that hostname off-box.
+ * suggestion pills / inline setup card) needed the same identity ladder.
+ *
+ * This is the first rung only. Everything below it — the endpoint's own
+ * favicon, then the initial — lives in `components/ui/connector-logo`, which
+ * is what a surface should render when it wants a mark rather than a glyph.
+ * Either way we never ask a third-party favicon service: an MCP URL can be a
+ * private host, and that lookup would leak the hostname off-box.
*/
import {
SiAirtable,
@@ -17,6 +20,7 @@ import {
SiHuggingface,
SiIntercom,
SiLinear,
+ SiN8n,
SiNetlify,
SiNotion,
SiPaypal,
@@ -25,6 +29,7 @@ import {
SiSquare,
SiStripe,
SiSupabase,
+ SiUnrealengine,
SiVercel,
SiWebflow,
SiZapier
@@ -52,6 +57,7 @@ export const MCP_BRAND_ICONS: Record<string, McpBrand> = {
huggingface: { Icon: SiHuggingface, color: '#FFD21E' },
intercom: { Icon: SiIntercom, color: '#6AFDEF' },
linear: { Icon: SiLinear, color: '#5E6AD2' },
+ n8n: { Icon: SiN8n, color: '#EA4B71' },
netlify: { Icon: SiNetlify, color: '#00C7B7' },
notion: { Icon: SiNotion, color: '#000000', monochrome: true },
paypal: { Icon: SiPaypal, color: '#003087' },
@@ -61,6 +67,7 @@ export const MCP_BRAND_ICONS: Record<string, McpBrand> = {
square: { Icon: SiSquare, color: '#3E4348', monochrome: true },
stripe: { Icon: SiStripe, color: '#635BFF' },
supabase: { Icon: SiSupabase, color: '#3FCF8E' },
+ 'unreal-engine': { Icon: SiUnrealengine, color: '#0E1128', monochrome: true },
vercel: { Icon: SiVercel, color: '#000000', monochrome: true },
webflow: { Icon: SiWebflow, color: '#146EF5' },
zapier: { Icon: SiZapier, color: '#FF4A00' }
@@ -71,8 +78,23 @@ export const MCP_BRAND_ICONS: Record<string, McpBrand> = {
export const brandGlyphStyle = (brand: McpBrand): { color: string } | undefined =>
brand.monochrome ? undefined : { color: brand.color }
+/** The same brand under every spelling a connector arrives with: catalog slug
+ * (`unreal-engine`), registry id (`unreal_engine`), display name (`Unreal
+ * Engine`). Compare on letters and digits alone so none of them miss. */
+const squash = (value: string): string => value.toLowerCase().replace(/[^a-z0-9]/g, '')
+
export const brandFor = (name: string): McpBrand | null => {
- const lower = name.toLowerCase()
+ const target = squash(name)
+
+ if (!target) {
+ return null
+ }
+
+ const entries = Object.entries(MCP_BRAND_ICONS)
- return MCP_BRAND_ICONS[lower] ?? Object.entries(MCP_BRAND_ICONS).find(([key]) => lower.includes(key))?.[1] ?? null
+ return (
+ entries.find(([key]) => squash(key) === target)?.[1] ??
+ entries.find(([key]) => target.includes(squash(key)))?.[1] ??
+ null
+ )
}