import { useActionQuery } from "@agent-native/core/client/hooks"; import { useT } from "@agent-native/core/client/i18n"; import { IconApps } from "@tabler/icons-react"; import { Link, useLocation } from "react-router"; import { cn } from "../../lib/utils"; import { isWorkspaceAppVisibleInDefaultLaunchers, workspaceAppIdFromRoute, workspaceAppRoute, workspaceAppHref, type WorkspaceAppSummary, } from "../../lib/workspace-apps"; import { AppIcon } from "../app-icon"; import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; function appMatchesPath(app: WorkspaceAppSummary, pathname: string): boolean { return workspaceAppIdFromRoute(pathname) === app.id; } function appLabel(app: WorkspaceAppSummary): string { return app.name.trim() || app.id; } export function WorkspaceAppsRail({ collapsed = false, onNavigate, }: { collapsed?: boolean; onNavigate?: () => void; }) { const t = useT(); const location = useLocation(); const appsQuery = useActionQuery( "list-workspace-apps", { includeAgentCards: false, }, ); if (appsQuery.isError || !appsQuery.data) return null; const apps = appsQuery.data .filter( (app) => isWorkspaceAppVisibleInDefaultLaunchers(app) && !app.archived && app.status !== "pending" && !!workspaceAppHref(app), ) .sort((a, b) => appLabel(a).localeCompare(appLabel(b))); if (apps.length === 0) return null; const renderAppLink = (app: WorkspaceAppSummary) => { const href = workspaceAppHref(app); if (!href) return null; const label = appLabel(app); const active = appMatchesPath(app, location.pathname); const link = ( {!collapsed ? {label} : null} ); if (!collapsed) return link; return ( {link} {label} ); }; return (
{!collapsed ? (
{t("dispatch.pages.workspaceApps", { defaultValue: "Workspace apps", })}
) : ( {t("dispatch.pages.workspaceApps", { defaultValue: "Workspace apps", })} )}
    {apps.map((app) => { const href = workspaceAppHref(app); if (!href) return null; return
  • {renderAppLink(app)}
  • ; })}
); }