Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions frontend/src/lib/utils/grouped-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ export function groupProjects(projects: Project[]): GroupedProjects {
const nonGitProjects = projects.filter((p) => !p.git_root_path);

// Normalize path separators for cross-platform comparison (Windows uses backslashes,
// git outputs forward slashes — normalize both to forward slashes before comparing)
const normalizePath = (p: string) => p.replace(/\\/g, '/');
// git outputs forward slashes — normalize both to forward slashes before comparing).
// Also uppercase the Windows drive letter: Claude Code may record `f:/repo` while
// git reports `F:/repo`, which would otherwise leave the group with 0 projects.
const normalizePath = (p: string) =>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this live in $lib/utils.ts as an exported normalizePath and be used by getRelativePath below as well? That function still does a plain startsWith on the un-normalized root, so a nested f:/code/journal/pkg under the new F:/code/journal key renders as an absolute path instead of ./pkg. There are five other .replace(/\\/g, '/') sites across this file and utils.ts, and decodeProjectPath already uppercases the drive on its own.

p.replace(/\\/g, '/').replace(/^([a-z]):/, (_, d: string) => d.toUpperCase() + ':');

// Step 2: Group git projects by normalized git_root_path
const groupMap = new Map<string, Project[]>();
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/tests/grouped-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,18 @@ describe('groupProjects — Windows paths', () => {
const result = groupProjects(projects as any);
expect(result.singleGitProjects).toHaveLength(1);
});

it('matches project to git root when drive letter case differs', () => {
const projects = [
makeProject({
encoded_name: 'f--code-journal',
path: 'f:/code/journal',

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding a nested project to this fixture (path: 'f:/code/journal/pkg', is_nested_project: true) and asserting getRelativePath(...) returns ./pkg. That's the case the current code still misses.

git_root_path: 'F:/code/journal',
is_nested_project: false
})
];
const result = groupProjects(projects as any);
expect(result.gitRoots).toHaveLength(0);
expect(result.singleGitProjects).toHaveLength(1);
});
});
Loading