Uh oh!
There was an error while loading. Please reload this page.
fix: normalize Windows paths in session directory SQL queries - #34806
fix: normalize Windows paths in session directory SQL queries#34806VoidPurifier wants to merge 1 commit into
Conversation
SessionTable.directory stores paths in POSIX format (D:/Workspace) via directoryColumn.toDriver(). Query side passed raw Windows paths (D:\Workspace with backslashes) to eq(), causing SQLite byte-level comparison to fail — session list returned zero results on Windows. Applied dbDir() normalization helper (win32: \\ -> /) to all 5 eq(SessionTable.directory, ...) call sites across 3 files.
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
Related PR:
Check PR #30367 in detail—it may already solve this problem or provide relevant context for the current fix. |
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
VoidPurifier
commented
Jul 2, 2026
Correction: the actual root cause is differentThe What the DB revealedAll 1052 sessions (from first use on May 24 to present) have:
No session has ever been stored with a real workspace directory. Why this happensStorage side — constrepo=yield*git.repo.discover(input)if(!repo)return{id: ID.global,directory: AbsolutePath.make(path.parse(input).root),vcs: undefined}When no git repo is found (user works outside a git repo, or discovery fails), it returns the drive root ( Query side — if("directory"ininput)conditions.push(eq(SessionTable.directory,dbDir(input.directory)))The web app's Why the backslash fix is insufficientDrizzle's Suggested proper fixOption A — Change if(!repo)return{id: ID.global,directory: input,vcs: undefined}Sessions would then store the user's real working directory. Option B — Skip directory filter for global-project sessions in if("directory"ininput&&input.directory!=="C:/"){conditions.push(eq(SessionTable.directory,dbDir(input.directory)))}Or better, check against the project ID when available. This PR's statusThe |
Hona
commented
Jul 2, 2026
Thanks for the effort here, but closing this as the change is a no-op. Path separator handling was fixed in #29666 (shipped in v1.16.0) at the database boundary: This is covered by an existing test: Your follow-up comment reaches the same conclusion, so no disagreement there. The |
What does this PR do?
Fixes path separator mismatch on Windows where
SessionTable.directorystores paths in POSIX format (D:/Workspace) but query parameters arrive with backslashes (D:\Workspace), causing SQLite exact-match to fail and session lists to appear empty.Added
dbDir()normalization (\\ -> /on win32 only) to all 5eq(SessionTable.directory, ...)call sites across 3 files:packages/core/src/session.ts—V2Session.listpackages/opencode/src/session/session.ts—listGlobal,listByProject(2x)packages/opencode/src/project/project.ts— project migration queryType of change
How did you verify your code works?
packages/opencodesuccessfully (bun run build)process.platform === "win32"guard)Checklist
Issue for this PR
Fixes#30374