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
@@ -7,7 +7,7 @@ import { useSessionPinnedStore } from '@/stores/useSessionPinnedStore';
import { useGitAllBranches, useGitStore } from '@/stores/useGitStore';
import { useRuntimeAPIs } from '@/hooks/useRuntimeAPIs';
import type { SessionNode } from '../types';
import { compareSessionsByPinnedAndTime } from '../utils';
import { compareSessionsByPinnedAndTime, isPathWithinProject } from '../utils';
export type SwitcherItem = {
node: SessionNode;
@@ -60,7 +60,7 @@ export const useSwitcherItems = (enabled: boolean, options: SwitcherItemsOptions
(directory: string | null) => {
if (!directory) return null;
const matches = normalizedProjects
.filter((project) => directory === project.normalizedPath || directory.startsWith(`${project.normalizedPath}/`))
.filter((project) => isPathWithinProject(directory, project.normalizedPath))
.sort((a, b) => (b.normalizedPath?.length ?? 0) - (a.normalizedPath?.length ?? 0));
return matches[0] ?? null;
},