fix(app): resolve a session's project by directory, not by shared ID - #39666
Open
Luppa90 wants to merge 1 commit into
Open
fix(app): resolve a session's project by directory, not by shared ID#39666Luppa90 wants to merge 1 commit into
Luppa90 wants to merge 1 commit into
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
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, 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 looked that ID up first, so every session across those directories resolved to whichever project was opened first: tabs for a second project showed the first project's name and avatar, and the same misattribution reached the command palette and the home session list. The server compounds it by keeping the first directory's worktree on the shared row. Match the worktree or a sandbox path first, since either identifies an opened project on its own, and fall back to the ID only for sessions below a repo root where no path matches exactly. This does not change how project identity is derived (anomalyco#36233); it stops the UI misattributing sessions when two directories collide on one ID.
Luppa90
force-pushed
the
fix-project-avatar
branch
from
July 30, 2026 13:28
b794c0a to
2d18f96
Compare
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #39667
The root cause is #36233 — project identity derived solely from the git remote is what makes two distinct directories collide on one ID, and #35714 reports the same collision causing wrong-project redirects. This PR deliberately does not close either: it does not change how identity is derived, it stops the UI misattributing sessions once a collision already exists.
Type of change
What does this PR do?
With two projects open, every session tab showed the first project's name and avatar — a chat in project B and a chat in project T both rendered as B.
A project ID does not identify an opened directory.
Project.resolvekeys it off the git remote, falling back to a cached ID and then the repo's root commit: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.
projectForSessionlooked that ID up before the directory, so every session across those directories resolved to whichever project was opened first. It isn't only cosmetic: the same helper feeds the command palette and the home session list, so sessions were attributed to the wrong project there too. The server compounds it —worktree: projectID === ID.global ? worktree : existing.worktreekeeps the first directory's worktree on the shared row.The fix matches the worktree or a sandbox path first, since either identifies an opened project on its own, and falls back to the ID only for sessions below a repo root where no path matches exactly. Repo setups are unaffected: a session in a subdirectory still resolves through the ID, which is exactly the fallback case.
How did you verify your code works?
projectForSessioncovering both collision routes (directories sharing a repo identity, and directories outside a repo sharing the global ID), plus the repo-subdirectory fallback, sandbox matching, and the no-match case. Both collision tests were checked against the pre-fix implementation to confirm they actually fail there.bun testfor the app package and typecheck are clean. The only failing test is the pre-existingari18n parity gap, which fails identically ondev.Screenshots / recordings
Not a visual change beyond the corrected label: tabs for a second project now show that project's own name and avatar instead of the first project's.
Checklist