wip: use [Image #X] placeholder for clipboard paste and drag and drop#14706
wip: use [Image #X] placeholder for clipboard paste and drag and drop#14706jackwotherspoon wants to merge 8 commits intomainfrom
Conversation
Summary of ChangesHello @jackwotherspoon, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience for interacting with image content within the Gemini CLI. Instead of relying on the model to resolve local file paths, images are now displayed as user-friendly Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant improvement for handling images by using placeholders like [Image #1] instead of file paths. The implementation is well-structured, introducing a new useClipboardImages hook, utility functions for image path parsing, and integrating this new flow into the input prompt and submission stream. The code is generally robust, with good handling of asynchronous operations and edge cases like escaped spaces in file paths. I've identified one high-severity issue where adding the same image multiple times does not behave as a user would expect. Please see the detailed comment.
| // Check if this path is already registered to prevent duplicates | ||
| if (prev.some((img) => img.path === absolutePath)) { | ||
| return prev; | ||
| } |
There was a problem hiding this comment.
The current implementation prevents registering an image if its path already exists in the images array. This can lead to unexpected behavior for the user. For example, if a user pastes the same image twice, they will see two distinct placeholders in the input (e.g., [Image #1] and [Image #2]), but only the first one will be registered and sent to the API. The second placeholder will be ignored, which is not what the user would expect.
To fix this, you should allow registering the same image path multiple times, each with its own unique ID. This ensures that each placeholder in the UI corresponds to an image that will be included in the prompt.
|
Size Change: +8.95 kB (+0.04%) Total Size: 21.5 MB
ℹ️ View Unchanged
|
Summary
This branch improves how pasted and drag-and-dropped images are handled in the
Gemini CLI input.
drag.and.drop.images.mp4
Details
Before: Images were inserted as
@path/to/image.pngfile references,requiring the model to resolve them.
After: Images are displayed as
[Image #1],[Image #2], etc. placeholdersin the input, then injected directly as base64-encoded inline data when
submitting to the Gemini API.
Key Features
[Image #N]tags that aresyntax-highlighted and editable
only images with remaining tags are sent
with proper handling of escaped spaces in filenames
@pathsyntax
Files Changed
useClipboardImages.tsclipboardUtils.tshighlight.ts[Image #N]tokensInputPrompt.tsxuseGeminiStream.tsSupported Formats
PNG, JPEG, WEBP, HEIC, HEIF (per
Gemini API spec)
Details
Related Issues
How to Validate
Pre-Merge Checklist