supermemory/apps/web/lib/configure-routes.ts
MaheshtheDev a051ba0e28 feat(web): give Configure sections real routes under /configure (#1378)
Configure sections were local useState, so they could not be linked or bookmarked and always opened on the default section. Each section is now a route (/configure, /configure/models, /configure/workspace-prompt, /configure/proactivity, /configure/automations), mirroring the existing /integrations/[card] pattern. The shell renders from the segment layout so switching sections does not remount the app, and legacy /?view=configure links forward to /configure.

Fixes ENG-1140
2026-07-30 19:27:36 +00:00

37 lines
1.1 KiB
TypeScript

// Sections under the /configure route.
// "tools" is the "Integrations" section, slugged to avoid clashing with /integrations.
export const CONFIGURE_SECTIONS = [
"tools",
"models",
"workspace-prompt",
"proactivity",
"automations",
] as const
export type ConfigureSection = (typeof CONFIGURE_SECTIONS)[number]
export const DEFAULT_CONFIGURE_SECTION: ConfigureSection = "tools"
export function isConfigureSection(slug: string): slug is ConfigureSection {
return (CONFIGURE_SECTIONS as readonly string[]).includes(slug)
}
export function configureSectionToPath(section: ConfigureSection): string {
return section === DEFAULT_CONFIGURE_SECTION
? "/configure"
: `/configure/${section}`
}
export function pathToConfigureSection(
pathname: string,
): ConfigureSection | null {
const trimmed = pathname.replace(/\/$/, "")
if (trimmed === "/configure") return DEFAULT_CONFIGURE_SECTION
const slug = trimmed.match(/^\/configure\/([^/]+)$/)?.[1]
if (slug && isConfigureSection(slug)) return slug
return null
}
export function isConfigurePath(pathname: string): boolean {
return pathToConfigureSection(pathname) !== null
}