anomalyco / anomalyco/opencode

Web UI: session tabs show the first opened project's name and avatar when two directories share a project ID

Open
#39,667 1 comment 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Jul 30, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

With more than one project open in the web UI, every session tab shows the first project's name and avatar. A chat in project B and a chat in project T both render as B.

It is not only cosmetic. The same helper feeds the command palette and the home session list, so sessions are attributed to the wrong project there too.

Steps to reproduce

  1. Start opencode web and open project B.
  2. Open a second project T that shares a repo identity with B — a second clone of the same remote, a sibling git worktree, or a directory nested inside B's repo. Two directories outside any repo also work.
  3. Open a session in B and a session in T.
  4. Look at the tab strip: the tab for T's session shows B's name and avatar.

Reverting the fix below and reloading brings the wrong label straight back, so it reproduces on demand.

Cause

A project ID does not identify an opened directory. Project.resolve keys it off the git remote, falling back to a cached ID and then the repo's root commit:

const id = (yield* remote(repo)) ?? previous ?? (yield* root(repo))

So separate clones, sibling worktrees, and a directory nested inside another's repo all resolve to the same ID — as does every directory outside a repo, under the global ID.

projectForSession (packages/app/src/pages/layout/helpers.ts) looks that ID up before the directory:

const direct = byID.get(session.projectID)
if (direct) return direct
// directory match never reached

With several opened projects sharing one ID, byID holds a single entry, so every session across those directories resolves to whichever project was opened first.

The server compounds it: worktree: projectID === ID.global ? worktree : existing.worktree keeps the first directory's worktree on the shared row.

Worth noting the same file already treats this ID as non-unique elsewhere — packages/app/src/context/layout.tsx special-cases id === "global" in two places and keys off the worktree instead. projectForSession never got that treatment.

Relationship to #36233

#36233 is the actual root cause — project identity being derived solely from the git remote is what makes two distinct directories collide in the first place, and #35714 reports the same collision causing wrong-project redirects.

This issue is the narrower downstream symptom: given that a collision already exists, the UI resolves sessions to the wrong opened project. Fixing identity derivation in #36233 would remove the collision; fixing this makes the UI correct even while the collision exists. They are worth tracking separately, and this one is a much smaller change.

Environment

  • opencode 1.18.5, opencode web
  • Reproduced in a git repo; also applies to directories outside a repo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.