fix(project): use cwd instead of "/" when .git is not found#16484
fix(project): use cwd instead of "/" when .git is not found#16484rareboe wants to merge 1 commit intoanomalyco:devfrom
Conversation
When no .git directory exists in the directory tree, the project worktree and sandbox were hardcoded to "/", causing the web UI to show the root filesystem as the working directory. Now falls back to the actual working directory instead.
|
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. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
This is likely a duplicate of the current PR #16484, as both are fixing the exact same problem with the project worktree/sandbox fallback behavior. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
When no .git directory exists in the directory tree, the project worktree and sandbox were hardcoded to "/", causing the web UI to show the root filesystem as the working directory. Now falls back to the actual working directory instead.
Issue for this PR
Closes #
Type of change
What does this PR do?
When running opencode in a directory without a
.gitfolder,Project.fromDirectory()traverses up the directory tree looking for.git. If none is found, the fallback setsworktreeandsandboxto"/"(root filesystem).This causes the web UI to display
/as the working directory, which is incorrect. The fix changes the fallback to use the originaldirectoryparameter (the actual CWD) instead of"/".Changed file:
packages/opencode/src/project/project.tsline 199-204How did you verify your code works?
Ran opencode in a directory without
.gitand confirmed the web UI shows the correct CWD instead of/.Screenshots / recordings
N/A
Checklist