Skip to content

Show tool-result images while the tool card is collapsed - #826

Open
uvforce wants to merge 2 commits into
agegr:mainfrom
uvforce:pr/chat-images
Open

uvforce wants to merge 2 commits into
agegr:mainfrom
uvforce:pr/chat-images

Conversation

@uvforce

@uvforce uvforce commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Problem

Tool results that include ImageContent (browser screenshots, generated images) are only rendered inside the expanded result area. The default collapsed tool card therefore hides the one thing the user usually wants to see.

Assistant markdown images have a second, related gap: user-message and tool-result images already open ImagePreview on click, but a markdown ![](...) stays a plain <img> and cannot be enlarged.

Change

  • Render the tool-result image grid directly under the tool header. Arguments and text output stay behind the existing expand toggle. No tool-name checks, no new API, no new dependency.
  • When a result has images and empty text, expanding no longer shows the "no output" placeholder.
  • Edit-tool diffs no longer swallow images; the image grid is independent of the text/diff branch.
  • Wrap markdown images in the same official ImagePreview. The dialog still mounts only after the click, so server rendering never emits a <dialog> inside a <p>.

This is content-based: any ImageContent block and any markdown image works the same way, regardless of which tool or model produced it.

Collapsed cards with many historical screenshots will keep those images in the DOM (loading="lazy" already applies). That is the intended default; a setting can be added later if it becomes a problem.

Tests

  • shows tool-result images while the tool details stay collapsed
  • opens markdown images in the shared image preview
  • npm test for MessageView and MarkdownBody: 32 passed
  • TypeScript, ESLint, and git diff --check passed

Tool results that carry ImageContent were only rendered inside the
expanded result area, so a collapsed tool card hid screenshots and
generated images. Render the image grid under the tool header and
leave arguments and text output behind the existing toggle.

Assistant markdown images were plain <img> tags, unlike user-message
and tool-result images that already use ImagePreview. Wrap them in
the same preview so a click opens the full-screen dialog. The dialog
still mounts only after the click, so server rendering never emits a
dialog inside a paragraph.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-12T20:14:53.020609Z de9e760 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 604c57179f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/MarkdownBody.tsx Outdated
Comment on lines +89 to +91
<ImagePreview src={imageSrc} alt={alt ?? ""} className="markdown-image">
{image}
</ImagePreview>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid nesting preview buttons inside image links

For linked-image Markdown such as [![diagram](diagram.png)](https://example.com), the img renderer now returns an ImagePreview button inside the a renderer. Clicking the image therefore opens the preview and bubbles to the enclosing link, which also navigates or opens a new tab; local links similarly invoke onOpenFile. Prevent the nested preview from triggering its parent link, or preserve linked images as links rather than wrapping them in another interactive element.

Useful? React with 👍 / 👎.

Comment thread components/MarkdownBody.tsx Outdated
Comment on lines +89 to +90
<ImagePreview src={imageSrc} alt={alt ?? ""} className="markdown-image">
{image}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve markdown image alt text in the preview trigger

For every Markdown image with meaningful alt text, ImagePreview gives the wrapping button its own aria-label (chat.previewImage), which overrides the descendant image's alt text when computing the accessible name. Screen-reader users now hear only “Preview image” and lose the image description; pass an accessible label incorporating the Markdown alt text or otherwise allow that text to name the trigger.

Useful? React with 👍 / 👎.

A markdown image inside a link such as [![diagram](a.png)](url) would
wrap ImagePreview's button in the enclosing anchor, so a click both
opened the dialog and followed the link. Skip the preview wrapper when
the image is already inside a link.

ImagePreview's trigger used a fixed "Preview image" aria-label, which
hid the markdown alt text from the accessible name. Keep that generic
label when alt is empty; otherwise prefix it with the alt text.
@uvforce

uvforce commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the two Codex notes in de9e760:

  • Linked images ([![alt](src)](url)) stay links. The preview button is skipped when the image is already inside an <a>, so a click no longer opens the dialog and navigates at the same time.
  • The preview trigger keeps the generic “Preview image” label when alt is empty, and uses Preview image: {alt} when markdown provides alt text.

@uvforce

uvforce commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: de9e760995

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant