Skip to content

Fix mangled project paths in By Project and Top Sessions panels#295

Closed
meghraoa wants to merge 1 commit into
getagentseal:mainfrom
meghraoa:fix/by-project-mangled-paths
Closed

Fix mangled project paths in By Project and Top Sessions panels#295
meghraoa wants to merge 1 commit into
getagentseal:mainfrom
meghraoa:fix/by-project-mangled-paths

Conversation

@meghraoa
Copy link
Copy Markdown
Contributor

@meghraoa meghraoa commented May 10, 2026

Summary

The By Project and Top Sessions panels in the dashboard displayed corrupted project names whenever a directory contained a dash or a dot. For example, ~/Projects/foo-bar rendered as Projects/foo/bar, and ~/Projects/site.github.io rendered as Projects/site/github/io with the Projects/ prefix dropped entirely on deeper paths.

Root cause

shortProject() in src/dashboard.tsx received Claude Code's encoded slug (e.g. -home-user-Projects-foo-bar) and tried to recover the original path by splitting on - and joining with /. This is intrinsically lossy: there's no way to distinguish dashes that came from path separators from dashes that were part of the original directory name.

Fix

ProjectSummary.projectPath is already populated from the canonical cwd extracted by parser.ts (extractCanonicalCwd, with fallback to the legacy decode when no JSONL cwd is found). Other consumers (export.ts, cli.ts) already use it. The dashboard was the last holdout still re-decoding the slug.

This PR:

  • Switches both the By Project and Top Sessions panels to consume projectPath (the real cwd).
  • Rewrites shortProject to operate on an absolute path: split on /, keep the last 3 segments, strip the home prefix and any private/tmp/... macOS noise.
  • Renames the in-flight projectName field to projectPath for semantic accuracy.
  • Exports shortProject so it can be unit-tested.

Test plan

  • npm test passes (added 6 cases for shortProject covering dashes, dots, the home dir itself, deep nesting, and paths outside home).
  • Manual: ran the dashboard against ~/.claude/projects/; directories with dashes and dots now render verbatim instead of being split.

shortProject() decoded Claude Code slugs by splitting on '-', which
broke directory names containing dashes ('foo-bar' became 'foo/bar').
Switch the dashboard to consume ProjectSummary.projectPath (the
canonical cwd already extracted by parser.ts) and rewrite shortProject
to operate on a real absolute path.
@AgentSeal AgentSeal added the needs-validation PR requires validation against real-world usage before review label May 12, 2026
@iamtoruk
Copy link
Copy Markdown
Member

Merged via #320 with your fix as the base. Added homedir caching, Windows backslash normalization, and aligned the test helper field name. Thanks for the clean fix @meghraoa.

@iamtoruk iamtoruk closed this May 12, 2026
@iamtoruk iamtoruk added invalid This doesn't seem right and removed needs-validation PR requires validation against real-world usage before review labels May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants