Skip to content

The agent that grows with you

fix(desktop): render tool activity images with MarkdownImage

teknium193e7c4f40243
diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback-vision-image.test.tsx b/apps/desktop/src/components/assistant-ui/tool/fallback-vision-image.test.tsx
index 4994a7b3582..63b3981265e 100644
--- a/apps/desktop/src/components/assistant-ui/tool/fallback-vision-image.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/tool/fallback-vision-image.test.tsx
@@ -96,4 +96,15 @@ describe('vision_analyze activity image', () => {
)
expect(readFileDataUrl).not.toHaveBeenCalled()
})
+
+ it('says so when the image cannot be read instead of silently dropping the preview', async () => {
+ $connection.set({ mode: 'local' } as never)
+ readFileDataUrl.mockRejectedValueOnce(new Error('ENOENT'))
+ renderVisionRow()
+
+ fireEvent.click(screen.getByRole('button', { expanded: false }))
+
+ expect(await screen.findByText(/Couldn't load/)).toBeTruthy()
+ expect(screen.queryByRole('img')).toBeNull()
+ })
})
diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx b/apps/desktop/src/components/assistant-ui/tool/fallback.tsx
index 0a49c542279..0b4846c7447 100644
--- a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx
+++ b/apps/desktop/src/components/assistant-ui/tool/fallback.tsx
@@ -19,6 +19,7 @@ import {
import { useSessionView } from '@/app/chat/session-view'
import { AnsiText } from '@/components/assistant-ui/ansi-text'
+import { MarkdownImage } from '@/components/assistant-ui/markdown-text'
import { TimelineTimestamp } from '@/components/assistant-ui/thread/timeline-timestamp'
import { useElapsedSeconds } from '@/components/chat/activity-timer'
import { ActivityTimerText } from '@/components/chat/activity-timer-text'
@@ -31,7 +32,6 @@ import {
SCAFFOLD_META_CLASS,
ScaffoldRow
} from '@/components/chat/scaffold-row'
-import { ZoomableImage } from '@/components/chat/zoomable-image'
import { Button } from '@/components/ui/button'
import { Codicon } from '@/components/ui/codicon'
import { CopyButton } from '@/components/ui/copy-button'
@@ -44,7 +44,6 @@ import { useI18n } from '@/i18n'
import { connectorCalls, mcpTargets } from '@/lib/connector-tools'
import { PrettyLink, LinkifiedText as SharedLinkifiedText, urlSlugTitleLabel } from '@/lib/external-link'
import { AlertCircle, CheckCircle2 } from '@/lib/icons'
-import { resolveMediaDisplaySrc } from '@/lib/media'
import { isOnboardingEnabled } from '@/lib/onboarding-enabled'
import { toolResultRecord } from '@/lib/tool-result-metadata'
import { useEnterAnimation } from '@/lib/use-enter-animation'
@@ -113,41 +112,6 @@ const TOOL_SECTION_PRE_CLASS = cn(TOOL_SECTION_SURFACE_CLASS, 'font-mono text-[0
// Raw args/result dump — reference material, so a notch smaller than a body.
const TOOL_PAYLOAD_PRE_CLASS = cn(TOOL_SECTION_SURFACE_CLASS, 'font-mono text-[0.65rem] leading-relaxed')
-function ToolActivityImage({ alt, src }: { alt: string; src: string }) {
- const [resolvedSrc, setResolvedSrc] = useState('')
-
- useEffect(() => {
- let cancelled = false
-
- setResolvedSrc('')
- void resolveMediaDisplaySrc(src)
- .then(value => {
- if (!cancelled) {
- setResolvedSrc(value)
- }
- })
- .catch(() => {
- if (!cancelled) {
- setResolvedSrc('')
- }
- })
-
- return () => {
- cancelled = true
- }
- }, [src])
-
- if (!resolvedSrc) {
- return null
- }
-
- return (
- <div className="max-w-72 overflow-hidden rounded-[0.25rem] border border-(--ui-stroke-tertiary)">
- <ZoomableImage alt={alt} className="h-auto w-full object-cover" src={resolvedSrc} />
- </div>
- )
-}
-
/**
* Technical-mode raw payload, behind a chevron disclosure.
*
@@ -660,7 +624,11 @@ function ToolEntry({ part }: ToolEntryProps) {
{part.toolName === 'terminal' && toolViewMode !== 'technical' && (
<TerminalTranscript command={view.terminalCommand} exitCode={view.terminalExitCode} />
)}
- {view.imageUrl && <ToolActivityImage alt={copy.outputAlt} src={view.imageUrl} />}
+ {view.imageUrl && (
+ <div className="max-w-72 overflow-hidden rounded-[0.25rem] border border-(--ui-stroke-tertiary)">
+ <MarkdownImage alt={copy.outputAlt} className="h-auto w-full object-cover" src={view.imageUrl} />
+ </div>
+ )}
{hasSearchHits && view.searchHits && (
<div className="max-w-full text-xs leading-relaxed text-(--ui-text-secondary)">
{view.searchQuery && (