Skip to content

project: duplicate project rows for the same directory, and archiving is undone on re-resolve #61104

Closed as duplicate

Description

@btranberg

Summary

OpenCode creates multiple project rows for the same canonical directory, and archiving one does not stick. One row is keyed by the repo's first-commit hash; evicting/re-resolving the location creates a second row with a random ID. There is no API/CLI/UI to archive or delete a project, and when a row is archived directly in the database, re-resolving the location (e.g. after a restart) reactivates it.

Environment

  • opencode version: 2.2.0
  • OS: Windows_NT 10.0.26300 (win32 x64)
  • Terminal: xterm-256color (OpenCode desktop app)
  • Shell: pwsh configured; ComSpec C:\Windows\system32\cmd.exe
  • Install/channel: desktop app, latest
  • Active plugins: none

Reproduction

  1. Have several git repositories under a directory tree and open each once so it registers a project (GET /api/location or by using it in the app).
  2. Evict and re-resolve a location:
    • DELETE /api/debug/location?location[directory]=<dir>
    • GET /api/location?location[directory]=<dir>
  3. GET /api/project now returns two entries with the same canonical but different id.
  4. Archive the extra row — there is no API for it, so set time_archived in the project table — then restart OpenCode / re-resolve the location.

Expected Behavior

  • Exactly one project per canonical directory.
  • Re-resolving a location reuses the existing project instead of creating a new row.
  • Archiving/deleting a project is supported and persists.

Actual Behavior

  • Duplicate project rows per canonical directory. In one session, evicting + re-resolving each of 8 locations created 8 extra rows; a later reboot revived one archived row when its location was restored.
  • Archiving is undone by re-resolution: after the reboot, the archived duplicate for the location that was restored became active again, while archived rows for locations that were never touched stayed archived.
  • No supported way to remove or archive a project:
    • GET /api/project supports listing (with an archived filter), and PATCH /api/project/{projectID} accepts only canonical, name, icon, commands — no delete/archive.
    • The desktop app's project client exposes the same two operations.
    • The CLI has no project subcommand.

Additional Context

project table rows for a single directory (illustrative). The first id equals that repo's initial commit hash; the second is random:

id=ec38b3013dbcc4980ad0bc27905420e65743bfec  worktree=C:/lab/projects/home-assistant  vcs=git  name="Home Assistant Configuration"
id=bab03753f2112a6b2bd6f6a5673cdfc2f85232b8  worktree=C:/lab/projects/home-assistant  vcs=git  name=null
  • Frequency: reproducible — a loop of evict + re-resolve over 8 directories produced 8 new rows; the reboot recurrence happened once when a previously-archived location was restored.
  • Workaround: edit the SQLite project table directly (time_archived) to hide the extra rows. This is the only way found; it can be reverted by re-resolution.
Raw active/duplicate counts observed (via the local opencode.db)
total active: 17   total archived: 12
C:/lab/projects/home-assistant  -> 2 active rows (true duplicate)

Activity

  1. opencodejr commented on Nov 1, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report! I think this is a duplicate of #57985.

    The two IDs come from how OpenCode picks a git project's ID: a hash of the origin remote URL is used first, ahead of the stored ID and the root commit. A repo first registered under its root-commit ID (your ec38b30… row) gets a second, remote-derived row (bab0375…) the next time its location is resolved from scratch, for example after an eviction. That is the mechanism described in #57985.

    On the other two points:

    Possible duplicates and related issues, ordered by likelihood:

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, if you see duplicates in a repo with no origin remote, that would be different.

  2. opencodejr commented on Nov 2, 2026

    @opencodejr
    Contributor

    There hasn't been a reply in the past day, so I'm closing this as a duplicate of #57985. The duplicate project rows come from the git project ID switching from the root-commit ID to a remote-derived ID. Please follow #57985 for that, and #51197 / PR #59580 for archiving and deleting projects through the API.

    If your case is different, for example duplicates in a repo with no origin remote, please reply here with the details and we can reopen it. Thanks again for the thorough report!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions