Skip to content

feat(app): copy remote SFTP files to the system clipboard - #288

Open
Irzos wants to merge 4 commits into
TooonyChen:mainfrom
Irzos:feature/sftp-copy-to-clipboard
Open

Irzos wants to merge 4 commits into
TooonyChen:mainfrom
Irzos:feature/sftp-copy-to-clipboard

Conversation

@Irzos

@Irzos Irzos commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Copy to Clipboard to the SFTP file table. Select one or more
    files or folders and use the context menu, Cmd+C on macOS, or Ctrl+C
    on Windows and Linux.
  • Stage the entire selection through the transfer queue before writing
    to the clipboard. Failed or canceled transfers leave the clipboard
    intact. Only the latest file-copy request can publish its result.
  • Clean up failed, canceled, and superseded transfers. Keep the last
    successfully copied files available for paste until another copy
    succeeds or the app exits. Render copy errors in the current UI language.

This is the remote-to-local clipboard follow-up split out of #224.

Closes #286

Testing

  • Verified actual paste into Finder on macOS 26.7.3, File Explorer on
    Windows 11 ARM64, and Thunar 4.20.2 on Debian 13 ARM64. On all three,
    the file with a space in its name and the nested file matched the
    source byte for byte, and the empty subdirectory was preserved.
  • Started the copy with Cmd+C in Finallyshell on macOS. On Windows and
    Linux, a test harness invoked the app's copy action, followed by
    Ctrl+V in the native file manager.
  • The clipboard-specific race tests, go vet ./..., and
    go tool mygo vet passed. The full go test -race ./... run failed
    on TestCloseAllMixed, which also fails on upstream main in the
    same environment.

Irzos added 2 commits December 1, 2026 12:53
Stage selections in the transfer queue and publish only when the newest
request finishes. Keep staged files available for paste until a successful
replacement or app exit.

Refs TooonyChen#286

Copy link
Copy Markdown
Owner

Thanks for splitting this out and for the careful follow-through. All five points from the #224 review are handled: the clipboard keeps its contents until the files are ready (also after a failed or canceled copy, and when two copies finish out of order), staged folders are removed on failure, cancel, supersede and quit, ordinary downloads behave as before (same results on base and here for an empty folder, a fifo, links and a re-download), errors follow the UI language, and the description says what was pasted where. Names from the server stay inside the staging folder, and Ctrl/Cmd+C keeps copying text in the terminal, the path field, the search field, the rename field and the breadcrumb editor.

One thing blocks it, and it only appears now that #224's paste is on main:

A newer copy deletes the staged files while an earlier paste is still uploading them. Paste uploads straight from the staging folder, and finishClipboardCopy removes the previous folder as soon as a newer copy succeeds. On main + this branch:

  • Copy, paste into the same folder so the replace question shows, copy something else, then answer Yes: both uploads fail with lstat …: no such file or directory.
  • Copy a folder of 400 files, paste it into another remote folder, and copy a small file while the upload runs: the upload ends as Done with only a few dozen of the 400 files on the server (8, 42, 49 and 28 in four runs). The folder upload skips sources that have disappeared (the "broken link" branch in remotefs.go), so nothing reports it.

The second case is silent data loss from the user's point of view, so it has to be closed before this merges. Any of these would do: keep the previous staged folder while an upload is reading from it (a reference count, or remove it when the last job using it ends), or have paste take its own copy or hold of the staged files. Independently of that, an upload whose source vanishes part-way should fail, not finish as Done; that can be its own small change if you prefer.

Smaller, your call:

  • Folders left by a crash are never removed now that the 24-hour sweep is gone; a sweep of finallyshell-clipboard-* at start would cover it (Windows never cleans %TEMP%).
  • A superseded copy keeps downloading to the end and is then discarded, shown as "Canceled"; canceling it when the newer copy starts would save the transfer.
  • Menu: "Copy to Clipboard" is title case where the other items are sentence case, and it sits at the bottom next to "Copy path" while "Paste" is in the second group. "Copy" beside "Paste" would read more naturally.
  • UnsafeEntryError still reads "unsafe name in the archive: …" in English in both languages, which is the wrong wording for a copy.
  • Two names differing only in case fail the whole copy on macOS and Windows (the exclusive create); worth a clear message.

Generated by Claude Code

Irzos commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I’ve pushed the fixes to PR #288 in commit d4bc6c4.

A paste now keeps its staged files while it checks for conflicts, waits for overwrite confirmation, and uploads. A newer copy can replace the clipboard while the earlier paste continues using its files. If a source file goes missing during upload, the transfer reports a failure.

I also added startup cleanup for staging folders left after a crash, made new copies cancel superseded copies immediately, moved Copy next to Paste, and added localized messages for unsafe file names and case-only name collisions.

This branch has not been deployed

No deployments
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.

feat(app): copy remote SFTP files to the system clipboard

2 participants