Repository navigation
Description
Summary
When a copy of an already-opened git repository is added as a project, OpenCode V2.2.6 silently resolves it to the existing project. The project keeps its original canonical directory, so new sessions are created in the old folder. There is no warning, no indication in the UI, and no way to change the canonical path from the desktop app (only PATCH /api/project/{id}). As a result the user's mental model (a new project at the new path) differs from the actual state (the old project at the old path), and edits may silently target the old folder.
Impact
- The user believes they are working in the copied folder, but new sessions and snapshots are created in the old canonical directory. Edits and shell commands can run against the old working tree, and the two copies silently diverge.
- Because the session was created in the old canonical directory, config discovery walked up from that old path and applied its ancestor
opencode.jsonc. The user had just added the new folder and reasonably assumed the old folder's config was irrelevant, but nothing in the UI indicated which directory the session actually used. - In our case that stale ancestor
opencode.jsonccontained a placeholder provider key (<APIキー>, non-ASCII). Every request failed withHeader 'Authorization' has invalid value, even though the moved copy's own config was correct. - The failure is opaque: the desktop app only shows that the conversation does not start. Nothing points at the stale canonical directory or the offending config file, and there is no in-app way to see or change which directory the project actually uses or which config files apply.
- Adding the copy again appears to succeed, so users keep retrying the same non-fix.
Environment
- opencode version: 2.2.6 (OpenCode Desktop, bundled CLI)
- OS: Windows 11 Enterprise 10.0.26100 (win32 x64)
- Terminal: OpenCode Desktop (Electron app), no terminal attached
- Shell: C:\WINDOWS\system32\cmd.exe
- Install/channel: latest (desktop)
- Active plugins: orca-opencode-status (local status helper, not implicated)
Reproduction
- Open repo
Rat<old>/Rin OpenCode Desktop. A project is created; its ID equals R's root commit (e.g.edbcafe6510c...) andGET /api/projectreportscanonical = <old>/R. - Copy/move
Rto<new>/R(same.git, same root commit) and add it as a project in the desktop app. - Start a new session in
<new>/R. GET /api/projectstill reports the old canonical path. The project was not re-registered; the new directory was only added under the existing project.
Expected Behavior
Adding a directory that resolves to an existing project should be visible and actionable, for example:
- show "this repository is already registered as project X at ";
- offer to update the project canonical to the directory being added (the server already supports this via
PATCH /api/project/{id}), or add it explicitly as a sibling directory; - and/or expose "Change project location..." in the desktop UI;
- and show which directory the project/session resolves to and which config files are in effect (or surface the
opencode debug configsources in the UI).
Actual Behavior
Silent reuse. The UI gives no hint that the old path is still authoritative. In our case the old folder had an ancestor opencode.jsonc with a placeholder provider key (<APIキー>, non-ASCII). Because config is resolved from the canonical path's ancestors, that placeholder overrode the global key and every request failed with Header 'Authorization' has invalid value. The desktop app showed only "the conversation does not start"; the real error was only visible in ~/.local/share/opencode/log/opencode.log. Changing the moved copy had no effect because the old directory was still being used.
Additional Context
- DB: a single
projectrow; extra directories appear inworktree.project.worktreestays at the first path. - Project ID = root commit, consistent with worktree: worktree_create targets the project's canonical directory, not the session directory (project ID collision after history import) #58148.
- API check (2.2.6):
GET /api/session/ses_e410fd308ffetrLbqEPEB9ltHs(the failed session) returnslocation.directory = <old>/R; a session created in<new>/Rreturnslocation.directory = <new>/Rwithoutcome: "succeeded". The failing request used the old folder's ancestor config because the session actually ran there (see desktop v2: new session in a git worktree (sandbox) project binds to the project canonical (main worktree) directory instead of the selected worktree #51992 / session: new session created from a project binds to the service default location and is missing from that project's history #51196). - Related: [FEATURE]: Allow renaming/moving a project folder while persisting session history (replacement for stale-closed #25625) #44256 (move a project while preserving sessions), desktop: new-session project chip never reflects sibling directories of the same git repo #55351 (sibling-directory chip), desktop v2: new session in a git worktree (sandbox) project binds to the project canonical (main worktree) directory instead of the selected worktree #51992 (session bound to canonical), closed Desktop 1.18.30: opening a moved Git project reuses its missing canonical path and stale session directories #48278 / [1.18.30 Desktop] Renaming a project folder keeps a stale project.worktree (git-remote project id + close-only "remove project") #48349 (same stale-canonical symptom on V1 desktop; still reproducible on 2.2.6).
- Workaround:
PATCH /api/project/{id}with{"canonical": "<new path>"}. Alternative: copy without.gitand re-init so the root commit differs (loses history).
Activity
opencodejr commentedon Nov 9, 2026
Thanks for the detailed write-up and the workaround.
To restate the request: when you add a directory that resolves to an existing project (same root commit), the desktop app should tell you, show the current location, and let you either make the new directory the project's canonical location or add it on purpose as a sibling. It should also offer a "Change project location..." action instead of needing
PATCH /api/project/{id}.In v2 this reuse is currently intended. Copies of a repo share one project ID, and the stored canonical directory is only replaced when the old folder no longer exists. That is why your copy joined the existing project while the old folder was still there. I've filed this as a feature request for maintainers to consider.
One detail may be a separate bug. Config is normally found by walking up from the session's own directory, not the project's canonical one. If the placeholder key from the old folder's
opencode.jsoncwas used for a session you started in<new>/R, the session may have actually run in the old folder. That would be related to #51992 / #51196. If you can confirm which directory that session shows (for example itsdirectoryin the API), that would help.Related issues:
kaito-toyama commentedon Nov 9, 2026
Thanks — confirmed, and your hypothesis is right.
GET /api/session/ses_e410fd308ffetrLbqEPEB9ltHs(the failed session) returns:{"outcome":"failed","location":{"directory":"<old>/R"}}i.e. its
location.directoryis the old canonical folder, not the<new>/Rfolder that had just been added. A session created in<new>/Rat the same time returnslocation.directory = <new>/Rand succeeds (outcome: "succeeded"). So config discovery did walk up from the session's own directory — the problem is that the session itself was created in the old canonical directory, i.e. the #51992 / #51196 behavior.The desktop UI gave no indication of that: the new folder had just been added, and the failed session looked like it belonged to it.
I've updated the issue body to correct the "config resolved from the canonical directory" wording and point that part at #51992 / #51196. The feature request part (notify when adding a directory that resolves to an existing project, show the current location, allow changing the canonical or adding it as a sibling) still stands.
neriousy commentedon Dec 2, 2026
Thanks for the report! This looks like the same bug as #67333, so I'm closing this one to keep the discussion in one place. If yours turns out to be different, leave a comment and we'll reopen it.