fix: keep sessions discoverable for non-git projects on Windows - #40503
fix: keep sessions discoverable for non-git projects on Windows#40503BB-84C wants to merge 1 commit into
Conversation
Non-git projects use worktree "/", and on Windows path.resolve("/")
resolves to the drive root of the current process. sessionPath() therefore
stored a machine-dependent absolute path (e.g. "D:/repo") that the session
list query's worktree-relative match can never find, hiding those sessions
from the picker.
- sessionPath(): return undefined when the worktree-relative result is
absolute (cross-volume / non-git Windows), so sessions fall back to the
existing directory-based scoping in the list query.
- TUI session list: pass directory alongside path so the server can match
pathless rows.
- Migration: NULL out legacy absolute/empty paths so existing sessions
become visible again.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #35750
Type of change
What does this PR do?
Sessions created in non-git projects on Windows can disappear from the session picker.
Non-git projects use worktree
"/"(set inProject.fromDirectory). On Windows,path.resolve("/")resolves to the drive root of the current process, sosessionPath()produced a machine-dependent absolute path likeD:/repoand stored it insession.path. The session list query matches paths relative to the worktree, so those rows never matched and the sessions vanished from the picker. Which sessions were visible depended on which drive root the server process happened to be rooted at. Related reports: #37041, #37353, #38780.Changes:
sessionPath()returnsundefinedwhen the worktree-relative result is absolute (cross-volume, which is what happens for non-git worktrees on Windows). Sessions without a usable path fall back to the existing directory-based scoping inlistByProject(path IS NULL AND directory = ?).directoryalongsidepath, which is what makes the directory fallback reachable for project instances. POSIX behavior and git-project behavior are unchanged (the path condition still matches first).20260804120000_normalize_session_pathNULLs out legacy absolute/empty paths so existing sessions become visible again after upgrade.How did you verify your code works?
sessionPath(win32 cross-volume returns undefined, same-volume keeps relative, posix unchanged) inpackages/opencode/test/session/session-path.test.ts.packages/opencode/test/server/session-list.test.ts: a NULL-path session is listed whendirectoryis provided and stays hidden without it. 12/12 pass in that file.tsgo --noEmitpasses foropencode,tui, andcore; oxlint clean on changed files.D:\BB84.ai): built the fork binary, pointed it at a snapshot copy of a real production DB (16,873 sessions, including rows with stored absolute paths likeD:/BB84.aiand empty paths), enabled session directory filtering in the TUI, and confirmed sessions remain visible instead of being lost. The migration was exercised on the snapshot only; the production DB was not modified.Screenshots / recordings
No screenshots - verification was done interactively in the TUI.
Checklist