Skip to content

desktop: adding a copy of an existing repo silently reuses the original project and stale canonical directory #62842

Duplicate

Description

@kaito-toyama

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.jsonc contained a placeholder provider key (<APIキー>, non-ASCII). Every request failed with Header '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

  1. Open repo R at <old>/R in OpenCode Desktop. A project is created; its ID equals R's root commit (e.g. edbcafe6510c...) and GET /api/project reports canonical = <old>/R.
  2. Copy/move R to <new>/R (same .git, same root commit) and add it as a project in the desktop app.
  3. Start a new session in <new>/R.
  4. GET /api/project still 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 config sources 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

Activity

  1. opencodejr commented on Nov 9, 2026

    @opencodejr
    Contributor

    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.jsonc was 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 its directory in the API), that would help.

    Related issues:

  2. kaito-toyama commented on Nov 9, 2026

    @kaito-toyama
    Author

    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.directory is the old canonical folder, not the <new>/R folder that had just been added. A session created in <new>/R at the same time returns location.directory = <new>/R and 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.

  3. neriousy commented on Dec 2, 2026

    @neriousy
    Member

    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.

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