Skip to content

project: no way to remove a project entry (stale dirs accumulate in Ctrl+O) #58197

Closed as duplicate

Description

@rlueder

Summary

There is no way to remove a project entry. Any directory opencode is ever run in (or a session is imported into) becomes a permanent row in the project table and shows up in the Ctrl+O "Open session or project" picker forever, even after every session in it has been deleted. Temp dirs, scratch workspaces, and one-off worktrees accumulate as noise with no supported cleanup.

Environment

  • opencode version: 2.0.25
  • OS: Darwin 25.6.0 (darwin arm64)
  • Terminal: ghostty (TERM=xterm-ghostty, COLORTERM=truecolor)
  • Shell: /bin/zsh
  • Install/channel: latest (Homebrew)
  • Active plugins: none configured globally; a repo-local .opencode/plugins/ spike exists in one project but was not involved

Reproduction

  1. cd "$(mktemp -d)" && opencode run "hi" (or opencode session import --directory <tmpdir> file.json).
  2. opencode session delete <that session id> so the project has zero sessions.
  3. Press Ctrl+O in the TUI, or opencode api get /api/project.

The temp directory is still listed as a project.

Expected Behavior

One of:

  • A project.remove operation (API DELETE /api/project/{projectID}, a TUI command in the Ctrl+O picker / command palette, and/or opencode project remove <dir>), ideally refusing or confirming when the project still has sessions.
  • Or, at minimum, empty projects being pruned automatically (e.g. when their last session is deleted, or when the canonical directory no longer exists).

Actual Behavior

  • The HTTP API only exposes GET /api/project and PATCH /api/project/{projectID} (checked in /openapi.json for 2.0.25); there is no delete.
  • The TUI has no remove/hide action for projects; the palette commands touching projects are "Open session or project", "Return to projects", and "Show project worktrees".
  • opencode session delete removes the session but leaves the project row.

After importing ~130 sessions from other tools and deleting the junk ones, I was left with 15 dead project entries (macOS $TMPDIR subdirs, Claude desktop scratch-workspaces/…, ~/Downloads, ~/Documents, worktrees that no longer exist). The only way to clean them was to edit opencode.db directly:

PRAGMA foreign_keys = ON;
DELETE FROM project WHERE id IN (...)
  AND (SELECT count(*) FROM session    s WHERE s.project_id = project.id) = 0
  AND (SELECT count(*) FROM session_v2 s WHERE s.project_id = project.id) = 0;

which worked (the project FKs cascade), but is exactly what the troubleshooting docs tell users not to do.

Additional Context

  • Reproducible consistently.
  • Related: the project list is the only navigation surface for sessions across directories, so stale entries directly degrade Ctrl+O. Even a hidden/archived flag settable via the existing PATCH /api/project/{projectID} would be a workable first step.

Activity

  1. opencode-agent commented on Oct 22, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up and the SQL workaround! I think this is a duplicate of #51197, which reports the same gap on v2: there is no API (only GET and PATCH on /api/project) or UI action to remove a project entry, so stale rows can only be cleaned up by editing opencode.db.

    Possible duplicates and closely related issues, ordered from most to least likely:

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. Your suggestion to prune empty projects automatically, or to add a hidden/archived flag through the existing PATCH, would be a useful addition on #51197.

  2. neriousy commented on Oct 23, 2026

    @neriousy
    Member

    Closing as a duplicate of #51197. The TUI Ctrl+O reproduction and the auto-prune/hidden-archive suggestions have been transferred to that canonical issue.

  3. opencode-agent commented on Oct 23, 2026

    @opencode-agent
    Contributor

    Closing this as a duplicate of #51197, since there has been no reply in the last day saying how this differs. That issue covers the same gap: there is no API or UI to remove a project entry, so stale directories pile up in the project list. Please follow #51197 for updates. Your idea of pruning empty projects automatically, or adding a hidden/archived flag through the existing PATCH /api/project/{projectID}, would be a useful comment there. Related: #49442 and #37280. If your case turns out to be different, reply here and we can 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions