Repository navigation
feat(app): move files and folders by dragging them in the SFTP file panel - #297
Merged
Merged
Conversation
…anel Rows of the file table drag onto a folder row, a folder of the tree, the up button or a breadcrumb, which moves them there with an SFTP rename (remotefs.Move). A taken file name asks before replacing, folders are never merged or replaced, and items that could not move are reported with the reason while the others stay moved. Closes #295 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015nMqJEvqPnRmPgi6dnraZM
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Summary
Rows of the SFTP file table can now be dragged onto a folder to move them there on the server, as asked in #295 ("我没办法在文件栏拖动文件,比如移动他到文件夹里。需要添加支持").
What is dragged: the row pressed, or every chosen row when the pressed row is one of them (MyGo's
ListState.DragRows, as the connection manager does since #239). A row that is not chosen drags alone and the choice is left as it is. With a search open, rows the search hides are already unchosen (#276), so only shown rows move; with a sort (#272) the drag goes by name, not by row index. A press and release without moving is still a click, and the header does not drag rows.Drop targets, outlined while a valid drag is over them, with a note at the bottom of the table ("Drop to move to /opt/magpie"):
Refused or no-op drops show no outline and do nothing: the rows' own folder, a dragged row itself, a folder into itself or a folder inside it, another session's panel, no SFTP connection. While a move runs nothing can be dragged (
DragRowsreturns nil and targets refuse), so a second drag cannot overlap a running move; the toolbar shows the spinner meanwhile.The move itself is a new
remotefs.Move(c, from, names, to, replace)next toRename, run in a goroutine with the result posted throughApp.postand dropped when the session's SFTP client changed. LikeRenameit looks before it moves and never replaces silently:Lstat/ReadLink, because some servers' realpath, including pkg/sftp's, does not resolve links);ExistsError. The panel then asks with the existing upload question ("Replace existing items?"); Replace uses OpenSSH's posix-rename, Cancel leaves both files untouched;FolderExistsError: folders are never merged, and a file and a folder never replace each other (the issue's recommendation). It is reported rather than asked.Items whose names are free move at once, before the question; only the conflicting ones wait for the answer. This avoids a check-then-act gap and matches Explorer. When some items fail (folder conflict, permission denied, a server refusing a cross-device rename, an item gone since it was listed), a dialog lists each with its reason and says how many others were moved; those stay moved. The replace question got an optional
nocallback so that failures are still reported after Cancel.Afterwards the current folder is listed again, the source and target folders are re-read in the tree if loaded, and the tree's open/loaded state of a moved folder follows it (the rename code's tree bookkeeping became
fileState.treeMoved, shared by both). Moved rows disappear from the selection; the rest of the selection stays.OS file drops still upload: the new targets take only in-app values (
ui.Drop[*fileMoveDrag]), so files from Finder/Explorer still reach the table and tree drop zones, and an in-app drag never shows the "Drop to upload" note.Where this deviates from or settles the issue:
mvin the terminal.Docs: a "Moving by dragging" section in
docs/en/features.mdanddocs/zh-CN/features.md, and one clause in the Files paragraph of both READMEs. New strings inlocales/en.jsonandlocales/zh-Hans.json,catalog_gen.goregenerated.go run ./tools/screenshotsleavesdocs/screenshots/unchanged.Closes #295
Testing
go build ./...,go vet ./...,GOOS=windows go vet .,GOOS=darwin go vet .,go tool mygo vet, gofmtgo test -race -count=1 -timeout 30m ./...(see note below)TestMove(internal/remotefs): move into another folder, no-op into the own folder directly or through a link, refused into itself or a descendant (also through a link), taken name refused then replaced, file over folder and folder over folder refused with replace, links moved as links, bad names.TestFileMoveToFolderRow: one row and three chosen rows (chosen by click and Cmd-click, including a folder) onto a folder row; files' new places, listing, tree, selection; the hint while over; OS file drop on a folder row still uploads; click and double-click to open still work.TestFileMoveToTree: onto a tree folder outside the current folder, a folder moved and the tree updated, onto the up button, onto a breadcrumb.TestFileMoveRefused: onto itself, file onto file, folder into its own subfolder in the tree, onto its own folder, a header dragged onto a folder, no drag without SFTP or during a move, another session's panel.TestFileMoveConflict: question shown, Cancel leaves both, Replace replaces while a free name moved at once, folder-over-folder reported with the other item moved, an item deleted on the server meanwhile reported while the other moved, OK and Escape close the report.TestFileMoveSearchSort: with a search hiding a chosen row and a size sort, only the shown chosen rows move.Generated by Claude Code