Repository navigation
Description
Description
On OpenCode Desktop (v1.18.14, macOS arm64), renaming a project folder in Finder (outside OpenCode) permanently breaks the project↔directory binding. The app keeps a phantom project whose worktree/project_directory point to non-existent paths, the project display name cannot be changed, and new sessions silently fall back to the global project (or fail to start when clicking the phantom).
To Reproduce
- Create a project in OpenCode Desktop (folder
A). Rename the project in-app to e.g. "DarkRain" → Save. - Rename folder
A→Bin Finder, then rename the project in-app → name does not change. - Rename folder
B→Cin Finder. Delete the project in-app, then create a new project selecting folderC→ the name auto-reverts to the original project name, and a phantom entry pointing at a dead path still shows in the sidebar. - Click that phantom project and start a conversation → no output, no session is created.
Expected behavior
- Renaming the project folder in Finder should either re-associate the same project (follow the rename) or the app should detect the stale record and clean it up / relink it.
- In-app project rename should always persist.
- Recreating a project on a new path must not reuse the stale DB record.
Environment
- OpenCode Desktop 1.18.14
- macOS arm64
- SQLite storage at
~/.local/share/opencode/opencode.db
Root cause (from bundled code)
Project.fromDirectorydoes an exact-match lookup of the directory (viaprojectV2.resolve+project_directory). After a Finder rename the new path has no row, so it silently resolves to theglobalproject (worktree = "/", pernode-CU9-BMuP.jsfromDirectory).ProjectCopy.refreshonly deletes stored directory rows whose paths no longer exist; it never adopts a renamed folder as the same project, so the oldproject.worktree/project_directory.directorystay stale.- The edit-project dialog (
edit-project.js) special-cases theglobalproject: for it the save path only callssync.project.meta(...)(silent, no DBprojectrow), which is why renames appear to do nothing.
Observed DB state after the sequence above:
project: cfdc78b7… name=DarkRain worktree=/old/A (deleted)
project_directory: cfdc78b7… /old/B (deleted)
session for folder C: project_id=global
The snapshot (.local/share/opencode/snapshot/<projectID>) also keeps a git worktree config pointing at the deleted path.
Related issues
- Project display name changes ignored in NewLayout (v1.18.x) #38478 (project display name changes ignored in NewLayout)
- Deleting and re-adding a project with a different path reuses stale worktree #35851 (deleting and re-adding a project with a different path reuses stale worktree)
- Desktop app freezes / can't open sessions after the project folder is moved or renamed #40336 / Desktop silently returns an empty response when the saved project directory no longer exists #39471 (sessions fail / empty response when saved directory no longer exists)
- Server keeps stale
project.worktreeafter project folder is renamed on disk; remote clients keep reopening the dead path #35240 (staleproject.worktreeafter folder rename)
中文版描述
问题描述
OpenCode Desktop (v1.18.14, macOS arm64) 中,在 Finder 里直接重命名项目文件夹(OpenCode 之外的操作)会永久破坏"项目 ↔ 目录"的绑定:应用里留下一个幽灵项目,其 worktree/project_directory 指向已不存在的路径;项目显示名无法修改;新会话会静默回退到 global 项目(点击幽灵项目发起会话则直接无响应)。
复现步骤
- 在 OpenCode Desktop 新建项目(文件夹
A),在应用内把项目改名为如 "DarkRain" → 保存。 - 在 Finder 里把文件夹
A改名为B,然后在应用内改名项目 → 名称不变化。 - 在 Finder 里把文件夹
B改名为C。在应用内删除该项目,再新建项目并选择文件夹C→ 名称自动变回最初的项目名,侧边栏仍显示一个指向死路径的幽灵条目。 - 点击该幽灵项目发起对话 → 无任何输出,不创建会话。
预期行为
- 在 Finder 中重命名项目文件夹后,应用应能重新关联同一项目(跟随改名),或检测到失效记录并清理/重新关联。
- 应用内修改项目名称应始终生效。
- 在新路径重建项目时,不得复用旧的数据库残留记录。
环境
- OpenCode Desktop 1.18.14
- macOS arm64
- 数据存储:
~/.local/share/opencode/opencode.db(SQLite)
根因分析(来自打包代码)
Project.fromDirectory对目录做精确匹配(通过projectV2.resolve+project_directory)。Finder 改名后新路径无对应记录,便静默降级到global项目(worktree = "/",见node-CU9-BMuP.js的fromDirectory)。ProjectCopy.refresh只会删除路径已不存在的目录记录,从不把改名后的新目录重新关联为同一项目,导致project.worktree/project_directory.directory一直残留旧路径。- 编辑项目对话框(
edit-project.js)对global项目做了特判:保存时只调用sync.project.meta(...)(静默,不写project表),这就是改名看起来"没生效"的原因。
上述操作序列后观察到的数据库状态:
project: cfdc78b7… name=DarkRain worktree=/old/A (已删除)
project_directory: cfdc78b7… /old/B (已删除)
文件夹 C 的会话: project_id=global
快照目录(.local/share/opencode/snapshot/<projectID>)中的 git worktree 配置同样指向已删除的路径。
Activity
github-actions commentedon Aug 7, 2026
This issue might be a duplicate of existing open issues that cover the same bugs. Please check:
project.worktreeafter project folder is renamed on disk; remote clients keep reopening the dead path #35240: Server keeps staleproject.worktreeafter project folder is renamed on diskYour report combines symptoms from several of these existing issues. If you have new information or a reproducible sequence that ties them together in a way not already captured, please add a comment to the most relevant existing issue rather than opening a new one.
hello2038 commentedon Aug 16, 2026
project rename silently fails for non-git projects (id "global")
#42853
Description
Renaming a project via the "Edit Project" dialog silently has no effect when the project's resolved ID is
"global"(i.e., a plain/non-git folder, or a git repo with no remote, no commits, and no cached ID). The dialog closes but the displayed name never changes. Restarting, re-opening the project, or closing/re-adding the workspace does not help.Root cause: for such projects the app's
savepath (packages/app/src/components/edit-project.ts) only performs the real update whenprops.project.idis set and not"global":Project.resolve(packages/core/src/project.ts) returnsID.globalfor any directory that isn't a git repo, or whose repo has no remote /.git/opencodecache / root commit:The fallback
sync.project.meta(...)writes tochildStore.projectMeta(localStorage), but that store is write-only in the codebase —enrich()(global.tsx/layout.tsx) only ever reads the server'sdata.project. So the rename appears to succeed (dialog closes) but is never persisted or displayed.Plugins
None (OpenCode Desktop, default plugins).
OpenCode version
1.18.18 (OpenCode Desktop;)
Steps to reproduce
git initin a folder but do not commit / add a remote.Operating System
Windows 11
Terminal
N/A — OpenCode Desktop (Electron app), old layout
Hona commentedon Sep 2, 2026
Fixed for opencode2 launch via #46713
You can try the desktop beta here: https://github.com/anomalyco/opencode-beta