Skip to content

为SSH远程会话添加服务器文件浏览器边栏#150

Closed
bayunai wants to merge 9 commits into
zerx-lab:mainfrom
bayunai:codex/sidebar-server-file-browser
Closed

为SSH远程会话添加服务器文件浏览器边栏#150
bayunai wants to merge 9 commits into
zerx-lab:mainfrom
bayunai:codex/sidebar-server-file-browser

Conversation

@bayunai
Copy link
Copy Markdown

@bayunai bayunai commented May 23, 2026

总结

-添加服务器文件左侧面板,用于通过SSH远程服务器协议浏览远程目录,包括路径导航、展开/折叠和上下文操作(打开、下载、上传、重命名、删除、复制路径、终端中的cd)。

-将面板连接到终端焦点和“cd”导航,同时在远程工作目录更改时保留会话绑定。

-添加带有分期、冲突处理、排队批次和共享传输进度面板的上传管道;添加每个文件栏的下载进度。

-修复共享菜单组件中的嵌套上下文子菜单悬停/定位回归。

测试计划

  • 连接到启用“SshRemoteServer”的远程主机;打开服务器文件并验证列表、展开/折叠和路径栏导航。

  • 上传单个文件和文件夹;确认冲突对话框、排队、分期提升和进度面板。

  • 下载文件和文件夹;确认本地路径和进度标签包括选定的文件夹根(例如test/...)。

  • 在终端中聚焦,键入(包括IME Enter)并确认文件树不会窃取箭头/回车键;单击面板并确认键盘导航工作正常。

  • 断开SSH或失去会话;确认列表清除并发送友好消息。重新连接后,删除/重命名/刷新应该可以在不重新聚焦终端的情况下工作。

  • 终端cd然后从文件浏览器中删除,没有错误的“无会话”错误。

  • 行使嵌套上下文子菜单(上传/新)用于悬停和单击目标。

bayunai and others added 9 commits May 23, 2026 10:44
Adds the remote-server protocol/client/model support needed by the server file browser, plus the feature-gated left panel entry and initial browser view.

The browser can bind to the active remote SSH context, resolve/list remote paths through the remote server client, and fall back to the existing session where needed during early setup.
Fleshes out the server file browser with file operations such as opening remote files, context menu actions, upload/download entry points, rename/delete flows, and localized UI text.

This keeps the feature scoped to the current remote session while reusing the existing menu and workspace event plumbing.
Fixes generic Menu submenu hover behavior by scoping saved submenu positions per menu instance/row and preventing stale hover-out events from clearing a newer submenu selection.

Also updates menu tests for submenu positioning, nested depth handling, and selected-state cleanup so the server file browser context menu behaves consistently on hover.
Fixes upload refresh and conflict handling so folder uploads preserve the expected remote tree state and same-name uploads are scanned, queued, and promoted in order.

Adds the user-facing conflict/queue messaging needed for the upload progress UI.
Binds the server file browser to the active terminal SessionId instead of selecting an arbitrary session for the same remote host.

This ensures fallback remote shell commands used by rename/delete and upload staging cleanup/promote run against the current SSH session when multiple panes are connected to the same host.
Adds a separated New submenu under Upload with actions for creating remote files and folders.

New entries use conflict-free default names before refreshing the current remote directory listing.
Clear context menu items when dismissing server file browser menus so Enter cannot repeat the last create action.

After creating a remote entry, refresh and enter inline rename for the new path, and update loaded directory caches when file renames complete.
Only handle list navigation keys when the panel is focused so terminal input is not intercepted. Show a localized connection-lost message, clear stale listings on remote errors, and reload when the client becomes available again.

Co-authored-by: Cursor <cursoragent@cursor.com>
Track downloads in the shared transfer progress panel with per-file bars. Preserve SSH session binding when the terminal cds, resolve delete credentials at confirm time, and show download paths including the selected folder root. Use accent color instead of a numeric badge on the progress toolbar button.

Co-authored-by: Cursor <cursoragent@cursor.com>
zerx-lab added a commit that referenced this pull request May 24, 2026
PR #150 (来自 @bayunai, fork: bayunai/warp:codex/sidebar-server-file-browser)
原始 9 个 commits 压缩为单个 commit 合入。

主要改动:
- 新增 "Server files" 左侧面板,用于在 SSH 远程会话下浏览服务器目录
  (路径栏、展开/折叠、右键菜单: 打开、下载、上传、重命名、删除、复制路径、
  cd 到终端)。在 host 切换或断开时清理面板状态并停止进度轮询。
- 上传管道:暂存目录 → 冲突扫描(覆盖/跳过) → 队列化 → 提升;
  下载管道:每个文件进度条 + 共享传输进度面板。
- 远端协议扩展:新增 4 个 RPC (ResolvePath / CreateDirectory /
  ReadFileChunk / WriteFileChunk);ListDirectory 与 DirEntry 增加
  kind / size_bytes / modified_epoch_millis / canonical_path 字段。
  客户端在 kind=Unspecified(旧 server) 时回退到 is_dir,
  未知 kind 归 Other,兼容旧版与未来版本。
- 修复嵌套上下文子菜单 hover / 定位回归:为 Menu 引入
  submenu_position_namespace,SavePosition 改为 per-row,
  UnhoverSubmenuParent 携带 row_index,HoverSubmenuLeafNode 携带 select 标志,
  并新增 5 个回归测试。
- workspace::view::cd_to_directory 保持原 "填入 buffer" 语义(FileTree/Drive
  等本地入口不受影响);新增的 cd_to_remote_directory(远端文件浏览器
  右键菜单触发)使用 try_execute_command + cd -- {q} 立即执行。
- completer: SSH 会话未完成 remote-server 握手但 SshRemoteServer flag
  启用时,避免缓存空补全结果。
- 新 Feature Flag: ServerFileBrowser(dogfood 段,与 SshRemoteServer 联动)。

review fixes (合并前在 worktree 内完成):
- 修复 PR 引入的 6 个 clippy warning (redundant_locals × 2、
  too_many_arguments allow × 3、sort_by → sort_by_key × 1)。
- 修复 delegate_pointer_action_to_selected_submenu 在嵌套深度大于 1
  时事件被静默吞掉的潜在 bug (\!= → >)。
- host/session 切换时 stop_progress_poll(),避免旧 host timer
  在新连接上空转。

follow-up 在 #154 跟进:
- 上传暂存目录污染目标父目录
- 进程崩溃时残留清理
- 服务端 read_file_chunk 每次 chunk 重开文件 (O(N^2) syscall)
- 4969 行单文件的可维护性

Co-authored-by: bayunai <bayunai@users.noreply.github.com>
@zerx-lab
Copy link
Copy Markdown
Owner

感谢 @bayunai 提交此 PR!

本 PR 已通过 squash merge 合入 main,作为 commit d2611320。原因是 head 在 fork (bayunai/warp:codex/sidebar-server-file-browser),GitHub 直接合并按钮不可用,因此本地完成 squash + push。

合并前的 review fixes(已包含在 squash commit 中)

  1. 回归修复:workspace::view::cd_to_directory 还原为原 replace_buffer_content 语义,保护 FileTree / Drive 等本地入口的既有 UX;新增的 cd_to_remote_directory(远端文件浏览器右键菜单触发)继续使用 try_execute_command + cd -- {q}
  2. clippy:消除本 PR 引入的 6 个 warning(2x redundant_locals,3x too_many_arguments allow,1x sort_bysort_by_key)。
  3. 旧服务端兼容:list_directoryFileSystemEntryKind::Unspecified 时回退 proto 旧字段 is_dir,未知 kind 归 Other,避免旧 server 上双击目录走 ResolvePath 报错。
  4. 嵌套 submenu 路由:delegate_pointer_action_to_selected_submenusubmenu.depth != event_depthsubmenu.depth > event_depth,允许指针事件递归到任意深度的目标 submenu。
  5. 进度轮询清理:set_remote_root 在 host / session 切换时调用 stop_progress_poll(),避免旧 host 的 timer 在新连接上空转。

Follow-up issue

以下 3 个非阻塞问题已记录在 #154 跟进,未在本 PR 内处理:

  • C-1 上传暂存目录 .zap-upload-staging 放在目标父目录,上传期间用户可见,失败时可能残留。
  • C-2 App 进程崩溃 / 网络中断时暂存目录无自动清理机制。
  • C-3 服务端 handle_read_file_chunk 每次 chunk 重开文件,1GB 文件约 1000 次 open + seek syscall。

另外建议作为可选 follow-up:将 4969 行的 server_file_browser.rs 拆分为多个子模块(upload / download / render / shell_util)。

验证

  • cargo check --workspace --exclude command-signatures-v2 通过。
  • cargo clippy -p warp --no-deps:PR 引入的 6 个 warning 全部消除,剩余 6 个为 pre-existing(与本 PR 无关)。
  • 新增 5 个 submenu 回归测试 + 12 个 server_file_browser 单测全部通过。
  • remote_server 测试 63/64 通过(失败那 1 个是 pre-existing 的 zap-oss/warp-oss 命名问题)。

再次感谢 🙏

@zerx-lab zerx-lab closed this May 24, 2026
@bayunai bayunai deleted the codex/sidebar-server-file-browser branch May 24, 2026 05:48
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.

2 participants