Skip to content

feat(site): render computer tool screenshots as images in chat UI#23074

Merged
ThomasK33 merged 5 commits intomainfrom
computer-tool-screenshot
Mar 16, 2026
Merged

feat(site): render computer tool screenshots as images in chat UI#23074
ThomasK33 merged 5 commits intomainfrom
computer-tool-screenshot

Conversation

@ThomasK33
Copy link
Copy Markdown
Member

Instead of showing raw base64 JSON for Anthropic's computer use tool, render the screenshot as an inline image. The image is clickable to open at full resolution in a new tab.

Changes

  • ComputerTool.tsx — New component that renders base64 image data as an <img> tag
  • Tool.tsx — Added ComputerRenderer handling both single-object and array-of-blocks result shapes
  • ToolIcon.tsx — Added MonitorIcon for the computer tool
  • ToolLabel.tsx — Added \Screenshot\ label for the computer tool

Instead of showing raw base64 JSON for Anthropic's computer use tool,
render the screenshot as an inline image. The image is clickable to
open at full resolution in a new tab.

Adds ComputerTool component and registers it in the tool renderer map.
Handles both single-object and array-of-blocks result shapes.
Copy link
Copy Markdown
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an update to the storybook tests to capture this change

Covers five scenarios:
- ComputerScreenshot: completed with base64 image data
- ComputerRunning: in-progress with spinner
- ComputerTextFallback: completed with text, no image
- ComputerError: error state with destructive styling
- ComputerArrayResult: result as array of content blocks

Each story includes play functions that verify DOM structure,
image src attributes, link targets, and error styling.
Remove unused args parameter from ComputerRenderer and apply
biome formatting fixes.
Replace the tiny 4x4 test pixel with a real 400x225 desktop
screenshot fixture so the storybook stories show what the component
actually looks like in practice.
@ThomasK33
Copy link
Copy Markdown
Member Author

ThomasK33 commented Mar 14, 2026

There should be an update to the storybook tests to capture this change

Thanks @DanielleMaywood. Added storybook tests. Do you want to review/approve them or shall I do it?

@kylecarbs
Copy link
Copy Markdown
Member

Hmm, I think the outline on the tool block is unlike our other ones. Tell agent to take inspiration from Read file and Write file pls. I might be wrong here too the story might just render weird.

Rewrite ComputerTool to use ToolCollapsible like ReadFile and
WriteFile, giving it the same collapsible header with chevron,
error tooltip, and content border styling. Screenshots with image
data default to expanded; text-only results are collapsed.

Remove the custom MonitorIcon header layout in favor of the
shared ToolCollapsible structure.
@ThomasK33 ThomasK33 merged commit d630646 into main Mar 16, 2026
25 checks passed
@ThomasK33 ThomasK33 deleted the computer-tool-screenshot branch March 16, 2026 11:36
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants