Skip to content

fix: use fspath.Base to strip Windows paths on SSH remote drag-drop#3118

Merged
sawka merged 1 commit intowavetermdev:mainfrom
majiayu000:fix/issue-3079-windows-drag-drop-path
Mar 25, 2026
Merged

fix: use fspath.Base to strip Windows paths on SSH remote drag-drop#3118
sawka merged 1 commit intowavetermdev:mainfrom
majiayu000:fix/issue-3079-windows-drag-drop-path

Conversation

@majiayu000
Copy link
Contributor

Fixes #3079

Summary

When dragging a local file from Windows to an SSH remote connection, the full Windows path (e.g. D:\package\AA.tar) was being passed to filepath.Base on the remote (Linux) side. Since filepath.Base on Linux does not recognize backslashes as separators, the full path was used as the destination filename.

  • In RemoteFileCopyCommand (wshremote_file.go:159), replace filepath.Base(srcConn.Path) with fspath.Base(srcConn.Path)
  • fspath.Base calls ToSlash before path.Base, converting backslashes to forward slashes first, so D:\package\AA.tar correctly yields AA.tar on any OS
  • Same-host copies at line 86 use filepath.Base(srcPathCleaned) and are unaffected — those run on the same OS where filepath.Base is correct

Test Plan

  • Added pkg/remote/fileshare/fspath/fspath_test.go with table-driven tests for fspath.Base:
    • Windows path with backslashes: D:\package\AA.tarAA.tar
    • Windows path with forward slashes: D:/package/AA.tarAA.tar
    • Unix path: /home/user/file.txtfile.txt
    • Filename only: file.txtfile.txt
  • go test ./pkg/remote/fileshare/fspath/... passes

When drag-dropping a local Windows file (e.g. D:\package\AA.tar) to an
SSH remote, filepath.Base was called on the remote (Linux) side, which
does not recognise backslashes as separators and kept the full Windows
path as the filename. Replace with fspath.Base, which converts
backslashes to forward slashes before extracting the basename.

Fixes wavetermdev#3079

Signed-off-by: majiayu000 <1835304752@qq.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 937ea68d-b76a-4255-a288-c25219f67372

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@majiayu000 majiayu000 marked this pull request as ready for review March 25, 2026 17:10
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 25, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

The PR correctly fixes the Windows path issue (#3079) by introducing a new fspath package that normalizes backslashes to forward slashes before extracting the base filename. The fix is minimal and targeted.

Files Reviewed (2 files)

  • pkg/remote/fileshare/fspath/fspath.go - New OS-agnostic path utilities
  • pkg/remote/fileshare/fspath/fspath_test.go - Unit tests for fspath.Base
  • pkg/wshrpc/wshremote/wshremote_file.go - Fixed to use fspath.Base at line 160

Notes

  • The fspath package also provides Dir, Join, and FirstLevelDir functions that use the same ToSlash normalization - good consistency
  • The PR description correctly notes that same-host copies at line 86 using filepath.Base are unaffected (they run on the same OS)
  • Test coverage is sufficient for the immediate fix; consider adding tests for other fspath functions if they're used in similar cross-OS contexts in the future

Reviewed by minimax-m2.5-20260211 · 279,071 tokens

@sawka sawka merged commit 0b29c49 into wavetermdev:main Mar 25, 2026
2 checks passed
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.

[Bug]: Windows: Drag & drop local file to SSH remote keeps full Windows path

2 participants