fix: workspace navigation path from /workspace to /workspaces

This commit is contained in:
Haileyesus
2026-04-07 18:23:38 +03:00
parent 7200533dda
commit 783cba4792

View File

@@ -23,8 +23,7 @@ import {
splitWorkspacesByStarred, splitWorkspacesByStarred,
} from '@/components/refactored/sidebar/utils/workspaceTransforms'; } from '@/components/refactored/sidebar/utils/workspaceTransforms';
const SESSION_ROUTE_PATTERN = /^\/session\/([^/]+)$/; const SESSION_ROUTE_PATTERN = /^\/workspaces\/[^/]+\/sessions\/([^/]+)(?:\/[^/]+)?$/;
const LEGACY_SESSION_ROUTE_PATTERN = /^\/sessions\/([^/]+)$/;
const extractSessionIdFromPathname = (pathname: string): string | null => { const extractSessionIdFromPathname = (pathname: string): string | null => {
const sessionMatch = pathname.match(SESSION_ROUTE_PATTERN); const sessionMatch = pathname.match(SESSION_ROUTE_PATTERN);
@@ -32,11 +31,6 @@ const extractSessionIdFromPathname = (pathname: string): string | null => {
return decodeURIComponent(sessionMatch[1]); return decodeURIComponent(sessionMatch[1]);
} }
const legacySessionMatch = pathname.match(LEGACY_SESSION_ROUTE_PATTERN);
if (legacySessionMatch?.[1]) {
return decodeURIComponent(legacySessionMatch[1]);
}
return null; return null;
}; };
@@ -116,9 +110,20 @@ export const useWorkspaces = () => {
nextSet.add(workspacePath); nextSet.add(workspacePath);
return nextSet; return nextSet;
}); });
navigate(`/session/${encodeURIComponent(sessionId)}`);
const matchedWorkspace = workspaces.find(
(workspace) => workspace.workspaceOriginalPath === workspacePath,
);
if (!matchedWorkspace) {
return;
}
navigate(
`/workspaces/${encodeURIComponent(matchedWorkspace.workspaceId)}/sessions/${encodeURIComponent(sessionId)}`,
);
}, },
[navigate], [navigate, workspaces],
); );
const openNewSession = useCallback(() => { const openNewSession = useCallback(() => {