fix(session): anchor non-git session paths to the directory drive - #41568
Open
wxj006007 wants to merge 1 commit into
Open
fix(session): anchor non-git session paths to the directory drive#41568wxj006007 wants to merge 1 commit into
wxj006007 wants to merge 1 commit into
Conversation
Non-git projects synthesize a worktree of "/" (project.ts). On Windows
path.resolve("/") anchors to the launch drive root, so the same directory
could store sessions under different relative paths ("Users/..." vs
"Dev/...") depending on which drive opencode was started from, which
made session.path unstable and hid sessions from path-based filters.
- sessionPath(): anchor a synthetic "/" worktree to the directory own
drive root so stored paths are deterministic (no-op on POSIX where the
root is always "/"); also reused by cli import to avoid drift.
- tests: unit coverage for sessionPath and server coverage for
project-wide (scope project) listing of non-git sessions.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Found a related PR that may be addressing similar Windows session path issues: Related PR:
The current PR (#41568) appears to be a more targeted fix that ensures stored session paths are deterministic across different drive launches on Windows, while #40503 may have addressed an earlier aspect of the same problem. You may want to check if #40503 is still open/merged and whether it fully resolves the underlying issue or if this PR provides a complementary fix. |
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.
Issue for this PR
Closes #41567
Type of change
What does this PR do?
On Windows, non-git projects get a synthetic worktree of
"/"(project.ts).path.relative(path.resolve("/"), cwd)then anchors the relative path to the drive root of the process working directory, so the same directory stores differentsession.pathvalues depending on which drive opencode was launched from (Users/...vsDev/..., or absolute-styleC:/Users/...when crossing drives). Path-based directory filtering in/sessionsthen hides sessions depending on the launch drive.The fix anchors a synthetic
"/"worktree to the directory's own drive root (path.parse(dir).root) when computingsessionPath(), making stored paths deterministic and independent of the launch drive. On POSIX the root is always"/"so behavior is unchanged.cli/import.tshad a second copy of the same path logic and now reusessessionPath()to avoid drift.Note: same-directory visibility from
/sessionsis scoped by directory in #38532; this PR makes the underlying stored paths stable on Windows.How did you verify your code works?
sessionPath()covering the git worktree, non-git"/"worktree, and cross-drive absolute results.scope: "project") listing and for listing non-git sessions stored relative to the directory root.bun run typecheckinpackages/opencodeand the TUI tests.C:remain listed under a path anchored toC:, and no longer produce drive-dependent relative paths.Screenshots / recordings
N/A (not a UI change)
Checklist