Repository navigation
fix(desktop): show ordinary Windows paths in mobile session files - #589
Merged
Merged
Conversation
Windows \Path::canonicalize\ returns the extended-length spelling (\\\\\?\\D:\\...\). The session-files listing for paired phones serialized it verbatim, so the mobile panel rendered \\\\\?\\D:\\future-os\ as the session directory instead of the \D:\\...\ every Windows tool prints. Strip the prefix where the listing crosses to the client, mirroring the agent sandbox's path model (\�gent/src/sandbox/paths.rs\); \\\\\?\\UNC\\server\\share\ becomes \\\\\server\\share\. Containment checks keep using the canonical path, and the phone's round-tripped paths re-canonicalize on the way back in. The old assertions compared two canonicalized spellings, which is self-consistent and passed either way; assert the prefix is absent instead so a regression fails.
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.
Problem
Opening Session files from a paired phone against a Windows desktop showed the session directory as:
\\?\is the Windows extended-length (verbatim) path prefix. Rust'sPath::canonicalizereturns that spelling on Windows (GetFinalPathNameByHandleW), and the session-files listing serialized it verbatim — the mobile panel renderslisting.pathdirectly, so the user saw the kernel spelling instead of theD:\future-osevery Windows tool prints.macOS/Linux
canonicalizereturns an ordinary path, which is why this is Windows-only and CI (Linux-only desktop tests) never caught it.Fix
desktop/src-tauri/src/remote_host/session_files.rsnormalizes the prefix away where the listing crosses to the client — the same normalization the agent's sandbox already applies to its rule paths (agent/src/sandbox/paths.rs).\\?\UNC\server\sharebecomes\\server\share.Applied to
rootPath,pathand every entrypath. The function is purely textual: a canonical POSIX path never carries the prefix, so it is a no-op off Windows.Safety is unchanged — containment checks (
starts_with(root), symlink/junction escape, credential files) all keep using the canonical path. Directory navigation still round-trips: the phone sends back the path it was shown,root.join(...)replaces the root, andcanonicalizere-applies the prefix for the check.Why the tests changed
The existing assertions compared two canonicalized spellings (
listing.path == root.canonicalize()...), which is self-consistent and passes either way — that is exactly why this shipped. They now assert the prefix is absent, which is what actually catches the regression; the root/target directory equality is retained semantically by re-canonicalizing.Verified locally on Windows by temporarily neutering the normalizer: the new assertions fail (
left: "\\\\?\\D:\\future-os\\src") and pass once restored.Scope
desktop/src-taurionly.cargo fmt --checkandcargo clippy --all-targets -- -D warningsclean. Targeted tests (session_files,presence_and_catalog_commands) pass. The full desktop suite shows no new failures — every failure with this change (26) is a pre-existing local Windows environment failure (Os code 5, PermissionDeniedon git tempdirs) and a strict subset of the 42 seen without it.