fix/windows path normalization(#21441)#21852
fix/windows path normalization(#21441)#21852chenyy9527 wants to merge 3 commits intoanomalyco:devfrom
Conversation
…omalyco#21441) On Windows, directory paths used backslashes which caused cache key mismatches in Maps (booting, sdkCache, sessionMeta, queue, prefetch, seen). Extract Filesystem.posixPath() on the server and consistently use workspaceKey() on the client so all lookups use normalized paths.
… compatibility (anomalyco#21441) - Update project.test.ts to use Filesystem.posixPath for sandbox comparisons - Update global-session-list.test.ts to use Filesystem.posixPath for worktree comparisons - Add unit tests for posixPath, contains, and overlaps
…-normalization # Conflicts: # packages/app/src/context/sync.tsx # packages/opencode/src/server/instance.ts
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found several potentially related PRs addressing Windows path handling issues: Related/Potentially Duplicate PRs:
Note: The primary results all return PR #21852 (the current PR being checked), so these are the only distinct related PRs found in the search results. |
Closes #21441
Summary
Filesystem.posixPath()and apply to all API responses and session read/write paths for consistent POSIX-style outputcontains()andoverlaps()to returnfalsefor cross-drive paths on WindowsworkspaceKey()for all internal map keys to prevent duplicate caches from mixed path formats (D:/foovsD:\foo)normalizeDirectoryin Session withFilesystem.posixPathposixPath,contains,overlaps; update existing tests for path format consistencyIssue for this PR
Closes #21441
Type of change
What does this PR do?
On Windows, the same directory can have different path formats (
D:/foovsD:\foo), causing:path.relative()returns the target as-is for cross-drive paths, socontains()incorrectly returnedtruefor arbitrary paths like/etc/passwd.booting,sdkCache,sessionMeta, etc.) used raw directory as keys, creating duplicate entries and causing session data loss on store eviction.Fix: Add
isAbsoluteguard tocontains()/overlaps()for cross-drive detection. ExtractposixPath()as single normalization function. Apply it consistently at server API boundaries and client cache keys.How did you verify your code works?
bun typecheckpasses (13/13 packages)posixPath()edge cases: drive roots, trailing slashes, mixed separatorsloadSessionscall paths → API requests → store writes → render, confirming the normalization unifies all paths.Checklist