Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

fix(project): use cwd instead of "/" when .git is not found#16484

Closed
rareboe wants to merge 1 commit intoanomalyco:devfrom
rareboe:fix/project-cwd-fallback
Closed

fix(project): use cwd instead of "/" when .git is not found#16484
rareboe wants to merge 1 commit intoanomalyco:devfrom
rareboe:fix/project-cwd-fallback

Conversation

@rareboe
Copy link

@rareboe rareboe commented Mar 7, 2026

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

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When running opencode in a directory without a .git folder, Project.fromDirectory() traverses up the directory tree looking for .git. If none is found, the fallback sets worktree and sandbox to "/" (root filesystem).

This causes the web UI to display / as the working directory, which is incorrect. The fix changes the fallback to use the original directory parameter (the actual CWD) instead of "/".

Changed file: packages/opencode/src/project/project.ts line 199-204

- worktree: "/",
- sandbox: "/",
+ worktree: directory,
+ sandbox: directory,

How did you verify your code works?

Ran opencode in a directory without .git and confirmed the web UI shows the correct CWD instead of /.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • No issue referenced. Please add Closes #<number> linking to the relevant issue.

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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

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.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 7, 2026
@github-actions github-actions bot closed this Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant