@tangle-network/agent-app 0.53.4 → 0.53.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/assistant/index.js +7 -6
  2. package/dist/assistant/index.js.map +1 -1
  3. package/dist/chat-react/index.js +3 -3
  4. package/dist/chunk-2WELYICW.js +78 -0
  5. package/dist/chunk-2WELYICW.js.map +1 -0
  6. package/dist/{chunk-6FYFGQ6I.js → chunk-AUA75YFF.js} +2 -2
  7. package/dist/{chunk-7HMDNSIA.js → chunk-JZ64GXYP.js} +4 -4
  8. package/dist/{chunk-IYK5BRL4.js → chunk-LVSKKDX2.js} +7 -4
  9. package/dist/chunk-LVSKKDX2.js.map +1 -0
  10. package/dist/{chunk-ODP3X4BN.js → chunk-QHLQPK2H.js} +11 -5
  11. package/dist/chunk-QHLQPK2H.js.map +1 -0
  12. package/dist/{chunk-NH32EPWU.js → chunk-WZ2FER6A.js} +15 -72
  13. package/dist/chunk-WZ2FER6A.js.map +1 -0
  14. package/dist/{chunk-BINC6OWR.js → chunk-ZFFBT5BF.js} +2 -2
  15. package/dist/{mention-editor-E6J2RUG4.js → mention-editor-4EWHJ5G5.js} +2 -2
  16. package/dist/studio-react/index.js +3 -2
  17. package/dist/studio-react/index.js.map +1 -1
  18. package/dist/web-react/action-dialog.d.ts +15 -0
  19. package/dist/web-react/controls.d.ts +6 -1
  20. package/dist/web-react/index.js +9 -6
  21. package/dist/web-react/workspace-switcher.d.ts +9 -0
  22. package/dist/workspace-react/index.d.ts +13 -1
  23. package/dist/workspace-react/index.js +589 -20
  24. package/dist/workspace-react/index.js.map +1 -1
  25. package/dist/workspace-react/rail-identity.d.ts +55 -0
  26. package/dist/workspace-react/workspace-list.d.ts +82 -0
  27. package/package.json +1 -1
  28. package/dist/chunk-IYK5BRL4.js.map +0 -1
  29. package/dist/chunk-NH32EPWU.js.map +0 -1
  30. package/dist/chunk-ODP3X4BN.js.map +0 -1
  31. /package/dist/{chunk-6FYFGQ6I.js.map → chunk-AUA75YFF.js.map} +0 -0
  32. /package/dist/{chunk-7HMDNSIA.js.map → chunk-JZ64GXYP.js.map} +0 -0
  33. /package/dist/{chunk-BINC6OWR.js.map → chunk-ZFFBT5BF.js.map} +0 -0
  34. /package/dist/{mention-editor-E6J2RUG4.js.map → mention-editor-4EWHJ5G5.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/workspace-react/index.tsx","../../src/workspace-react/companion.tsx"],"sourcesContent":["import { SidebarLayout, type SidebarLayoutNavItem, type SidebarLayoutProps } from '@tangle-network/sandbox-ui/dashboard'\nimport type { ReactNode } from 'react'\n\nimport type { WorkspaceAppRecord } from '../workspace-apps'\n\nimport {\n buildSessionNavItem,\n composeSidebarSessions,\n resolveActiveNavId,\n type NavRouteDef,\n type RailPrefetch,\n type SessionRowActions,\n type SessionSummary,\n} from '../session-shell'\n\ntype WorkspaceIcon = SidebarLayoutNavItem['icon']\n\nfunction routePathFromHref(href: string, base: string): string | null {\n const path = href.split(/[?#]/, 1)[0] ?? ''\n const root = base.replace(/\\/+$/, '')\n if (path === root) return '/'\n if (!path.startsWith(`${root}/`)) return null\n return path.slice(root.length)\n}\n\n/** The session data and product-owned URLs needed by the default workspace. */\nexport interface AgentWorkspaceSessionConfig {\n /** Icon shown beside the expandable History row. */\n icon: WorkspaceIcon\n /** Id for the session row; defaults to `history`. */\n id?: string\n /** Product copy for the session row; defaults to `History`. */\n label?: string\n /** Full-history route used by the row and overflow item. */\n href: string\n /** Product-owned URL for an individual session. */\n hrefForSession: (sessionId: string) => string\n /** Server-loaded rows, ordered by the product's query. */\n sessions: SessionSummary[]\n /** Sessions created by another tab before the loader revalidates. */\n optimisticSessions?: SessionSummary[]\n /** Number of rows shown in the rail before the full-history link. */\n limit?: number\n /** Total persisted session count, used to decide whether overflow exists. */\n totalCount?: number\n /** Session currently open in the route. */\n activeSessionId?: string | null\n /** Sessions with a live turn. */\n respondingSessionIds?: ReadonlySet<string>\n /** Live unread ids from the product's event channel. */\n liveUnreadIds?: ReadonlySet<string>\n /** Ids this tab has opened since the loader ran. */\n locallyReadIds?: ReadonlySet<string>\n /** Optional product-owned rename/delete/pin actions. */\n actions?: SessionRowActions<WorkspaceIcon>\n /** Label for the overflow row. Defaults to `View all chats`. */\n overflowLabel?: string\n /** Empty state for the expanded rail row. Defaults to `No chats yet`. */\n emptyLabel?: string\n /** Fallback title for untitled sessions. */\n untitledLabel?: string\n /** Router prefetch behavior for session links. */\n prefetch?: RailPrefetch\n /** Whether History starts expanded. Defaults to `true`. */\n defaultOpen?: boolean\n}\n\n/**\n * Registered apps shown under one expandable workspace destination.\n * Products supply authorized rows and their real route; preview URLs never\n * become navigation hrefs.\n */\nexport interface AgentWorkspaceAppsConfig {\n icon: WorkspaceIcon\n items: readonly Pick<WorkspaceAppRecord, 'id' | 'name'>[]\n hrefForApp: (appId: string) => string\n prefetch?: RailPrefetch\n}\n\n/** Route data for the shared active-nav resolver. */\nexport interface AgentWorkspaceActiveRoute {\n /** Current browser pathname, including the product's workspace base. */\n pathname: string\n /** Product route root, for example `/app/ws_123`. */\n base: string\n /** Product-owned rail routes, relative to `base`. */\n routes: NavRouteDef[]\n /** Extra route prefixes that should highlight an existing row. */\n aliases?: Record<string, string>\n /** Route prefixes that intentionally highlight no row. */\n claimsNothing?: string[]\n}\n\nexport interface AgentWorkspaceLayoutProps\n extends Omit<SidebarLayoutProps, 'activeId' | 'children' | 'navItems' | 'hideBelow' | 'railLabels'> {\n children: ReactNode\n /** Product-owned destinations. Shared Apps and History rows follow them. */\n navItems: SidebarLayoutNavItem[]\n /** Omit for a workflow-only shell with no conversational session rail. */\n sessions?: AgentWorkspaceSessionConfig\n /** Authorized app destinations, in the product's persisted order. */\n apps?: AgentWorkspaceAppsConfig\n /** When supplied, active navigation is resolved by the shared route rules. */\n activeRoute?: AgentWorkspaceActiveRoute\n /** Escape hatch for routers that already resolved the active item. */\n activeId?: string\n /** Hide the fixed desktop rail below this breakpoint. Defaults to `lg`. */\n hideBelow?: SidebarLayoutProps['hideBelow']\n /** Show labels beside rail icons. Defaults to `true`. */\n railLabels?: SidebarLayoutProps['railLabels']\n}\n\n/**\n * The default agent workspace composition.\n *\n * Products own their navigation taxonomy, routes, and session storage. This\n * component owns the repeated assembly: the standard visual layout, the\n * expandable Apps and History rows, capped session composition, unread state,\n * and active route resolution. The full History route and the empty-state composer stay\n * separate because their data and domain copy belong to the product; pair this\n * with `SessionHistoryPanel` and `EntryComposer` for the complete chat-first\n * structure.\n */\nexport function AgentWorkspaceLayout({\n children,\n navItems,\n sessions,\n apps,\n activeRoute,\n activeId,\n ...sidebarProps\n}: AgentWorkspaceLayoutProps) {\n const sessionNav = sessions\n ? (() => {\n const composed = composeSidebarSessions({\n loaderSessions: sessions.sessions,\n optimisticSessions: sessions.optimisticSessions,\n limit: sessions.limit ?? 20,\n totalCount: sessions.totalCount,\n liveUnreadIds: sessions.liveUnreadIds,\n locallyReadIds: sessions.locallyReadIds,\n currentSessionId: sessions.activeSessionId,\n })\n\n return buildSessionNavItem<WorkspaceIcon>({\n id: sessions.id,\n label: sessions.label,\n icon: sessions.icon,\n href: sessions.href,\n sessions: composed.sessions,\n hrefForSession: sessions.hrefForSession,\n activeSessionId: sessions.activeSessionId,\n respondingSessionIds: sessions.respondingSessionIds,\n actions: sessions.actions,\n overflow: composed.hasMore\n ? { href: sessions.href, label: sessions.overflowLabel }\n : undefined,\n emptyLabel: sessions.emptyLabel,\n untitledLabel: sessions.untitledLabel,\n prefetch: sessions.prefetch,\n defaultOpen: sessions.defaultOpen,\n })\n })()\n : undefined\n\n const appNavItems: SidebarLayoutNavItem[] = (apps?.items ?? []).map((app) => {\n const href = apps!.hrefForApp(app.id)\n if (!href.startsWith('/') || href.startsWith('//') || /[?#\\\\]/.test(href)) {\n throw new Error('Workspace app href must be a local route path')\n }\n return {\n id: 'workspace-app:' + app.id,\n label: app.name,\n icon: apps!.icon,\n href,\n prefetch: apps!.prefetch,\n }\n })\n const appRoutes: NavRouteDef[] = activeRoute\n ? appNavItems.map((item) => {\n const path = routePathFromHref(item.href!, activeRoute.base)\n if (!path) throw new Error('Workspace app href must be under the active workspace')\n return { id: item.id, path }\n })\n : []\n\n const historyRoutePath = sessions && activeRoute\n ? routePathFromHref(sessions.href, activeRoute.base)\n : null\n\n const resolvedActiveId = activeRoute\n ? resolveActiveNavId({\n ...activeRoute,\n routes: [\n ...activeRoute.routes,\n ...appRoutes,\n ...(sessionNav && historyRoutePath\n ? [{ id: sessions?.id ?? 'history', path: historyRoutePath }]\n : []),\n ],\n })\n : activeId\n\n const activeAppId = appNavItems.some((item) => item.id === resolvedActiveId)\n ? resolvedActiveId\n : undefined\n const appGroup: SidebarLayoutNavItem | undefined = apps && appNavItems.length > 0\n ? {\n id: 'workspace-apps',\n label: 'Apps',\n icon: apps.icon,\n expandable: true,\n defaultOpen: activeAppId !== undefined,\n subItems: appNavItems.map(({ id, label, icon, href, prefetch }) => ({\n id,\n label,\n icon,\n href: href!,\n prefetch,\n })),\n subActiveIds: activeAppId ? [activeAppId] : undefined,\n }\n : undefined\n const workspaceNavItems: SidebarLayoutNavItem[] = [\n ...navItems,\n ...(appGroup ? [appGroup] : []),\n ...(sessionNav ? [sessionNav] : []),\n ]\n\n const layoutProps = {\n hideBelow: 'lg' as const,\n railLabels: true,\n ...sidebarProps,\n }\n\n return (\n <SidebarLayout\n {...layoutProps}\n navItems={workspaceNavItems}\n activeId={activeAppId ? appGroup?.id : resolvedActiveId}\n >\n {children}\n </SidebarLayout>\n )\n}\n\nexport { AgentWorkspaceCompanion, createAgentWorkspaceCompanionTabs, type AgentWorkspaceCompanionHandle, type AgentWorkspaceCompanionProps, type AgentWorkspaceCompanionTab, type AgentWorkspaceCompanionTool, type AgentWorkspaceCompanionTools, type AgentWorkspaceCompanionNavigation } from './companion'\n\nexport { WorkspaceSwitcher, type WorkspaceSwitcherItem, type WorkspaceSwitcherProps } from '../web-react/workspace-switcher'\n","import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState, type ReactNode } from 'react'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '@tangle-network/sandbox-ui/primitives'\nimport { WorkspaceLayout } from '@tangle-network/sandbox-ui/workspace'\nimport { FlaskConical, FolderOpen, GitCompare, Monitor, Terminal } from 'lucide-react'\n\nexport interface AgentWorkspaceCompanionTab {\n id: string\n label: string\n icon?: ReactNode\n /** Retain a visited tab through tab switches, pane closure, and viewport changes. */\n keepMounted?: boolean\n renderContent: (state: { active: boolean }) => ReactNode\n}\n\nexport type AgentWorkspaceCompanionTool = 'files' | 'agent' | 'terminal' | 'changes' | 'preview'\n\n/** Supply only tools the product can actually serve. Content remains product-owned. */\nexport type AgentWorkspaceCompanionTools = Partial<Record<AgentWorkspaceCompanionTool, AgentWorkspaceCompanionTab['renderContent']>>\n\nconst companionTools = [\n { id: 'files', label: 'Files', Icon: FolderOpen },\n { id: 'agent', label: 'Agent', Icon: FlaskConical },\n { id: 'terminal', label: 'Terminal', Icon: Terminal },\n { id: 'changes', label: 'Changes', Icon: GitCompare },\n { id: 'preview', label: 'Preview', Icon: Monitor },\n] as const\n\n/** Canonical order, labels, icons and lazy retention for companion tools. */\nexport function createAgentWorkspaceCompanionTabs(tools: AgentWorkspaceCompanionTools): AgentWorkspaceCompanionTab[] {\n return companionTools.flatMap(({ id, label, Icon }) => {\n const renderContent = tools[id]\n return renderContent ? [{ id, label, icon: <Icon className=\"h-3.5 w-3.5\" aria-hidden />, keepMounted: true, renderContent }] : []\n })\n}\n\nexport interface AgentWorkspaceCompanionNavigation {\n content: ReactNode\n header?: ReactNode\n open?: boolean\n onOpenChange?: (open: boolean) => void\n label?: string\n defaultWidth?: number\n minWidth?: number\n maxWidth?: number\n collapsedControl?: ReactNode\n}\n\nexport interface AgentWorkspaceCompanionHandle {\n openTab: (tabId: string) => boolean\n}\n\nexport interface AgentWorkspaceCompanionProps {\n children: ReactNode\n /** Use tools for shared defaults; tabs overrides them for product-specific navigation. */\n tabs?: readonly AgentWorkspaceCompanionTab[]\n tools?: AgentWorkspaceCompanionTools\n /** Optional session navigation, composed in the same responsive layout. */\n navigation?: AgentWorkspaceCompanionNavigation\n keyboardShortcuts?: boolean\n open?: boolean\n onOpenChange?: (open: boolean) => void\n defaultOpen?: boolean\n activeTabId?: string\n onActiveTabChange?: (tabId: string) => void\n defaultActiveTabId?: string\n /** Namespace for remembered tab selection and underlying pane dimensions. */\n persistenceKey?: string\n label?: string\n defaultWidth?: number\n className?: string\n}\n\n/** Product-owned tools beside a conversation; omitted tools have no tabs or effects. */\nexport const AgentWorkspaceCompanion = forwardRef<AgentWorkspaceCompanionHandle, AgentWorkspaceCompanionProps>(function AgentWorkspaceCompanion({\n children,\n tabs: customTabs,\n tools,\n navigation,\n keyboardShortcuts,\n open: controlledOpen,\n onOpenChange,\n defaultOpen = false,\n activeTabId,\n onActiveTabChange,\n defaultActiveTabId,\n persistenceKey,\n label = 'Workspace tools',\n defaultWidth = 420,\n className,\n}, ref) {\n const tabs = customTabs ?? createAgentWorkspaceCompanionTabs(tools ?? {})\n const [uncontrolledOpen, setOpen] = useState(defaultOpen)\n const open = controlledOpen ?? uncontrolledOpen\n const [selection, setSelection] = useState({ key: persistenceKey, id: defaultActiveTabId })\n const [visits, setVisits] = useState<{ key: string | undefined; ids: ReadonlySet<string> }>(() => ({ key: persistenceKey, ids: new Set() }))\n const requested = activeTabId ?? (selection.key === persistenceKey ? selection.id : defaultActiveTabId)\n const active = tabs.find((tab) => tab.id === requested)?.id ?? tabs[0]?.id\n const visited = visits.key === persistenceKey ? visits.ids : new Set<string>()\n const storageKey = persistenceKey ? `${persistenceKey}:companion-tab` : undefined\n\n const pendingRestoration = useRef<{ key: string | undefined; id: string | undefined } | undefined>(undefined)\n const reconciledSelection = useRef<string | undefined>(undefined)\n const restoredKey = useRef<string | undefined>(undefined)\n useEffect(() => {\n const key = JSON.stringify([persistenceKey, defaultActiveTabId])\n if (restoredKey.current === key || tabs.length === 0) return\n let id = activeTabId ?? defaultActiveTabId\n if (storageKey) {\n try { id = window.localStorage.getItem(storageKey) ?? id } catch { /* Browser storage is optional. */ }\n }\n const resolved = tabs.find((tab) => tab.id === id)?.id ?? tabs[0]?.id\n restoredKey.current = key\n pendingRestoration.current = { key: persistenceKey, id: resolved }\n setSelection({ key: persistenceKey, id: resolved })\n if (resolved && resolved !== activeTabId) {\n reconciledSelection.current = JSON.stringify([persistenceKey, requested, resolved])\n onActiveTabChange?.(resolved)\n }\n }, [storageKey, persistenceKey, defaultActiveTabId, activeTabId, requested, tabs, onActiveTabChange])\n\n useEffect(() => {\n // Let restored selection reach the controlled parent before reconciling stale props.\n const pending = pendingRestoration.current\n if (pending) {\n const acknowledged = activeTabId === undefined\n ? selection.key === pending.key && selection.id === pending.id\n : activeTabId === pending.id\n if (!acknowledged) return\n pendingRestoration.current = undefined\n }\n if (!active || tabs.some((tab) => tab.id === requested)) {\n reconciledSelection.current = undefined\n return\n }\n const key = JSON.stringify([persistenceKey, requested, active])\n if (reconciledSelection.current === key) return\n reconciledSelection.current = key\n setSelection({ key: persistenceKey, id: active })\n onActiveTabChange?.(active)\n }, [active, activeTabId, requested, selection, persistenceKey, tabs, onActiveTabChange])\n\n useEffect(() => {\n if (!open || !active) return\n setVisits((previous) => {\n const ids = previous.key === persistenceKey ? previous.ids : new Set<string>()\n return ids.has(active) ? previous : { key: persistenceKey, ids: new Set([...ids, active]) }\n })\n }, [open, active, persistenceKey])\n\n const selectTab = useCallback((id: string) => {\n if (!tabs.some((tab) => tab.id === id)) return false\n setSelection({ key: persistenceKey, id })\n onActiveTabChange?.(id)\n if (storageKey) {\n try { window.localStorage.setItem(storageKey, id) } catch { /* Selection still works without storage. */ }\n }\n return true\n }, [tabs, persistenceKey, storageKey, onActiveTabChange])\n const changeOpen = useCallback((next: boolean) => {\n setOpen(next)\n onOpenChange?.(next)\n }, [onOpenChange])\n\n useImperativeHandle(ref, () => ({\n openTab(id) {\n if (!selectTab(id)) return false\n changeOpen(true)\n return true\n },\n }), [selectTab, changeOpen])\n\n if (tabs.length === 0 && !navigation) return <>{children}</>\n\n return (\n <Tabs key={persistenceKey} value={active} onValueChange={selectTab} className={`flex h-full min-h-0 min-w-0 flex-1 flex-col ${className ?? ''}`}>\n <WorkspaceLayout\n className=\"h-full min-h-0 min-w-0 flex-1\"\n collapsedControlsPlacement=\"overlay\"\n keepRightMounted\n center={children}\n left={navigation?.content}\n leftContentClassName=\"py-0\"\n leftHeader={navigation && (navigation.header !== undefined ? navigation.header : <span className=\"text-sm font-medium\">{navigation.label ?? 'Chats'}</span>)}\n leftOpen={navigation?.open}\n onLeftOpenChange={navigation?.onOpenChange}\n leftLabel={navigation?.label ?? 'Chats'}\n defaultLeftWidth={navigation?.defaultWidth ?? 260}\n minLeftWidth={navigation?.minWidth ?? 200}\n maxLeftWidth={navigation?.maxWidth ?? 400}\n leftCollapsedControl={navigation?.collapsedControl}\n keyboardShortcuts={keyboardShortcuts}\n rightOpen={open}\n onRightOpenChange={changeOpen}\n rightLabel={label}\n defaultRightWidth={defaultWidth}\n persistenceKey={persistenceKey}\n minRightWidth={280}\n rightContentClassName=\"flex flex-col overflow-hidden\"\n rightHeader={tabs.length > 0 ? (\n <TabsList aria-label={label} className=\"h-9 max-w-full justify-start overflow-x-auto bg-transparent p-0\">\n {tabs.map((tab) => (\n <TabsTrigger key={tab.id} value={tab.id} className=\"gap-1.5 px-2.5 text-sm\">\n {tab.icon}<span>{tab.label}</span>\n </TabsTrigger>\n ))}\n </TabsList>\n ) : undefined}\n right={tabs.length > 0 ? tabs.map((tab) => {\n const isActive = tab.id === active\n const retained = tab.keepMounted && visited.has(tab.id)\n if (!(open && isActive) && !retained) return null\n return (\n <TabsContent\n key={tab.id}\n value={tab.id}\n forceMount={retained ? true : undefined}\n hidden={!open || !isActive}\n className=\"m-0 h-full min-h-0 min-w-0 flex-1 data-[state=inactive]:hidden\"\n >\n {tab.renderContent({ active: open && isActive })}\n </TabsContent>\n )\n }) : undefined}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AAAA,IACH,QAAQ;AAAA,MACN,GAAG,YAAY;AAAA,MACf,GAAG;AAAA,MACH,GAAI,cAAc,mBACd,CAAC,EAAE,IAAI,UAAU,MAAM,WAAW,MAAM,iBAAiB,CAAC,IAC1D,CAAC;AAAA,IACP;AAAA,EACF,CAAC,IACD;AAEJ,QAAM,cAAc,YAAY,KAAK,CAAC,SAAS,KAAK,OAAO,gBAAgB,IACvE,mBACA;AACJ,QAAM,WAA6C,QAAQ,YAAY,SAAS,IAC5E;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,MAAM,KAAK;AAAA,IACX,YAAY;AAAA,IACZ,aAAa,gBAAgB;AAAA,IAC7B,UAAU,YAAY,IAAI,CAAC,EAAE,IAAI,OAAO,MAAM,MAAM,SAAS,OAAO;AAAA,MAClE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE;AAAA,IACF,cAAc,cAAc,CAAC,WAAW,IAAI;AAAA,EAC9C,IACA;AACJ,QAAM,oBAA4C;AAAA,IAChD,GAAG;AAAA,IACH,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;AAAA,IAC7B,GAAI,aAAa,CAAC,UAAU,IAAI,CAAC;AAAA,EACnC;AAEA,QAAM,cAAc;AAAA,IAClB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,GAAG;AAAA,EACL;AAEA,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,UAAU;AAAA,MACV,UAAU,cAAc,UAAU,KAAK;AAAA,MAEtC;AAAA;AAAA,EACH;AAEJ;","names":["AgentWorkspaceCompanion","jsx"]}
1
+ {"version":3,"sources":["../../src/workspace-react/index.tsx","../../src/workspace-react/rail-identity.tsx","../../src/workspace-react/companion.tsx","../../src/workspace-react/workspace-list.tsx"],"sourcesContent":["import { SidebarLayout, type SidebarLayoutNavItem, type SidebarLayoutProps } from '@tangle-network/sandbox-ui/dashboard'\nimport type { ReactNode } from 'react'\n\nimport type { WorkspaceAppRecord } from '../workspace-apps'\nimport { AgentRailIdentity, type AgentProductIdentity, type AgentWorkspaceIdentity } from './rail-identity'\n\nimport {\n buildSessionNavItem,\n composeSidebarSessions,\n resolveActiveNavId,\n type NavRouteDef,\n type RailPrefetch,\n type SessionRowActions,\n type SessionSummary,\n} from '../session-shell'\n\ntype WorkspaceIcon = SidebarLayoutNavItem['icon']\n\nfunction routePathFromHref(href: string, base: string): string | null {\n const path = href.split(/[?#]/, 1)[0] ?? ''\n const root = base.replace(/\\/+$/, '')\n if (path === root) return '/'\n if (!path.startsWith(`${root}/`)) return null\n return path.slice(root.length)\n}\n\n/** The session data and product-owned URLs needed by the default workspace. */\nexport interface AgentWorkspaceSessionConfig {\n /** Icon shown beside the expandable History row. */\n icon: WorkspaceIcon\n /** Id for the session row; defaults to `history`. */\n id?: string\n /** Product copy for the session row; defaults to `History`. */\n label?: string\n /** Full-history route used by the row and overflow item. */\n href: string\n /** Product-owned URL for an individual session. */\n hrefForSession: (sessionId: string) => string\n /** Server-loaded rows, ordered by the product's query. */\n sessions: SessionSummary[]\n /** Sessions created by another tab before the loader revalidates. */\n optimisticSessions?: SessionSummary[]\n /** Number of rows shown in the rail before the full-history link. */\n limit?: number\n /** Total persisted session count, used to decide whether overflow exists. */\n totalCount?: number\n /** Session currently open in the route. */\n activeSessionId?: string | null\n /** Sessions with a live turn. */\n respondingSessionIds?: ReadonlySet<string>\n /** Live unread ids from the product's event channel. */\n liveUnreadIds?: ReadonlySet<string>\n /** Ids this tab has opened since the loader ran. */\n locallyReadIds?: ReadonlySet<string>\n /** Optional product-owned rename/delete/pin actions. */\n actions?: SessionRowActions<WorkspaceIcon>\n /** Label for the overflow row. Defaults to `View all chats`. */\n overflowLabel?: string\n /** Empty state for the expanded rail row. Defaults to `No chats yet`. */\n emptyLabel?: string\n /** Fallback title for untitled sessions. */\n untitledLabel?: string\n /** Router prefetch behavior for session links. */\n prefetch?: RailPrefetch\n /** Whether History starts expanded. Defaults to `true`. */\n defaultOpen?: boolean\n}\n\n/**\n * Registered apps shown under one expandable workspace destination.\n * Products supply authorized rows and their real route; preview URLs never\n * become navigation hrefs.\n */\nexport interface AgentWorkspaceAppsConfig {\n icon: WorkspaceIcon\n items: readonly Pick<WorkspaceAppRecord, 'id' | 'name'>[]\n hrefForApp: (appId: string) => string\n prefetch?: RailPrefetch\n}\n\n/** Route data for the shared active-nav resolver. */\nexport interface AgentWorkspaceActiveRoute {\n /** Current browser pathname, including the product's workspace base. */\n pathname: string\n /** Product route root, for example `/app/ws_123`. */\n base: string\n /** Product-owned rail routes, relative to `base`. */\n routes: NavRouteDef[]\n /** Extra route prefixes that should highlight an existing row. */\n aliases?: Record<string, string>\n /** Route prefixes that intentionally highlight no row. */\n claimsNothing?: string[]\n}\n\nexport interface AgentWorkspaceLayoutProps\n extends Omit<SidebarLayoutProps, 'activeId' | 'children' | 'navItems' | 'hideBelow' | 'railLabels'> {\n children: ReactNode\n /**\n * The product's name, mark, and home. With it the shell draws the canonical\n * rail top — mark, then the open workspace and product name — so products\n * stop hand-building `logo` and `railHeaderContent`.\n */\n product?: AgentProductIdentity\n /** The open workspace and where else this person can go. Omit on the listing. */\n workspace?: AgentWorkspaceIdentity | null\n /** Product-owned destinations. Shared Apps and History rows follow them. */\n navItems: SidebarLayoutNavItem[]\n /** Omit for a workflow-only shell with no conversational session rail. */\n sessions?: AgentWorkspaceSessionConfig\n /** Authorized app destinations, in the product's persisted order. */\n apps?: AgentWorkspaceAppsConfig\n /** When supplied, active navigation is resolved by the shared route rules. */\n activeRoute?: AgentWorkspaceActiveRoute\n /** Escape hatch for routers that already resolved the active item. */\n activeId?: string\n /** Hide the fixed desktop rail below this breakpoint. Defaults to `lg`. */\n hideBelow?: SidebarLayoutProps['hideBelow']\n /** Show labels beside rail icons. Defaults to `true`. */\n railLabels?: SidebarLayoutProps['railLabels']\n}\n\n/**\n * The default agent workspace composition.\n *\n * Products own their navigation taxonomy, routes, and session storage. This\n * component owns the repeated assembly: the standard visual layout, the\n * expandable Apps and History rows, capped session composition, unread state,\n * and active route resolution. The full History route and the empty-state composer stay\n * separate because their data and domain copy belong to the product; pair this\n * with `SessionHistoryPanel` and `EntryComposer` for the complete chat-first\n * structure.\n */\nexport function AgentWorkspaceLayout({\n children,\n navItems,\n sessions,\n apps,\n activeRoute,\n activeId,\n product,\n workspace,\n ...sidebarProps\n}: AgentWorkspaceLayoutProps) {\n const sessionNav = sessions\n ? (() => {\n const composed = composeSidebarSessions({\n loaderSessions: sessions.sessions,\n optimisticSessions: sessions.optimisticSessions,\n limit: sessions.limit ?? 20,\n totalCount: sessions.totalCount,\n liveUnreadIds: sessions.liveUnreadIds,\n locallyReadIds: sessions.locallyReadIds,\n currentSessionId: sessions.activeSessionId,\n })\n\n return buildSessionNavItem<WorkspaceIcon>({\n id: sessions.id,\n label: sessions.label,\n icon: sessions.icon,\n href: sessions.href,\n sessions: composed.sessions,\n hrefForSession: sessions.hrefForSession,\n activeSessionId: sessions.activeSessionId,\n respondingSessionIds: sessions.respondingSessionIds,\n actions: sessions.actions,\n overflow: composed.hasMore\n ? { href: sessions.href, label: sessions.overflowLabel }\n : undefined,\n emptyLabel: sessions.emptyLabel,\n untitledLabel: sessions.untitledLabel,\n prefetch: sessions.prefetch,\n defaultOpen: sessions.defaultOpen,\n })\n })()\n : undefined\n\n const appNavItems: SidebarLayoutNavItem[] = (apps?.items ?? []).map((app) => {\n const href = apps!.hrefForApp(app.id)\n if (!href.startsWith('/') || href.startsWith('//') || /[?#\\\\]/.test(href)) {\n throw new Error('Workspace app href must be a local route path')\n }\n return {\n id: 'workspace-app:' + app.id,\n label: app.name,\n icon: apps!.icon,\n href,\n prefetch: apps!.prefetch,\n }\n })\n const appRoutes: NavRouteDef[] = activeRoute\n ? appNavItems.map((item) => {\n const path = routePathFromHref(item.href!, activeRoute.base)\n if (!path) throw new Error('Workspace app href must be under the active workspace')\n return { id: item.id, path }\n })\n : []\n\n const historyRoutePath = sessions && activeRoute\n ? routePathFromHref(sessions.href, activeRoute.base)\n : null\n\n const resolvedActiveId = activeRoute\n ? resolveActiveNavId({\n ...activeRoute,\n routes: [\n ...activeRoute.routes,\n ...appRoutes,\n ...(sessionNav && historyRoutePath\n ? [{ id: sessions?.id ?? 'history', path: historyRoutePath }]\n : []),\n ],\n })\n : activeId\n\n const activeAppId = appNavItems.some((item) => item.id === resolvedActiveId)\n ? resolvedActiveId\n : undefined\n const appGroup: SidebarLayoutNavItem | undefined = apps && appNavItems.length > 0\n ? {\n id: 'workspace-apps',\n label: 'Apps',\n icon: apps.icon,\n expandable: true,\n defaultOpen: activeAppId !== undefined,\n subItems: appNavItems.map(({ id, label, icon, href, prefetch }) => ({\n id,\n label,\n icon,\n href: href!,\n prefetch,\n })),\n subActiveIds: activeAppId ? [activeAppId] : undefined,\n }\n : undefined\n const workspaceNavItems: SidebarLayoutNavItem[] = [\n ...navItems,\n ...(appGroup ? [appGroup] : []),\n ...(sessionNav ? [sessionNav] : []),\n ]\n\n const hideBelow = sidebarProps.hideBelow ?? 'lg'\n const identityProps = product\n ? {\n logo: product.mark,\n logoHref: product.href,\n railHeaderContent: (\n <AgentRailIdentity\n product={product}\n workspace={workspace}\n hideBelow={hideBelow}\n LinkComponent={sidebarProps.LinkComponent}\n />\n ),\n }\n : {}\n const layoutProps = {\n hideBelow,\n railLabels: true,\n ...identityProps,\n ...sidebarProps,\n }\n\n return (\n <SidebarLayout\n {...layoutProps}\n navItems={workspaceNavItems}\n activeId={activeAppId ? appGroup?.id : resolvedActiveId}\n >\n {children}\n </SidebarLayout>\n )\n}\n\nexport { AgentWorkspaceCompanion, createAgentWorkspaceCompanionTabs, type AgentWorkspaceCompanionHandle, type AgentWorkspaceCompanionProps, type AgentWorkspaceCompanionTab, type AgentWorkspaceCompanionTool, type AgentWorkspaceCompanionTools, type AgentWorkspaceCompanionNavigation } from './companion'\n\nexport { WorkspaceSwitcher, type WorkspaceSwitcherItem, type WorkspaceSwitcherProps } from '../web-react/workspace-switcher'\n\nexport { WorkspaceInitial } from '../web-react/workspace-switcher'\nexport {\n AgentRailIdentity,\n DEFAULT_WORKSPACE_NOUN,\n type AgentProductIdentity,\n type AgentRailIdentityProps,\n type AgentWorkspaceIdentity,\n type AgentWorkspaceNoun,\n} from './rail-identity'\n\nexport {\n WorkspaceList,\n type WorkspaceListAction,\n type WorkspaceListField,\n type WorkspaceListItem,\n type WorkspaceListProps,\n} from './workspace-list'\n","import { useCallback, useState, type ComponentType, type ReactNode } from 'react'\n\nimport { CheckGlyph, OVERLAY_SHADOW, PopoverSurface } from '../web-react/controls'\nimport { usePopoverDialog } from '../web-react/popover-dialog'\nimport { WorkspaceInitial } from '../web-react/workspace-switcher'\n\n/** What a product is called and how it is marked. The same three values for every product. */\nexport interface AgentProductIdentity {\n /** Short product name, for example `Legal` or `GTM`. */\n name: string\n /** Square brand mark, sized by the product for a 20px slot. */\n mark: ReactNode\n /** Where the mark leads: the workspace listing, or home when there is none. */\n href: string\n}\n\n/** The words a product uses for one workspace and for several. */\nexport interface AgentWorkspaceNoun {\n singular: string\n plural: string\n}\n\nexport const DEFAULT_WORKSPACE_NOUN: AgentWorkspaceNoun = { singular: 'workspace', plural: 'workspaces' }\n\n/** The workspace that is open, and where else this person can go. */\nexport interface AgentWorkspaceIdentity {\n id: string\n name: string\n /** Defaults to workspace / workspaces. */\n noun?: AgentWorkspaceNoun\n /** Every workspace this person can open, including the open one, in the product's order. */\n options?: readonly { id: string; name: string }[]\n /** Required with `options`: the route that opens a workspace. */\n hrefForWorkspace?: (workspaceId: string) => string\n /** The listing route. Adds an \"All …\" entry. */\n listHref?: string\n /** The creation route. Adds a \"New …\" entry. */\n createHref?: string\n}\n\n/** The number of workspaces past which the switcher offers a search field. */\nconst SEARCH_THRESHOLD = 7\n\nconst HIDE_ON_RAIL: Record<'md' | 'lg', string> = { md: 'md:hidden', lg: 'lg:hidden' }\n\nfunction capitalize(text: string): string {\n return text.charAt(0).toLocaleUpperCase() + text.slice(1)\n}\n\nexport interface AgentRailIdentityProps {\n product: AgentProductIdentity\n workspace?: AgentWorkspaceIdentity | null\n /**\n * The breakpoint below which the fixed rail is hidden. The rail draws the\n * mark itself; below this width the same content heads the mobile bar and\n * drawer, which have no mark of their own.\n */\n hideBelow?: 'md' | 'lg'\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches SidebarLayout's router-agnostic link slot\n LinkComponent?: ComponentType<any>\n}\n\nfunction DefaultLink({ href, to, ...props }: { href?: string; to?: string; [key: string]: unknown }) {\n return <a href={href ?? to} {...props} />\n}\n\n/**\n * The top of every product's rail: which product, and which workspace.\n *\n * One line when no workspace is open (the listing), two when one is: the\n * workspace name, then the product beneath it. Both truncate inside the rail\n * and carry the full text as a tooltip, so a long name can never push into\n * the collapse button or the page beside the rail. It is a switcher only when\n * there is somewhere to switch to; a menu that lists one item is not offered.\n */\nexport function AgentRailIdentity({ product, workspace, hideBelow = 'lg', LinkComponent }: AgentRailIdentityProps) {\n const Link = LinkComponent ?? DefaultLink\n const mobileMark = (\n <span aria-hidden className={`flex h-7 w-7 shrink-0 items-center justify-center ${HIDE_ON_RAIL[hideBelow]}`}>\n {product.mark}\n </span>\n )\n\n if (!workspace) {\n return (\n <Link\n href={product.href}\n to={product.href}\n title={product.name}\n className=\"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 transition-colors hover:bg-accent\"\n >\n {mobileMark}\n <span className=\"min-w-0 flex-1 truncate text-sm font-semibold text-foreground\">{product.name}</span>\n </Link>\n )\n }\n\n const stack = (\n <span className=\"min-w-0 flex-1 text-left\">\n <span className=\"block truncate text-sm font-semibold leading-5 text-foreground\">{workspace.name}</span>\n <span className=\"block truncate text-xs leading-4 text-muted-foreground\">{product.name}</span>\n </span>\n )\n const others = (workspace.options ?? []).filter((option) => option.id !== workspace.id)\n const switchable = (others.length > 0 && workspace.hrefForWorkspace !== undefined) || Boolean(workspace.listHref) || Boolean(workspace.createHref)\n\n if (!switchable) {\n return (\n <div title={`${workspace.name} · ${product.name}`} className=\"flex w-full min-w-0 items-center gap-2 px-1.5 py-1\">\n {mobileMark}\n {stack}\n </div>\n )\n }\n\n return <WorkspaceMenu product={product} workspace={workspace} mobileMark={mobileMark} stack={stack} Link={Link} />\n}\n\nfunction WorkspaceMenu({\n product,\n workspace,\n mobileMark,\n stack,\n Link,\n}: {\n product: AgentProductIdentity\n workspace: AgentWorkspaceIdentity\n mobileMark: ReactNode\n stack: ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- router-agnostic link slot\n Link: ComponentType<any>\n}) {\n const [open, setOpen] = useState(false)\n const [query, setQuery] = useState('')\n const changeOpen = useCallback((next: boolean) => {\n setOpen(next)\n if (!next) setQuery('')\n }, [])\n // A non-modal dialog, like WorkspaceSwitcher: opening focuses the first\n // control, and Tab past the last one returns beside the trigger.\n const { containerRef, triggerRef, panelRef, triggerProps, id: panelId } = usePopoverDialog(open, changeOpen)\n const noun = workspace.noun ?? DEFAULT_WORKSPACE_NOUN\n const options = workspace.hrefForWorkspace ? workspace.options ?? [] : []\n const search = query.trim().toLocaleLowerCase()\n const visible = search ? options.filter((option) => option.name.toLocaleLowerCase().includes(search)) : options\n const close = () => changeOpen(false)\n const rowClass = 'flex min-h-9 w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent'\n\n return (\n <div ref={containerRef} className=\"w-full min-w-0\">\n <button\n type=\"button\"\n {...triggerProps}\n aria-label={`${capitalize(noun.singular)}: ${workspace.name}. Switch ${noun.singular}`}\n title={`${workspace.name} · ${product.name}`}\n onClick={() => changeOpen(!open)}\n className=\"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 transition-colors hover:bg-accent aria-expanded:bg-accent\"\n >\n {mobileMark}\n {stack}\n <svg aria-hidden className=\"h-4 w-4 shrink-0 text-muted-foreground\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\">\n <path d=\"m8 9 4-4 4 4m-8 6 4 4 4-4\" />\n </svg>\n </button>\n <PopoverSurface\n open={open}\n id={panelId}\n role=\"dialog\"\n aria-label={`Switch ${noun.singular}`}\n side=\"below\"\n triggerRef={triggerRef}\n panelRef={panelRef}\n contentKey={`${query}:${options.length}`}\n className={`w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-lg border border-card-edge bg-popover p-1.5 text-foreground ${OVERLAY_SHADOW}`}\n >\n {options.length > SEARCH_THRESHOLD && (\n <input\n data-autofocus\n aria-label={`Search ${noun.plural}`}\n placeholder={`Search ${noun.plural}`}\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n className=\"mb-1.5 h-9 w-full rounded-md border border-border bg-background px-2.5 text-sm text-foreground\"\n />\n )}\n {options.length > 0 && (\n <div className=\"max-h-72 overflow-y-auto\">\n {visible.map((option) => (\n <Link\n key={option.id}\n href={workspace.hrefForWorkspace!(option.id)}\n to={workspace.hrefForWorkspace!(option.id)}\n aria-current={option.id === workspace.id ? 'page' : undefined}\n title={option.name}\n onClick={close}\n className={rowClass}\n >\n <WorkspaceInitial name={option.name} />\n <span className=\"min-w-0 flex-1 truncate\">{option.name}</span>\n {option.id === workspace.id && <CheckGlyph className=\"h-4 w-4 shrink-0 text-primary\" />}\n </Link>\n ))}\n {visible.length === 0 && (\n <p role=\"status\" className=\"px-2 py-2 text-sm text-muted-foreground\">\n No {noun.plural} match “{query.trim()}”.\n </p>\n )}\n </div>\n )}\n {(workspace.listHref || workspace.createHref) && (\n <div className={options.length > 0 ? 'mt-1.5 border-t border-border pt-1.5' : undefined}>\n {workspace.listHref && (\n <Link href={workspace.listHref} to={workspace.listHref} onClick={close} className={rowClass}>\n <svg aria-hidden className=\"h-4 w-4 shrink-0 text-muted-foreground\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\">\n <rect x=\"4\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" /><rect x=\"13.5\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" /><rect x=\"4\" y=\"13.5\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" /><rect x=\"13.5\" y=\"13.5\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" />\n </svg>\n <span className=\"min-w-0 flex-1 truncate\">All {noun.plural}</span>\n </Link>\n )}\n {workspace.createHref && (\n <Link href={workspace.createHref} to={workspace.createHref} onClick={close} className={rowClass}>\n <svg aria-hidden className=\"h-4 w-4 shrink-0 text-muted-foreground\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\">\n <path d=\"M12 5v14M5 12h14\" />\n </svg>\n <span className=\"min-w-0 flex-1 truncate\">New {noun.singular}</span>\n </Link>\n )}\n </div>\n )}\n </PopoverSurface>\n </div>\n )\n}\n","import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState, type ReactNode } from 'react'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '@tangle-network/sandbox-ui/primitives'\nimport { WorkspaceLayout } from '@tangle-network/sandbox-ui/workspace'\nimport { FlaskConical, FolderOpen, GitCompare, Monitor, Terminal } from 'lucide-react'\n\nexport interface AgentWorkspaceCompanionTab {\n id: string\n label: string\n icon?: ReactNode\n /** Retain a visited tab through tab switches, pane closure, and viewport changes. */\n keepMounted?: boolean\n renderContent: (state: { active: boolean }) => ReactNode\n}\n\nexport type AgentWorkspaceCompanionTool = 'files' | 'agent' | 'terminal' | 'changes' | 'preview'\n\n/** Supply only tools the product can actually serve. Content remains product-owned. */\nexport type AgentWorkspaceCompanionTools = Partial<Record<AgentWorkspaceCompanionTool, AgentWorkspaceCompanionTab['renderContent']>>\n\nconst companionTools = [\n { id: 'files', label: 'Files', Icon: FolderOpen },\n { id: 'agent', label: 'Agent', Icon: FlaskConical },\n { id: 'terminal', label: 'Terminal', Icon: Terminal },\n { id: 'changes', label: 'Changes', Icon: GitCompare },\n { id: 'preview', label: 'Preview', Icon: Monitor },\n] as const\n\n/** Canonical order, labels, icons and lazy retention for companion tools. */\nexport function createAgentWorkspaceCompanionTabs(tools: AgentWorkspaceCompanionTools): AgentWorkspaceCompanionTab[] {\n return companionTools.flatMap(({ id, label, Icon }) => {\n const renderContent = tools[id]\n return renderContent ? [{ id, label, icon: <Icon className=\"h-3.5 w-3.5\" aria-hidden />, keepMounted: true, renderContent }] : []\n })\n}\n\nexport interface AgentWorkspaceCompanionNavigation {\n content: ReactNode\n header?: ReactNode\n open?: boolean\n onOpenChange?: (open: boolean) => void\n label?: string\n defaultWidth?: number\n minWidth?: number\n maxWidth?: number\n collapsedControl?: ReactNode\n}\n\nexport interface AgentWorkspaceCompanionHandle {\n openTab: (tabId: string) => boolean\n}\n\nexport interface AgentWorkspaceCompanionProps {\n children: ReactNode\n /** Use tools for shared defaults; tabs overrides them for product-specific navigation. */\n tabs?: readonly AgentWorkspaceCompanionTab[]\n tools?: AgentWorkspaceCompanionTools\n /** Optional session navigation, composed in the same responsive layout. */\n navigation?: AgentWorkspaceCompanionNavigation\n keyboardShortcuts?: boolean\n open?: boolean\n onOpenChange?: (open: boolean) => void\n defaultOpen?: boolean\n activeTabId?: string\n onActiveTabChange?: (tabId: string) => void\n defaultActiveTabId?: string\n /** Namespace for remembered tab selection and underlying pane dimensions. */\n persistenceKey?: string\n label?: string\n defaultWidth?: number\n className?: string\n}\n\n/** Product-owned tools beside a conversation; omitted tools have no tabs or effects. */\nexport const AgentWorkspaceCompanion = forwardRef<AgentWorkspaceCompanionHandle, AgentWorkspaceCompanionProps>(function AgentWorkspaceCompanion({\n children,\n tabs: customTabs,\n tools,\n navigation,\n keyboardShortcuts,\n open: controlledOpen,\n onOpenChange,\n defaultOpen = false,\n activeTabId,\n onActiveTabChange,\n defaultActiveTabId,\n persistenceKey,\n label = 'Workspace tools',\n defaultWidth = 420,\n className,\n}, ref) {\n const tabs = customTabs ?? createAgentWorkspaceCompanionTabs(tools ?? {})\n const [uncontrolledOpen, setOpen] = useState(defaultOpen)\n const open = controlledOpen ?? uncontrolledOpen\n const [selection, setSelection] = useState({ key: persistenceKey, id: defaultActiveTabId })\n const [visits, setVisits] = useState<{ key: string | undefined; ids: ReadonlySet<string> }>(() => ({ key: persistenceKey, ids: new Set() }))\n const requested = activeTabId ?? (selection.key === persistenceKey ? selection.id : defaultActiveTabId)\n const active = tabs.find((tab) => tab.id === requested)?.id ?? tabs[0]?.id\n const visited = visits.key === persistenceKey ? visits.ids : new Set<string>()\n const storageKey = persistenceKey ? `${persistenceKey}:companion-tab` : undefined\n\n const pendingRestoration = useRef<{ key: string | undefined; id: string | undefined } | undefined>(undefined)\n const reconciledSelection = useRef<string | undefined>(undefined)\n const restoredKey = useRef<string | undefined>(undefined)\n useEffect(() => {\n const key = JSON.stringify([persistenceKey, defaultActiveTabId])\n if (restoredKey.current === key || tabs.length === 0) return\n let id = activeTabId ?? defaultActiveTabId\n if (storageKey) {\n try { id = window.localStorage.getItem(storageKey) ?? id } catch { /* Browser storage is optional. */ }\n }\n const resolved = tabs.find((tab) => tab.id === id)?.id ?? tabs[0]?.id\n restoredKey.current = key\n pendingRestoration.current = { key: persistenceKey, id: resolved }\n setSelection({ key: persistenceKey, id: resolved })\n if (resolved && resolved !== activeTabId) {\n reconciledSelection.current = JSON.stringify([persistenceKey, requested, resolved])\n onActiveTabChange?.(resolved)\n }\n }, [storageKey, persistenceKey, defaultActiveTabId, activeTabId, requested, tabs, onActiveTabChange])\n\n useEffect(() => {\n // Let restored selection reach the controlled parent before reconciling stale props.\n const pending = pendingRestoration.current\n if (pending) {\n const acknowledged = activeTabId === undefined\n ? selection.key === pending.key && selection.id === pending.id\n : activeTabId === pending.id\n if (!acknowledged) return\n pendingRestoration.current = undefined\n }\n if (!active || tabs.some((tab) => tab.id === requested)) {\n reconciledSelection.current = undefined\n return\n }\n const key = JSON.stringify([persistenceKey, requested, active])\n if (reconciledSelection.current === key) return\n reconciledSelection.current = key\n setSelection({ key: persistenceKey, id: active })\n onActiveTabChange?.(active)\n }, [active, activeTabId, requested, selection, persistenceKey, tabs, onActiveTabChange])\n\n useEffect(() => {\n if (!open || !active) return\n setVisits((previous) => {\n const ids = previous.key === persistenceKey ? previous.ids : new Set<string>()\n return ids.has(active) ? previous : { key: persistenceKey, ids: new Set([...ids, active]) }\n })\n }, [open, active, persistenceKey])\n\n const selectTab = useCallback((id: string) => {\n if (!tabs.some((tab) => tab.id === id)) return false\n setSelection({ key: persistenceKey, id })\n onActiveTabChange?.(id)\n if (storageKey) {\n try { window.localStorage.setItem(storageKey, id) } catch { /* Selection still works without storage. */ }\n }\n return true\n }, [tabs, persistenceKey, storageKey, onActiveTabChange])\n const changeOpen = useCallback((next: boolean) => {\n setOpen(next)\n onOpenChange?.(next)\n }, [onOpenChange])\n\n useImperativeHandle(ref, () => ({\n openTab(id) {\n if (!selectTab(id)) return false\n changeOpen(true)\n return true\n },\n }), [selectTab, changeOpen])\n\n if (tabs.length === 0 && !navigation) return <>{children}</>\n\n return (\n <Tabs key={persistenceKey} value={active} onValueChange={selectTab} className={`flex h-full min-h-0 min-w-0 flex-1 flex-col ${className ?? ''}`}>\n <WorkspaceLayout\n className=\"h-full min-h-0 min-w-0 flex-1\"\n collapsedControlsPlacement=\"overlay\"\n keepRightMounted\n center={children}\n left={navigation?.content}\n leftContentClassName=\"py-0\"\n leftHeader={navigation && (navigation.header !== undefined ? navigation.header : <span className=\"text-sm font-medium\">{navigation.label ?? 'Chats'}</span>)}\n leftOpen={navigation?.open}\n onLeftOpenChange={navigation?.onOpenChange}\n leftLabel={navigation?.label ?? 'Chats'}\n defaultLeftWidth={navigation?.defaultWidth ?? 260}\n minLeftWidth={navigation?.minWidth ?? 200}\n maxLeftWidth={navigation?.maxWidth ?? 400}\n leftCollapsedControl={navigation?.collapsedControl}\n keyboardShortcuts={keyboardShortcuts}\n rightOpen={open}\n onRightOpenChange={changeOpen}\n rightLabel={label}\n defaultRightWidth={defaultWidth}\n persistenceKey={persistenceKey}\n minRightWidth={280}\n rightContentClassName=\"flex flex-col overflow-hidden\"\n rightHeader={tabs.length > 0 ? (\n <TabsList aria-label={label} className=\"h-9 max-w-full justify-start overflow-x-auto bg-transparent p-0\">\n {tabs.map((tab) => (\n <TabsTrigger key={tab.id} value={tab.id} className=\"gap-1.5 px-2.5 text-sm\">\n {tab.icon}<span>{tab.label}</span>\n </TabsTrigger>\n ))}\n </TabsList>\n ) : undefined}\n right={tabs.length > 0 ? tabs.map((tab) => {\n const isActive = tab.id === active\n const retained = tab.keepMounted && visited.has(tab.id)\n if (!(open && isActive) && !retained) return null\n return (\n <TabsContent\n key={tab.id}\n value={tab.id}\n forceMount={retained ? true : undefined}\n hidden={!open || !isActive}\n className=\"m-0 h-full min-h-0 min-w-0 flex-1 data-[state=inactive]:hidden\"\n >\n {tab.renderContent({ active: open && isActive })}\n </TabsContent>\n )\n }) : undefined}\n />\n </Tabs>\n )\n})\n","import { useId, useMemo, useState, type ComponentType, type ReactNode } from 'react'\n\nimport { ActionDialog, ActionDialogButton } from '../web-react/action-dialog'\nimport { OVERLAY_SHADOW, PopoverSurface, usePopover } from '../web-react/controls'\nimport { WorkspaceInitial } from '../web-react/workspace-switcher'\nimport { DEFAULT_WORKSPACE_NOUN, type AgentWorkspaceNoun } from './rail-identity'\n\n/** One workspace as the listing shows it. */\nexport interface WorkspaceListItem {\n id: string\n name: string\n /** The route that opens it. */\n href: string\n /** One line under the name. Not shown when it only repeats the name. */\n description?: string | null\n /** Last activity. Shown as a short date. */\n updatedAt?: string | number | Date | null\n /** Values for the product's `fields`, keyed by field id. */\n values?: Readonly<Record<string, ReactNode>>\n /** Replaces the initial avatar, for example with a logo the product already has. */\n avatar?: ReactNode\n}\n\n/** A product column: a value the user compares across workspaces (tax year, status, owner). */\nexport interface WorkspaceListField {\n id: string\n label: string\n}\n\n/** A non-destructive product action in an item's overflow menu. */\nexport interface WorkspaceListAction {\n id: string\n label: string\n onSelect: (item: WorkspaceListItem) => void\n}\n\nexport interface WorkspaceListProps {\n items: readonly WorkspaceListItem[]\n /** The product's words for one workspace and several. Defaults to workspace / workspaces. */\n noun?: AgentWorkspaceNoun\n /** Page title. Defaults to the capitalized plural noun. */\n title?: string\n /** One sentence under the title, when the page needs one. */\n description?: ReactNode\n /** `list` rows for records people compare; `grid` cards for a handful of rich projects. */\n layout?: 'list' | 'grid'\n /** Product values, shown as columns (list) or under the description (grid). */\n fields?: readonly WorkspaceListField[]\n /**\n * The one primary action, labelled \"New {singular}\" unless `label` says otherwise.\n * `href` navigates; `onSelect` opens the product's own creation flow; `onCreate`\n * asks for a name in the shared dialog and hands it over — reject with an Error\n * to show its message, and navigate to the new workspace from inside it.\n */\n create?: {\n label?: string\n href?: string\n onSelect?: () => void\n onCreate?: (name: string) => Promise<void>\n /** Placeholder for the name field. Defaults to \"{Singular} name\". */\n namePlaceholder?: string\n }\n /** First-use copy. The create action is offered beneath it. */\n empty?: { title?: string; description?: string }\n /** Persist a new name. Reject with an Error to show its message in the dialog. */\n rename?: (item: WorkspaceListItem, name: string) => Promise<void>\n /** Delete for good. Offered in the overflow menu, behind a confirmation. */\n remove?: (item: WorkspaceListItem) => Promise<void>\n /** What deleting loses, for the confirmation. */\n removeConsequence?: (item: WorkspaceListItem) => string\n /** Extra overflow-menu actions. */\n actions?: (item: WorkspaceListItem) => readonly WorkspaceListAction[]\n /** Product content between the header and the items, such as a home summary. */\n children?: ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- router-agnostic link slot, same as SidebarLayout\n LinkComponent?: ComponentType<any>\n /** Formats `updatedAt`. Defaults to a short month and day, with the year when it is not this year. */\n formatDate?: (value: Date) => string\n}\n\n/** The number of items past which the listing offers a search field. */\nconst SEARCH_THRESHOLD = 8\n\n// Fixed widths keep every row's columns on the same x, whatever a date or value renders as.\nconst FIELD_CELL = 'hidden w-32 min-w-0 shrink-0 md:block'\nconst DATE_CELL = 'w-20 shrink-0 text-right sm:w-24'\n\nfunction DefaultLink({ href, to, ...props }: { href?: string; to?: string; [key: string]: unknown }) {\n return <a href={href ?? to} {...props} />\n}\n\nfunction capitalize(text: string): string {\n return text.charAt(0).toLocaleUpperCase() + text.slice(1)\n}\n\nfunction defaultFormatDate(value: Date): string {\n const sameYear = value.getFullYear() === new Date().getFullYear()\n return value.toLocaleDateString(undefined, sameYear ? { month: 'short', day: 'numeric' } : { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\nfunction present(value: ReactNode): boolean {\n return value !== null && value !== undefined && value !== false && value !== ''\n}\n\nfunction toDate(value: WorkspaceListItem['updatedAt']): Date | null {\n if (value === null || value === undefined || value === '') return null\n const date = value instanceof Date ? value : new Date(value)\n return Number.isNaN(date.getTime()) ? null : date\n}\n\n/** A description is noise when it says the name again (\"GTM Agent / GTM Agent\"). */\nfunction usefulDescription(item: WorkspaceListItem): string | null {\n const text = item.description?.trim()\n if (!text) return null\n return text.toLocaleLowerCase() === item.name.trim().toLocaleLowerCase() ? null : text\n}\n\n/**\n * The listing every product opens on: one title, one primary action, the\n * workspaces, and nothing that counts them. Destructive actions live in each\n * item's overflow menu behind a confirmation, never as an icon on every row.\n * The product supplies its noun, its columns, and its create route; render it\n * inside `AgentWorkspaceLayout` (with no `workspace`) so the listing wears the\n * same shell as the workspace it opens.\n */\nexport function WorkspaceList({\n items,\n noun = DEFAULT_WORKSPACE_NOUN,\n title,\n description,\n layout = 'list',\n fields = [],\n create,\n empty,\n rename,\n remove,\n removeConsequence,\n actions,\n children,\n LinkComponent,\n formatDate = defaultFormatDate,\n}: WorkspaceListProps) {\n const Link = LinkComponent ?? DefaultLink\n const headingId = useId()\n const [query, setQuery] = useState('')\n const [renaming, setRenaming] = useState<WorkspaceListItem | null>(null)\n const [renameValue, setRenameValue] = useState('')\n const [removing, setRemoving] = useState<WorkspaceListItem | null>(null)\n const [creating, setCreating] = useState(false)\n const [createValue, setCreateValue] = useState('')\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState<string | null>(null)\n\n const search = query.trim().toLocaleLowerCase()\n const visible = useMemo(\n () => (search ? items.filter((item) => item.name.toLocaleLowerCase().includes(search)) : items),\n [items, search],\n )\n const createLabel = create?.label ?? `New ${noun.singular}`\n const openCreate = () => {\n setError(null)\n setCreateValue('')\n setCreating(true)\n }\n const createControl = create\n ? <CreateButton create={create.onCreate && !create.href ? { ...create, onSelect: openCreate } : create} label={createLabel} Link={Link} />\n : null\n const submitCreate = () => {\n const name = createValue.trim()\n if (!name || !create?.onCreate) return\n void run(() => create.onCreate!(name), () => setCreating(false))\n }\n\n const hasDates = items.some((item) => toDate(item.updatedAt) !== null)\n const hasMenu = Boolean(rename) || Boolean(remove) || Boolean(actions)\n const menuFor = (item: WorkspaceListItem): MenuEntry[] => [\n ...(rename ? [{ id: 'rename', label: 'Rename', onSelect: () => { setError(null); setRenaming(item); setRenameValue(item.name) } }] : []),\n ...(actions?.(item) ?? []).map((action) => ({ id: action.id, label: action.label, onSelect: () => action.onSelect(item) })),\n ...(remove ? [{ id: 'delete', label: 'Delete', destructive: true, onSelect: () => { setError(null); setRemoving(item) } }] : []),\n ]\n\n const run = async (work: () => Promise<void>, done: () => void) => {\n setBusy(true)\n setError(null)\n try {\n await work()\n done()\n } catch (cause) {\n setError(cause instanceof Error && cause.message ? cause.message : 'That did not save. Try again.')\n } finally {\n setBusy(false)\n }\n }\n\n const submitRename = () => {\n if (!renaming || !rename) return\n const name = renameValue.trim()\n if (!name || name === renaming.name) {\n setRenaming(null)\n return\n }\n void run(() => rename(renaming, name), () => setRenaming(null))\n }\n\n return (\n <section aria-labelledby={headingId} className=\"mx-auto w-full max-w-5xl px-4 py-6 sm:px-6 sm:py-8 lg:px-8\">\n <header className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-3\">\n <div className=\"min-w-0 flex-1\">\n <h1 id={headingId} className=\"text-xl font-semibold tracking-tight text-foreground\">\n {title ?? capitalize(noun.plural)}\n </h1>\n {description != null && <div className=\"mt-1 max-w-prose text-sm text-muted-foreground\">{description}</div>}\n </div>\n {items.length > 0 && createControl}\n </header>\n\n {children != null && <div className=\"mt-6\">{children}</div>}\n\n {items.length === 0 ? (\n <div className=\"mt-6 flex flex-col items-center rounded-xl border border-dashed border-border px-6 py-14 text-center\">\n <span aria-hidden className=\"flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10 text-primary\">\n <svg className=\"h-5 w-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\">\n <rect x=\"4\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" /><rect x=\"13.5\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" /><rect x=\"4\" y=\"13.5\" width=\"6.5\" height=\"6.5\" rx=\"1.5\" /><path d=\"M16.75 13.5v6.5M13.5 16.75H20\" />\n </svg>\n </span>\n <h2 className=\"mt-4 text-base font-semibold text-foreground\">{empty?.title ?? `No ${noun.plural} yet`}</h2>\n {empty?.description && <p className=\"mt-1.5 max-w-sm text-sm text-muted-foreground\">{empty.description}</p>}\n {createControl && <div className=\"mt-5\">{createControl}</div>}\n </div>\n ) : (\n <>\n {items.length > SEARCH_THRESHOLD && (\n <div className=\"mt-6\">\n <input\n type=\"search\"\n aria-label={`Search ${noun.plural}`}\n placeholder={`Search ${noun.plural}`}\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n className=\"h-9 w-full max-w-sm rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground\"\n />\n </div>\n )}\n {visible.length === 0 ? (\n <p role=\"status\" className=\"mt-6 rounded-xl border border-border px-4 py-8 text-center text-sm text-muted-foreground\">\n No {noun.plural} match “{query.trim()}”.{' '}\n <button type=\"button\" onClick={() => setQuery('')} className=\"font-medium text-foreground underline underline-offset-2\">\n Clear search\n </button>\n </p>\n ) : layout === 'grid' ? (\n <ul className={`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 ${items.length > SEARCH_THRESHOLD ? 'mt-3' : 'mt-6'}`}>\n {visible.map((item) => (\n <GridCard key={item.id} item={item} fields={fields} menu={menuFor(item)} Link={Link} formatDate={formatDate} />\n ))}\n </ul>\n ) : (\n <div className={`overflow-hidden rounded-xl border border-border bg-card ${items.length > SEARCH_THRESHOLD ? 'mt-3' : 'mt-6'}`}>\n {fields.length > 0 && (\n <div aria-hidden className=\"hidden items-center gap-3 border-b border-border px-4 py-2 text-xs font-medium text-muted-foreground md:flex\">\n <span className=\"w-10 shrink-0\" />\n <span className=\"min-w-0 flex-1\">Name</span>\n {fields.map((field) => (\n <span key={field.id} className={`${FIELD_CELL} truncate`}>{field.label}</span>\n ))}\n <span className={DATE_CELL}>{hasDates ? 'Updated' : ''}</span>\n {hasMenu && <span className=\"w-8 shrink-0\" />}\n </div>\n )}\n <ul className=\"divide-y divide-border\">\n {visible.map((item) => (\n <ListRow key={item.id} item={item} fields={fields} menu={menuFor(item)} reserveMenu={hasMenu} Link={Link} formatDate={formatDate} />\n ))}\n </ul>\n </div>\n )}\n </>\n )}\n\n {renaming && (\n <ActionDialog\n title={`Rename ${noun.singular}`}\n onClose={() => setRenaming(null)}\n busy={busy}\n error={error}\n footer={\n <>\n <ActionDialogButton variant=\"ghost\" onClick={() => setRenaming(null)} disabled={busy}>Cancel</ActionDialogButton>\n <ActionDialogButton onClick={submitRename} disabled={busy || !renameValue.trim()}>Save</ActionDialogButton>\n </>\n }\n >\n <label htmlFor={`${headingId}-rename`} className=\"text-xs text-muted-foreground\">Name</label>\n <input\n id={`${headingId}-rename`}\n value={renameValue}\n autoFocus\n onChange={(event) => setRenameValue(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && !busy) {\n event.preventDefault()\n submitRename()\n }\n }}\n className=\"mt-1.5 h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground\"\n />\n </ActionDialog>\n )}\n\n {creating && create?.onCreate && (\n <ActionDialog\n title={createLabel}\n onClose={() => setCreating(false)}\n busy={busy}\n error={error}\n footer={\n <>\n <ActionDialogButton variant=\"ghost\" onClick={() => setCreating(false)} disabled={busy}>Cancel</ActionDialogButton>\n <ActionDialogButton onClick={submitCreate} disabled={busy || !createValue.trim()}>Create</ActionDialogButton>\n </>\n }\n >\n <label htmlFor={`${headingId}-create`} className=\"text-xs text-muted-foreground\">Name</label>\n <input\n id={`${headingId}-create`}\n value={createValue}\n autoFocus\n placeholder={create.namePlaceholder ?? `${capitalize(noun.singular)} name`}\n onChange={(event) => setCreateValue(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && !busy) {\n event.preventDefault()\n submitCreate()\n }\n }}\n className=\"mt-1.5 h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground\"\n />\n </ActionDialog>\n )}\n\n {removing && remove && (\n <ActionDialog\n title={`Delete ${noun.singular}?`}\n onClose={() => setRemoving(null)}\n busy={busy}\n error={error}\n footer={\n <>\n <ActionDialogButton variant=\"ghost\" onClick={() => setRemoving(null)} disabled={busy}>Cancel</ActionDialogButton>\n <ActionDialogButton variant=\"destructive\" onClick={() => void run(() => remove(removing), () => setRemoving(null))} disabled={busy}>\n Delete\n </ActionDialogButton>\n </>\n }\n >\n <p className=\"break-words text-sm text-muted-foreground\">\n {removeConsequence?.(removing) ?? `“${removing.name}” and everything in it will be deleted. This cannot be undone.`}\n </p>\n </ActionDialog>\n )}\n </section>\n )\n}\n\ninterface MenuEntry {\n id: string\n label: string\n destructive?: boolean\n onSelect: () => void\n}\n\ninterface ItemProps {\n reserveMenu?: boolean\n item: WorkspaceListItem\n fields: readonly WorkspaceListField[]\n menu: MenuEntry[]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- router-agnostic link slot\n Link: ComponentType<any>\n formatDate: (value: Date) => string\n}\n\nfunction UpdatedAt({ value, formatDate, className = 'shrink-0' }: { value: WorkspaceListItem['updatedAt']; formatDate: (value: Date) => string; className?: string }) {\n const date = toDate(value)\n if (!date) return <span className={className} />\n return (\n // Server and browser can format a date differently (zone, locale); the\n // browser's reading is the one the user should see.\n <time dateTime={date.toISOString()} suppressHydrationWarning className={`${className} text-xs tabular-nums text-muted-foreground`}>\n {formatDate(date)}\n </time>\n )\n}\n\n/**\n * The name is the row's link, stretched over the whole row with an `after:`\n * overlay, so the overflow menu can sit on top as a real sibling button\n * instead of a button nested inside a link.\n */\nfunction ListRow({ item, fields, menu, reserveMenu, Link, formatDate }: ItemProps) {\n const detail = usefulDescription(item)\n return (\n <li className=\"group relative isolate flex min-h-16 items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/60\">\n {item.avatar ?? <WorkspaceInitial name={item.name} size=\"lg\" />}\n <div className=\"min-w-0 flex-1\">\n <Link\n href={item.href}\n to={item.href}\n title={item.name}\n className=\"block truncate text-sm font-medium text-foreground after:absolute after:inset-0 after:content-[''] focus-visible:outline-none focus-visible:after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-ring\"\n >\n {item.name}\n </Link>\n {detail && <p className=\"truncate text-xs text-muted-foreground\" title={detail}>{detail}</p>}\n </div>\n {fields.map((field) => (\n <div key={field.id} className={`${FIELD_CELL} truncate text-sm text-muted-foreground`}>\n <span className=\"sr-only\">{field.label}: </span>\n {present(item.values?.[field.id]) ? item.values![field.id] : '—'}\n </div>\n ))}\n <UpdatedAt value={item.updatedAt} formatDate={formatDate} className={DATE_CELL} />\n {menu.length > 0 ? <ItemMenu item={item} entries={menu} /> : reserveMenu ? <span className=\"w-8 shrink-0\" /> : null}\n </li>\n )\n}\n\nfunction GridCard({ item, fields, menu, Link, formatDate }: ItemProps) {\n const detail = usefulDescription(item)\n const shownFields = fields.filter((field) => present(item.values?.[field.id]))\n return (\n <li className=\"group relative isolate flex min-h-36 flex-col overflow-hidden rounded-xl border border-border bg-card p-4 transition-[border-color,box-shadow] hover:border-primary/40 hover:shadow-sm\">\n <span aria-hidden className=\"pointer-events-none absolute inset-x-0 top-0 -z-10 h-16 bg-gradient-to-b from-primary/[0.07] to-transparent\" />\n <div className=\"flex items-start gap-3\">\n {item.avatar ?? <WorkspaceInitial name={item.name} size=\"lg\" />}\n <div className=\"min-w-0 flex-1 pt-0.5\">\n <Link\n href={item.href}\n to={item.href}\n title={item.name}\n className=\"line-clamp-2 break-words text-sm font-semibold text-foreground after:absolute after:inset-0 after:content-[''] focus-visible:outline-none focus-visible:after:rounded-xl focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-ring\"\n >\n {item.name}\n </Link>\n {detail && <p className=\"mt-0.5 truncate text-xs text-muted-foreground\" title={detail}>{detail}</p>}\n </div>\n {menu.length > 0 && <ItemMenu item={item} entries={menu} />}\n </div>\n <div className=\"mt-auto flex items-end justify-between gap-3 pt-4\">\n {shownFields.length > 0 ? (\n <dl className=\"flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs\">\n {shownFields.map((field) => (\n <div key={field.id} className=\"flex min-w-0 gap-1\">\n <dt className=\"text-muted-foreground\">{field.label}</dt>\n <dd className=\"truncate font-medium text-foreground\">{item.values?.[field.id]}</dd>\n </div>\n ))}\n </dl>\n ) : <span />}\n <UpdatedAt value={item.updatedAt} formatDate={formatDate} />\n </div>\n </li>\n )\n}\n\nfunction ItemMenu({ item, entries }: { item: WorkspaceListItem; entries: MenuEntry[] }) {\n const [open, setOpen] = useState(false)\n const panelId = useId()\n const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen)\n return (\n <div ref={containerRef} className=\"relative z-10 shrink-0\">\n <button\n type=\"button\"\n {...triggerProps}\n aria-label={`Actions for ${item.name}`}\n aria-controls={open ? panelId : undefined}\n onClick={() => setOpen(!open)}\n // Hidden until hover only where hover exists; a touch screen of any width shows it.\n className=\"flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground focus-visible:opacity-100 aria-expanded:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover:opacity-100\"\n >\n <svg aria-hidden className=\"h-4 w-4\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <circle cx=\"5\" cy=\"12\" r=\"1.6\" /><circle cx=\"12\" cy=\"12\" r=\"1.6\" /><circle cx=\"19\" cy=\"12\" r=\"1.6\" />\n </svg>\n </button>\n <PopoverSurface\n open={open}\n id={panelId}\n role=\"menu\"\n aria-label={`Actions for ${item.name}`}\n side=\"below\"\n align=\"end\"\n triggerRef={triggerRef}\n panelRef={panelRef}\n className={`w-44 overflow-hidden rounded-md border border-card-edge bg-popover py-1 ${OVERLAY_SHADOW}`}\n >\n {entries.map((entry, index) => (\n <button\n key={entry.id}\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n setOpen(false)\n // The dialog this opens returns focus to whatever had it — the trigger, not <body>.\n triggerRef.current?.focus()\n entry.onSelect()\n }}\n className={`block w-full px-3 py-1.5 text-left text-sm transition ${\n entry.destructive ? 'text-destructive hover:bg-destructive/10' : 'text-foreground hover:bg-accent'\n } ${entry.destructive && index > 0 ? 'mt-1 border-t border-border pt-2' : ''}`}\n >\n {entry.label}\n </button>\n ))}\n </PopoverSurface>\n </div>\n )\n}\n\nfunction CreateButton({\n create,\n label,\n Link,\n}: {\n create: NonNullable<WorkspaceListProps['create']>\n label: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- router-agnostic link slot\n Link: ComponentType<any>\n}) {\n const className = 'inline-flex h-9 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3.5 text-sm font-medium text-primary-foreground transition hover:opacity-90 active:scale-[0.98]'\n const icon = (\n <svg aria-hidden className=\"h-4 w-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\">\n <path d=\"M12 5v14M5 12h14\" />\n </svg>\n )\n if (create.href) {\n return (\n <Link href={create.href} to={create.href} className={className}>\n {icon}\n {label}\n </Link>\n )\n }\n return (\n <button type=\"button\" onClick={create.onSelect} className={className}>\n {icon}\n {label}\n </button>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAyE;;;ACAlF,SAAS,aAAa,gBAAoD;AA+DjE,cAsBH,YAtBG;AAzCF,IAAM,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,QAAM,gBAAgB,UAClB;AAAA,IACE,MAAM,QAAQ;AAAA,IACd,UAAU,QAAQ;AAAA,IAClB,mBACE,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe,aAAa;AAAA;AAAA,IAC9B;AAAA,EAEJ,IACA,CAAC;AACL,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,YAAY;AAAA,IACZ,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,UAAU;AAAA,MACV,UAAU,cAAc,UAAU,KAAK;AAAA,MAEtC;AAAA;AAAA,EACH;AAEJ;","names":["useCallback","useState","jsx","jsxs","AgentWorkspaceCompanion","useState","Fragment","jsx","jsxs","SEARCH_THRESHOLD","DefaultLink","capitalize","useState","jsx"]}
@@ -0,0 +1,55 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ /** What a product is called and how it is marked. The same three values for every product. */
3
+ export interface AgentProductIdentity {
4
+ /** Short product name, for example `Legal` or `GTM`. */
5
+ name: string;
6
+ /** Square brand mark, sized by the product for a 20px slot. */
7
+ mark: ReactNode;
8
+ /** Where the mark leads: the workspace listing, or home when there is none. */
9
+ href: string;
10
+ }
11
+ /** The words a product uses for one workspace and for several. */
12
+ export interface AgentWorkspaceNoun {
13
+ singular: string;
14
+ plural: string;
15
+ }
16
+ export declare const DEFAULT_WORKSPACE_NOUN: AgentWorkspaceNoun;
17
+ /** The workspace that is open, and where else this person can go. */
18
+ export interface AgentWorkspaceIdentity {
19
+ id: string;
20
+ name: string;
21
+ /** Defaults to workspace / workspaces. */
22
+ noun?: AgentWorkspaceNoun;
23
+ /** Every workspace this person can open, including the open one, in the product's order. */
24
+ options?: readonly {
25
+ id: string;
26
+ name: string;
27
+ }[];
28
+ /** Required with `options`: the route that opens a workspace. */
29
+ hrefForWorkspace?: (workspaceId: string) => string;
30
+ /** The listing route. Adds an "All …" entry. */
31
+ listHref?: string;
32
+ /** The creation route. Adds a "New …" entry. */
33
+ createHref?: string;
34
+ }
35
+ export interface AgentRailIdentityProps {
36
+ product: AgentProductIdentity;
37
+ workspace?: AgentWorkspaceIdentity | null;
38
+ /**
39
+ * The breakpoint below which the fixed rail is hidden. The rail draws the
40
+ * mark itself; below this width the same content heads the mobile bar and
41
+ * drawer, which have no mark of their own.
42
+ */
43
+ hideBelow?: 'md' | 'lg';
44
+ LinkComponent?: ComponentType<any>;
45
+ }
46
+ /**
47
+ * The top of every product's rail: which product, and which workspace.
48
+ *
49
+ * One line when no workspace is open (the listing), two when one is: the
50
+ * workspace name, then the product beneath it. Both truncate inside the rail
51
+ * and carry the full text as a tooltip, so a long name can never push into
52
+ * the collapse button or the page beside the rail. It is a switcher only when
53
+ * there is somewhere to switch to; a menu that lists one item is not offered.
54
+ */
55
+ export declare function AgentRailIdentity({ product, workspace, hideBelow, LinkComponent }: AgentRailIdentityProps): import("react").JSX.Element;
@@ -0,0 +1,82 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import { type AgentWorkspaceNoun } from './rail-identity';
3
+ /** One workspace as the listing shows it. */
4
+ export interface WorkspaceListItem {
5
+ id: string;
6
+ name: string;
7
+ /** The route that opens it. */
8
+ href: string;
9
+ /** One line under the name. Not shown when it only repeats the name. */
10
+ description?: string | null;
11
+ /** Last activity. Shown as a short date. */
12
+ updatedAt?: string | number | Date | null;
13
+ /** Values for the product's `fields`, keyed by field id. */
14
+ values?: Readonly<Record<string, ReactNode>>;
15
+ /** Replaces the initial avatar, for example with a logo the product already has. */
16
+ avatar?: ReactNode;
17
+ }
18
+ /** A product column: a value the user compares across workspaces (tax year, status, owner). */
19
+ export interface WorkspaceListField {
20
+ id: string;
21
+ label: string;
22
+ }
23
+ /** A non-destructive product action in an item's overflow menu. */
24
+ export interface WorkspaceListAction {
25
+ id: string;
26
+ label: string;
27
+ onSelect: (item: WorkspaceListItem) => void;
28
+ }
29
+ export interface WorkspaceListProps {
30
+ items: readonly WorkspaceListItem[];
31
+ /** The product's words for one workspace and several. Defaults to workspace / workspaces. */
32
+ noun?: AgentWorkspaceNoun;
33
+ /** Page title. Defaults to the capitalized plural noun. */
34
+ title?: string;
35
+ /** One sentence under the title, when the page needs one. */
36
+ description?: ReactNode;
37
+ /** `list` rows for records people compare; `grid` cards for a handful of rich projects. */
38
+ layout?: 'list' | 'grid';
39
+ /** Product values, shown as columns (list) or under the description (grid). */
40
+ fields?: readonly WorkspaceListField[];
41
+ /**
42
+ * The one primary action, labelled "New {singular}" unless `label` says otherwise.
43
+ * `href` navigates; `onSelect` opens the product's own creation flow; `onCreate`
44
+ * asks for a name in the shared dialog and hands it over — reject with an Error
45
+ * to show its message, and navigate to the new workspace from inside it.
46
+ */
47
+ create?: {
48
+ label?: string;
49
+ href?: string;
50
+ onSelect?: () => void;
51
+ onCreate?: (name: string) => Promise<void>;
52
+ /** Placeholder for the name field. Defaults to "{Singular} name". */
53
+ namePlaceholder?: string;
54
+ };
55
+ /** First-use copy. The create action is offered beneath it. */
56
+ empty?: {
57
+ title?: string;
58
+ description?: string;
59
+ };
60
+ /** Persist a new name. Reject with an Error to show its message in the dialog. */
61
+ rename?: (item: WorkspaceListItem, name: string) => Promise<void>;
62
+ /** Delete for good. Offered in the overflow menu, behind a confirmation. */
63
+ remove?: (item: WorkspaceListItem) => Promise<void>;
64
+ /** What deleting loses, for the confirmation. */
65
+ removeConsequence?: (item: WorkspaceListItem) => string;
66
+ /** Extra overflow-menu actions. */
67
+ actions?: (item: WorkspaceListItem) => readonly WorkspaceListAction[];
68
+ /** Product content between the header and the items, such as a home summary. */
69
+ children?: ReactNode;
70
+ LinkComponent?: ComponentType<any>;
71
+ /** Formats `updatedAt`. Defaults to a short month and day, with the year when it is not this year. */
72
+ formatDate?: (value: Date) => string;
73
+ }
74
+ /**
75
+ * The listing every product opens on: one title, one primary action, the
76
+ * workspaces, and nothing that counts them. Destructive actions live in each
77
+ * item's overflow menu behind a confirmation, never as an icon on every row.
78
+ * The product supplies its noun, its columns, and its create route; render it
79
+ * inside `AgentWorkspaceLayout` (with no `workspace`) so the listing wears the
80
+ * same shell as the workspace it opens.
81
+ */
82
+ export declare function WorkspaceList({ items, noun, title, description, layout, fields, create, empty, rename, remove, removeConsequence, actions, children, LinkComponent, formatDate, }: WorkspaceListProps): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.53.4",
3
+ "version": "0.53.5",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/web-react/controls.tsx"],"sourcesContent":["/**\n * Shared chat-shell control primitives — the LEAF that both the web-react barrel\n * (`./index`) and the composer children (`./agent-session-controls`,\n * `./seat-paywall`) import directly, so neither child has to reach back through\n * the barrel (which would re-create an import cycle). The barrel re-exports the\n * public names (`usePopover`, `usePending`, `ModelPicker`, `EffortPicker`, …)\n * unchanged, so the published export surface is identical.\n *\n * Styling contract matches the rest of `web-react`: Tailwind classes against the\n * shared design tokens; the glyphs are inline SVGs, no icon-library dependency.\n */\n\nimport {\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n type RefObject,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { ProviderLogo } from './provider-logo'\nimport {\n MAX_RECOMMENDED_MODELS,\n sortModelsByFreshness,\n type CatalogModel,\n} from '../runtime/model-catalog'\n\n// ── shared glyphs (no icon-library dependency) ────────────────────────────\n\nexport function ChevronDown({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n )\n}\n\nfunction SearchGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <circle cx=\"11\" cy=\"11\" r=\"8\" />\n <path d=\"m21 21-4.3-4.3\" />\n </svg>\n )\n}\n\nfunction SparkleGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M12 3v3m0 12v3M3 12h3m12 0h3M5.6 5.6l2.1 2.1m8.6 8.6 2.1 2.1m0-12.8-2.1 2.1M7.7 16.3l-2.1 2.1\" />\n </svg>\n )\n}\n\n/** lucide `brain` (v1.27) inlined — `/web-react` ships no icon-library\n * dependency, so the thinking glyph follows the same pattern as the rest of\n * this set. */\nexport function BrainGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M12 18V5\" />\n <path d=\"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4\" />\n <path d=\"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5\" />\n <path d=\"M17.997 5.125a4 4 0 0 1 2.526 5.77\" />\n <path d=\"M18 18a4 4 0 0 0 2-7.464\" />\n <path d=\"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517\" />\n <path d=\"M6 18a4 4 0 0 1-2-7.464\" />\n <path d=\"M6.003 5.125a4 4 0 0 0-2.526 5.77\" />\n </svg>\n )\n}\n\n/** lucide `check` — the selected-row mark in the picker menus. */\nexport function CheckGlyph({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n )\n}\n\n/**\n * Keyboard + pointer model for a trigger-and-popover pair, dependency-free.\n * Outside-mousedown and Escape both close; Escape also returns focus to the\n * trigger so keyboard users aren't dropped at the top of the document. The\n * returned `triggerProps` carry the ARIA contract (`aria-haspopup`/\n * `aria-expanded`); spread them onto the trigger button.\n *\n * `panelRef` belongs to the popover panel and MUST be wired when the panel is\n * rendered through {@link PopoverSurface}: a portaled panel is not inside\n * `containerRef`, so a container-only outside test reads every click on the\n * menu's own rows as an outside click and closes before the row's handler runs.\n */\nexport function usePopover(open: boolean, setOpen: (open: boolean) => void) {\n const containerRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const panelRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!open) return\n function onMouseDown(e: MouseEvent) {\n const target = e.target as Node\n if (containerRef.current?.contains(target)) return\n const panel = panelRef.current\n if (panel?.contains(target)) return\n // A popover opened FROM this one portals as a SIBLING at body level, so\n // `contains` cannot see it and a click on its rows would read as outside.\n // Surfaces stamp their ancestor chain, so descendancy survives the portal.\n const ownPath = panel?.getAttribute(POPOVER_SURFACE_ATTR)\n const hitPath =\n target instanceof Element\n ? target.closest(`[${POPOVER_SURFACE_ATTR}]`)?.getAttribute(POPOVER_SURFACE_ATTR)\n : null\n if (ownPath && hitPath && (hitPath === ownPath || hitPath.startsWith(`${ownPath}${POPOVER_PATH_SEPARATOR}`))) return\n setOpen(false)\n }\n function onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && !e.defaultPrevented) {\n const ownPath = panelRef.current?.getAttribute(POPOVER_SURFACE_ATTR)\n const focusedPath = document.activeElement?.closest(`[${POPOVER_SURFACE_ATTR}]`)?.getAttribute(POPOVER_SURFACE_ATTR)\n if (ownPath && focusedPath?.startsWith(`${ownPath}${POPOVER_PATH_SEPARATOR}`)) return\n e.preventDefault()\n setOpen(false)\n triggerRef.current?.focus()\n }\n }\n document.addEventListener('mousedown', onMouseDown)\n document.addEventListener('keydown', onKeyDown)\n return () => {\n document.removeEventListener('mousedown', onMouseDown)\n document.removeEventListener('keydown', onKeyDown)\n }\n }, [open, setOpen])\n\n return {\n containerRef,\n triggerRef,\n panelRef,\n triggerProps: {\n ref: triggerRef,\n 'aria-haspopup': true as const,\n 'aria-expanded': open,\n },\n }\n}\n\n// ── PopoverSurface ────────────────────────────────────────────────────────\n\n/** Distance between the trigger and the panel it opens. */\nconst POPOVER_GAP = 8\n/** Minimum distance the panel keeps from every viewport edge. */\nconst POPOVER_VIEWPORT_MARGIN = 16\n/** Floor for the computed max-height, so a cramped side still shows rows\n * rather than collapsing to a sliver the user cannot read. */\nconst POPOVER_MIN_HEIGHT = 120\n\n/**\n * Marks the portaled panel in the DOM. Products and audits (see\n * `playground/scripts/popover-hit-test.mjs`) select on this rather than on a\n * Tailwind class, which is presentation and free to change.\n *\n * Its VALUE is the surface's ancestor path (`outer/inner`), which is what\n * restores \"is this click inside my popover\" after the portal flattens two\n * nested panels into two siblings of `<body>`.\n */\nexport const POPOVER_SURFACE_ATTR = 'data-agent-app-popover'\nconst POPOVER_PATH_SEPARATOR = '/'\n\n/**\n * `PopoverSurface` is now mounted (closed) inside every server-rendered\n * composer, so its hooks run on the server once per composer per request.\n * React 18 logs \"useLayoutEffect does nothing on the server\" for that; React 19\n * does not (measured silent on react-dom 19.2.8). The peer floor is `react >=18`,\n * so bind the synchronous hook only where there is a DOM and the effect hook\n * elsewhere — placement never runs on the server either way.\n */\nconst useBrowserLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect\n\nexport interface PopoverSurfaceProps {\n open: boolean\n /** The trigger the panel anchors to — `usePopover`'s `triggerRef`. */\n triggerRef: RefObject<HTMLElement | null>\n /** `usePopover`'s `panelRef`; also what the outside-click test consults. */\n panelRef: RefObject<HTMLDivElement | null>\n /** Presentation classes. Placement and elevation are owned here — a caller\n * must not pass `absolute`/`fixed`/`top-*`/`bottom-*`/`z-*`. */\n className?: string\n role?: string\n id?: string\n 'aria-label'?: string\n /** Make the panel at least as wide as its trigger. A portaled panel has no\n * `w-full` to inherit — the trigger is no longer its offset parent — so a\n * menu that used to stretch to a full-width trigger declares it here. */\n matchTriggerWidth?: boolean\n /** Opt in to remeasurement when asynchronous or filtered content changes. */\n contentKey?: unknown\n children: ReactNode\n}\n\n/**\n * The floating panel every canonical picker opens.\n *\n * It renders through a PORTAL to `document.body` and anchors itself to the\n * trigger in viewport coordinates, because an in-place `absolute` panel's\n * visibility is decided by markup this package does not own. Measured in\n * production: the shipped chat composer docks these controls inside a\n * horizontally scrolling rail (`overflow-x-auto`), and a scroll container\n * clips every positioned descendant whose containing block sits inside it —\n * so a correct 420x457 menu with correct coordinates painted zero pixels and\n * could not be clicked. An ancestor `transform`/`filter`/`contain` would trap\n * it the same way through the stacking context instead of the clip. Leaving\n * the DOM subtree is the only placement a host cannot re-break.\n *\n * Placement prefers ABOVE the trigger (these controls dock at the bottom of a\n * composer), flips below when there is more room there, clamps horizontally\n * into the viewport, and caps its own height to the space on the chosen side.\n * The panel is `visibility: hidden` for the measure pass so it never paints at\n * the pre-placement origin.\n */\nexport function PopoverSurface({\n open,\n triggerRef,\n panelRef,\n className,\n role,\n id,\n 'aria-label': ariaLabel,\n matchTriggerWidth,\n contentKey,\n children,\n}: PopoverSurfaceProps) {\n const surfaceId = useId()\n const [style, setStyle] = useState<CSSProperties>(() => ({\n position: 'fixed',\n top: 0,\n left: 0,\n visibility: 'hidden',\n }))\n\n const place = useCallback(() => {\n const trigger = triggerRef.current\n const panel = panelRef.current\n if (!trigger || !panel) return\n const anchor = trigger.getBoundingClientRect()\n const viewportWidth = window.innerWidth\n const viewportHeight = window.innerHeight\n\n // `scrollHeight` is the panel's CONTENT height, so it does not feed back\n // on the `maxHeight` this function just applied — reading `offsetHeight`\n // here would measure the previous pass's clamp and ratchet the panel\n // smaller on every scroll event.\n const contentHeight = panel.scrollHeight\n const panelWidth = panel.offsetWidth\n\n const roomAbove = anchor.top - POPOVER_GAP - POPOVER_VIEWPORT_MARGIN\n const roomBelow = viewportHeight - anchor.bottom - POPOVER_GAP - POPOVER_VIEWPORT_MARGIN\n const above = contentHeight <= roomAbove || roomAbove >= roomBelow\n const maxHeight = Math.max(POPOVER_MIN_HEIGHT, above ? roomAbove : roomBelow)\n const height = Math.min(contentHeight, maxHeight)\n\n const top = above ? Math.max(POPOVER_VIEWPORT_MARGIN, anchor.top - POPOVER_GAP - height) : anchor.bottom + POPOVER_GAP\n const rightBound = Math.max(POPOVER_VIEWPORT_MARGIN, viewportWidth - panelWidth - POPOVER_VIEWPORT_MARGIN)\n const left = Math.min(Math.max(POPOVER_VIEWPORT_MARGIN, anchor.left), rightBound)\n\n setStyle({\n position: 'fixed',\n top,\n left,\n maxHeight,\n visibility: 'visible',\n ...(matchTriggerWidth ? { minWidth: anchor.width } : {}),\n })\n }, [matchTriggerWidth, panelRef, triggerRef])\n\n // Layout effect: placement is resolved before the browser paints, so the\n // panel is never seen at the origin it mounts at.\n useBrowserLayoutEffect(() => {\n if (!open) {\n setStyle({ position: 'fixed', top: 0, left: 0, visibility: 'hidden' })\n return\n }\n place()\n }, [open, place, contentKey])\n\n useEffect(() => {\n if (!open) return\n const onViewportChange = () => place()\n // `capture` so the rail's OWN scroll re-anchors the panel — a scroll inside\n // an ancestor does not bubble to window.\n window.addEventListener('scroll', onViewportChange, true)\n window.addEventListener('resize', onViewportChange)\n return () => {\n window.removeEventListener('scroll', onViewportChange, true)\n window.removeEventListener('resize', onViewportChange)\n }\n }, [open, place])\n\n if (!open || typeof document === 'undefined') return null\n\n const ownerPath = triggerRef.current?.closest?.(`[${POPOVER_SURFACE_ATTR}]`)?.getAttribute(POPOVER_SURFACE_ATTR)\n const path = ownerPath ? `${ownerPath}${POPOVER_PATH_SEPARATOR}${surfaceId}` : surfaceId\n\n return createPortal(\n <div\n ref={panelRef}\n id={id}\n role={role}\n aria-label={ariaLabel}\n style={style}\n {...{ [POPOVER_SURFACE_ATTR]: path }}\n className={`z-[1000] ${className ?? ''}`}\n >\n {children}\n </div>,\n document.body,\n )\n}\n\n/**\n * Focus treatment for a row inside a popover panel.\n *\n * The ring itself now comes from the `:focus-visible` floor in tokens.css, so\n * this no longer restates a width or a colour. What it still has to say is\n * WHERE the ring is drawn: a popover option is a full-width row inside a panel\n * that clips its own corners (`overflow-hidden rounded-xl`), and an outward\n * ring on the first or last row is clipped away by that panel. Pulling the\n * offset negative draws the same ring just inside the row instead.\n */\nexport const POPOVER_OPTION_FOCUS = 'focus-visible:[outline-offset:-2px]'\n\n/**\n * The one overlay elevation for floating surfaces — picker menus, popovers,\n * drawers, modals. Reads the theme's `--shadow-overlay` token, so every overlay\n * lifts with the same shadow and re-themes from one source. The floating\n * composer uses the quieter `shadow-raised` rung instead.\n *\n * Written as an arbitrary value rather than the preset's `shadow-overlay`\n * utility, because that utility only exists where the preset is part of the\n * Tailwind build. A host that gets its tokens through a precompiled bundle —\n * `@tangle-network/sandbox-ui` ships brand's tokens inlined, with no `@theme`\n * block surviving the compile — receives `--shadow-overlay` as a plain custom\n * property, from which no `shadow-overlay` utility can be generated, and these\n * surfaces render flat. The arbitrary form emits from the class alone and works\n * either way.\n */\nexport const OVERLAY_SHADOW = 'shadow-[var(--shadow-overlay)]'\n\n/**\n * Root geometry for a picker — the box that holds the trigger — in one place\n * because every picker in this family has to agree on it.\n *\n * Shrink-wrapping (`inline-flex`) is the default: these controls dock on a\n * composer row where an expanding pill shoves its neighbours around. A STACKED\n * panel wants the opposite — the compact `AgentSessionControls` gear popover\n * lays its controls out in a column, and a shrink-wrapped root there makes a\n * trigger's own `w-full` a no-op, since it fills a box the trigger itself\n * sized. That is what left Agent backend short of the panel edge and Thinking\n * narrower still.\n *\n * The panel is portaled ({@link PopoverSurface}), so widening the root widens\n * the TRIGGER only. A menu that should follow it declares `matchTriggerWidth`.\n */\nexport function pickerRootClass(fullWidth: boolean): string {\n return `relative ${fullWidth ? 'flex w-full' : 'inline-flex'}`\n}\n\n/**\n * How a picker's TRIGGER is drawn. The menu it opens is the same either way.\n *\n * - `chip` (default): the 36px bordered pill — `rounded-full border\n * border-border bg-card font-medium`. A consumer that names no variant\n * renders exactly what it rendered before this prop existed.\n * - `quiet`: a 28px borderless text button — muted label, small glyph, a\n * surface fill on hover and while the menu is open, nothing else. For a\n * composer whose card already draws the border: three pills docked under\n * the input there read as three more cards, not as the input's controls.\n */\nexport type PickerVariant = 'chip' | 'quiet'\n\n/** The quiet trigger at rest: geometry, type, and keyboard focus. */\nconst QUIET_PICKER_TRIGGER_BASE =\n 'inline-flex h-7 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md bg-transparent px-2 text-sm font-normal text-muted-foreground transition focus:outline-none focus-visible:ring-2 focus-visible:ring-ring'\n\n/** The fills a quiet trigger shows on hover and while its menu is open — the\n * only two states it draws. Reads `data-state`, which every picker trigger\n * in this family stamps. */\nconst QUIET_PICKER_TRIGGER_INTERACTIVE =\n 'hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground'\n\n/**\n * Trigger classes for a `quiet` picker. Height, padding, radius, and type are\n * fixed here so the triggers on one composer row agree; a caller adds only\n * width (`w-full`) and alignment (`justify-between`).\n *\n * The focus ring is drawn on the element rather than left to the tokens.css\n * `:focus-visible` floor: a quiet trigger sits beside the composer's own action\n * buttons (attach, dictate, send), which draw `focus-visible:ring-2\n * focus-visible:ring-ring`, and a row whose controls answer keyboard focus two\n * different ways reads as two families.\n *\n * `interactive: false` is for a PINNED control (see `HarnessPicker`'s\n * `lockReason`): it keeps the resting treatment and draws no hover or open\n * fill, because a fill promises a menu the control will not open.\n */\nexport function quietPickerTriggerClass({ interactive = true }: { interactive?: boolean } = {}): string {\n return interactive\n ? `${QUIET_PICKER_TRIGGER_BASE} ${QUIET_PICKER_TRIGGER_INTERACTIVE}`\n : `${QUIET_PICKER_TRIGGER_BASE} cursor-default`\n}\n\n/**\n * Guard an async action against double-submit. `run` ignores re-entrant calls\n * while a promise is in flight and flips `pending` so the caller can disable\n * the control — the fix for double-charge / double-approve on a slow network.\n * Settles (success or throw) before clearing, and no-ops state updates after\n * unmount.\n */\nexport function usePending(): { pending: boolean; run: (action: () => void | Promise<void>) => void } {\n const [pending, setPending] = useState(false)\n const inFlight = useRef(false)\n const mounted = useRef(true)\n useEffect(() => {\n mounted.current = true\n return () => {\n mounted.current = false\n }\n }, [])\n const run = (action: () => void | Promise<void>) => {\n if (inFlight.current) return\n let result: void | Promise<void>\n try {\n result = action()\n } catch {\n return\n }\n if (!(result instanceof Promise)) return\n inFlight.current = true\n setPending(true)\n void result.finally(() => {\n inFlight.current = false\n if (mounted.current) setPending(false)\n })\n }\n return { pending, run }\n}\n\n// ── ModelPicker ───────────────────────────────────────────────────────────\n\nexport interface ModelPickerProps {\n /** Controlled, opaque saved id. Never replaced merely because the catalogue omits it. */\n value: string\n onChange: (id: string) => void\n /** Catalogue models — from `GET`ing the app's catalogue route (see\n * `runtime/model-catalog`), plus any product-specific entries appended. */\n models: CatalogModel[]\n /** Host-owned request state. Loading takes precedence over error and results. */\n loading?: boolean\n /** Host-safe failure message. null/undefined means no failure; even '' is an error. */\n error?: string | null\n /** Ask the host to retry. The host owns fetching, loading, errors and cancellation. */\n onRetry?: () => void\n /** Disable the trigger and close an open picker; does not change the saved value. */\n disabled?: boolean\n /** Associations belong to the trigger button, not its surrounding div. */\n id?: string\n 'aria-label'?: string\n 'aria-labelledby'?: string\n 'aria-describedby'?: string\n /** Render a provider logo/badge; default is ProviderLogo. */\n renderProviderBadge?: (provider: string) => ReactNode\n /** Section label for `featured` models. */\n recommendedLabel?: string\n /** Pin a labeled section to the TOP of the list (above Recommended) for the\n * models a product wants surfaced first — e.g. a tuner app's own fine-tuned\n * models (`{ label: 'Your Fine-Tuned Models', match: (m) => m.provider === 'tuner' }`).\n * Matching models are shown only in this section, not duplicated below. */\n priorityGroup?: {\n label: string\n match: (model: CatalogModel) => boolean\n }\n /** Trigger treatment — see {@link PickerVariant}. Default `chip`. */\n variant?: PickerVariant\n /** Optional accessible trigger content for a picker docked beside an editable model field. */\n triggerContent?: ReactNode\n}\n\nfunction formatPrice(p?: string): string | undefined {\n if (!p) return undefined\n const n = Number(p)\n if (isNaN(n) || n === 0) return undefined\n const perM = n * 1_000_000\n const amount = Number.isInteger(perM) ? perM.toFixed(0) : perM.toFixed(2)\n return `$${amount}/M`\n}\n\nfunction formatContext(len?: number): string | undefined {\n if (!len) return undefined\n if (len >= 1_000_000) return `${(len / 1_000_000).toFixed(1)}M ctx`\n if (len >= 1_000) return `${Math.round(len / 1_000)}K ctx`\n return `${len} ctx`\n}\n\nfunction SectionHeader({ children }: { children: ReactNode }) {\n return (\n <div className=\"px-3 pb-1 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground\">\n {children}\n </div>\n )\n}\n\nfunction ModelRow({\n model,\n selected,\n onSelect,\n renderProviderBadge,\n}: {\n model: CatalogModel\n selected: boolean\n onSelect: () => void\n renderProviderBadge?: (provider: string) => ReactNode\n}) {\n const price = formatPrice(model.pricing?.prompt)\n const ctx = formatContext(model.contextLength)\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n title={`${model.name} (${model.id})`}\n className={`flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm transition ${POPOVER_OPTION_FOCUS} ${\n selected ? 'bg-primary/10 font-medium' : 'hover:bg-accent'\n }`}\n >\n <span className=\"shrink-0\" aria-hidden>\n {renderProviderBadge ? renderProviderBadge(model.provider) : <ProviderLogo provider={model.provider} size={16} />}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block break-words [overflow-wrap:anywhere]\">{model.name}</span>\n {(ctx || price || !model.supportsTools) && (\n <span className=\"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs font-normal text-muted-foreground\">\n {!model.supportsTools && <span className=\"rounded bg-secondary px-1.5 py-0.5\">no tools</span>}\n {ctx && <span>{ctx}</span>}\n {price && <span>{price}</span>}\n </span>\n )}\n </span>\n {selected && <CheckGlyph className=\"h-3.5 w-3.5 shrink-0 text-primary\" />}\n </button>\n )\n}\n\n/**\n * Searchable model picker pill + popover. A featured model is recommended\n * when the catalog marks it as a current choice. The first view stays short;\n * search and the browse action retain every routeable legacy model.\n *\n * This is the CANONICAL ecosystem model picker (see docs/ui-picker-canon.md).\n * Catalogue requests, retry outcomes and persisted selections belong to the host.\n * The non-modal dialog uses native buttons, not a partial combobox/listbox:\n * Tab and Enter/Space work normally; arrow keys also move through its controls.\n */\nexport function ModelPicker({\n value, onChange, models, loading = false, error, onRetry, disabled = false,\n id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy,\n renderProviderBadge, recommendedLabel = 'Recommended', priorityGroup,\n variant = 'chip', triggerContent,\n}: ModelPickerProps) {\n const [open, setOpen] = useState(false)\n const [query, setQuery] = useState('')\n const [showAll, setShowAll] = useState(false)\n const changeOpen = useCallback((next: boolean) => {\n setOpen(next && !disabled)\n if (!next) {\n setQuery('')\n setShowAll(false)\n }\n }, [disabled])\n const expanded = open && !disabled\n const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(expanded, changeOpen)\n const inputRef = useRef<HTMLInputElement>(null)\n const panelId = useId()\n const valueId = useId()\n const unavailable = error != null\n const sortedModels = useMemo(() => sortModelsByFreshness(models), [models])\n const contentKey = useMemo(() => ({ query, showAll, loading, error, models, value, priorityGroup }),\n [query, showAll, loading, error, models, value, priorityGroup])\n\n useEffect(() => {\n if (disabled) changeOpen(false)\n }, [disabled, changeOpen])\n\n useEffect(() => {\n if (!expanded) return\n // The portal's placement may commit a second render. Focus after that too.\n const focus = () => inputRef.current?.focus()\n focus()\n if (typeof requestAnimationFrame !== 'function') return\n const frame = requestAnimationFrame(focus)\n return () => cancelAnimationFrame(frame)\n }, [expanded])\n\n useEffect(() => {\n const panel = panelRef.current\n if (!expanded || !panel) return\n function onKeyDown(event: KeyboardEvent) {\n if (event.defaultPrevented || event.isComposing || event.altKey || event.ctrlKey || event.metaKey) return\n const input = inputRef.current\n if (!input || !panel) return\n const controls: HTMLElement[] = [input, ...panel.querySelectorAll<HTMLButtonElement>('button:not(:disabled)')]\n const index = controls.indexOf(document.activeElement as HTMLElement)\n if (index < 0) return\n if (event.key === 'Tab') {\n // Portals are last in DOM order. Exit beside the trigger, not at the\n // top of the page; Shift+Tab from search returns to the trigger itself.\n if ((event.shiftKey && index === 0) || (!event.shiftKey && index === controls.length - 1)) {\n changeOpen(false)\n triggerRef.current?.focus()\n if (event.shiftKey) event.preventDefault()\n }\n return\n }\n let next: number\n if (event.key === 'ArrowDown') next = (index + 1) % controls.length\n else if (event.key === 'ArrowUp') next = (index - 1 + controls.length) % controls.length\n else if (event.key === 'Home' && index > 0) next = 1\n else if (event.key === 'End' && index > 0) next = controls.length - 1\n else return // Home/End in search remain text-editing keys.\n event.preventDefault()\n controls[next]?.focus()\n }\n panel.addEventListener('keydown', onKeyDown)\n return () => panel.removeEventListener('keydown', onKeyDown)\n }, [expanded, changeOpen, panelRef, triggerRef])\n\n const selected = sortedModels.find((m) => m.id === value)\n const selectedLabel = selected?.name ?? value\n const describeValue = triggerContent != null || Boolean(id || ariaLabel || ariaLabelledBy)\n const filtered = useMemo(() => {\n const q = query.trim().toLowerCase()\n if (!q) return null\n return sortedModels.filter(\n (m) =>\n m.id.toLowerCase().includes(q) ||\n m.name.toLowerCase().includes(q) ||\n (m.description?.toLowerCase() ?? '').includes(q) ||\n m.provider.toLowerCase().includes(q),\n )\n }, [sortedModels, query])\n\n const sections = useMemo(() => {\n const isPriority = priorityGroup ? (m: CatalogModel) => priorityGroup.match(m) : () => false\n const priority = priorityGroup ? sortedModels.filter(isPriority) : []\n const featured = sortedModels.filter((model) => model.featured && !isPriority(model))\n const recommended = featured.slice(0, MAX_RECOMMENDED_MODELS)\n const visibleIds = new Set([...priority, ...recommended].map((model) => model.id))\n const currentSelection = sortedModels.find((model) => model.id === value && !visibleIds.has(model.id))\n const byProvider: Array<{ provider: string; items: CatalogModel[] }> = []\n for (const model of sortedModels) {\n if (visibleIds.has(model.id)) continue\n const last = byProvider[byProvider.length - 1]\n if (last && last.provider === model.provider) last.items.push(model)\n else byProvider.push({ provider: model.provider, items: [model] })\n }\n return { priority, recommended, currentSelection, byProvider }\n }, [sortedModels, priorityGroup, value])\n\n const select = (modelId: string) => {\n if (disabled || loading || unavailable) return\n changeOpen(false)\n triggerRef.current?.focus()\n onChange(modelId)\n }\n const row = (model: CatalogModel) => (\n <ModelRow key={model.id} model={model} selected={model.id === value} onSelect={() => select(model.id)} renderProviderBadge={renderProviderBadge} />\n )\n\n return (\n <div ref={containerRef} className=\"relative inline-flex min-w-0 max-w-full\">\n <button\n type=\"button\"\n {...triggerProps}\n id={id}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[ariaDescribedBy, describeValue && value ? valueId : undefined].filter(Boolean).join(' ') || undefined}\n aria-haspopup=\"dialog\"\n aria-controls={expanded ? panelId : undefined}\n onClick={() => changeOpen(!expanded)}\n onKeyDown={(event) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n changeOpen(true)\n }\n }}\n title={selectedLabel || 'Select model'}\n data-state={expanded ? 'open' : 'closed'}\n className={`${\n variant === 'quiet'\n ? quietPickerTriggerClass({ interactive: !disabled })\n : `inline-flex min-h-[36px] items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-3 py-1.5 text-sm font-medium text-foreground transition ${disabled ? '' : 'hover:bg-accent'}`\n } max-w-full disabled:cursor-not-allowed disabled:opacity-50`}\n >\n {triggerContent ?? <>\n <span className=\"shrink-0\" aria-hidden>\n {selected ? (renderProviderBadge ? renderProviderBadge(selected.provider) : <ProviderLogo provider={selected.provider} size={16} />) : <SparkleGlyph className=\"h-3.5 w-3.5 text-muted-foreground\" />}\n </span>\n <span className=\"max-w-[160px] truncate\">{selectedLabel || 'Select model'}</span>\n </>}\n <ChevronDown className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </button>\n {describeValue && value && <span id={valueId} className=\"sr-only\">Selected model: {selectedLabel}</span>}\n\n <PopoverSurface\n open={expanded}\n id={panelId}\n role=\"dialog\"\n aria-label=\"Choose a model\"\n contentKey={contentKey}\n triggerRef={triggerRef}\n panelRef={panelRef}\n className={`flex w-[420px] max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-xl border border-card-edge bg-popover text-foreground ${OVERLAY_SHADOW}`}\n >\n <div className=\"shrink-0 border-b border-border px-3 py-2\">\n <div className=\"flex items-center gap-2 rounded-lg border border-strong bg-background px-3 py-2 focus-within:ring-2 focus-within:ring-ring\">\n <SearchGlyph className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n placeholder=\"Search models...\"\n aria-label=\"Search all models\"\n className=\"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground\"\n />\n </div>\n </div>\n {/* min-h-0 lets results absorb the surface's viewport height limit. */}\n <div className=\"max-h-[520px] min-h-0 overflow-y-auto p-1 pb-2\">\n {value && !selected && (\n <div className=\"mx-2 mb-1 mt-2 rounded-lg bg-secondary px-3 py-2 text-sm\">\n <p className=\"text-xs font-medium text-muted-foreground\">Saved model</p>\n <p className=\"break-words [overflow-wrap:anywhere]\">{value}</p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n {loading || unavailable ? 'Your saved selection is unchanged.' : 'Not in this catalogue. Your saved selection is unchanged.'}\n </p>\n </div>\n )}\n {loading ? (\n <div role=\"status\" className=\"px-3 py-4 text-center text-sm text-muted-foreground\">Loading models...</div>\n ) : unavailable ? (\n <div className=\"px-3 py-4 text-sm\">\n <div role=\"alert\">\n <p className=\"font-medium\">Model catalogue unavailable</p>\n <p className=\"mt-1 break-words text-muted-foreground [overflow-wrap:anywhere]\">{error || 'The catalogue could not be loaded.'}</p>\n </div>\n {onRetry && <button type=\"button\" className={`mt-3 rounded-md border border-border bg-card px-3 py-2 font-medium hover:bg-accent ${POPOVER_OPTION_FOCUS}`}\n onClick={() => {\n // Retry may remove this button synchronously. Keep focus on\n // the stable search input while the host updates its state.\n inputRef.current?.focus()\n onRetry()\n }}>Retry</button>}\n </div>\n ) : models.length === 0 ? (\n <div role=\"status\" className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No models available</div>\n ) : filtered ? (\n <>\n {filtered.length === 0 && <div role=\"status\" className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No models match your search</div>}\n {filtered.map(row)}\n </>\n ) : (\n <>\n {priorityGroup && sections.priority.length > 0 && <>\n <SectionHeader>{priorityGroup.label}</SectionHeader>\n {sections.priority.map(row)}\n </>}\n {sections.currentSelection && !showAll && <>\n <SectionHeader>Selected model</SectionHeader>\n {row(sections.currentSelection)}\n </>}\n {sections.recommended.length > 0 && <>\n <SectionHeader>{recommendedLabel}</SectionHeader>\n {sections.recommended.map(row)}\n </>}\n {sections.recommended.length === 0 && sections.priority.length === 0 && !sections.currentSelection && (\n <div className=\"px-3 py-3 text-sm text-muted-foreground\">Search or browse all models</div>\n )}\n {sections.byProvider.length > 0 && <button\n type=\"button\"\n aria-expanded={showAll}\n onClick={() => setShowAll(!showAll)}\n className={`mt-2 w-full rounded-md px-3 py-2 text-left text-sm text-muted-foreground hover:bg-accent hover:text-foreground ${POPOVER_OPTION_FOCUS}`}\n >{showAll ? 'Hide older models' : 'Browse all models'}</button>}\n {showAll && sections.byProvider.map((group) => (\n <div key={group.provider}>\n <SectionHeader>{group.provider}</SectionHeader>\n {group.items.map(row)}\n </div>\n ))}\n </>\n )}\n </div>\n </PopoverSurface>\n </div>\n )\n}\n\n// ── EffortPicker ──────────────────────────────────────────────────────────\n\n/** One reasoning-budget level: the engine `id` is unchanged (the value the\n * product sends to the loop); only the user-facing `label` is renamed to the\n * plainer \"how hard should it think\" vocabulary from docs/product-surfaces.md.\n * `low`→Quick, `medium`→Standard, `high`→Extended. The mapping is overridable\n * via `EffortPickerProps.levels`, so a product can relabel without losing the\n * ids the runtime expects. */\nexport interface EffortLevel {\n id: string\n label: string\n}\n\n/**\n * The engine ids this package NAMES, and the word each one reads as.\n *\n * Deliberately WIDER than {@link DEFAULT_EFFORT_LEVELS}: the default list is\n * what a picker OFFERS when a product declares nothing, while this is the\n * vocabulary — the labels a named id keeps wherever it appears. The two are\n * different questions, and folding them together is what made a real engine\n * rung read as its own id: `xhigh` and `ultracode` are rungs claude-code\n * applies above `high`, so a product declaring them got \"Xhigh\" while every\n * neighbouring rung had a plain English word. Naming them here is what stops\n * each product inventing its own — the drift `effortLevelsFromIds` exists to\n * prevent. They stay OUT of the offered default because most backends do not\n * apply them, and offering a rung the backend ignores is the defect\n * `effortLevels` was added to close.\n */\nconst KNOWN_EFFORT_LABELS = {\n off: 'Off',\n low: 'Quick',\n medium: 'Standard',\n high: 'Extended',\n xhigh: 'Extra',\n ultracode: 'Ultra',\n} as const\n\nexport const DEFAULT_EFFORT_LEVELS: readonly EffortLevel[] = [\n { id: 'off', label: KNOWN_EFFORT_LABELS.off },\n { id: 'low', label: KNOWN_EFFORT_LABELS.low },\n { id: 'medium', label: KNOWN_EFFORT_LABELS.medium },\n { id: 'high', label: KNOWN_EFFORT_LABELS.high },\n]\n\n/**\n * The user-facing label for an engine level id: the canonical vocabulary when\n * the id is one this package names, otherwise the id itself made readable\n * (`auto` -> \"Auto\", `ultra-code` -> \"Ultra code\"). Never invents a depth word,\n * so an id nobody declared a label for still reads as ITSELF and never as some\n * other level.\n */\nexport function effortLevelLabel(id: string): string {\n const known = (KNOWN_EFFORT_LABELS as Record<string, string | undefined>)[id]\n if (known) return known\n const words = id.replace(/[-_]+/g, ' ').trim()\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : id\n}\n\n/**\n * Build a levels list from the engine ids a backend applies — the shape the\n * removed `ComposerAgentControls` took as `reasoning.available`, so a product\n * migrating that list has one call to make instead of a hand-written label map\n * per product (which is how \"Quick\" and \"Low\" drift apart across surfaces).\n */\nexport function effortLevelsFromIds(ids: readonly string[]): readonly EffortLevel[] {\n return ids.map((id) => ({ id, label: effortLevelLabel(id) }))\n}\n\n/**\n * The list {@link EffortPicker} RENDERS for `value` — the declared levels, plus\n * `value` itself when the declaration omits it.\n *\n * A picker cannot honestly resolve a selected value it was not given, and the\n * failure it used to take instead — fall back to the middle entry — renders the\n * session's real depth as a DIFFERENT level's name. That is exactly the defect\n * `levels` was added to prevent: the legacy adapter's `available` list excluded\n * the `auto` sentinel because the old picker injected it, so a product mapping\n * that list straight across ships a session running on `auto` labelled\n * \"Extended\". Admitting the value is not offering a new choice — it is\n * reporting the state the session is already in, and it disappears from the\n * list as soon as the user picks a declared level.\n *\n * A blank value is not admitted (there is no honest label for it); the picker\n * renders no selection instead.\n */\nexport function reconcileEffortLevels(\n value: string,\n levels: readonly EffortLevel[] = DEFAULT_EFFORT_LEVELS,\n): readonly EffortLevel[] {\n if (!value || levels.some((l) => l.id === value)) return levels\n return [{ id: value, label: effortLevelLabel(value) }, ...levels]\n}\n\n// ── effort strength meter ─────────────────────────────────────────────────\n\n/** Segments the meter draws — fixed geometry so the ladder stays tabular\n * across levels (and across the trigger and its menu rows). */\nexport const EFFORT_METER_SEGMENTS = 4\n\n/** Filled-segment opacity ladder: translucent on the left, heavy on the\n * right — the ramp carries strength even at a glance, the count carries it\n * exactly. Unfilled segments sit at a fixed ghost opacity. */\nconst EFFORT_METER_FILL_OPACITY = [0.25, 0.5, 0.75, 1] as const\nconst EFFORT_METER_GHOST_OPACITY = 0.15\n\n/** Level ids that mean \"no reasoning\" — the meter renders all-ghost. */\nconst OFF_LEVEL_IDS: ReadonlySet<string> = new Set(['off', 'none'])\n\n/**\n * Ids that name a POLICY rather than a depth: `auto` means \"let the harness and\n * model decide\", so it has no position on a strength ladder.\n *\n * Without this it lands wherever the declaration puts it and draws a filled\n * meter — measured on a product that offers `auto` first: every harness read\n * `Auto` at a FULL four bars, including `cli-base`, which has no agent to think\n * at all. A meter is a claim about how hard the run will think, and a sentinel\n * cannot make that claim.\n */\nconst UNPLACEABLE_LEVEL_IDS: ReadonlySet<string> = new Set(['auto'])\n\n/**\n * Filled-segment count for a level: 0 for off/none (or an id the levels list\n * does not carry); otherwise the level's position among the non-off choices\n * scaled onto the meter, so the ladder reads low < medium < high and the top\n * level fills the whole scale. The canonical four levels land 0 / 1 / 2 / 4.\n */\nexport function effortMeterFill(\n levelId: string,\n levels: readonly EffortLevel[] = DEFAULT_EFFORT_LEVELS,\n): number {\n if (OFF_LEVEL_IDS.has(levelId) || UNPLACEABLE_LEVEL_IDS.has(levelId)) return 0\n const active = levels.filter((l) => !OFF_LEVEL_IDS.has(l.id) && !UNPLACEABLE_LEVEL_IDS.has(l.id))\n const index = active.findIndex((l) => l.id === levelId)\n if (index < 0 || active.length === 0) return 0\n return Math.max(1, Math.floor(((index + 1) * EFFORT_METER_SEGMENTS) / active.length))\n}\n\n/**\n * The thinking-strength meter: four 12px bars, filled count = level, filled\n * opacity ramping 25→100% left to right (unfilled at a faint ghost). Purely\n * decorative — the level name is always rendered as text beside it, so the\n * meter is `aria-hidden` and adds no second accessible name.\n */\nexport function EffortMeter({ fill, className }: { fill: number; className?: string }) {\n return (\n <span aria-hidden className={`inline-flex items-center gap-[2px] ${className ?? ''}`}>\n {Array.from({ length: EFFORT_METER_SEGMENTS }, (_, i) => (\n <span\n key={i}\n className=\"h-3 w-[3px] rounded-full bg-current\"\n style={{ opacity: i < fill ? EFFORT_METER_FILL_OPACITY[i] : EFFORT_METER_GHOST_OPACITY }}\n />\n ))}\n </span>\n )\n}\n\nexport interface EffortPickerProps {\n value: string\n onChange: (id: string) => void\n /** Selectable levels (engine id + user-facing label). Defaults to the plain\n * \"Thinking\" vocabulary; override to relabel without changing the ids the\n * runtime receives.\n *\n * A list that omits the current `value` is not a rendering error the picker\n * papers over: `value` is reconciled INTO the rendered list under its own\n * name (see {@link reconcileEffortLevels}), because a control must report\n * the depth the session is running at and never some other list entry. */\n levels?: readonly EffortLevel[]\n /** Prefix shown before the active level on the pill — the \"what is this\"\n * context the bare value lacked. Default \"Thinking\". Pass '' to hide it. */\n label?: string\n /** Fill the container instead of shrink-wrapping — opt-in, default `false`;\n * see {@link pickerRootClass} for when and why. */\n fullWidth?: boolean\n /** Trigger treatment — see {@link PickerVariant}. Default `chip`. */\n variant?: PickerVariant\n}\n\n/** Thinking-budget selector pill, styled to match {@link ModelPicker}. Show\n * it only when the selected model `supportsReasoning`. \"Thinking\" is the\n * plain-English name for what was internally called \"effort\".\n *\n * The CANONICAL ecosystem effort picker — sandbox-ui's reasoning menu (inside\n * its `chat/AgentSessionControls`) is legacy and frozen. */\nexport function EffortPicker({ value, onChange, levels = DEFAULT_EFFORT_LEVELS, label = 'Thinking', fullWidth = false, variant = 'chip' }: EffortPickerProps) {\n const [open, setOpen] = useState(false)\n const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen)\n const panelId = useId()\n const rendered = reconcileEffortLevels(value, levels)\n // The strength ladder is computed over the DECLARED levels only, so admitting\n // the selected value cannot shift where the declared ones sit on the meter.\n // A level the declaration does not carry has no position on that ladder, so\n // it renders with NO meter — an all-ghost meter is what `off` looks like, and\n // \"we cannot place this\" is not \"no thinking\".\n const isDeclared = (id: string) => levels.some((l) => l.id === id) && !UNPLACEABLE_LEVEL_IDS.has(id)\n const selected = rendered.find((l) => l.id === value)\n\n return (\n <div ref={containerRef} className={pickerRootClass(fullWidth)}>\n <button\n type=\"button\"\n {...triggerProps}\n aria-controls={open ? panelId : undefined}\n onClick={() => setOpen(!open)}\n title={label ? `${label} — how hard the agent reasons before answering` : 'Reasoning effort'}\n data-state={open ? 'open' : 'closed'}\n className={`${\n variant === 'quiet'\n ? quietPickerTriggerClass()\n : 'inline-flex min-h-[36px] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-3 py-1.5 text-sm font-medium text-foreground transition hover:bg-accent'\n } ${fullWidth ? 'w-full' : ''}`}\n >\n <BrainGlyph className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n {/* Full width gives the label the slack, so the meter and chevron park\n on the trailing edge and the glyph stays against the text. */}\n <span className={fullWidth ? 'flex-1 truncate text-left' : undefined}>\n {label ? <span className=\"text-muted-foreground\">{label}: </span> : null}\n {selected ? selected.label : '—'}\n </span>\n {/* Quiet inherits the trigger's tone, so the meter is muted at rest\n and lifts with the label on hover instead of staying at full foreground. */}\n {selected && isDeclared(selected.id) && (\n <EffortMeter\n fill={effortMeterFill(selected.id, levels)}\n className={variant === 'quiet' ? 'shrink-0' : 'shrink-0 text-foreground'}\n />\n )}\n <ChevronDown className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n </button>\n <PopoverSurface\n open={open}\n id={panelId}\n role=\"menu\"\n triggerRef={triggerRef}\n panelRef={panelRef}\n // A portaled panel has no `w-full` to inherit, so a full-width trigger\n // hands its measured width to the panel instead.\n matchTriggerWidth={fullWidth}\n className={`w-44 overflow-y-auto rounded-xl border border-card-edge bg-popover p-1 ${OVERLAY_SHADOW}`}\n >\n {rendered.map((l) => (\n <button\n key={l.id}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={l.id === value}\n onClick={() => {\n onChange(l.id)\n setOpen(false)\n }}\n className={`flex min-h-[40px] w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition ${POPOVER_OPTION_FOCUS} ${\n l.id === value ? 'bg-primary/10 font-medium' : 'hover:bg-accent'\n }`}\n >\n <BrainGlyph className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate\">{l.label}</span>\n {isDeclared(l.id) && (\n <EffortMeter fill={effortMeterFill(l.id, levels)} className=\"ml-auto text-foreground\" />\n )}\n {l.id === value && (\n <CheckGlyph className={`${isDeclared(l.id) ? '' : 'ml-auto '}h-3.5 w-3.5 shrink-0 text-primary`} />\n )}\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