desktop: new-session project chip never reflects sibling directories of the same git repo
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- electron, typescript
- Domain
- desktop
Research direction
The bug is in the composer's selected-item resolver, which runs list.find() with an OR of e.worktree === dir and e.sandboxes?.some(...). Start from the project chip and dropdown code in the renderer, and check the projects store that merges GET /api/project records into each directory entry. Done means the chip label and checkmark follow the selected sibling directory, with exact matches tried before the sandboxes fallback, and the sidebar behaviour unchanged.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 213k
- Forks
- 28.4k
- Avg merge
- 8h 32m
- Merged PRs (30d)
- 253
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from anomalyco/opencode
-
reproduced
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
anomalyco/opencode#55676 · 1 comment ·
Maintainers usually reply within 1 day
-
tui: NumPad End/Home ignored under kitty keyboard protocol (Windows Terminal reports KP_END 57424)Possibly taken @argszero claimed this today. Openreproduced
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anomalyco/opencode#55533 · 2 comments ·
Maintainers usually reply within 1 day
-
pending close triaging
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anomalyco/opencode#55392 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
anomalyco/opencode#55383 · 3 comments ·
Maintainers usually reply within 1 day
-
web: second Firefox tab never connects to /api/event - Cache-Control: no-cache lets Firefox's HTTP cache block concurrent SSE requestsPossibly taken @zonemeen claimed this 1 day ago. Openreproduced
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anomalyco/opencode#55369 · 2 comments ·
Maintainers usually reply within 1 day
All issues in anomalyco/opencode
Similar issues
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flagsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vicharanashala/ajrasakha#1439 ·
Maintainers usually reply within 1 day
-
Add: TV5Monde AsieOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
backnotprop/plannotator#1932 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 62/100
ibm-granite/granite.build#504 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Koenkk/zigbee-herdsman-converters#13502 ·
Maintainers usually reply within 1 day