Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Dec 18, 2025

Summary

Add support for resolving image file @mentions into inline images, and align edit-dialog test expectations with current behavior (empty-array images for submits; undefined for edit-dialog payload).

Changes

  • Add image mention resolver and wire it into the webview message flow.
  • Add unit + integration tests for image mention resolution.
  • Fix edit-dialog related tests to match actual images payload shape.

Important

Adds support for resolving image file mentions into inline images and updates related tests and message handling.

  • Behavior:
    • Adds resolveImageMentions function in resolveImageMentions.ts to convert image file mentions into inline images.
    • Integrates resolveImageMentions into webviewMessageHandler.ts to handle image mentions in messages.
    • Updates editMessageConfirm and askResponse cases in webviewMessageHandler.ts to use resolved images.
  • Tests:
    • Adds unit tests in resolveImageMentions.spec.ts for various image formats and scenarios.
    • Adds integration tests in webviewMessageHandler.imageMentions.integration.spec.ts for newTask and askResponse message types.
    • Updates existing tests in ClineProvider.spec.ts and webviewMessageHandler.edit.spec.ts to align with new image payload expectations.
  • Misc:
    • Updates getFileOrFolderContent in index.ts to omit binary files from text context.

This description was created by Ellipsis for f2d1554. You can customize this summary. It will automatically update as commits are pushed.

- Add resolveImageMentions to convert @/path/to/image.png mentions to base64 data URLs
- Integrate image resolution for newTask, askResponse, editMessageConfirm, queueMessage
- Add binary file detection to skip including binary content as text context
- Support png, jpg, jpeg, webp formats with 20 image limit per message
- Add unit and integration tests for image mention handling
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Dec 18, 2025
@roomote
Copy link
Contributor

roomote bot commented Dec 18, 2025

Oroocle Clock   See task on Roo Cloud

Re-review complete. No new issues found in the latest commit; remaining follow-ups below.

  • Enforce image size limits when resolving image @mentions (avoid large base64 payloads / memory spikes)
  • Ensure .rooignore enforcement is consistent for image @mentions even when no current task exists (newTask path)
  • Ensure image @mentions respect model image capability (avoid resolving/encoding for non-vision models)
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 18, 2025
text,
images,
cwd: getCurrentCwd(),
rooIgnoreController: currentTask?.rooIgnoreController,
Copy link
Contributor

Choose a reason for hiding this comment

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

resolveIncomingImages uses the task's rooIgnoreController but falls back to provider.cwd when there is no current task. That means image mentions in the initial newTask message do not get .rooignore enforcement (unless provider.getCurrentTask() already exists), which is a behavior difference from text mention expansion. Consider using a provider-level RooIgnoreController for the fallback path as well.

Fix it with Roo Code or mention @roomote and request a fix.

- Add support for all 11 image formats (.gif, .svg, .bmp, .ico, .tiff, .tif, .avif)
- Add per-file size validation using validateImageForProcessing
- Add total memory tracking with ImageMemoryTracker
- Add supportsImages check for model compatibility
- Reuse IMAGE_MIME_TYPES and SUPPORTED_IMAGE_FORMATS from imageHelpers
- Add JSDoc for resolveIncomingImages helper
- Update integration tests to use os.tmpdir() instead of process.cwd()
- Add comprehensive test coverage for new validation behavior
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 18, 2025
images,
cwd,
rooIgnoreController,
supportsImages = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

supportsImages defaults to true here, so if a caller forgets to pass the real model capability this will still read and base64-encode image mentions for non-vision models (extra memory + large payloads). Consider deriving/passing supportsImages from the active model info (or defaulting this to false so callers must opt-in explicitly).

Fix it with Roo Code or mention @roomote and request a fix.

@daniel-lxs
Copy link
Member

A couple spots where we could reuse existing helpers from imageHelpers.ts:

  1. isSupportedImageExtension() is identical to the already-exported isSupportedImageFormat() - can just import that instead of defining a local version.

  2. The base64/data URL logic:

const buffer = await fs.readFile(absPath)
const base64 = buffer.toString("base64")
newImages.push(`data:${mimeType};base64,${base64}`)

readImageAsDataUrlWithBuffer() already does exactly this and is exported. Could simplify to:

const { dataUrl } = await readImageAsDataUrlWithBuffer(absPath)
newImages.push(dataUrl)

Minor stuff, but keeps things aligned with existing patterns.

- Use isSupportedImageFormat() from imageHelpers instead of local isSupportedImageExtension()
- Use readImageAsDataUrlWithBuffer() instead of manual fs.readFile + base64 conversion
- Remove local getMimeType() as readImageAsDataUrlWithBuffer handles MIME type internally
- Update tests to mock the new dependencies

import { resolveImageMentions } from "../resolveImageMentions"

const SUPPORTED_IMAGE_FORMATS = [
Copy link
Contributor

Choose a reason for hiding this comment

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

The constant SUPPORTED_IMAGE_FORMATS (lines 5–17) is declared but never used. Consider removing it to keep the test file clean.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 18, 2025
@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Review] in Roo Code Roadmap Dec 19, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: PR [Needs Review]

Development

Successfully merging this pull request may close these issues.

3 participants