anomalyco / anomalyco/opencode
[Bug] Desktop: removing a project does not purge cache, re-adding resurrects stale path
@Hona is already working on this.
Since Sep 7, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
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
- Have a Desktop project at
D:\IFBA\20252_TCC\orientador-llm, with sessions. - Move the folder on disk to
D:\IFBA\OCI\vibe-code\orientador-llm(old path ceases to exist). - In Desktop, remove the project from the sidebar.
- Re-add the project selecting the new folder
D:\IFBA\OCI\vibe-code\orientador-llm. - Open a session and send any prompt (e.g. invoke openspec skill).
- Observe
PlatformError: NotFound ... D:/IFBA/20252_TCC/orientador-llmandprompt_async failed. Log:C:\Users\leandro\.local\share\opencode\log\opencode.log(167k lines, 07/09 14:16–14:23, runs690f44ca,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:
-
C:\Users\<user>\AppData\Roaming\ai.opencode.desktop\opencode.global.dat→ keyserver:{"projects":{"local":[ {"worktree":"D:\\IFBA\\20252_TCC\\orientador-llm","expanded":true}, ... ]},"lastProject":{"local":"D:\\IFBA\\OCI\\vibe-code\\orientador-llm"}}The old
worktreeentry survives UI removal. -
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-llmThe new folder was registered as a sandbox alias of the old project, so re-adding resolves to the same
project_idand resurrects old state.sessiontable for this project shows 8 rows split across both directories (4 old + 4 new). -
opencode.workspace.RDpcSUZCQVwy.*.dat(5 files) — prefix is base64 of the old path:
RDpcSUZCQVwyMDI1Ml9UQ0Ncb3JpZW50YWRvci1sbG0→D:\IFBA\20252_TCC\orientador-llm.
LayoutsessionTabskeys 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 inopencode.global.dat, deleteproject+project_directoryrows (or cascade/archive sessions), and deleteopencode.workspace.<b64-old-path>.*.dat+ relatedlayout.sessionTabskeys. - On project add, if
worktreedoes not exist on disk (lstat ENOENT), do not silently alias viasandboxes: show a "path not found / moved?" dialog offering Migrate (UPDATEproject.worktree, clearsandboxes) vs Remove stale record. - Normalize Windows paths (
\vs/, case) before hashing/comparingproject_idsoD:\IFBA\...andD:/IFBA/...do not fork. - Guard
FileSystem.realPathat bootstrap: fail fast with actionable UI error ("project folder moved — update or remove") instead ofprompt_async failedon every message. - Consider a
Vacuum / Prune missing projectsaction 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.