Skip to content

fix(windows): context menu "Open Warp in new tab" navigates to home dir (#9844)#9849

Open
KuaaMU wants to merge 1 commit intowarpdotdev:masterfrom
KuaaMU:fix/windows-context-menu-path-encoding
Open

fix(windows): context menu "Open Warp in new tab" navigates to home dir (#9844)#9849
KuaaMU wants to merge 1 commit intowarpdotdev:masterfrom
KuaaMU:fix/windows-context-menu-path-encoding

Conversation

@KuaaMU
Copy link
Copy Markdown

@KuaaMU KuaaMU commented May 1, 2026

Summary

  • parse_tab_path trims trailing whitespace from the decoded path, catching an edge-case where %1/%V expansion appends invisible characters
  • path_if_directory falls back to std::fs::canonicalize() when is_dir() returns false, resolving symlinks, ./.. segments, and other minor path normalization issues before giving up
  • on_open_urls has a Windows-only fallback: if Url::parse() fails on a bare C:\... path, it converts to a file:/// URL before retrying

Root cause

The Windows Explorer context menu passes raw filesystem paths via %1/%V without URL-encoding them into the warp:// URI query string. While the url crate handles bare backslashes and drive-letter colons correctly in most cases, the resulting PathBuf can still fail the is_dir() gate in path_if_directory() — for example when the OS needs a canonicalized form (symlinks, trailing separators, \?\ prefix, etc.). When that happens the initial directory is silently dropped and the new tab falls back to ~.

Verified by running actual Rust tests:

Input: warp://action/new_tab?path=C:\Projects\my-app
  decoded: "path"="C:\Projects\my-app"   ← correct
  PathBuf: "C:\Projects\my-app"           ← correct

The URL parsing itself works fine — the issue is downstream in path_if_directory where is_dir() can fail for paths that need canonicalization.

Test plan

  • Right-click a folder in Windows Explorer → "Open Warp in new tab" → verify it opens at the selected directory
  • Right-click empty space inside a folder → "Open Warp in new tab" → verify it opens at the current directory
  • Right-click a folder with spaces in the name → verify it works
  • Right-click a folder that is a symlink/junction → verify it resolves correctly
  • "Open Warp in new window" variants also work

Closes #9844
Related: #6665 (Linux counterpart), #6143 (duplicate instances)

🤖 Generated with Claude Code

…nstead of selected directory (warpdotdev#9844)

The Windows Explorer context menu passes raw filesystem paths via `%1`/`%V`
without URL-encoding them into the `warp://` URI query string. While the
`url` crate handles bare backslashes and drive-letter colons correctly in
most cases, the resulting `PathBuf` can still fail the `is_dir()` gate in
`path_if_directory()` — for example when the OS needs a canonicalized form
(symlinks, trailing separators, `\?\` prefix, etc.). When that happens the
initial directory is silently dropped and the new tab falls back to `~`.

Three changes:

1. `parse_tab_path` now trims trailing whitespace from the decoded path,
   catching an edge-case where `%1`/`%V` expansion appends invisible chars.

2. `path_if_directory` now falls back to `std::fs::canonicalize()` when
   `is_dir()` returns false, resolving symlinks, `.` / `..` segments, and
   other minor path normalization issues before giving up.

3. `on_open_urls` now has a Windows-only fallback: if `Url::parse()` fails
   on a bare `C:\...` path, it converts it to a `file:///` URL before
   retrying. This is a defense-in-depth measure for any code path that
   receives a raw Windows path instead of a properly-formatted URI.

Closes warpdotdev#9844

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 1, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @KuaaMU on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 1, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 1, 2026

@KuaaMU

I ran into an unexpected error while working on this.

You can view the conversation on Warp.

Powered by Oz

@KuaaMU
Copy link
Copy Markdown
Author

KuaaMU commented May 1, 2026

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label May 1, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 1, 2026

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: 'Open Warp in New Tab' from Explorer context menu doesn't navigate to current directory on Windows

1 participant