Skip to content

Project retains stale worktree path in SQLite when repository root is moved or renamed #50023

Closed as not planned

Description

@rapha4lx

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

  1. Open OpenCode in a git repository at /path/A.
  2. Move or rename the repository directory to /path/B.
  3. Open OpenCode in /path/B.
  4. In SQLite ProjectTable, worktree remains /path/A and /path/B is added to sandboxes.

Operating System

Linux

Activity

  1. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions