Skip to content

Fix browser image paste in remote terminals - #969

Draft
wesm wants to merge 1 commit into
mainfrom
x11-image-paste-bug
Draft

Fix browser image paste in remote terminals#969
wesm wants to merge 1 commit into
mainfrom
x11-image-paste-bug

Conversation

@wesm

@wesm wesm commented Aug 24, 2026

Copy link
Copy Markdown
Member

Forge now handles image-only browser paste at the web-terminal boundary, so remote Linux terminals no longer ask the host X11 clipboard for browser content.

  • Uploads PNG, JPEG, and WebP clipboard payloads to the terminal-owning host, including Fleet HTTP and SSH peers, then pastes readable paths through the existing bracketed-paste flow.
  • Keeps text-first paste behavior and supports sequential multi-image paste.
  • Preserves macOS terminal bindings by replaying Ctrl+V whenever the clipboard is not image-only or browser clipboard access fails. Alt+V remains terminal-owned.

Browser paste shortcuts run in the client, while an agent on a remote Linux
host can only read that host's clipboard. This mismatch sent image paste
through X11 and failed when no reachable display existed.

Upload image-only clipboard payloads to the terminal-owning host and paste the
returned path. Keep text paste precedence, and replay macOS Ctrl+V when the
clipboard is not image-only so readline and terminal UI bindings still work.

Generated with Codex

Co-authored-by: Codex <noreply@openai.com>
@roborev-ci

roborev-ci Bot commented Aug 24, 2026

Copy link
Copy Markdown

roborev: Combined Review (8865906)

Image upload handling is generally sound, but three medium-severity issues should be fixed before merging.

Medium

  • Consecutive uploads produce an invalid shell tokenfrontend/src/lib/components/terminal/XtermTerminalPane.svelte:428
    Multiple uploaded paths are sent in consecutive bracketed-paste frames without whitespace, causing shells to concatenate them. Join the quoted paths with spaces in a single paste, or insert separators between frames, and test the combined terminal input.

  • Asynchronous clipboard probing can reorder terminal inputfrontend/src/lib/components/terminal/XtermTerminalPane.svelte:472
    On macOS, Ctrl+V is replayed only after an asynchronous clipboard read while subsequent keystrokes continue immediately. This can break sequences such as quoted-insert followed by a character. Buffer or serialize terminal input until the clipboard probe completes, then replay Ctrl+V or paste the image path before flushing later input.

  • SSH proxy request body is read without a size boundinternal/server/fleetapi/fleet_ssh.go:448
    The raw Adapter().Handle callback uses unbounded io.ReadAll, so MaxBodyBytes does not protect this route and an oversized request can consume arbitrary memory. Read through a MaxImageBytes + 1 limit, return HTTP 413 when exceeded, and add an over-limit SSH fleet-route test.


Reviewers: 2 done | Synthesis: codex, 10s | Total: 9m21s

@wesm

wesm commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

I'll probably have to wait for #965 to merge and then rebase this

@mariusvniekerk
mariusvniekerk marked this pull request as draft August 24, 2026 21:49
@mariusvniekerk

Copy link
Copy Markdown
Collaborator

moving to draft to prevent accidental trigger fingers

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants