Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jackwotherspoon
Copy link
Collaborator

@jackwotherspoon jackwotherspoon commented Dec 9, 2025

Summary

Adds support for dragging and dropping multiple files into the terminal at once, automatically adding @ prefix to each valid path.

Details

  • Add splitEscapedPaths utility to parse space-separated paths while preserving escaped spaces in filenames
  • Add processPastedPaths to handle single and multiple path validation with @ prefix insertion
  • Add PATH_PREFIX_PATTERN constant for consistent path prefix detection (supports Unix, Windows drive letters, and UNC paths)
  • Add debug logging for clipboard operations
  • Use unescapePath and escapePath consistently across all path handling
  • Add performance optimization to skip filesystem checks for non-path segments
  • Support copy-paste paths with unescaped spaces (automatically escapes them for CLI compatibility)

Behavior

Before: Dragging multiple files → inserted as /path/img1.png /path/img2.png
image

After: Dragging multiple files → becomes @/path/img1.png @/path/img2.png
image

  • Only valid paths get the @ prefix
  • Escaped spaces in filenames are preserved (e.g., /my\ image.png)
  • Copy-paste paths with unescaped spaces are automatically escaped (e.g., /my file.png@/my\ file.png )
  • Works with mixed text and paths (e.g., check this /path/file.pngcheck this @/path/file.png )
  • Normal text input is unaffected
  • Cross-platform support:
    • Unix paths (/path/to/file)
    • Windows paths (C:\path\to\file)
    • UNC paths (\\server\share\file)

Test plan

  • Drag single file into terminal → gets @ prefix
  • Drag multiple files into terminal → each valid path gets @ prefix
  • Paste path with escaped spaces → escaping preserved
  • Paste path with unescaped spaces (copy from Finder/Explorer) → automatically escaped
  • Paste mixed text and paths → only paths get @ prefix
  • Paste large text without paths → no performance impact
  • Invalid paths remain unchanged
  • Windows paths with drive letters work (C:\...)
  • Windows UNC paths work (\\server\share\...)

Related Issues

Related to #14706

Part 2 of smaller chunks of breaking up.

How to Validate

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@jackwotherspoon jackwotherspoon requested a review from a team as a code owner December 9, 2025 15:29
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 improves the user experience for interacting with image files in the terminal by enabling robust multi-file drag-and-drop functionality. It introduces intelligent parsing of multiple space-separated file paths, automatically applying the necessary '@' prefix to valid image files while correctly handling filenames with escaped spaces. This ensures that users can seamlessly input multiple images without manual path modification, streamlining workflows that involve visual content.

Highlights

  • Multi-file Drag and Drop Support: The terminal now correctly handles dragging and dropping multiple image files simultaneously, enhancing user interaction.
  • Automatic '@' Prefixing: Valid image file paths dropped into the terminal are automatically prefixed with '@', aligning with system requirements.
  • Escaped Space Handling: Filenames containing spaces, which are typically escaped (e.g., my\ image.png), are now correctly parsed and preserved.
  • New Path Utilities: Introduced splitEscapedPaths for robust parsing of space-separated paths and several looksLike and get utilities for comprehensive image path validation.
  • Enhanced Text Buffer Logic: The useTextBuffer hook has been updated to leverage these new utilities for intelligent multi-path processing during paste operations.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Size Change: +1.49 kB (+0.01%)

Total Size: 21.6 MB

Filename Size Change
./bundle/gemini.js 21.6 MB +1.49 kB (+0.01%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new utility functions in clipboardUtils.ts for parsing and validating single and multiple file paths, particularly image paths, from pasted text. These utilities handle @ prefixes and escaped spaces (\ ) common in drag-and-drop operations. The useTextBuffer hook in text-buffer.ts was updated to leverage these new utilities, allowing it to automatically prepend @ to valid file paths when pasting multiple paths or paths with escaped spaces. Review comments highlight a critical bug in the splitEscapedPaths function, noting it fails to correctly parse paths enclosed in single quotes, leading to incorrect splitting. Additionally, the review points out an inconsistency in useTextBuffer's logic where single-segment paths bypass multi-segment processing, and suggests that parseImagePath should also handle single quotes. The reviewer also requested additional test cases for splitEscapedPaths, getImagePathFromText, and looksLikeImagePath to cover paths enclosed in single quotes.

@jackwotherspoon
Copy link
Collaborator Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces robust support for multi-file drag and drop and copy-paste operations, automatically prefixing valid paths with @. This feature significantly enhances user experience by streamlining the process of inputting file paths, especially those containing spaces. The changes include new utility functions splitEscapedPaths and processPastedPaths for intelligent path parsing and validation, along with comprehensive unit tests covering various edge cases, including Windows paths and escaped spaces. Debug logging has also been added to error handling for improved maintainability. The implementation demonstrates careful consideration for correctness, efficiency, and cross-platform compatibility.

while (i < text.length) {
const char = text[i];

if (char === '\\' && i + 1 < text.length && text[i + 1] === ' ') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

an edge case this will get confused by is
/Users/jacobr/git/gemini-cli/silly.txt2\\ /Users/jacobr/git/gemini-cli/test.txt
which is what MacOs will return if the first file ends in a \ and the second file doesn't.

you want to track the number of \ so you ignore slashes that are escaped. only an odd number of slashes in a row followed by a space really indicate an unescaped spaces.

Copy link
Collaborator

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

Approved after the escaping edge case is addressed.

@jacob314 jacob314 added this pull request to the merge queue Dec 12, 2025
Merged via the queue into main with commit 1e734d7 Dec 12, 2025
19 of 20 checks passed
@jacob314 jacob314 deleted the multi-file-drag-drop branch December 12, 2025 17:26
thacio added a commit to thacio/auditaria that referenced this pull request Dec 13, 2025
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.

3 participants