Menu
popagent
publicLatest change 770b3f9e71398c87310eddcf6c2cec0f603cd0e7 - Add repository changelog page by AkurAI Build
export const SETTINGS_SECTIONS = ["appearance", "agents", "channels", "browser", "secrets", "memory", "runtime", "autonomy", "schedules", "observability"] as const;
export type SettingsSection = (typeof SETTINGS_SECTIONS)[number];
export type AppRoute =
| { page: "overview" }
| { page: "changelog" }
| { page: "workspace"; workspaceId: string }
| { page: "documentation"; workspaceId: string; path?: string }
| { page: "chat"; sessionId: string }
| { page: "channel"; channelId: 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.length === 1 && parts[0] === "changelog") return { page: "changelog" };
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[0] === "workspaces" && parts[2] === "docs" && parts.length >= 3) {
const workspaceId = decoded(parts[1]!);
const pathParts = parts.slice(3).map(decoded);
if (workspaceId && pathParts.every(Boolean)) {
const path = pathParts.length ? pathParts.join("/") : undefined;
return { page: "documentation", workspaceId, ...(path ? { path } : {}) };
}
}
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 };
}
if (parts.length === 2 && parts[0] === "channels") {
const channelId = decoded(parts[1]!);
if (channelId) return { page: "channel", channelId };
}
return { page: "overview" };
}
export function appRoutePath(route: AppRoute): string {
switch (route.page) {
case "overview": return "/";
case "changelog": return "/changelog";
case "workspace": return `/workspaces/${encodeURIComponent(route.workspaceId)}`;
case "documentation": return `/workspaces/${encodeURIComponent(route.workspaceId)}/docs${route.path ? `/${route.path.split("/").map(encodeURIComponent).join("/")}` : ""}`;
case "chat": return `/chats/${encodeURIComponent(route.sessionId)}`;
case "channel": return `/channels/${encodeURIComponent(route.channelId)}`;
case "settings": return `/settings/${route.section}`;
}
}