The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): show brand icons on links to known domains
Brooklyn Nicholson23459c036138
diff --git a/apps/desktop/src/app/artifacts/index.tsx b/apps/desktop/src/app/artifacts/index.tsxindex 70a6a0338ca..bdcf5d103e2 100644--- a/apps/desktop/src/app/artifacts/index.tsx+++ b/apps/desktop/src/app/artifacts/index.tsx@@ -19,7 +19,15 @@ import { RowButton } from '@/components/ui/row-button'import { Tip } from '@/components/ui/tooltip'import { getSessionMessages, listAllProfileSessions } from '@/hermes'import { type Translations, useI18n } from '@/i18n'-import { ExternalLink, ExternalLinkIcon, hostPathLabel, urlSlugTitleLabel, useLinkTitle } from '@/lib/external-link'+import { resolveBrandIcon } from '@/lib/brand-icon'+import {+ ExternalLink,+ ExternalLinkIcon,+ hostPathLabel,+ shortHostLabel,+ urlSlugTitleLabel,+ useLinkTitle+} from '@/lib/external-link'import { FileImage, FileText, FolderOpen, Link2, Loader2, RefreshCw } from '@/lib/icons'import { downloadGatewayMediaFile, isRemoteGateway } from '@/lib/media'import { normalize } from '@/lib/text'@@ -543,7 +551,8 @@ function ArtifactCellAction({function PrimaryCell({ artifact, ctx }: { artifact: ArtifactRecord; ctx: CellCtx }) {const isLink = artifact.kind === 'link'- const Icon = isLink ? Link2 : FileText+ const brand = isLink ? resolveBrandIcon(shortHostLabel(artifact.href)) : null+ const Icon = brand ?? (isLink ? Link2 : FileText)const fetchedTitle = useLinkTitle(isLink ? artifact.href : null)const label = isLink ? fetchedTitle || urlSlugTitleLabel(artifact.href) : artifact.labeldiff --git a/apps/desktop/src/lib/external-link.test.tsx b/apps/desktop/src/lib/external-link.test.tsxindex 57c0176e37c..5407639199c 100644--- a/apps/desktop/src/lib/external-link.test.tsx+++ b/apps/desktop/src/lib/external-link.test.tsx@@ -248,4 +248,28 @@ describe('external link helpers', () => {const link = screen.getByRole('link', { name: 'agent.log' })expect(link.getAttribute('href')).toBe('https://agent.log')})++ it('prefixes a pretty link to a known host with its brand glyph', () => {+ installDesktopBridge()++ const url = 'https://github.com/NousResearch/hermes-agent/pull/123'++ render(<PrettyLink fallbackLabel="#123" href={url} />)++ const link = screen.getByTitle(url)++ expect(link.querySelector('svg')).toBeTruthy()+ // The glyph is decorative — it must not pollute the link's accessible name.+ expect(link.textContent).toBe('#123')+ })++ it('renders no brand glyph for an unknown host', () => {+ installDesktopBridge()++ const url = 'https://example.com/some/page'++ render(<PrettyLink fallbackLabel="Some Page" href={url} />)++ expect(screen.getByTitle(url).querySelector('svg')).toBeNull()+ })})diff --git a/apps/desktop/src/lib/external-link.tsx b/apps/desktop/src/lib/external-link.tsxindex 17f82c6a2cb..4f6dc396b7d 100644--- a/apps/desktop/src/lib/external-link.tsx+++ b/apps/desktop/src/lib/external-link.tsx@@ -3,6 +3,7 @@ import { useEffect, useMemo, useState } from 'react'import { ArrowUpRight } from '@/lib/icons'+import { resolveBrandIcon } from './brand-icon'import { cn } from './utils'const titleCache = new Map<string, string>()@@ -210,6 +211,22 @@ export function ExternalLinkIcon({ className }: { className?: string }) {return <ArrowUpRight aria-hidden className={cn('ml-1 inline size-[0.78em] align-[-0.08em] opacity-70', className)} />}+// Brand mark for a known host, sized in `em` so it tracks the surrounding text+// at any font size. It paints in `currentColor` rather than the brand hex —+// several brand colors (GitHub's near-black, Unity's white) vanish against one+// theme or the other.+//+// `title=""` is load-bearing: Simple Icons always renders a <title> defaulting+// to the brand name, which lands in the anchor's textContent and accessible+// name — a PR link would read "GitHub#123".+export function LinkBrandIcon({ className, href }: { className?: string; href: string }) {+ const Icon = resolveBrandIcon(shortHostLabel(href))++ return Icon ? (+ <Icon aria-hidden className={cn('mr-1 inline size-[0.85em] align-[-0.12em] opacity-80', className)} title="" />+ ) : null+}+export function ExternalLink({children,className,@@ -261,6 +278,7 @@ export function PrettyLink({ className, fallbackLabel, href, label, ...rest }: Preturn (<ExternalLink className={cn('wrap-break-word', className)} href={target} title={target} {...rest}>+ <LinkBrandIcon href={target} /><span className="font-medium">{display}</span></ExternalLink>)