diff --git a/packages/app/src/app/_layout.tsx b/packages/app/src/app/_layout.tsx index d51118acd..0540dfb2e 100644 --- a/packages/app/src/app/_layout.tsx +++ b/packages/app/src/app/_layout.tsx @@ -577,7 +577,7 @@ function OfferLinkListener({ if (cancelled) return; const serverId = (profile as any)?.serverId; if (typeof serverId !== "string" || !serverId) return; - router.replace(buildHostRootRoute(serverId) as any); + router.replace(buildHostRootRoute(serverId)); }) .catch((error) => { if (cancelled) return; @@ -695,7 +695,7 @@ function AppWithSidebar({ children }: { children: ReactNode }) { if (hosts.some((host) => host.serverId === activeServerId)) { return; } - router.replace(mapPathnameToServer(pathname, hosts[0]!.serverId) as any); + router.replace(mapPathnameToServer(pathname, hosts[0]!.serverId)); }, [activeServerId, hosts, pathname, router]); // Parse selectedAgentKey directly from pathname diff --git a/packages/app/src/app/h/[serverId]/agent/[agentId].tsx b/packages/app/src/app/h/[serverId]/agent/[agentId].tsx index 3ffa090b6..a42d57379 100644 --- a/packages/app/src/app/h/[serverId]/agent/[agentId].tsx +++ b/packages/app/src/app/h/[serverId]/agent/[agentId].tsx @@ -73,7 +73,7 @@ export default function HostAgentReadyRoute() { } if (!client || !isConnected) { redirectedRef.current = true; - router.replace(buildHostRootRoute(serverId) as any); + router.replace(buildHostRootRoute(serverId)); } }, [agentCwd, agentId, client, hasHydratedWorkspaces, isConnected, router, serverId]); @@ -111,14 +111,14 @@ export default function HostAgentReadyRoute() { ); return; } - router.replace(buildHostRootRoute(serverId) as any); + router.replace(buildHostRootRoute(serverId)); }) .catch(() => { if (cancelled || redirectedRef.current) { return; } redirectedRef.current = true; - router.replace(buildHostRootRoute(serverId) as any); + router.replace(buildHostRootRoute(serverId)); }); return () => { diff --git a/packages/app/src/app/h/[serverId]/index.tsx b/packages/app/src/app/h/[serverId]/index.tsx index 973570cdf..1dcf0baeb 100644 --- a/packages/app/src/app/h/[serverId]/index.tsx +++ b/packages/app/src/app/h/[serverId]/index.tsx @@ -93,7 +93,7 @@ export default function HostIndexRoute() { return; } - router.replace(buildHostOpenProjectRoute(serverId) as any); + router.replace(buildHostOpenProjectRoute(serverId)); }, HOST_ROOT_REDIRECT_DELAY_MS); return () => clearTimeout(timer); diff --git a/packages/app/src/app/index.tsx b/packages/app/src/app/index.tsx index 60ca668ce..1180dcb8f 100644 --- a/packages/app/src/app/index.tsx +++ b/packages/app/src/app/index.tsx @@ -61,7 +61,7 @@ export default function Index() { const targetRoute = anyOnlineServerId ? buildHostRootRoute(anyOnlineServerId) : WELCOME_ROUTE; - router.replace(targetRoute as any); + router.replace(targetRoute); }, [anyOnlineServerId, pathname, router, storeReady]); return ; diff --git a/packages/app/src/app/pair-scan.tsx b/packages/app/src/app/pair-scan.tsx index 5c716e4db..bf02d23ce 100644 --- a/packages/app/src/app/pair-scan.tsx +++ b/packages/app/src/app/pair-scan.tsx @@ -174,7 +174,7 @@ export default function PairScanScreen() { const returnToSource = useCallback( (serverId: string) => { if (source === "onboarding") { - router.replace(buildHostRootRoute(serverId) as any); + router.replace(buildHostRootRoute(serverId)); return; } if (source === "editHost" && targetServerId) { @@ -190,7 +190,7 @@ export default function PairScanScreen() { router.back(); } catch { const settingsServerId = sourceServerId ?? serverId; - router.replace(buildHostSettingsRoute(settingsServerId) as any); + router.replace(buildHostSettingsRoute(settingsServerId)); } }, [router, source, sourceServerId, targetServerId], @@ -209,7 +209,7 @@ export default function PairScanScreen() { router.back(); } catch { if (sourceServerId) { - router.replace(buildHostSettingsRoute(sourceServerId) as any); + router.replace(buildHostSettingsRoute(sourceServerId)); return; } router.replace("/" as any); diff --git a/packages/app/src/app/settings.tsx b/packages/app/src/app/settings.tsx index d0a3b48bb..6e425ddf0 100644 --- a/packages/app/src/app/settings.tsx +++ b/packages/app/src/app/settings.tsx @@ -16,7 +16,7 @@ export default function LegacySettingsRoute() { if (!targetServerId) { return; } - router.replace(buildHostSettingsRoute(targetServerId) as any); + router.replace(buildHostSettingsRoute(targetServerId)); }, [router, targetServerId]); if (!targetServerId) { diff --git a/packages/app/src/components/agent-list.tsx b/packages/app/src/components/agent-list.tsx index f89ad51a3..84cc3ca33 100644 --- a/packages/app/src/components/agent-list.tsx +++ b/packages/app/src/components/agent-list.tsx @@ -256,7 +256,7 @@ export function AgentList({ target: { kind: "agent", agentId }, pin: Boolean(agent.archivedAt), }); - router.navigate(route as any); + router.navigate(route); }, [isActionSheetVisible, onAgentSelect], ); diff --git a/packages/app/src/components/agent-stream-view.tsx b/packages/app/src/components/agent-stream-view.tsx index 298da47f4..4ba4c99f3 100644 --- a/packages/app/src/components/agent-stream-view.tsx +++ b/packages/app/src/components/agent-stream-view.tsx @@ -187,7 +187,7 @@ const AgentStreamViewComponent = forwardRef { - router.replace(buildNewAgentRoute(serverId, targetWorkingDir) as any); + router.replace(buildNewAgentRoute(serverId, targetWorkingDir)); }) .catch((err) => { const message = err instanceof Error ? err.message : "Failed to archive worktree"; diff --git a/packages/app/src/components/left-sidebar.tsx b/packages/app/src/components/left-sidebar.tsx index ab5b40371..653c58942 100644 --- a/packages/app/src/components/left-sidebar.tsx +++ b/packages/app/src/components/left-sidebar.tsx @@ -229,21 +229,21 @@ export const LeftSidebar = memo(function LeftSidebar({ return; } closeToAgent(); - router.push(buildHostSettingsRoute(activeServerId) as any); + router.push(buildHostSettingsRoute(activeServerId)); }, [activeServerId, closeToAgent]); const handleSettingsDesktop = useCallback(() => { if (!activeServerId) { return; } - router.push(buildHostSettingsRoute(activeServerId) as any); + router.push(buildHostSettingsRoute(activeServerId)); }, [activeServerId]); const handleViewMoreNavigate = useCallback(() => { if (!activeServerId) { return; } - router.push(buildHostSessionsRoute(activeServerId) as any); + router.push(buildHostSessionsRoute(activeServerId)); }, [activeServerId]); const handleHostSelect = useCallback( @@ -253,7 +253,7 @@ export const LeftSidebar = memo(function LeftSidebar({ } const nextPath = mapPathnameToServer(pathname, nextServerId); setIsHostPickerOpen(false); - router.push(nextPath as any); + router.push(nextPath); }, [pathname], ); diff --git a/packages/app/src/components/sidebar-workspace-list.tsx b/packages/app/src/components/sidebar-workspace-list.tsx index d1cc18f04..1f016d1ba 100644 --- a/packages/app/src/components/sidebar-workspace-list.tsx +++ b/packages/app/src/components/sidebar-workspace-list.tsx @@ -1118,7 +1118,7 @@ function WorkspaceRowWithMenu({ serverId: workspace.serverId, archivedWorkspaceId: workspace.workspaceId, workspaces: sessionWorkspaces.values(), - }) as any, + }), ); }, [activeWorkspaceSelection, sessionWorkspaces, workspace.serverId, workspace.workspaceId]); diff --git a/packages/app/src/components/welcome-screen.tsx b/packages/app/src/components/welcome-screen.tsx index be54b0b97..ed6414c24 100644 --- a/packages/app/src/components/welcome-screen.tsx +++ b/packages/app/src/components/welcome-screen.tsx @@ -275,12 +275,12 @@ export function WelcomeScreen({ onHostAdded }: WelcomeScreenProps) { if (pendingNameHost) { return; } - router.replace(buildHostRootRoute(anyOnlineServerId) as any); + router.replace(buildHostRootRoute(anyOnlineServerId)); }, [anyOnlineServerId, pendingNameHost, router]); const finishOnboarding = useCallback( (serverId: string) => { - router.replace(buildHostRootRoute(serverId) as any); + router.replace(buildHostRootRoute(serverId)); }, [router], ); diff --git a/packages/app/src/hooks/use-command-center.ts b/packages/app/src/hooks/use-command-center.ts index 15e2f02a2..dae233ed5 100644 --- a/packages/app/src/hooks/use-command-center.ts +++ b/packages/app/src/hooks/use-command-center.ts @@ -171,7 +171,7 @@ export function useCommandCenter() { const settingsRoute = useMemo(() => { const serverIdFromPath = activeServerId; - return serverIdFromPath ? (buildHostSettingsRoute(serverIdFromPath) as Href) : "/"; + return serverIdFromPath ? buildHostSettingsRoute(serverIdFromPath) : "/"; }, [activeServerId]); const actionItems = useMemo(() => { @@ -234,7 +234,7 @@ export function useCommandCenter() { workspaceId, target: { kind: "agent", agentId: agent.id }, }); - router.navigate(route as any); + router.navigate(route); }, [setOpen], ); diff --git a/packages/app/src/hooks/use-git-actions.ts b/packages/app/src/hooks/use-git-actions.ts index e028ef282..9856685b2 100644 --- a/packages/app/src/hooks/use-git-actions.ts +++ b/packages/app/src/hooks/use-git-actions.ts @@ -190,7 +190,7 @@ export function useGitActions({ serverId, cwd, icons }: UseGitActionsInput): Use const targetWorkingDir = resolveNewAgentWorkingDir(cwd, status ?? null); void runArchiveWorktree({ serverId, cwd, worktreePath }) .then(() => { - router.replace(buildNewAgentRoute(serverId, targetWorkingDir) as any); + router.replace(buildNewAgentRoute(serverId, targetWorkingDir)); }) .catch((err) => { const message = err instanceof Error ? err.message : "Failed to archive worktree"; diff --git a/packages/app/src/hooks/use-workspace-navigation.ts b/packages/app/src/hooks/use-workspace-navigation.ts index 2cf8017aa..269252a5c 100644 --- a/packages/app/src/hooks/use-workspace-navigation.ts +++ b/packages/app/src/hooks/use-workspace-navigation.ts @@ -11,7 +11,7 @@ import { buildHostWorkspaceRoute } from "@/utils/host-routes"; */ export function navigateToWorkspace(serverId: string, workspaceId: string) { const href = buildHostWorkspaceRoute(serverId, workspaceId); - router.navigate(href as any); + router.navigate(href); } export function useWorkspaceNavigation() { diff --git a/packages/app/src/screens/sessions-screen.tsx b/packages/app/src/screens/sessions-screen.tsx index a6a4e3f50..6e8934683 100644 --- a/packages/app/src/screens/sessions-screen.tsx +++ b/packages/app/src/screens/sessions-screen.tsx @@ -54,7 +54,7 @@ function SessionsScreenContent({ serverId }: { serverId: string }) { diff --git a/packages/app/src/utils/host-routes.ts b/packages/app/src/utils/host-routes.ts index 9b2c640a6..1dcd5aa60 100644 --- a/packages/app/src/utils/host-routes.ts +++ b/packages/app/src/utils/host-routes.ts @@ -288,125 +288,125 @@ export function parseHostWorkspaceRouteFromPathname( return { serverId, workspaceId }; } -export function buildHostWorkspaceRoute(serverId: string, workspaceId: string): string { +export function buildHostWorkspaceRoute(serverId: string, workspaceId: string) { const normalizedServerId = trimNonEmpty(serverId); const normalizedWorkspaceId = trimNonEmpty(workspaceId); if (!normalizedServerId || !normalizedWorkspaceId) { - return "/"; + return "/" as const; } const encodedWorkspaceId = encodeWorkspaceIdForPathSegment(normalizedWorkspaceId); if (!encodedWorkspaceId) { - return "/"; + return "/" as const; } - return `/h/${encodeSegment(normalizedServerId)}/workspace/${encodeSegment(encodedWorkspaceId)}`; + return `/h/${encodeSegment(normalizedServerId)}/workspace/${encodeSegment(encodedWorkspaceId)}` as const; } export function buildHostWorkspaceOpenRoute( serverId: string, workspaceId: string, openIntent: string, -): string { +) { const base = buildHostWorkspaceRoute(serverId, workspaceId); const normalizedOpenIntent = trimNonEmpty(openIntent); if (base === "/" || !normalizedOpenIntent) { return base; } - return `${base}?open=${encodeURIComponent(normalizedOpenIntent)}`; + return `${base}?open=${encodeURIComponent(normalizedOpenIntent)}` as const; } export function buildHostAgentDetailRoute( serverId: string, agentId: string, workspaceId?: string, -): string { +) { const normalizedWorkspaceId = trimNonEmpty(workspaceId); if (normalizedWorkspaceId) { const normalizedAgentId = trimNonEmpty(agentId); if (!normalizedAgentId) { - return "/"; + return "/" as const; } return buildHostWorkspaceOpenRoute(serverId, normalizedWorkspaceId, `agent:${normalizedAgentId}`); } const normalizedServerId = trimNonEmpty(serverId); const normalizedAgentId = trimNonEmpty(agentId); if (!normalizedServerId || !normalizedAgentId) { - return "/"; + return "/" as const; } - return `${buildHostRootRoute(normalizedServerId)}/agent/${encodeSegment(normalizedAgentId)}`; + return `${buildHostRootRoute(normalizedServerId)}/agent/${encodeSegment(normalizedAgentId)}` as const; } -export function buildHostRootRoute(serverId: string): string { +export function buildHostRootRoute(serverId: string) { const normalized = trimNonEmpty(serverId); if (!normalized) { - return "/"; + return "/" as const; } - return `/h/${encodeSegment(normalized)}`; + return `/h/${encodeSegment(normalized)}` as const; } -export function buildHostSessionsRoute(serverId: string): string { +export function buildHostSessionsRoute(serverId: string) { const base = buildHostRootRoute(serverId); if (base === "/") { - return "/"; + return "/" as const; } - return `${base}/sessions`; + return `${base}/sessions` as const; } -export function buildHostOpenProjectRoute(serverId: string): string { +export function buildHostOpenProjectRoute(serverId: string) { const base = buildHostRootRoute(serverId); if (base === "/") { - return "/"; + return "/" as const; } - return `${base}/open-project`; + return `${base}/open-project` as const; } export function buildHostNewWorkspaceRoute( serverId: string, sourceDirectory: string, options?: { displayName?: string }, -): string { +){ const base = buildHostRootRoute(serverId); if (base === "/") { - return "/"; + return "/" as const; } const params = new URLSearchParams(); params.set("dir", sourceDirectory); if (options?.displayName) { params.set("name", options.displayName); } - return `${base}/new?${params.toString()}`; + return `${base}/new?${params.toString()}` as const; } -export function buildHostSettingsRoute(serverId: string): string { +export function buildHostSettingsRoute(serverId: string) { const base = buildHostRootRoute(serverId); if (base === "/") { - return "/"; + return "/" as const; } - return `${base}/settings`; + return `${base}/settings` as const; } -export function mapPathnameToServer(pathname: string, nextServerId: string): string { +export function mapPathnameToServer(pathname: string, nextServerId: string) { const normalized = trimNonEmpty(nextServerId); if (!normalized) { - return "/"; + return "/" as const; } const suffix = pathname.replace(/^\/h\/[^/]+\/?/, ""); const base = buildHostRootRoute(normalized); if (suffix.startsWith("settings")) { - return `${base}/settings`; + return `${base}/settings` as const; } if (suffix.startsWith("sessions")) { - return `${base}/sessions`; + return `${base}/sessions` as const; } if (suffix.startsWith("open-project")) { - return `${base}/open-project`; + return `${base}/open-project` as const; } const workspaceRoute = parseHostWorkspaceRouteFromPathname(pathname); if (workspaceRoute) { return buildHostWorkspaceRoute(normalized, workspaceRoute.workspaceId); } if (suffix.startsWith("agent/")) { - return `${base}/${suffix}`; + return `${base}/${suffix}` as const; } return base; } diff --git a/packages/app/src/utils/new-agent-routing.ts b/packages/app/src/utils/new-agent-routing.ts index a121cb7e1..cd62ed8e0 100644 --- a/packages/app/src/utils/new-agent-routing.ts +++ b/packages/app/src/utils/new-agent-routing.ts @@ -69,7 +69,7 @@ export function resolveNewAgentWorkingDir( return inferMainRepoRootFromPaseoWorktreePath(cwd) ?? cwd; } -export function buildNewAgentRoute(serverId: string, workingDir?: string | null): string { +export function buildNewAgentRoute(serverId: string, workingDir?: string | null) { const trimmedWorkingDir = workingDir?.trim(); return buildHostWorkspaceRoute(serverId, trimmedWorkingDir || "."); } diff --git a/packages/app/src/utils/notification-routing.ts b/packages/app/src/utils/notification-routing.ts index d1de8e444..1d4b0772b 100644 --- a/packages/app/src/utils/notification-routing.ts +++ b/packages/app/src/utils/notification-routing.ts @@ -27,17 +27,17 @@ export function resolveNotificationTarget(data: NotificationData): { }; } -export function buildNotificationRoute(data: NotificationData): string { +export function buildNotificationRoute(data: NotificationData) { const { serverId, agentId, workspaceId } = resolveNotificationTarget(data); if (serverId && agentId) { if (workspaceId) { const base = buildHostWorkspaceRoute(serverId, workspaceId); - return `${base}?open=${encodeURIComponent(`agent:${agentId}`)}`; + return `${base}?open=${encodeURIComponent(`agent:${agentId}`)}` as const; } return buildHostAgentDetailRoute(serverId, agentId); } if (serverId) { return buildHostRootRoute(serverId); } - return "/"; + return "/" as const; } diff --git a/packages/app/src/utils/workspace-archive-navigation.ts b/packages/app/src/utils/workspace-archive-navigation.ts index 9eafc1a2b..d0895e863 100644 --- a/packages/app/src/utils/workspace-archive-navigation.ts +++ b/packages/app/src/utils/workspace-archive-navigation.ts @@ -41,7 +41,7 @@ export function buildWorkspaceArchiveRedirectRoute(input: { serverId: string; archivedWorkspaceId: string; workspaces: Iterable; -}): string { +}) { const redirectWorkspaceId = resolveWorkspaceArchiveRedirectWorkspaceId({ archivedWorkspaceId: input.archivedWorkspaceId, workspaces: input.workspaces, diff --git a/packages/app/src/utils/workspace-navigation.ts b/packages/app/src/utils/workspace-navigation.ts index 1e6458c51..bad58ed5e 100644 --- a/packages/app/src/utils/workspace-navigation.ts +++ b/packages/app/src/utils/workspace-navigation.ts @@ -25,7 +25,7 @@ function getPreparedTarget(target: WorkspaceTabTarget): WorkspaceTabTarget { return { kind: "draft", draftId: generateDraftId() }; } -export function prepareWorkspaceTab(input: PrepareWorkspaceTabInput): string { +export function prepareWorkspaceTab(input: PrepareWorkspaceTabInput) { const target = getPreparedTarget(input.target); const key = buildWorkspaceTabPersistenceKey({