Skip to content

[Bug] Desktop: removing a project does not purge cache, re-adding resurrects stale path #47803

Closed as not planned

Description

@leandro-costa

Bug report — Desktop: removing a project does not purge cache, re-adding resurrects stale config

Gerado a partir do caso real 2026-09-07. Repo alvo: anomalyco/opencode (dev, template .github/ISSUE_TEMPLATE/bug-report.yml).

Description

Removing a project in Opencode Desktop (sidebar > remove) does not remove it from the persisted cache. When the user re-adds the project from its new location, Desktop silently resolves back to the old project record and resurrects the old configuration instead of using the new folder.

Concrete case:

  • Old location (deleted/moved): D:\IFBA\20252_TCC\orientador-llm (D:/IFBA/20252_TCC/orientador-llm)
  • New location: D:\IFBA\OCI\vibe-code\orientador-llm (D:/IFBA/OCI/vibe-code/orientador-llm)
  • After remove + re-add, any prompt (including openspec skills) fails before the LLM call with:
level=ERROR run=690f44ca/5fb9df8f/b8feb4ba message=failed
error="PlatformError: NotFound: FileSystem.realPath (D:/IFBA/20252_TCC/orientador-llm)
  (cause: ENOENT: no such file or directory, lstat 'D:\\IFBA\\20252_TCC\\orientador-llm')"
cause="...@opencode-aidesktop/resources/app.asar/..."

followed by:

message="prompt_async failed" sessionID=ses_f83c2ca20ffe4IiHQT04XDX4cg
cause="Die(PlatformError: NotFound: FileSystem.realPath (D:\\IFBA\\20252_TCC\\orientador-llm) ...)"

Test-Path D:\IFBA\20252_TCC\orientador-llm = False. The real directory is D:\IFBA\OCI\vibe-code\orientador-llm (confirmed in the same log at 14:23:49 creating instance).

Plugins

openspec skills (openspec-propose, openspec-explore, openspec-apply-change, openspec-archive-change, openspec-sync-specs) installed in both .claude/skills and .opencode/skills (duplicate-skill WARNs in log, non-fatal). No custom Desktop plugins relevant.

OpenCode version

  • CLI: 1.18.28 (opencode --version)
  • Desktop sessions in log: version=1.18.29 (e.g. ses_f8411b479ffeMkTySSrRPjVa9k, ses_f83c2ca20ffe4IiHQT04XDX4cg)
  • Sidecar: @opencode-aidesktop (Electron, app.asar/out/main/chunks/node-C7Unr5h8.js)

Steps to reproduce

  1. Have a Desktop project at D:\IFBA\20252_TCC\orientador-llm, with sessions.
  2. Move the folder on disk to D:\IFBA\OCI\vibe-code\orientador-llm (old path ceases to exist).
  3. In Desktop, remove the project from the sidebar.
  4. Re-add the project selecting the new folder D:\IFBA\OCI\vibe-code\orientador-llm.
  5. Open a session and send any prompt (e.g. invoke openspec skill).
  6. Observe PlatformError: NotFound ... D:/IFBA/20252_TCC/orientador-llm and prompt_async failed. Log: C:\Users\leandro\.local\share\opencode\log\opencode.log (167k lines, 07/09 14:16–14:23, runs 690f44ca, 5fb9df8f, b8feb4ba).

Screenshot and/or share link

No /share link (prompt never reaches the LLM). Evidence excerpts above are from opencode.log tail. Full log available on request (36 MB).

Operating System

Windows 11 x64, Test-Path PowerShell, project on D:\.

Terminal

  • C:\Program Files\PowerShell\7\pwsh.EXE (PowerShell 7.5.5, also 7.6.2 banner in pty buffer)
  • Desktop pty: pty_ed090b7db001Vn66Ap04zsVDVa

Root cause (found while debugging, to help maintainers)

Three persistence layers keep pointing at the old path after UI removal:

  1. C:\Users\<user>\AppData\Roaming\ai.opencode.desktop\opencode.global.dat → key server:

    {"projects":{"local":[
      {"worktree":"D:\\IFBA\\20252_TCC\\orientador-llm","expanded":true},
      ...
    ]},"lastProject":{"local":"D:\\IFBA\\OCI\\vibe-code\\orientador-llm"}}

    The old worktree entry survives UI removal.

  2. C:\Users\<user>\.local\share\opencode\opencode.db → project id=edca4e2b38f99bd7ac7dfc0078a04fb682afe27f:

    worktree='D:/IFBA/20252_TCC/orientador-llm'
    sandboxes='["D:/IFBA/OCI/vibe-code/orientador-llm"]'
    

    plus project_directory:

    edca... | D:/IFBA/OCI/vibe-code/orientador-llm
    

    The new folder was registered as a sandbox alias of the old project, so re-adding resolves to the same project_id and resurrects old state. session table for this project shows 8 rows split across both directories (4 old + 4 new).

  3. opencode.workspace.RDpcSUZCQVwy.*.dat (5 files) — prefix is base64 of the old path:
    RDpcSUZCQVwyMDI1Ml9UQ0Ncb3JpZW50YWRvci1sbG0 → D:\IFBA\20252_TCC\orientador-llm.
    Layout sessionTabs keys also embed it: local␀RDpcSUZCQVwyMDI1Ml9UQ0Ncb3JpZW50YWRvci1sbG0/ses_....

Related history in log: WARN duplicate skill name for openspec (.claude/skills vs .opencode/skills) and older ERROR failed to load skill ENOENT in worktree .../quiet-nebula/.opencode/skills/openspec-* (2026-07-09) — same stale-path family.

Suggested fix

  • On project removal in Desktop, purge all three layers (or tombstone with explicit user consent): remove server.projects.local[] entry in opencode.global.dat, delete project + project_directory rows (or cascade/archive sessions), and delete opencode.workspace.<b64-old-path>.*.dat + related layout.sessionTabs keys.
  • On project add, if worktree does not exist on disk (lstat ENOENT), do not silently alias via sandboxes: show a "path not found / moved?" dialog offering Migrate (UPDATE project.worktree, clear sandboxes) vs Remove stale record.
  • Normalize Windows paths (\ vs /, case) before hashing/comparing project_id so D:\IFBA\... and D:/IFBA/... do not fork.
  • Guard FileSystem.realPath at bootstrap: fail fast with actionable UI error ("project folder moved — update or remove") instead of prompt_async failed on every message.
  • Consider a Vacuum / Prune missing projects action in Desktop settings + CLI (opencode project prune --missing).

Workaround used

Close Desktop, backup .dat/.db, delete old worktree object from global.dat, run UPDATE project SET worktree='D:/IFBA/OCI/vibe-code/orientador-llm', sandboxes='[]' WHERE id='edca...', delete stale opencode.workspace.RDpcSUZCQVwy.*.dat. Script saved at D:\IFBA\OCI\vibe-code\orientador-llm\.temp\fix-desktop-workspace.ps1.

Activity

  1. github-actions commented on Sep 7, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. 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

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