feat(remote): paste clipboard images into remote terminals#140
Open
matej21 wants to merge 2 commits into
Open
Conversation
Pasting an image into a remote-backed terminal wrote the image to the
client's temp dir and sent that client-local path to the server's PTY,
so the server-side process (e.g. Claude Code) couldn't find the file.
Route remote image pastes over HTTP instead: the desktop client uploads
the bytes to POST /v1/terminals/{id}/paste-image, the server writes them
to its own temp dir and bracketed-pastes that path into the terminal —
mirroring the local image-paste path, just across the wire.
- okena-views-terminal: ActionDispatch::upload_remote_paste_image (default
no-op); TerminalPane::handle_paste short-circuits to it for remote terminals
- action_dispatch: strip the remote prefix, delegate to the manager
- okena-remote-client: RemoteConnectionManager::upload_paste_image (HTTP,
mirrors send_action)
- remote server: paste-image route (20 MiB body limit) + RemoteCommand::PasteImage
-> ensure_terminal + send_paste on the GPUI thread
- enable tokio "fs" feature for async temp-file writes
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The rust-toolchain.toml bump to 1.95.0 turned several new clippy lints into CI errors (`cargo clippy --all-targets -- -D warnings`), failing the Build workflow on main independently of any one change. Apply the mechanical fixes: - collapse nested `if let` into the outer `match` arm (collapsible_match) - `sort_by(|a, b| b.k.cmp(&a.k))` -> `sort_by_key(|x| Reverse(x.k))` (unnecessary_sort_by) No behavior change. Pre-existing on main; unrelated to the remote image-paste feature on this branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pasting a clipboard image into a remote-backed terminal was broken.
TerminalPane::handle_pastewrote the image to the client's temp dir and sent that client-local path over the wire to the server's PTY — so the server-side process (e.g. Claude Code) got a path to a file that doesn't exist on it. Claude Code reads images by path, so this silently failed.Local image paste already worked this way (write temp file →
send_paste(path)); only the remote case was wrong.Approach
Route remote image pastes over HTTP so the file is materialised where the terminal's process runs:
ClipboardEntry::Image) and, when the terminal is remote, uploads the bytes toPOST /v1/terminals/{id}/paste-imageinstead of writing a local temp file.Scope: remote desktop client (okena desktop connected to a remote okena server). Web/mobile clients are unchanged for now; they'd reuse the same endpoint via an
onPastehandler.Changes
ActionDispatch::upload_remote_paste_image(default no-op);handle_pasteshort-circuits to it for remote terminals.remote:{cid}:prefix and delegate to the connection manager.RemoteConnectionManager::upload_paste_image— fire-and-forget HTTP upload, mirrorssend_action.paste-imageroute (20 MiB body limit, overriding the global 1 MiB cap; clipboard PNGs routinely exceed 1 MiB) +RemoteCommand::PasteImage→ensure_terminal+send_pasteon the GPUI thread.fsfeature for the async temp-file write.Testing
cargo clippy --workspace --all-targets -- -D warningsclean,cargo testgreen, CI passing.Notes
fix(lint)) is unrelated to this feature: therust-toolchain.tomlbump to 1.95.0 turned new clippy lints (collapsible_match,unnecessary_sort_by) into CI errors, which had already mademainred. Mechanical, no behavior change — included here so this branch's CI is green; can be cherry-picked tomainseparately to un-red it sooner.send_action, which builds anhttp://URL with a plainreqwest::Client(no cert pinning). So like every other action, image upload won't work over a TLS connection with a self-signed pinned cert — a pre-existing limitation of the action transport, not a new regression. Happy to fix both in a follow-up.🤖 Generated with Claude Code