Menu
popagent
publicLatest change 7cecf6a89b6f39dae8c5678f5b369014199aeb3c - Add self-hosted Mastra observability by AkurAI Build
export const SETTINGS_SECTIONS = ["appearance", "agents", "browser", "memory", "runtime", "tasks", "observability"] as const;
export type SettingsSection = (typeof SETTINGS_SECTIONS)[number];
export type AppRoute =
| { page: "overview" }
| { page: "workspace"; workspaceId: string }
| { page: "chat"; sessionId: string }
| { page: "settings"; section: SettingsSection };
function decoded(segment: string): string | undefined {
try {
return decodeURIComponent(segment);
} catch {
return undefined;
}
}
export function parseAppRoute(pathname: string): AppRoute {
const parts = pathname.split("/").filter(Boolean);
if (!parts.length) return { page: "overview" };
if (parts[0] === "settings" && parts.length <= 2) {
const section = parts[1] ?? "agents";
if (SETTINGS_SECTIONS.includes(section as SettingsSection)) {
return { page: "settings", section: section as SettingsSection };
}
}
if (parts.length === 2 && parts[0] === "workspaces") {
const workspaceId = decoded(parts[1]!);
if (workspaceId) return { page: "workspace", workspaceId };
}
if (parts.length === 2 && parts[0] === "chats") {
const sessionId = decoded(parts[1]!);
if (sessionId) return { page: "chat", sessionId };
}
return { page: "overview" };
}
export function appRoutePath(route: AppRoute): string {
switch (route.page) {
case "overview": return "/";
case "workspace": return `/workspaces/${encodeURIComponent(route.workspaceId)}`;
case "chat": return `/chats/${encodeURIComponent(route.sessionId)}`;
case "settings": return `/settings/${route.section}`;
}
}