Repository navigation
feat(terminal): paste clipboard images into SSH sessions as a file path (#630) - #639
Merged
Merged
Conversation
…th (#630) A program on the SSH host, such as Claude Code, can't reach this machine's clipboard. Pasting an image (Ctrl+V, Ctrl+Shift+V, right-click, or Cmd+V on macOS) when the clipboard holds no text now uploads it next to the session's shell and types its path, followed by a space. paste_image_read takes the image from the clipboard in Rust, encodes it as PNG and keeps the last few by id, so Retry sends the same picture even if the clipboard changed. paste_image_upload opens SFTP on the session's own SSH connection, writes ~/.cache/voltius/pastes/voltius-paste-<time>.png as a .part file with sftp-progress events and a cancel token, renames it when complete, makes the folder owner-only and prunes pastes older than 7 days. Uploads over 250 ms show a bottom-right progress toast with a thumbnail, host, size, dimensions and Cancel. Success shows the file with "Delete from host"; the first paste instead says where the image went and links to the setting. Failures name the host with the classified error and offer Retry. Pastes queue per session so paths land in paste order. Nothing uploads when the session doesn't accept input, and broadcast input refuses with a toast. Progress toasts can now carry a thumbnail, a detail line and an action once finished, and a finished one keeps its own duration. Built on ghecko's PR #630: the setting, its translations, the shared paste helper and the terminal hookup are his. Co-authored-by: ghecko <13104020+ghecko@users.noreply.github.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.
Takes over #630 by @ghecko with the changes from its review. His setting, translations, shared paste helper and terminal hookup are kept, and the squash commit credits him as co-author.
What
When the clipboard holds an image and no text, pasting into an SSH session uploads the image to the host and types its path, followed by a space. Paste works with Ctrl+V, Ctrl+Shift+V, right-click, and now also Cmd+V on macOS. Tools on the host such as Claude Code then attach it.
How
paste_image_readreads the clipboard in Rust, encodes PNG withpng(already in the tree) and returns the size, dimensions and a small thumbnail. It keeps the last four images by id for Retry. No webview clipboard-image permission is needed.paste_image_uploadopens SFTP on the session's existing connection. It ensures~/.cache/voltius/pastesexists and is owner-only, and prunes pastes older than 7 days. It writes<name>.partin 64 KB chunks withsftp-progress-<id>events and a cancel token, then renames to the final name. A failed or cancelled write deletes the.partfile.sessionAcceptsInputis shared withwriteToSession.sftp_write_bytesand its header plumbing, theFileBackend::write_file(&[u8])change, the canvas re-encode, andclipboard-manager:allow-read-image.Testing
commands::sftp::pastetests cover the file name, prune rules, thumbnail aspect and Retry memory.cargo clippy --workspace --all-targets -- -D warningsis clean.terminalImagePaste.test.tscovers no image, toggle off, no input, broadcast, fast and slow uploads, progress, Cancel, first use, failure with Retry, and queue order.terminalClipboard.test.tsadds macOS Cmd+V.tscis clean. The full vitest sweep (802 files) passed apart from two known 5 s timeouts under load, which pass when run on their own..partleft).