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:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
9c71119835
commit
00c112077d
@@ -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;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user