Fix Claude Code project names collapsing to a parent folder#540
Merged
iamtoruk merged 1 commit intoJun 21, 2026
Merged
Conversation
The 'By Project' panel collapsed sibling Claude Code projects to a parent
folder in two cases:
1) resolveCanonicalProjectPath walked up to ANY ancestor .git and used it as
the canonical project. A stray .git in a parent of several projects (a
dotfiles bare repo, an accidental git init) made every sibling resolve to
that parent ('Projects'/'home'). Now only a real linked worktree (.git is a
FILE pointing at <main>/.git/worktrees/<name>) canonicalizes to its main
repo; an ordinary repo or a stray ancestor .git keeps the session's own cwd
as the project. Genuine worktree grouping is preserved.
2) When a Claude session has no cwd metadata, the dir slug was unsanitized by
replacing every '-' with '/', inventing path segments that overview then
split on, so 'Projects-Content-OS' rendered as 'os'. The lossy slug is now
kept intact, and overview only basenames ABSOLUTE paths.
Fixes getagentseal#493
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.
Summary
Closes #493 by showing the real Claude Code project leaf in the "By Project" panel (TUI + menubar dropdown) and stopping sibling projects from collapsing under a parent folder.
Root cause
Two independent paths produced a parent folder or a wrong fragment instead of the project leaf:
.gitover-grouping.resolveCanonicalProjectPath(src/parser.ts) walked up to the nearest.gitand used it as the canonical project path. That is correct for a real linked worktree, but if a parent directory of several projects happens to contain a.git(a dotfiles bare repo, an accidentalgit initin~/Projects/), every sibling resolved to that parent — so the panel renderedProjects(orhome) for all of them.cwdfallback. When a Claude session has nocwdmetadata,projectPathfell back tounsanitizePath(dirName), which blindly replaces every-with/. A slug likeProjects-Content-OSbecameprojects/content/os, andprojectName()thenpop()-ed it toos.What changed
resolveCanonicalProjectPathnow canonicalizes to the main repo only for a real linked git worktree (.gitis a file whosegitdir:points at<main>/.git/worktrees/<name>). For an ordinary repo, or when a.gitis found only at an ancestor, it keeps the session's owncwdinstead of absorbing it into the parent.cwdfallback keeps the lossy directory slug intact (claudeSlugFallbackPath) instead of inventing path segments.projectName()(src/overview.ts) only basenames absolute paths; a relative slug-shaped name is shown as-is rather than split on invented separators.tests/parser-claude-cwd.test.tsandtests/overview.test.tsfor: sibling projects under a shared parent.git, hyphenated slug with absentcwd, and the no-cwdfallback. One existing test that asserted the oldfallback-slug->fallback/slugbehavior was updated to expect the slug kept intact.Behavior change worth flagging (re: #375)
PR #375 ("Group git worktrees under main project") also caused sessions launched from a subdirectory of an ordinary repo to group up to the repo root. With this change, a non-worktree subdirectory session keeps its own
cwd(it appears under its own directory rather than the repo root). Real git-worktree grouping is unchanged. I went with the worktree-only rule because there is no unambiguous signal to tell a project's own repo from an accidental ancestor.git. If you'd prefer to preserve subdirectory-to-repo-root grouping for ordinary repos, I'm happy to take a more surgical approach — just let me know.Validation
Checks run (en_US locale):
The new tests fail on
origin/main(verified by reverting only the source change) and pass with the fix, so the fix is causally required. Worktree-grouping and separate-git-dir tests remain green.Notes
npm run buildregeneratedsrc/data/litellm-snapshot.json/pricing-fallback.json; both were restored — unrelated to this fix.