Skip to content

fix(renderer): preserve dropped file path formatting#2146

Merged
arnestrickmann merged 2 commits into
mainfrom
fix-drop-file-format
May 20, 2026
Merged

fix(renderer): preserve dropped file path formatting#2146
arnestrickmann merged 2 commits into
mainfrom
fix-drop-file-format

Conversation

@janburzinski
Copy link
Copy Markdown
Collaborator

summary

  • fixes images not being pastes "correctly"

example: (bottom left is prod, behind is dev)
https://streamable.com/xtzhyb

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 20, 2026

Greptile Summary

This PR fixes drag-and-drop file paths not being pasted correctly into the terminal, specifically for paths that contain spaces (e.g. example image.png). The root cause was that forceBracketedPaste was gated behind hasMultilinePayload, so single-line paths were never wrapped in bracketed paste sequences.

  • prompt-injection.ts: The shouldUseBracketedPaste condition is restructured so that forceBracketedPaste: true always enables bracketed paste, regardless of whether the text is single- or multi-line.
  • pty-pane.tsx: Drag-and-drop handlers are refactored to use pastePromptInjection with forceBracketedPaste: true, and the path-escaping logic is extracted into a dedicated formatDroppedPaths helper.
  • prompt-injection.test.ts: A new test case covers the single-line + forced bracketed paste path.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to drag-and-drop path pasting and preserves all existing non-forced bracketed-paste behaviour.

The condition restructuring in buildPromptInjectionPayload is logically equivalent to the old code for every existing call site, and the new single-line forced-paste path is covered by an added test. The trailing space is appended to the already-wrapped payload in the sendInput lambda, so it lands correctly in the terminal after the bracketed-paste end sequence.

No files require special attention.

Important Files Changed

Filename Overview
src/renderer/lib/pty/prompt-injection.ts Condition refactored so forceBracketedPaste is independent of hasMultilinePayload; all existing semantics preserved for non-forced paths.
src/renderer/lib/pty/pty-pane.tsx Drop handler now uses pastePromptInjection with forceBracketedPaste: true; path escaping extracted to formatDroppedPaths; trailing space preserved outside the bracketed-paste sequence.
src/renderer/tests/prompt-injection.test.ts New test covers single-line content with forceBracketedPaste: true, directly validating the bug fix.

Sequence Diagram

sequenceDiagram
    participant User
    participant PtyPane
    participant pastePromptInjection
    participant buildPromptInjectionPayload
    participant Terminal

    User->>PtyPane: drag and drop files
    PtyPane->>PtyPane: formatDroppedPaths(paths)
    PtyPane->>pastePromptInjection: "text, forceBracketedPaste=true"
    pastePromptInjection->>buildPromptInjectionPayload: "text, forceBracketedPaste=true"
    Note over buildPromptInjectionPayload: forceBracketedPaste=true always wraps, even single-line
    buildPromptInjectionPayload-->>pastePromptInjection: ESC[200~path ESC[201~
    pastePromptInjection->>Terminal: sendInput with trailing space
Loading

Reviews (2): Last reviewed commit: "fix(renderer): keep separator after drop..." | Re-trigger Greptile

Comment thread src/renderer/lib/pty/pty-pane.tsx
@janburzinski
Copy link
Copy Markdown
Collaborator Author

@greptileai

@arnestrickmann arnestrickmann merged commit b6dc66e into main May 20, 2026
1 check passed
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.

2 participants