diff --git a/src/features/Workspace/useWorkspaceUrlSync.ts b/src/features/Workspace/useWorkspaceUrlSync.ts index 59c622ee53..a8bd5836b3 100644 --- a/src/features/Workspace/useWorkspaceUrlSync.ts +++ b/src/features/Workspace/useWorkspaceUrlSync.ts @@ -45,6 +45,21 @@ const parseFirstSegment = (pathname: string): string | null => { return match ? match[1] : null; }; +/** + * Whether `pathname`'s first segment could be an (as-yet-unresolved) workspace + * slug — i.e. it's present and not one of the reserved root segments. + * + * Top-level rendering only needs to block on the workspace list (to avoid a + * false 404 / wrong-scope paint) when this is `true`. On personal / reserved + * routes (`/`, `/agent/...`, `/settings/...`) the list isn't required to render, + * so callers can show personal context immediately and let the list hydrate in + * the background. + */ +export const isWorkspaceSlugCandidatePath = (pathname: string): boolean => { + const first = parseFirstSegment(pathname); + return !!first && !RESERVED_FIRST_SEGMENTS.has(first); +}; + /** * URL is the source of truth for workspace context. *