desktop: new-session project chip never reflects sibling directories of the same git repo
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 66/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- electron, typescript
- Ambito
- desktop
Direzione di ricerca
Il bug si trova nel resolver dell'elemento selezionato del composer, che esegue list.find() con un OR tra e.worktree === dir e e.sandboxes?.some(...). Parti dal codice del chip del progetto e del menu a discesa nel renderer, poi controlla lo store dei progetti che unisce i record di GET /api/project in ogni voce di directory. È completato quando l'etichetta del chip e il segno di spunta seguono la directory sorella selezionata, le corrispondenze esatte vengono provate prima del fallback sui sandbox e il comportamento della sidebar resta invariato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 215k
- Fork
- 28.9k
- Merge medio
- 7h 53m
- PR unite (30g)
- 278
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di anomalyco/opencode
-
pending close triaging
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
anomalyco/opencode#56765 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
anomalyco/opencode#56735 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
anomalyco/opencode#56663 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
pending close triaging
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
anomalyco/opencode#56625 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
anomalyco/opencode#56624 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di anomalyco/opencode
Issue simili
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
components-web-app/docs#260 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
521xueweihan/HelloGitHub#4025 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
ctrf-io/playwright-ctrf-json-reporter#117 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
voidzero-dev/void#478 ·
I maintainer di solito rispondono entro 1 giorno