Skip to content

fix(desktop): show ordinary Windows paths in mobile session files - #589

Merged
huichen merged 1 commit into
mainfrom
claude/mobile-session-file-path
Sep 13, 2026
Merged

huichen merged 1 commit into
mainfrom
claude/mobile-session-file-path

Conversation

@huichen

@huichen huichen commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

Opening Session files from a paired phone against a Windows desktop showed the session directory as:

\\?\D:\future-os

\\?\ is the Windows extended-length (verbatim) path prefix. Rust's Path::canonicalize returns that spelling on Windows (GetFinalPathNameByHandleW), and the session-files listing serialized it verbatim — the mobile panel renders listing.path directly, so the user saw the kernel spelling instead of the D:\future-os every Windows tool prints.

macOS/Linux canonicalize returns 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.rs normalizes 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\share becomes \\server\share.

Applied to rootPath, path and every entry path. 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, and canonicalize re-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-tauri only. cargo fmt --check and cargo clippy --all-targets -- -D warnings clean. 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, PermissionDenied on git tempdirs) and a strict subset of the 42 seen without it.

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.
@huichen
huichen enabled auto-merge (squash) September 13, 2026 08:41
@huichen
huichen merged commit ae7c959 into main Sep 13, 2026
12 checks passed
@huichen
huichen deleted the claude/mobile-session-file-path branch September 13, 2026 08:47
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.

1 participant