desktop: new-session project chip never reflects sibling directories of the same git repo
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- electron, typescript
- 领域
- desktop
调研方向
问题出在 composer 的已选项解析器中,它运行 list.find(),并用 e.worktree === dir 与 e.sandboxes?.some(...) 做或运算。请从 renderer 中项目芯片和下拉菜单的代码入手,再检查 projects store,它把 GET /api/project 的记录合并进每个目录条目。完成的标准是:芯片标签和对勾跟随所选的同级目录,精确匹配先于 sandboxes 回退尝试,并且侧边栏行为保持不变。
由索引模型根据 Issue 内容生成。
描述
Description
The new-session project chip (first chip under the composer) never follows a directory selection for sibling directories of the same repository. It keeps showing the repository's canonical directory, and the checkmark in the dropdown stays on that same row, so switching between sibling clones looks like it silently failed.
It is UI-only: the click does update the draft's directory (verified in the desktop state store), and the session is created in the clicked directory, but the chip label and the checkmark never change. This makes it impossible to tell which directory a new session will run in.
Root cause, read from the shipped renderer bundle. GET /api/project returns one Project for all clones:
{"id":"7f3bb1b0…","canonical":"/home/me/work/app-dev","sandboxes":["/home/me/work/app-uat","/home/me/work/app-release"]}
The server-scoped projects store resolves each directory entry as {...projectRecord, ...directoryEntry}, so every sibling directory entry carries the same sandboxes array. The composer's selected-item resolver then does one find() over both predicates:
list.find(e => e.worktree === dir || e.sandboxes?.some(s => s === dir))
For dir = .../app-uat, the first entry (app-dev, whose hydrated sandboxes contains app-uat) matches the second predicate, so find() returns it before the exact-match entry is ever considered. The chip label and the checkmark are both derived from that resolver.
Suggested fix: exact match first, sandboxes only as a fallback:
list.find(e => e.worktree === dir) ?? list.find(e => e.sandboxes?.some(s => s === dir))
The sidebar project rows are unaffected, because they compare the selected directory exactly.
Plugins
@tarquinen/opencode-dcp, @maximtop/opencode-session-namer, @prevalentware/opencode-goal-plugin, opencode-tui-usage
OpenCode version
v2.0.28
Steps to reproduce
- Clone the same git remote into three independent directories (e.g. app-dev, app-uat, app-release) — three plain clones, not worktrees, so they all resolve to the same project ID.
- Add all three directories as projects in OpenCode Desktop.
- Start a new session in one of the non-canonical clones (e.g. app-uat).
- Open the project chip dropdown under the composer. The chip and the checkmark both stay on app-dev.
- Select app-release. Still app-dev.
The click itself works: after selecting app-uat, the draft's directory in ~/.config/ai.opencode.desktop/drafts.sqlite becomes .../app-uat and lastProject follows, and GET /api/location?location[directory]=.../app-uat returns project.canonical = .../app-uat. Only the chip label and the checkmark are stale.
Reproducible every time for any repository that has more than one of its directories added as a project (I hit it with three clones of one repo).
Screenshot and/or share link
A 12s screen recording of the dropdown (checkmark stuck on the canonical directory while the draft directory is a sibling clone) is available on request.
Operating System
Linux 6.6.155-amd64-desktop-hwe (x86_64), Deepin desktop, X11
Terminal
OpenCode Desktop (Electron app), no terminal attached
- 主要语言
- TypeScript
- 星标
- 213k
- 派生
- 28.4k
- 平均合并
- 8 小时 58 分钟
- 30 天内合并 PR
- 251
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
reproduced
难度 2/5 1-3 小时 新手友好度 70/100
anomalyco/opencode#56038 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
anomalyco/opencode#56002 · 1 条评论 ·
维护者通常 1 天内回复
-
app: keybinds match the produced character, so Ctrl+F and other letter shortcuts fail on non-Latin layouts可能已有人在做 @ZXLyyds100 今天认领。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 82/100
anomalyco/opencode#55676 · 2 条评论 ·
维护者通常 1 天内回复
-
tui: NumPad End/Home ignored under kitty keyboard protocol (Windows Terminal reports KP_END 57424)可能已有人在做 @argszero 今天认领。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 75/100
anomalyco/opencode#55533 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
anomalyco/opencode#55383 · 3 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
aws/agentcore-cli#2606 ·
维护者通常 1 天内回复
-
ai-driven-qa bug Cosmetic
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
ai-driven-qa bug claude Minor
难度 2/5 1-3 小时 新手友好度 64/100
linagora/twake-mail-admin#301 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
streams:add
难度 2/5 1 小时以内 新手友好度 70/100
维护者通常 1 天内回复