Description
When creating a new workspace from a project opened inside a subdirectory of a Git repository, the workspace is created successfully, but its associated directory points to the root of the new worktree instead of the equivalent subdirectory inside that worktree.
For example, if opencode is opened at:
/repo/apps/web
and /repo is the Git repository root, creating a new workspace currently targets something like:
~/.local/share/opencode/worktree/<project>/<workspace>
I would expect it to target:
~/.local/share/opencode/worktree/<project>/<workspace>/apps/web
This causes the new workspace to lose the original project context when working in monorepos or repositories with nested projects.
From a quick look at the implementation, opencode already distinguishes the opened directory from the Git worktree root. Project.fromDirectory() discovers both the Git root/worktree and the sandbox/opened directory, but workspace creation appears to only carry the project ID forward. The worktree adapter then uses the new worktree root as the workspace target directory.
Plugins
None
OpenCode version
1.14.39
Steps to reproduce
- Create or use a Git repository with a nested project, for example
/repo/apps/web.
- Open opencode from the nested directory:
/repo/apps/web.
- Create a new workspace.
- Inspect or switch into the new workspace.
- Observe that the workspace directory is the new worktree root instead of the corresponding nested directory.
Screenshot and/or share link
N/A
Operating System
macOS
Terminal
OpenCode Desktop
Description
When creating a new workspace from a project opened inside a subdirectory of a Git repository, the workspace is created successfully, but its associated directory points to the root of the new worktree instead of the equivalent subdirectory inside that worktree.
For example, if opencode is opened at:
/repo/apps/weband
/repois the Git repository root, creating a new workspace currently targets something like:~/.local/share/opencode/worktree/<project>/<workspace>I would expect it to target:
~/.local/share/opencode/worktree/<project>/<workspace>/apps/webThis causes the new workspace to lose the original project context when working in monorepos or repositories with nested projects.
From a quick look at the implementation, opencode already distinguishes the opened directory from the Git worktree root.
Project.fromDirectory()discovers both the Git root/worktree and the sandbox/opened directory, but workspace creation appears to only carry the project ID forward. The worktree adapter then uses the new worktree root as the workspace target directory.Plugins
None
OpenCode version
1.14.39
Steps to reproduce
/repo/apps/web./repo/apps/web.Screenshot and/or share link
N/A
Operating System
macOS
Terminal
OpenCode Desktop