Conversation
本次提交显著扩展了SFTP文件管理器功能和交互体验,包括: - 支持按名称、大小、权限、修改时间排序,目录优先,列头可点击切换升降序; - 工具栏与右键菜单重构,支持新建文件/文件夹、下载、重命名、移动、复制路径/名称、属性等操作; - 文件列表切换为ListBox,支持多选和双击进入目录; - 新增属性弹窗、剪贴板复制、对话框输入等交互; - ISftpService接口扩展,支持文件创建、重命名/移动、获取工作目录、关闭会话等; - 新增“tools.files”命令(Ctrl+Shift+F),主窗口自动管理SFTP面板绑定与销毁; - 单元测试覆盖所有新增功能; - 代码风格和注释优化,.gitignore补充FodyWeavers.xsd。 整体提升了易用性、可维护性和现代化体验。
# Conflicts: # src/PulseTerm.App/ViewModels/MainWindowViewModel.cs
There was a problem hiding this comment.
Pull request overview
Adds/finishes the SFTP file manager workflow by extending the SFTP service API, wiring UI commands/shortcuts, and expanding the file browser UI/VM behaviors (sorting, activation, context menu operations), with corresponding test coverage.
Changes:
- Extend
ISftpService/SftpServiceto support working directory discovery, empty-file creation, rename/move, and per-session SFTP channel teardown. - Add a “tools.files” command +
Ctrl+Shift+Fshortcut and update views to expose the SFTP file manager via menu and keybinding. - Upgrade the file browser UI/VM with sortable columns, double-click directory navigation, and right-click context actions; add/adjust unit tests accordingly.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/PulseTerm.Core.Tests/Sftp/SftpServiceTests.cs | Adds tests for new SFTP service behaviors (cwd, close session, rename, create empty file). |
| tests/PulseTerm.App.Tests/ViewModels/MainWindowViewModelTests.cs | Verifies the new tools.files command/shortcut wiring and toggle behavior. |
| tests/PulseTerm.App.Tests/ViewModels/FileBrowserViewModelTests.cs | Expands coverage for activation, initial load to cwd, sorting, and context-menu actions. |
| src/PulseTerm.Infrastructure/Ssh/SftpClientWrapper.cs | Adds RenameFile wrapper to the concrete SFTP client adapter. |
| src/PulseTerm.Core/Ssh/ISftpClientWrapper.cs | Extends the wrapper interface with RenameFile. |
| src/PulseTerm.Core/Sftp/SftpService.cs | Implements create-file, rename, working-directory, and close-session APIs. |
| src/PulseTerm.Core/Sftp/ISftpService.cs | Exposes new SFTP APIs with documentation for UI consumption. |
| src/PulseTerm.App/Views/MenuBarView.axaml | Enables the menu entry to launch the SFTP file manager command. |
| src/PulseTerm.App/Views/MainWindow.axaml | Adds Ctrl+Shift+F keybinding for tools.files. |
| src/PulseTerm.App/Views/FileBrowserView.axaml.cs | Wires view-provided callbacks (prompt/clipboard/properties) and double-tap activation. |
| src/PulseTerm.App/Views/FileBrowserView.axaml | Switches to a selectable ListBox, adds sortable headers and context menus. |
| src/PulseTerm.App/ViewModels/MainWindowViewModel.cs | Registers the new command and manages file browser binding across connect/reconnect/tab close. |
| src/PulseTerm.App/ViewModels/FileBrowserViewModel.cs | Adds sorting, home-directory initial load, activation, and new context-menu operations. |
| .gitignore | Ignores additional local/auxiliary artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+5
to
+9
| using Avalonia; | ||
| using Avalonia.Controls; | ||
| using Avalonia.Input; | ||
| using Avalonia.Input.Platform; | ||
| using Avalonia.Layout; |
Comment on lines
+150
to
+166
| await Task.Run(() => | ||
| { | ||
| try | ||
| { | ||
| if (client.IsConnected) | ||
| { | ||
| client.Disconnect(); | ||
| } | ||
|
|
||
| client.Dispose(); | ||
| } | ||
| catch | ||
| { | ||
| // Best-effort teardown; the tab is already gone. | ||
| } | ||
| }, cancellationToken).ConfigureAwait(false); | ||
| } |
Comment on lines
+174
to
+175
| if (wasVisible) | ||
| FileBrowser.RefreshCommand.Execute().Subscribe(_ => { }, _ => { }); |
Comment on lines
+188
to
+189
| if (FileBrowser.IsVisible && FileBrowser.SessionId != Guid.Empty) | ||
| FileBrowser.RefreshCommand.Execute().Subscribe(_ => { }, _ => { }); |
Comment on lines
+358
to
+366
| var name = await PromptForText("新建文件夹", ""); | ||
| if (string.IsNullOrWhiteSpace(name)) | ||
| return; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| ErrorMessage = null; | ||
| var toDelete = SelectedFiles.ToList(); | ||
| await _sftpService.CreateDirectoryAsync(_sessionId, CombinePath(CurrentPath, name.Trim()), ct); | ||
| await RefreshAsync(ct); |
Comment on lines
+379
to
388
| var name = await PromptForText("新建文件", ""); | ||
| if (string.IsNullOrWhiteSpace(name)) | ||
| return; | ||
|
|
||
| try | ||
| { | ||
| ErrorMessage = null; | ||
| await _sftpService.CreateFileAsync(_sessionId, CombinePath(CurrentPath, name.Trim()), ct); | ||
| await RefreshAsync(ct); | ||
| } |
Comment on lines
+400
to
410
| var newName = await PromptForText("重命名", file.Name); | ||
| if (string.IsNullOrWhiteSpace(newName) || newName.Trim() == file.Name) | ||
| return; | ||
|
|
||
| try | ||
| { | ||
| ErrorMessage = null; | ||
| var target = CombinePath(ParentOf(file.FullPath), newName.Trim()); | ||
| await _sftpService.RenameAsync(_sessionId, file.FullPath, target, ct); | ||
| await RefreshAsync(ct); | ||
| } |
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.
No description provided.