Description
In packages/opencode/src/project/project.ts, Project.fromDirectory resolves the active directory (worktree = data.id === ProjectV2.ID.make("global") && !data.vcs ? "/" : data.directory).
However, when an existing project row is fetched from SQLite (ProjectTable), it unconditionally preserves the historical worktree:
const result: Info = {
...existing,
worktree: projectID === ProjectV2.ID.global ? worktree : existing.worktree,
vcs: data.vcs?.type ?? fakeVcs,
time: { ...existing.time, updated: Date.now() },
}
If a repository is moved to a new path or migrated across users, existing.worktree points to an obsolete directory that no longer exists on disk. Because data.directory !== result.worktree, OpenCode treats the active repository as a sandbox of the dead worktree (result.sandboxes.push(data.directory)). Downstream operations (such as favicon discovery or watchers) then continue targeting the non-existent worktree.
OpenCode version
1.18.31
Steps to reproduce
- Open OpenCode in a git repository at
/path/A.
- Move or rename the repository directory to
/path/B.
- Open OpenCode in
/path/B.
- In SQLite
ProjectTable, worktree remains /path/A and /path/B is added to sandboxes.
Operating System
Linux
Description
In
packages/opencode/src/project/project.ts,Project.fromDirectoryresolves the active directory (worktree = data.id === ProjectV2.ID.make("global") && !data.vcs ? "/" : data.directory).However, when an existing project row is fetched from SQLite (
ProjectTable), it unconditionally preserves the historical worktree:If a repository is moved to a new path or migrated across users,
existing.worktreepoints to an obsolete directory that no longer exists on disk. Becausedata.directory !== result.worktree, OpenCode treats the active repository as a sandbox of the dead worktree (result.sandboxes.push(data.directory)). Downstream operations (such as favicon discovery or watchers) then continue targeting the non-existent worktree.OpenCode version
1.18.31
Steps to reproduce
/path/A./path/B./path/B.ProjectTable,worktreeremains/path/Aand/path/Bis added tosandboxes.Operating System
Linux