fix: match root project sessions in switcher (#1274)

* fix: match root project sessions in switcher

* test: cover project path matching edge cases

---------

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-16 16:46:05 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent 9c71119835
commit 00c112077d
3 changed files with 40 additions and 2 deletions
@@ -81,6 +81,15 @@ export const normalizePath = (value?: string | null) => {
return normalized.length === 0 ? '/' : normalized;
};
export const isPathWithinProject = (directory?: string | null, projectPath?: string | null): boolean => {
const normalizedDirectory = normalizePath(directory);
const normalizedProjectPath = normalizePath(projectPath);
if (!normalizedDirectory || !normalizedProjectPath) return false;
if (normalizedDirectory === normalizedProjectPath) return true;
if (normalizedProjectPath === '/') return normalizedDirectory.startsWith('/');
return normalizedDirectory.startsWith(`${normalizedProjectPath}/`);
};
export const normalizeForBranchComparison = (value: string): string => {
return value
.toLowerCase()