Skip to content

fix(vscode/open): remove leading slash from folder URI#388

Merged
skevetter merged 7 commits intomainfrom
fix-trailing-slash-in-url
Jan 31, 2026
Merged

fix(vscode/open): remove leading slash from folder URI#388
skevetter merged 7 commits intomainfrom
fix-trailing-slash-in-url

Conversation

@skevetter
Copy link
Copy Markdown
Owner

@skevetter skevetter commented Jan 31, 2026

Signed-off-by: Samuel K skevetter@pm.me

Summary by CodeRabbit

  • Bug Fixes
    • More reliable VS Code remote URL and folder argument construction: workspace paths (including leading slashes) are handled consistently when opening.
    • Improved handling when opening in a new window; query parameters for new-window requests are now applied consistently.
    • More robust browser-open behavior with improved logging for troubleshooting.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Samuel K <skevetter@pm.me>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

Renamed protocolscheme in openConfig and switched URL/CLI assembly in pkg/ide/vscode/open.go from string formatting to structured net/url construction for browser opening and --folder-uri; preserves leading-slash trimming and NewWindow handling, and adds a debug log for opened URLs.

Changes

Cohort / File(s) Summary
VS Code remote URI & args
pkg/ide/vscode/open.go
Added net/url import and renamed openConfig.protocolopenConfig.scheme; updated openConfigs entries. openViaBrowser now constructs the browser URL with url.URL (scheme from config.scheme, host vscode-remote, path /ssh-remote+<workspace>.devpod/<folder> with leading slash trimmed) and appends windowId=_blank when NewWindow is true; logs the opened URL. buildOpenArgs now builds a vscode-remote URL (Scheme: vscode-remote, Host: ssh-remote+<workspace>.devpod, Path: trimmed folder), converts it to u.String() and passes it as a separate --folder-uri argument instead of embedding the URI in another string.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring URL construction in vscode/open from string concatenation to structured net/url building, with leading slash trimming for folder URIs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-trailing-slash-in-url

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pkg/ide/vscode/open.go`:
- Line 196: The browser URL construction in openViaBrowser uses params.Folder
directly which can produce a double slash; update the fmt.Sprintf call in
openViaBrowser to trim a leading slash from params.Folder (use
strings.TrimPrefix(params.Folder, "/")) so it matches the earlier change to args
(the fmt.Sprintf that builds
"--folder-uri=vscode-remote://ssh-remote+%s.devpod/%s"); ensure you import or
reference strings as used elsewhere and replace params.Folder in the format
string with the trimmed value so CLI and browser URIs are consistent.

Comment thread pkg/ide/vscode/open.go Outdated
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K <skevetter@pm.me>
@skevetter skevetter enabled auto-merge (squash) January 31, 2026 02:17
@skevetter skevetter disabled auto-merge January 31, 2026 02:18
Signed-off-by: Samuel K <skevetter@pm.me>
Signed-off-by: Samuel K <skevetter@pm.me>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pkg/ide/vscode/open.go`:
- Around line 105-110: The code uses path.Join to build VS Code remote URIs
which collapses the "://" scheme; in openViaBrowser (openURL) and in
buildOpenArgs (the argument built at line 202) stop using path.Join for the
scheme portion — instead concatenate the scheme and "://" (config.protocol +
"://") with the rest of the URL, and use path.Join only for the path segments
(e.g., join "vscode-remote", "ssh-remote+<Workspace>.devpod", and
strings.TrimPrefix(params.Folder, "/") into the path part), then prepend the
scheme + "://" so the final URI preserves the correct "vscode://" or
"vscode-remote://" form; update both openURL construction and the buildOpenArgs
URI construction accordingly, referencing openViaBrowser/openURL and
buildOpenArgs by name.

Comment thread pkg/ide/vscode/open.go Outdated
@skevetter
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 31, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request aims to fix VS Code remote SSH URI formatting by removing leading slashes from folder paths to ensure workspace paths are handled consistently when opening VS Code remotely.

Changes:

  • Refactored openViaBrowser function to use url.URL struct for more reliable URL construction
  • Modified buildOpenArgs function to strip leading slashes from folder paths and separate the --folder-uri flag from its value

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/ide/vscode/open.go Outdated
Comment thread pkg/ide/vscode/open.go Outdated
Signed-off-by: Samuel K <skevetter@pm.me>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pkg/ide/vscode/open.go`:
- Around line 105-109: The path assembly in open.go duplicates the folder:
params.Folder is inserted into pathStr via fmt.Sprintf and then appended again;
update the logic around the local variables folder and pathStr so the folder
appears only once (e.g., use folder := strings.TrimPrefix(params.Folder, "/")
and build pathStr with fmt.Sprintf("/ssh-remote+%s.devpod/%s", params.Workspace,
folder) and remove the subsequent if folder != "" { pathStr += "/" + folder }
block), and ensure empty folder yields a clean path (or use a single join
operation like path.Join semantics) so params.Workspace and folder are correctly
combined without duplication.

Comment thread pkg/ide/vscode/open.go Outdated
Signed-off-by: Samuel K <skevetter@pm.me>
@skevetter skevetter merged commit 70a678a into main Jan 31, 2026
39 checks passed
@skevetter skevetter deleted the fix-trailing-slash-in-url branch January 31, 2026 15:11
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