@agimon-ai/po-native-dashboard 0.0.0-alpha.2 → 0.0.0-alpha.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SessionScreen.mjs","names":["NativeTemplateSessionProps","ToolMessageRenderProps","ToolResultView","ThreadViewOptions","WebPluginSlotProps","Button","fontOf","List","MarkdownProps","Tabs","TabsList","TabsTrigger","ImageRefScope","subscribeWebPluginRegistry","personaInitials","sessionStoreFor","subscribeThread","unsubscribeThread","threadStoreKey","holdSessionChannels","HOST_SLOTS","pluginUserMessageActions","renderRegion","slotFills","TimelineEntry","DashboardEntry","toolMessageProps","toolPromptClaim","ToolPromptInput","ToolRendererBoundary","useImageRefs","webTabs","useRenderTrace","useStore","ComponentType","memo","ReactElement","ReactNode","useCallback","useEffect","useMemo","useReducer","useState","AccessibilityInfo","StyleSheet","ActivityPanel","Composer","ComposerProps","DialogSheet","MessageActionsSheet","nativeSlotProps","TimelineItem","CONVERSATION_TAB","EMPTY_ENTRIES","EMPTY_STATUSES","Readonly","Record","MemoTimelineItem","entryKey","entry","id","TOOL_GROUP_LIMIT","ToolPayload","toolCallId","args","result","output","running","isError","SessionScreenProps","entries","composer","Omit","transcript","SessionTranscript","createGrouper","renderItem","builtIn","useRegistryVersion","version","bump","value","SessionScreen","props","sessionId","onSend","sessionToolRenderer","ask","onAnswer","onCancel","activity","error","stopped","offline","statuses","activeTab","setActiveTab","drafts","setDrafts","actionTarget","setActionTarget","messageActions","updateDraft","onDraftChange","text","current","slotProps","tabId","addition","trim","draft","initialText","separator","test","pluginTabs","tabs","label","map","ActivePanel","find","tab","panel","prompt","readOnly","promptInput","fallbackAsk","dialogValue","onDialogValueChange","asking","dialog","name","failed","askingId","undefined","askingTitle","title","announceForAccessibility","emptyRegion","length","emptyStateRegion","composerShown","retainComposer","styles","screen","list","liveTranscript","markdown","offlineText","restoring","onRestore","promptDock","promptInset","promptError","contextItems","item","source","onRemoveContext","stoppedTitle","stoppedText","folder","stoppedError","waking","onWake","Boolean","draftStore","overlay","pluginId","component","Overlay","PluginToolMessage","message","Message","P","LiveActivity","streaming","state","SessionTimeline","live","onMessageActions","raw","mapEntry","createNativeEntryMapper","groupTools","createToolGrouper","data","flatMap","registryVersion","renderTool","toolName","tool","payload","details","nested","NonNullable","call","Nested","content","block","type","join","nestedFailed","cache","WeakMap","mapped","get","nativeEntry","set","previous","Map","next","out","run","flush","first","push","old","same","calls","every","index","group","role","create","theme","rt","maxHeight","paddingBottom","insets","ime","bottom","uni__dependencies","paddingHorizontal","spacing","fontFamily","sans","fontSize","sm","lineHeight","color","colors","red","flexDirection","flexWrap","gap","flex","backgroundColor","bg","paddingVertical","margin","padding","borderRadius","lg","borderWidth","borderColor","base","fontWeight","semibold","hi","lineHeightRelaxed","dim","alignItems","paddingLeft","paddingRight","at","timestamp","kind","images","identity","profile","author","initials","tone","tools","argSummary","NativeTranscript","threadId","options","Pick","key","limit","visible","slice"],"sources":["../../src/screens/SessionScreen.tsx"],"sourcesContent":["import type { NativeTemplateSessionProps } from '@agimon-ai/po-core/native';\nimport type {\n ToolMessageRenderProps,\n ToolResultView,\n ThreadViewOptions,\n WebPluginSlotProps,\n} from '@agimon-ai/po-core/web';\nimport { Button, fontOf, List, type MarkdownProps, Tabs, TabsList, TabsTrigger } from '@agimon-ai/po-native-components';\nimport {\n ImageRefScope,\n subscribeWebPluginRegistry,\n personaInitials,\n sessionStoreFor,\n subscribeThread,\n unsubscribeThread,\n threadStoreKey,\n holdSessionChannels,\n HOST_SLOTS,\n pluginUserMessageActions,\n renderRegion,\n slotFills,\n type TimelineEntry as DashboardEntry,\n toolMessageProps,\n toolPromptClaim,\n type ToolPromptInput,\n ToolRendererBoundary,\n useImageRefs,\n webTabs,\n useRenderTrace,\n} from '@agimon-ai/po-web-dashboard/core';\nimport { useStore } from '@tanstack/react-store';\nimport {\n type ComponentType,\n memo,\n type ReactElement,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useReducer,\n useState,\n} from 'react';\nimport { AccessibilityInfo, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { ActivityPanel } from '../components/ActivityPanel';\nimport { Composer, type ComposerProps } from '../components/Composer';\nimport { DialogSheet } from '../components/DialogSheet';\nimport { MessageActionsSheet } from '../components/MessageActionsSheet';\nimport { nativeSlotProps } from '../components/slotProps';\nimport { type TimelineEntry, TimelineItem } from '../components/TimelineItem';\n\nconst CONVERSATION_TAB = 'conversation';\nconst EMPTY_ENTRIES: readonly TimelineEntry[] = [];\nconst EMPTY_STATUSES: Readonly<Record<string, string>> = {};\nconst MemoTimelineItem = memo(TimelineItem);\nconst entryKey = (entry: TimelineEntry) => entry.id;\n/** The most tool calls one transcript cell holds; a longer run splits into several groups. */\nconst TOOL_GROUP_LIMIT = 20;\n\n/** The tool entry fields a plugin renderer reads, carried as TimelineEntry.payload. */\nexport interface ToolPayload {\n toolCallId: string;\n args: Record<string, unknown>;\n result: ToolResultView | null;\n output: string;\n running: boolean;\n isError: boolean;\n}\n\n/**\n * The app's session contract plus the presentation hooks a template may add. Every addition is\n * optional, so a template screen typed with these props still accepts what the app hands it.\n */\nexport interface SessionScreenProps extends NativeTemplateSessionProps {\n entries?: readonly TimelineEntry[];\n /** Options and run controls for the composer row. */\n composer?: Omit<ComposerProps, 'onSend' | 'disabled' | 'value' | 'onChangeText'>;\n /** Lets a template regroup and redraw transcript rows; absent keeps the built-in tool groups and rows. */\n transcript?: SessionTranscript;\n}\n\nexport interface SessionTranscript {\n /** Called once per transcript, so the grouper can keep unchanged groups by identity between renders. */\n createGrouper: () => (entries: readonly TimelineEntry[]) => TimelineEntry[];\n /** `builtIn` draws one entry the default way, with plugin tool cards, for rows the template keeps. */\n renderItem: (entry: TimelineEntry, builtIn: (entry: TimelineEntry) => ReactElement) => ReactElement | null;\n}\n\n/** Re-renders when plugin installs change what the registry resolves. */\nfunction useRegistryVersion(): number {\n const [version, bump] = useReducer((value: number) => value + 1, 0);\n useEffect(() => subscribeWebPluginRegistry(bump), []);\n return version;\n}\n\nexport function SessionScreen(props: SessionScreenProps) {\n useRenderTrace('SessionScreen');\n const {\n sessionId,\n entries = EMPTY_ENTRIES,\n onSend,\n sessionToolRenderer,\n ask,\n onAnswer,\n onCancel,\n activity,\n error,\n composer,\n stopped,\n offline,\n } = props;\n const statuses = props.statuses ?? EMPTY_STATUSES;\n const [activeTab, setActiveTab] = useState(CONVERSATION_TAB);\n const [drafts, setDrafts] = useState<Record<string, string>>({});\n const [actionTarget, setActionTarget] = useState<TimelineEntry>();\n const messageActions = pluginUserMessageActions();\n const updateDraft =\n props.onDraftChange ?? ((text: string) => setDrafts((current) => ({ ...current, [sessionId]: text })));\n useRegistryVersion();\n const slotProps =\n props.slotProps ??\n nativeSlotProps(\n sessionId,\n statuses,\n (tabId) => setActiveTab(tabId ?? CONVERSATION_TAB),\n (text) => {\n const addition = text.trim();\n if (!addition) return;\n setDrafts((current) => {\n const draft = current[sessionId] ?? composer?.initialText ?? '';\n const separator = draft === '' || /\\s$/.test(draft) ? '' : ' ';\n return { ...current, [sessionId]: `${draft}${separator}${addition}` };\n });\n },\n );\n const pluginTabs = webTabs(sessionId);\n const tabs = [{ id: CONVERSATION_TAB, label: 'Conversation' }, ...pluginTabs.map(({ id, label }) => ({ id, label }))];\n const ActivePanel = pluginTabs.find((tab) => tab.id === activeTab)?.panel;\n const prompt =\n !props.readOnly && props.promptInput && onAnswer && onCancel\n ? // The app builds it from the dashboard's own session state, so the contract's wide shape narrows back.\n toolPromptClaim(props.promptInput as ToolPromptInput, null, sessionId)\n : null;\n const fallbackAsk =\n !props.readOnly && ask && onAnswer ? (\n <DialogSheet\n ask={ask}\n onAnswer={onAnswer}\n onCancel={onCancel}\n value={props.dialogValue}\n onChangeValue={props.onDialogValueChange}\n />\n ) : null;\n const asking =\n prompt && onAnswer && onCancel ? (\n <ToolRendererBoundary key={`${sessionId}:${prompt.dialog.id}`} toolName={prompt.entry?.name ?? 'dialog'}>\n {(failed) =>\n failed ? (\n fallbackAsk\n ) : prompt.entry ? (\n <prompt.prompt.component\n {...toolMessageProps(slotProps, prompt.entry, statuses)}\n dialog={prompt.dialog}\n answer={(value) => onAnswer(prompt.dialog.id, value)}\n cancel={() => onCancel(prompt.dialog.id)}\n />\n ) : (\n <prompt.prompt.component\n {...slotProps}\n dialog={prompt.dialog}\n answer={(value) => onAnswer(prompt.dialog.id, value)}\n cancel={() => onCancel(prompt.dialog.id)}\n />\n )\n }\n </ToolRendererBoundary>\n ) : (\n fallbackAsk\n );\n const askingId = asking === null ? undefined : (prompt?.dialog.id ?? ask?.id);\n const askingTitle = prompt?.dialog.title ?? ask?.title;\n // Screen readers hear a question once when it arrives, not on every re-render.\n useEffect(() => {\n if (askingId !== undefined)\n AccessibilityInfo.announceForAccessibility(`Po is asking: ${askingTitle ?? 'a question'}`);\n }, [askingId, askingTitle]);\n // An empty conversation a person's own package may fill on the phone; with no fill the list shows as before.\n const emptyRegion =\n entries.length === 0 ? renderRegion(HOST_SLOTS.emptyStateRegion, null, slotProps, sessionId) : null;\n const composerShown =\n !props.readOnly && !stopped && !prompt && (props.panel === undefined || props.retainComposer === true);\n return (\n <View style={styles.screen}>\n {!props.slotProps && tabs.length > 1 ? (\n <Tabs value={activeTab} onValueChange={setActiveTab}>\n <TabsList>\n {tabs.map((tab) => (\n <TabsTrigger key={tab.id} value={tab.id}>\n {tab.label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n ) : null}\n {props.panel !== undefined ? (\n <View style={styles.list}>{props.panel}</View>\n ) : ActivePanel ? (\n <View style={styles.list}>\n <ActivePanel {...slotProps} />\n </View>\n ) : emptyRegion ? (\n <View style={styles.list}>{emptyRegion}</View>\n ) : (\n <SessionTimeline\n sessionId={sessionId}\n entries={entries}\n live={props.liveTranscript}\n slotProps={slotProps}\n statuses={statuses}\n sessionToolRenderer={sessionToolRenderer}\n onMessageActions={messageActions.length ? setActionTarget : undefined}\n markdown={props.markdown}\n transcript={props.transcript}\n />\n )}\n {props.liveTranscript ? (\n <LiveActivity sessionId={sessionId} error={error} />\n ) : (\n <ActivityPanel status={activity} error={error} />\n )}\n {offline && !props.readOnly && !stopped ? (\n <View style={styles.offline} accessibilityLiveRegion=\"polite\">\n <Text style={styles.offlineText}>Po on your computer is not connected. Your message is kept.</Text>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n loading={offline.restoring ?? false}\n loadingLabel=\"Restoring the connection\"\n onPress={offline.onRestore}\n >\n Restore\n </Button>\n </View>\n ) : null}\n {asking ? (\n // ponytail: a fixed share of the screen keeps the transcript visible; the prompt scrolls inside it.\n <View style={[styles.promptDock, !composerShown && styles.promptInset]}>\n {props.promptError ? (\n <Text style={styles.promptError} accessibilityRole=\"alert\">\n {props.promptError}\n </Text>\n ) : null}\n {asking}\n </View>\n ) : null}\n {props.contextItems?.length && (props.panel === undefined || props.retainComposer) ? (\n <View style={styles.contextItems}>\n {props.contextItems.map((item) => (\n <Button\n key={`${item.source}:${item.id}`}\n variant=\"ghost\"\n size=\"sm\"\n accessibilityLabel={`Remove ${item.label}`}\n onPress={() => props.onRemoveContext?.(item.source, item.id)}\n >\n {item.label} ×\n </Button>\n ))}\n </View>\n ) : null}\n {!props.readOnly && stopped ? (\n <View style={styles.stopped}>\n <Text style={styles.stoppedTitle}>Session stopped</Text>\n <Text style={styles.stoppedText}>\n Review the conversation above, then wake to continue.\n {stopped.folder ? ` History is on disk in ${stopped.folder}.` : ' Your history is saved.'}\n </Text>\n {stopped.error ? (\n <Text style={styles.stoppedError} accessibilityRole=\"alert\">\n {stopped.error}\n </Text>\n ) : null}\n <Button variant=\"primary\" size=\"md\" loading={stopped.waking} loadingLabel=\"Waking\" onPress={stopped.onWake}>\n Wake session\n </Button>\n </View>\n ) : composerShown ? (\n <Composer\n {...composer}\n onSend={onSend}\n disabled={Boolean(ask)}\n value={props.draftStore ? undefined : (props.draft ?? drafts[sessionId] ?? composer?.initialText ?? '')}\n onChangeText={props.draftStore ? undefined : updateDraft}\n draftStore={props.draftStore}\n sessionId={sessionId}\n slotProps={slotProps}\n />\n ) : null}\n <MessageActionsSheet\n sessionId={sessionId}\n message={actionTarget}\n actions={messageActions}\n onClose={() => setActionTarget(undefined)}\n />\n {!props.readOnly &&\n slotFills(HOST_SLOTS.overlay, sessionId).map(({ pluginId, id, component: Overlay }) =>\n Overlay ? <Overlay key={`${pluginId}:${id}`} {...slotProps} /> : null,\n )}\n </View>\n );\n}\n\n/** A plugin renderer reads result images inline, so one the transcript sent by reference is filled in once read. */\nfunction PluginToolMessage<P extends { result: ToolResultView | null }>({\n message: Message,\n props,\n}: {\n message: ComponentType<P>;\n props: P;\n}) {\n const result = useImageRefs(props.result);\n return <Message {...props} result={result} />;\n}\nfunction LiveActivity({ sessionId, error }: { sessionId: string; error?: string }) {\n const streaming = useStore(sessionStoreFor(sessionId), (state) => state.streaming);\n return <ActivityPanel status={streaming ? 'Working...' : undefined} error={error} />;\n}\n\nconst SessionTimeline = memo(function SessionTimeline({\n sessionId,\n entries,\n live,\n slotProps,\n statuses,\n sessionToolRenderer,\n onMessageActions,\n markdown,\n transcript,\n}: {\n sessionId: string;\n entries: readonly TimelineEntry[];\n live?: boolean;\n slotProps: WebPluginSlotProps;\n statuses: Readonly<Record<string, string>>;\n sessionToolRenderer?: SessionScreenProps['sessionToolRenderer'];\n onMessageActions?: (entry: TimelineEntry) => void;\n markdown?: SessionScreenProps['markdown'];\n transcript?: SessionTranscript;\n}) {\n const raw = useStore(sessionStoreFor(sessionId), (state) => (live ? state.entries : undefined));\n const mapEntry = useMemo(createNativeEntryMapper, []);\n const groupTools = useMemo(() => (transcript?.createGrouper ?? createToolGrouper)(), [transcript]);\n const data = useMemo(\n () => groupTools(raw === undefined ? entries : raw.flatMap(mapEntry)),\n [raw, entries, mapEntry, groupTools],\n );\n const registryVersion = useRegistryVersion();\n const renderTool = useCallback(\n (entry: TimelineEntry): ReactNode | null => {\n const toolName = entry.toolName;\n const tool = entry.payload as ToolPayload | undefined;\n if (!toolName || !tool) return null;\n const Message = sessionToolRenderer?.(sessionId, toolName, statuses, tool.result?.details)?.message;\n if (!Message) return null;\n // Another tool's own card for a call made on this one's behalf, as the web's nestedToolCard. Null when no\n // plugin claims the tool; the nested card gets no renderTool, so nesting stops at one level.\n const nested: NonNullable<ToolMessageRenderProps['renderTool']> = (call) => {\n const Nested = sessionToolRenderer?.(sessionId, call.toolName, statuses, call.result?.details)?.message;\n if (!Nested) return null;\n const output = (call.result?.content ?? [])\n .flatMap((item) => {\n const block = item as { type?: unknown; text?: unknown };\n return block.type === 'text' && typeof block.text === 'string' ? [block.text] : [];\n })\n .join('\\n');\n return (\n <ToolRendererBoundary toolName={call.toolName}>\n {(nestedFailed) =>\n nestedFailed ? (\n <Text selectable>{output}</Text>\n ) : (\n <PluginToolMessage\n message={Nested}\n props={{\n ...slotProps,\n toolCallId: `${tool.toolCallId}:${call.toolName}`,\n toolName: call.toolName,\n args: call.args,\n result: call.result,\n output,\n running: false,\n isError: call.isError,\n }}\n />\n )\n }\n </ToolRendererBoundary>\n );\n };\n return (\n <ToolRendererBoundary key={entry.id} toolName={toolName}>\n {(failed) =>\n failed ? (\n <TimelineItem entry={entry} />\n ) : (\n <PluginToolMessage message={Message} props={{ ...slotProps, toolName, ...tool, renderTool: nested }} />\n )\n }\n </ToolRendererBoundary>\n );\n },\n [sessionId, statuses, slotProps, sessionToolRenderer, registryVersion],\n );\n const renderItem = useCallback(\n (entry: TimelineEntry) => {\n const builtIn = (item: TimelineEntry) => (\n <MemoTimelineItem\n entry={item}\n renderTool={renderTool}\n onMessageActions={onMessageActions}\n markdown={markdown}\n />\n );\n return transcript ? transcript.renderItem(entry, builtIn) : builtIn(entry);\n },\n [renderTool, onMessageActions, markdown, transcript],\n );\n return (\n <ImageRefScope value={sessionId}>\n <List\n style={styles.list}\n startAtBottom\n separators={false}\n data={data}\n keyExtractor={entryKey}\n renderItem={renderItem}\n accessibilityLabel=\"Transcript\"\n />\n </ImageRefScope>\n );\n});\n\n/** Each transcript owns its cache; removed dashboard entries are only weakly referenced. */\nexport function createNativeEntryMapper(): (entry: DashboardEntry) => TimelineEntry[] {\n const cache = new WeakMap<DashboardEntry, TimelineEntry[]>();\n return (entry) => {\n let mapped = cache.get(entry);\n if (mapped === undefined) {\n mapped = nativeEntry(entry);\n cache.set(entry, mapped);\n }\n return mapped;\n };\n}\n\n/**\n * Folds each run of two or more consecutive tool calls into `tools` entries of\n * at most TOOL_GROUP_LIMIT calls, so one list cell never mounts a whole long\n * run. Chunks count from the run's start, so keys stay put as the run grows.\n * A group whose calls are unchanged keeps its object, so the memoised row and\n * the calls in it do not re-render while another entry streams.\n */\nexport function createToolGrouper(): (entries: readonly TimelineEntry[]) => TimelineEntry[] {\n let previous = new Map<string, TimelineEntry>();\n return (entries) => {\n const next = new Map<string, TimelineEntry>();\n const out: TimelineEntry[] = [];\n let run: TimelineEntry[] = [];\n const flush = () => {\n const first = run[0];\n if (first === undefined || run.length < 2) {\n out.push(...run);\n } else {\n const id = `tools:${first.id}`;\n const old = previous.get(id);\n const same = old?.calls?.length === run.length && run.every((call, index) => old.calls?.[index] === call);\n const group: TimelineEntry = same && old !== undefined ? old : { id, role: 'tools', text: '', calls: run };\n next.set(id, group);\n out.push(group);\n }\n run = [];\n };\n for (const entry of entries) {\n if (entry.role === 'tool') {\n run.push(entry);\n if (run.length === TOOL_GROUP_LIMIT) flush();\n } else {\n flush();\n out.push(entry);\n }\n }\n flush();\n previous = next;\n return out;\n };\n}\n\nconst styles = StyleSheet.create((theme, rt) => ({\n promptDock: { maxHeight: '70%' },\n // Clears the home indicator when no composer sits below; the keyboard covers that edge while it is open.\n promptInset: { paddingBottom: rt.insets.ime > 0 ? 0 : rt.insets.bottom },\n promptError: {\n paddingHorizontal: theme.spacing(4),\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.red,\n },\n contextItems: { flexDirection: 'row', flexWrap: 'wrap', paddingHorizontal: theme.spacing(3), gap: theme.spacing(2) },\n screen: {\n flex: 1,\n backgroundColor: theme.colors.bg,\n },\n list: {\n flex: 1,\n paddingVertical: theme.spacing(2),\n },\n stopped: {\n gap: theme.spacing(2),\n margin: theme.spacing(3),\n padding: theme.spacing(4),\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors['border-soft'],\n },\n stoppedTitle: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors.hi,\n },\n stoppedText: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.dim,\n },\n stoppedError: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.red,\n },\n offline: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2),\n paddingLeft: theme.spacing(4),\n paddingRight: theme.spacing(2),\n },\n offlineText: {\n flex: 1,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n },\n}));\n\n/** Maps dashboard transcript entries onto the native timeline; tool payload feeds plugin renderers. */\nexport function nativeEntry(entry: DashboardEntry): TimelineEntry[] {\n const at = entry.timestamp === undefined ? {} : { timestamp: entry.timestamp };\n switch (entry.kind) {\n case 'user':\n case 'queued':\n return [\n {\n id: entry.id,\n role: 'user',\n text: entry.text,\n ...(entry.images?.length ? { images: entry.images } : {}),\n ...at,\n },\n ];\n case 'assistant': {\n if (!entry.text) return [];\n const name = entry.identity?.name ?? entry.identity?.profile;\n const author = name === undefined ? {} : { author: { name, initials: personaInitials(name) } };\n return [{ id: entry.id, role: 'assistant', text: entry.text, ...author, ...at }];\n }\n case 'intercom':\n return [\n {\n id: entry.id,\n role: 'assistant',\n text: entry.text,\n author: { name: entry.name, initials: personaInitials(entry.name) },\n ...at,\n },\n ];\n case 'notice':\n return [{ id: entry.id, role: 'notice', text: entry.text, tone: entry.tone, ...at }];\n case 'settled':\n return [{ id: entry.id, role: 'settled', text: '', tools: entry.tools, ...at }];\n case 'tool':\n return [\n {\n id: entry.id,\n role: 'tool',\n toolName: entry.name,\n text: entry.output || entry.argSummary,\n ...at,\n payload: {\n toolCallId: entry.toolCallId,\n args: entry.args,\n result: entry.result,\n output: entry.output,\n running: entry.running,\n isError: entry.isError,\n },\n },\n ];\n default:\n return [];\n }\n}\n\n/** Host-owned native transcript adapters, using the same session/thread folds as the conversation. */\nexport function NativeTranscript({\n sessionId,\n threadId,\n options,\n markdown,\n}: {\n sessionId: string;\n threadId?: string;\n options?: ThreadViewOptions;\n markdown?: Pick<MarkdownProps, 'loadImage' | 'onFileLink'>;\n}) {\n useRenderTrace('NativeTranscript');\n useEffect(() => {\n if (threadId !== undefined) {\n subscribeThread(sessionId, threadId);\n return () => unsubscribeThread(sessionId, threadId);\n }\n // A transcript shown outside focus keeps its session's extension channels.\n return holdSessionChannels(sessionId);\n }, [sessionId, threadId]);\n const key = threadId === undefined ? sessionId : threadStoreKey(sessionId, threadId);\n const raw = useStore(sessionStoreFor(key), (state) => state.entries);\n const mapEntry = useMemo(createNativeEntryMapper, []);\n const entries = useMemo(() => raw.flatMap(mapEntry), [raw, mapEntry]);\n const limit = options?.limit;\n const visible = useMemo(\n () => (limit === undefined ? entries : limit <= 0 ? [] : entries.slice(-limit)),\n [entries, limit],\n );\n const renderItem = useCallback(\n (entry: TimelineEntry) => <MemoTimelineItem entry={entry} markdown={markdown} />,\n [markdown],\n );\n return (\n <ImageRefScope value={key}>\n <List\n data={visible}\n keyExtractor={entryKey}\n renderItem={renderItem}\n separators={false}\n accessibilityLabel=\"Transcript\"\n />\n </ImageRefScope>\n );\n}\n"],"mappings":";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atC,aAChBqB,UAAyB,oBAAC,kBAAD;EAAyBA;EAAiBuF;CAAS,IAC7E,CAACA,QAAQ,CACX;CACA,OACE,oBAAC,eAAD;EAAe,OAAOoI;YACpB,oBAAC,MAAD;GACE,MAAME;GACN,cAAc9N;GACFkB;GACZ,YAAY;GACZ,oBAAmB;EAAY;CAEpB;AAEnB"}
1
+ {"version":3,"file":"SessionScreen.mjs","names":["NativeTemplateSessionProps","ToolMessageRenderProps","ToolResultView","ThreadViewOptions","WebPluginSlotProps","Button","fontOf","List","MarkdownProps","Tabs","TabsList","TabsTrigger","ImageRefScope","subscribeWebPluginRegistry","personaInitials","sessionStoreFor","subscribeThread","unsubscribeThread","threadStoreKey","holdSessionChannels","HOST_SLOTS","pluginUserMessageActions","renderRegion","slotFills","TimelineEntry","DashboardEntry","toolMessageProps","toolPromptClaim","ToolPromptInput","ToolRendererBoundary","useImageRefs","webTabs","useRenderTrace","useStore","ComponentType","memo","ReactElement","ReactNode","useCallback","useEffect","useMemo","useReducer","useState","AccessibilityInfo","StyleSheet","ActivityPanel","Composer","ComposerProps","DialogSheet","MessageActionsSheet","nativeSlotProps","TimelineItem","CONVERSATION_TAB","EMPTY_ENTRIES","EMPTY_STATUSES","Readonly","Record","MemoTimelineItem","entryKey","entry","id","TOOL_GROUP_LIMIT","ToolPayload","toolCallId","args","result","output","running","isError","SessionScreenProps","entries","composer","Omit","transcript","SessionTranscript","createGrouper","renderItem","builtIn","slotProps","showsWork","useRegistryVersion","version","bump","value","SessionScreen","props","sessionId","onSend","sessionToolRenderer","ask","onAnswer","onCancel","activity","error","stopped","offline","statuses","activeTab","setActiveTab","drafts","setDrafts","actionTarget","setActionTarget","messageActions","updateDraft","onDraftChange","text","current","tabId","addition","trim","draft","initialText","separator","test","pluginTabs","tabs","label","map","ActivePanel","find","tab","panel","prompt","readOnly","promptInput","fallbackAsk","dialogValue","onDialogValueChange","asking","dialog","name","failed","askingId","undefined","askingTitle","title","announceForAccessibility","emptyRegion","length","emptyStateRegion","composerShown","retainComposer","styles","screen","list","liveTranscript","markdown","offlineText","restoring","onRestore","promptDock","promptInset","promptError","contextItems","item","source","onRemoveContext","stoppedTitle","stoppedText","folder","stoppedError","waking","onWake","Boolean","draftStore","overlay","pluginId","component","Overlay","PluginToolMessage","message","Message","P","TemplateItem","render","LiveActivity","mapEntry","createNativeEntryMapper","working","state","streaming","flatMap","SessionTimeline","live","onMessageActions","raw","groupTools","createToolGrouper","data","registryVersion","renderTool","toolName","tool","payload","details","nested","NonNullable","call","Nested","content","block","type","join","nestedFailed","cache","WeakMap","mapped","get","nativeEntry","set","previous","Map","next","out","run","flush","first","push","old","same","calls","every","index","group","role","create","theme","rt","maxHeight","paddingBottom","insets","ime","bottom","uni__dependencies","paddingHorizontal","spacing","fontFamily","sans","fontSize","sm","lineHeight","color","colors","red","flexDirection","flexWrap","gap","flex","backgroundColor","bg","paddingVertical","margin","padding","borderRadius","lg","borderWidth","borderColor","base","fontWeight","semibold","hi","lineHeightRelaxed","dim","alignItems","paddingLeft","paddingRight","at","timestamp","kind","images","identity","profile","author","initials","tone","tools","argSummary","NativeTranscript","threadId","options","Pick","key","limit","visible","slice"],"sources":["../../src/screens/SessionScreen.tsx"],"sourcesContent":["import type { NativeTemplateSessionProps } from '@agimon-ai/po-core/native';\nimport type {\n ToolMessageRenderProps,\n ToolResultView,\n ThreadViewOptions,\n WebPluginSlotProps,\n} from '@agimon-ai/po-core/web';\nimport { Button, fontOf, List, type MarkdownProps, Tabs, TabsList, TabsTrigger } from '@agimon-ai/po-native-components';\nimport {\n ImageRefScope,\n subscribeWebPluginRegistry,\n personaInitials,\n sessionStoreFor,\n subscribeThread,\n unsubscribeThread,\n threadStoreKey,\n holdSessionChannels,\n HOST_SLOTS,\n pluginUserMessageActions,\n renderRegion,\n slotFills,\n type TimelineEntry as DashboardEntry,\n toolMessageProps,\n toolPromptClaim,\n type ToolPromptInput,\n ToolRendererBoundary,\n useImageRefs,\n webTabs,\n useRenderTrace,\n} from '@agimon-ai/po-web-dashboard/core';\nimport { useStore } from '@tanstack/react-store';\nimport {\n type ComponentType,\n memo,\n type ReactElement,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useReducer,\n useState,\n} from 'react';\nimport { AccessibilityInfo, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { ActivityPanel } from '../components/ActivityPanel';\nimport { Composer, type ComposerProps } from '../components/Composer';\nimport { DialogSheet } from '../components/DialogSheet';\nimport { MessageActionsSheet } from '../components/MessageActionsSheet';\nimport { nativeSlotProps } from '../components/slotProps';\nimport { type TimelineEntry, TimelineItem } from '../components/TimelineItem';\n\nconst CONVERSATION_TAB = 'conversation';\nconst EMPTY_ENTRIES: readonly TimelineEntry[] = [];\nconst EMPTY_STATUSES: Readonly<Record<string, string>> = {};\nconst MemoTimelineItem = memo(TimelineItem);\nconst entryKey = (entry: TimelineEntry) => entry.id;\n/** The most tool calls one transcript cell holds; a longer run splits into several groups. */\nconst TOOL_GROUP_LIMIT = 20;\n\n/** The tool entry fields a plugin renderer reads, carried as TimelineEntry.payload. */\nexport interface ToolPayload {\n toolCallId: string;\n args: Record<string, unknown>;\n result: ToolResultView | null;\n output: string;\n running: boolean;\n isError: boolean;\n}\n\n/**\n * The app's session contract plus the presentation hooks a template may add. Every addition is\n * optional, so a template screen typed with these props still accepts what the app hands it.\n */\nexport interface SessionScreenProps extends NativeTemplateSessionProps {\n entries?: readonly TimelineEntry[];\n /** Options and run controls for the composer row. */\n composer?: Omit<ComposerProps, 'onSend' | 'disabled' | 'value' | 'onChangeText'>;\n /** Lets a template regroup and redraw transcript rows; absent keeps the built-in tool groups and rows. */\n transcript?: SessionTranscript;\n}\n\nexport interface SessionTranscript {\n /** Called once per transcript, so the grouper can keep unchanged groups by identity between renders. */\n createGrouper: () => (entries: readonly TimelineEntry[]) => TimelineEntry[];\n /**\n * `entry` arrives with images the transcript sent by reference filled in once read.\n * `builtIn` draws one entry the default way, with plugin tool cards, for rows the template keeps.\n */\n renderItem: (\n entry: TimelineEntry,\n builtIn: (entry: TimelineEntry) => ReactElement,\n /** The session's slot props, for a row that opens plugin surfaces such as Author. */\n slotProps: WebPluginSlotProps,\n ) => ReactElement | null;\n /** True when a row already shows the turn at work, so the screen leaves out its own Working line. */\n showsWork?: (entries: readonly TimelineEntry[]) => boolean;\n}\n\n/** Re-renders when plugin installs change what the registry resolves. */\nfunction useRegistryVersion(): number {\n const [version, bump] = useReducer((value: number) => value + 1, 0);\n useEffect(() => subscribeWebPluginRegistry(bump), []);\n return version;\n}\n\nexport function SessionScreen(props: SessionScreenProps) {\n useRenderTrace('SessionScreen');\n const {\n sessionId,\n entries = EMPTY_ENTRIES,\n onSend,\n sessionToolRenderer,\n ask,\n onAnswer,\n onCancel,\n activity,\n error,\n composer,\n stopped,\n offline,\n } = props;\n const statuses = props.statuses ?? EMPTY_STATUSES;\n const [activeTab, setActiveTab] = useState(CONVERSATION_TAB);\n const [drafts, setDrafts] = useState<Record<string, string>>({});\n const [actionTarget, setActionTarget] = useState<TimelineEntry>();\n const messageActions = pluginUserMessageActions();\n const updateDraft =\n props.onDraftChange ?? ((text: string) => setDrafts((current) => ({ ...current, [sessionId]: text })));\n useRegistryVersion();\n const slotProps =\n props.slotProps ??\n nativeSlotProps(\n sessionId,\n statuses,\n (tabId) => setActiveTab(tabId ?? CONVERSATION_TAB),\n (text) => {\n const addition = text.trim();\n if (!addition) return;\n setDrafts((current) => {\n const draft = current[sessionId] ?? composer?.initialText ?? '';\n const separator = draft === '' || /\\s$/.test(draft) ? '' : ' ';\n return { ...current, [sessionId]: `${draft}${separator}${addition}` };\n });\n },\n );\n const pluginTabs = webTabs(sessionId);\n const tabs = [{ id: CONVERSATION_TAB, label: 'Conversation' }, ...pluginTabs.map(({ id, label }) => ({ id, label }))];\n const ActivePanel = pluginTabs.find((tab) => tab.id === activeTab)?.panel;\n const prompt =\n !props.readOnly && props.promptInput && onAnswer && onCancel\n ? // The app builds it from the dashboard's own session state, so the contract's wide shape narrows back.\n toolPromptClaim(props.promptInput as ToolPromptInput, null, sessionId)\n : null;\n const fallbackAsk =\n !props.readOnly && ask && onAnswer ? (\n <DialogSheet\n ask={ask}\n onAnswer={onAnswer}\n onCancel={onCancel}\n value={props.dialogValue}\n onChangeValue={props.onDialogValueChange}\n />\n ) : null;\n const asking =\n prompt && onAnswer && onCancel ? (\n <ToolRendererBoundary key={`${sessionId}:${prompt.dialog.id}`} toolName={prompt.entry?.name ?? 'dialog'}>\n {(failed) =>\n failed ? (\n fallbackAsk\n ) : prompt.entry ? (\n <prompt.prompt.component\n {...toolMessageProps(slotProps, prompt.entry, statuses)}\n dialog={prompt.dialog}\n answer={(value) => onAnswer(prompt.dialog.id, value)}\n cancel={() => onCancel(prompt.dialog.id)}\n />\n ) : (\n <prompt.prompt.component\n {...slotProps}\n dialog={prompt.dialog}\n answer={(value) => onAnswer(prompt.dialog.id, value)}\n cancel={() => onCancel(prompt.dialog.id)}\n />\n )\n }\n </ToolRendererBoundary>\n ) : (\n fallbackAsk\n );\n const askingId = asking === null ? undefined : (prompt?.dialog.id ?? ask?.id);\n const askingTitle = prompt?.dialog.title ?? ask?.title;\n // Screen readers hear a question once when it arrives, not on every re-render.\n useEffect(() => {\n if (askingId !== undefined)\n AccessibilityInfo.announceForAccessibility(`Po is asking: ${askingTitle ?? 'a question'}`);\n }, [askingId, askingTitle]);\n // An empty conversation a person's own package may fill on the phone; with no fill the list shows as before.\n const emptyRegion =\n entries.length === 0 ? renderRegion(HOST_SLOTS.emptyStateRegion, null, slotProps, sessionId) : null;\n const composerShown =\n !props.readOnly && !stopped && !prompt && (props.panel === undefined || props.retainComposer === true);\n return (\n <View style={styles.screen}>\n {!props.slotProps && tabs.length > 1 ? (\n <Tabs value={activeTab} onValueChange={setActiveTab}>\n <TabsList>\n {tabs.map((tab) => (\n <TabsTrigger key={tab.id} value={tab.id}>\n {tab.label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n ) : null}\n {props.panel !== undefined ? (\n <View style={styles.list}>{props.panel}</View>\n ) : ActivePanel ? (\n <View style={styles.list}>\n <ActivePanel {...slotProps} />\n </View>\n ) : emptyRegion ? (\n <View style={styles.list}>{emptyRegion}</View>\n ) : (\n <SessionTimeline\n sessionId={sessionId}\n entries={entries}\n live={props.liveTranscript}\n slotProps={slotProps}\n statuses={statuses}\n sessionToolRenderer={sessionToolRenderer}\n onMessageActions={messageActions.length ? setActionTarget : undefined}\n markdown={props.markdown}\n transcript={props.transcript}\n />\n )}\n {/* A document panel carries its own progress in the host header; only failures still show here. */}\n {props.panel !== undefined ? (\n <ActivityPanel error={error} />\n ) : props.liveTranscript ? (\n <LiveActivity sessionId={sessionId} error={error} showsWork={props.transcript?.showsWork} />\n ) : (\n <ActivityPanel status={props.transcript?.showsWork?.(entries) ? undefined : activity} error={error} />\n )}\n {offline && !props.readOnly && !stopped ? (\n <View style={styles.offline} accessibilityLiveRegion=\"polite\">\n <Text style={styles.offlineText}>Po on your computer is not connected. Your message is kept.</Text>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n loading={offline.restoring ?? false}\n loadingLabel=\"Restoring the connection\"\n onPress={offline.onRestore}\n >\n Restore\n </Button>\n </View>\n ) : null}\n {asking ? (\n // ponytail: a fixed share of the screen keeps the transcript visible; the prompt scrolls inside it.\n <View style={[styles.promptDock, !composerShown && styles.promptInset]}>\n {props.promptError ? (\n <Text style={styles.promptError} accessibilityRole=\"alert\">\n {props.promptError}\n </Text>\n ) : null}\n {asking}\n </View>\n ) : null}\n {props.contextItems?.length && (props.panel === undefined || props.retainComposer) ? (\n <View style={styles.contextItems}>\n {props.contextItems.map((item) => (\n <Button\n key={`${item.source}:${item.id}`}\n variant=\"ghost\"\n size=\"sm\"\n accessibilityLabel={`Remove ${item.label}`}\n onPress={() => props.onRemoveContext?.(item.source, item.id)}\n >\n {item.label} ×\n </Button>\n ))}\n </View>\n ) : null}\n {!props.readOnly && stopped ? (\n <View style={styles.stopped}>\n <Text style={styles.stoppedTitle}>Session stopped</Text>\n <Text style={styles.stoppedText}>\n Review the conversation above, then wake to continue.\n {stopped.folder ? ` History is on disk in ${stopped.folder}.` : ' Your history is saved.'}\n </Text>\n {stopped.error ? (\n <Text style={styles.stoppedError} accessibilityRole=\"alert\">\n {stopped.error}\n </Text>\n ) : null}\n <Button variant=\"primary\" size=\"md\" loading={stopped.waking} loadingLabel=\"Waking\" onPress={stopped.onWake}>\n Wake session\n </Button>\n </View>\n ) : composerShown ? (\n <Composer\n {...composer}\n onSend={onSend}\n disabled={Boolean(ask)}\n value={props.draftStore ? undefined : (props.draft ?? drafts[sessionId] ?? composer?.initialText ?? '')}\n onChangeText={props.draftStore ? undefined : updateDraft}\n draftStore={props.draftStore}\n sessionId={sessionId}\n slotProps={slotProps}\n />\n ) : null}\n <MessageActionsSheet\n sessionId={sessionId}\n message={actionTarget}\n actions={messageActions}\n onClose={() => setActionTarget(undefined)}\n />\n {!props.readOnly &&\n slotFills(HOST_SLOTS.overlay, sessionId).map(({ pluginId, id, component: Overlay }) =>\n Overlay ? <Overlay key={`${pluginId}:${id}`} {...slotProps} /> : null,\n )}\n </View>\n );\n}\n\n/** A plugin renderer reads result images inline, so one the transcript sent by reference is filled in once read. */\nfunction PluginToolMessage<P extends { result: ToolResultView | null }>({\n message: Message,\n props,\n}: {\n message: ComponentType<P>;\n props: P;\n}) {\n const result = useImageRefs(props.result);\n return <Message {...props} result={result} />;\n}\n/** A template row reads images inline too, so it gets the entry with referenced images filled in. */\nfunction TemplateItem({\n entry,\n render,\n}: {\n entry: TimelineEntry;\n render: (entry: TimelineEntry) => ReactElement | null;\n}) {\n return render(useImageRefs(entry));\n}\nfunction LiveActivity({\n sessionId,\n error,\n showsWork,\n}: {\n sessionId: string;\n error?: string;\n showsWork?: SessionTranscript['showsWork'];\n}) {\n const mapEntry = useMemo(createNativeEntryMapper, []);\n // Entries are mapped only for a template that asks; the default screen reads the flag alone.\n const working = useStore(\n sessionStoreFor(sessionId),\n (state) => state.streaming && !showsWork?.(state.entries.flatMap(mapEntry)),\n );\n return <ActivityPanel status={working ? 'Working...' : undefined} error={error} />;\n}\n\nconst SessionTimeline = memo(function SessionTimeline({\n sessionId,\n entries,\n live,\n slotProps,\n statuses,\n sessionToolRenderer,\n onMessageActions,\n markdown,\n transcript,\n}: {\n sessionId: string;\n entries: readonly TimelineEntry[];\n live?: boolean;\n slotProps: WebPluginSlotProps;\n statuses: Readonly<Record<string, string>>;\n sessionToolRenderer?: SessionScreenProps['sessionToolRenderer'];\n onMessageActions?: (entry: TimelineEntry) => void;\n markdown?: SessionScreenProps['markdown'];\n transcript?: SessionTranscript;\n}) {\n const raw = useStore(sessionStoreFor(sessionId), (state) => (live ? state.entries : undefined));\n const mapEntry = useMemo(createNativeEntryMapper, []);\n const groupTools = useMemo(() => (transcript?.createGrouper ?? createToolGrouper)(), [transcript]);\n const data = useMemo(\n () => groupTools(raw === undefined ? entries : raw.flatMap(mapEntry)),\n [raw, entries, mapEntry, groupTools],\n );\n const registryVersion = useRegistryVersion();\n const renderTool = useCallback(\n (entry: TimelineEntry): ReactNode | null => {\n const toolName = entry.toolName;\n const tool = entry.payload as ToolPayload | undefined;\n if (!toolName || !tool) return null;\n const Message = sessionToolRenderer?.(sessionId, toolName, statuses, tool.result?.details)?.message;\n if (!Message) return null;\n // Another tool's own card for a call made on this one's behalf, as the web's nestedToolCard. Null when no\n // plugin claims the tool; the nested card gets no renderTool, so nesting stops at one level.\n const nested: NonNullable<ToolMessageRenderProps['renderTool']> = (call) => {\n const Nested = sessionToolRenderer?.(sessionId, call.toolName, statuses, call.result?.details)?.message;\n if (!Nested) return null;\n const output = (call.result?.content ?? [])\n .flatMap((item) => {\n const block = item as { type?: unknown; text?: unknown };\n return block.type === 'text' && typeof block.text === 'string' ? [block.text] : [];\n })\n .join('\\n');\n return (\n <ToolRendererBoundary toolName={call.toolName}>\n {(nestedFailed) =>\n nestedFailed ? (\n <Text selectable>{output}</Text>\n ) : (\n <PluginToolMessage\n message={Nested}\n props={{\n ...slotProps,\n toolCallId: `${tool.toolCallId}:${call.toolName}`,\n toolName: call.toolName,\n args: call.args,\n result: call.result,\n output,\n running: false,\n isError: call.isError,\n }}\n />\n )\n }\n </ToolRendererBoundary>\n );\n };\n return (\n <ToolRendererBoundary key={entry.id} toolName={toolName}>\n {(failed) =>\n failed ? (\n <TimelineItem entry={entry} />\n ) : (\n <PluginToolMessage message={Message} props={{ ...slotProps, toolName, ...tool, renderTool: nested }} />\n )\n }\n </ToolRendererBoundary>\n );\n },\n [sessionId, statuses, slotProps, sessionToolRenderer, registryVersion],\n );\n const renderItem = useCallback(\n (entry: TimelineEntry) => {\n const builtIn = (item: TimelineEntry) => (\n <MemoTimelineItem\n entry={item}\n renderTool={renderTool}\n onMessageActions={onMessageActions}\n markdown={markdown}\n />\n );\n return transcript ? (\n <TemplateItem entry={entry} render={(item) => transcript.renderItem(item, builtIn, slotProps)} />\n ) : (\n builtIn(entry)\n );\n },\n [renderTool, onMessageActions, markdown, transcript, slotProps],\n );\n return (\n <ImageRefScope value={sessionId}>\n <List\n style={styles.list}\n startAtBottom\n separators={false}\n data={data}\n keyExtractor={entryKey}\n renderItem={renderItem}\n accessibilityLabel=\"Transcript\"\n />\n </ImageRefScope>\n );\n});\n\n/** Each transcript owns its cache; removed dashboard entries are only weakly referenced. */\nexport function createNativeEntryMapper(): (entry: DashboardEntry) => TimelineEntry[] {\n const cache = new WeakMap<DashboardEntry, TimelineEntry[]>();\n return (entry) => {\n let mapped = cache.get(entry);\n if (mapped === undefined) {\n mapped = nativeEntry(entry);\n cache.set(entry, mapped);\n }\n return mapped;\n };\n}\n\n/**\n * Folds each run of two or more consecutive tool calls into `tools` entries of\n * at most TOOL_GROUP_LIMIT calls, so one list cell never mounts a whole long\n * run. Chunks count from the run's start, so keys stay put as the run grows.\n * A group whose calls are unchanged keeps its object, so the memoised row and\n * the calls in it do not re-render while another entry streams.\n */\nexport function createToolGrouper(): (entries: readonly TimelineEntry[]) => TimelineEntry[] {\n let previous = new Map<string, TimelineEntry>();\n return (entries) => {\n const next = new Map<string, TimelineEntry>();\n const out: TimelineEntry[] = [];\n let run: TimelineEntry[] = [];\n const flush = () => {\n const first = run[0];\n if (first === undefined || run.length < 2) {\n out.push(...run);\n } else {\n const id = `tools:${first.id}`;\n const old = previous.get(id);\n const same = old?.calls?.length === run.length && run.every((call, index) => old.calls?.[index] === call);\n const group: TimelineEntry = same && old !== undefined ? old : { id, role: 'tools', text: '', calls: run };\n next.set(id, group);\n out.push(group);\n }\n run = [];\n };\n for (const entry of entries) {\n if (entry.role === 'tool') {\n run.push(entry);\n if (run.length === TOOL_GROUP_LIMIT) flush();\n } else {\n flush();\n out.push(entry);\n }\n }\n flush();\n previous = next;\n return out;\n };\n}\n\nconst styles = StyleSheet.create((theme, rt) => ({\n promptDock: { maxHeight: '70%' },\n // Clears the home indicator when no composer sits below; the keyboard covers that edge while it is open.\n promptInset: { paddingBottom: rt.insets.ime > 0 ? 0 : rt.insets.bottom },\n promptError: {\n paddingHorizontal: theme.spacing(4),\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.red,\n },\n contextItems: { flexDirection: 'row', flexWrap: 'wrap', paddingHorizontal: theme.spacing(3), gap: theme.spacing(2) },\n screen: {\n flex: 1,\n backgroundColor: theme.colors.bg,\n },\n list: {\n flex: 1,\n paddingVertical: theme.spacing(2),\n },\n stopped: {\n gap: theme.spacing(2),\n margin: theme.spacing(3),\n padding: theme.spacing(4),\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors['border-soft'],\n },\n stoppedTitle: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors.hi,\n },\n stoppedText: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.dim,\n },\n stoppedError: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n color: theme.colors.red,\n },\n offline: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2),\n paddingLeft: theme.spacing(4),\n paddingRight: theme.spacing(2),\n },\n offlineText: {\n flex: 1,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n },\n}));\n\n/** Maps dashboard transcript entries onto the native timeline; tool payload feeds plugin renderers. */\nexport function nativeEntry(entry: DashboardEntry): TimelineEntry[] {\n const at = entry.timestamp === undefined ? {} : { timestamp: entry.timestamp };\n switch (entry.kind) {\n case 'user':\n case 'queued':\n return [\n {\n id: entry.id,\n role: 'user',\n text: entry.text,\n ...(entry.images?.length ? { images: entry.images } : {}),\n ...at,\n },\n ];\n case 'assistant': {\n if (!entry.text) return [];\n const name = entry.identity?.name ?? entry.identity?.profile;\n const author = name === undefined ? {} : { author: { name, initials: personaInitials(name) } };\n return [{ id: entry.id, role: 'assistant', text: entry.text, ...author, ...at }];\n }\n case 'intercom':\n return [\n {\n id: entry.id,\n role: 'assistant',\n text: entry.text,\n author: { name: entry.name, initials: personaInitials(entry.name) },\n ...at,\n },\n ];\n case 'notice':\n return [{ id: entry.id, role: 'notice', text: entry.text, tone: entry.tone, ...at }];\n case 'settled':\n return [{ id: entry.id, role: 'settled', text: '', tools: entry.tools, ...at }];\n case 'tool':\n return [\n {\n id: entry.id,\n role: 'tool',\n toolName: entry.name,\n text: entry.output || entry.argSummary,\n ...at,\n payload: {\n toolCallId: entry.toolCallId,\n args: entry.args,\n argSummary: entry.argSummary,\n result: entry.result,\n output: entry.output,\n running: entry.running,\n isError: entry.isError,\n },\n },\n ];\n default:\n return [];\n }\n}\n\n/** Host-owned native transcript adapters, using the same session/thread folds as the conversation. */\nexport function NativeTranscript({\n sessionId,\n threadId,\n options,\n markdown,\n}: {\n sessionId: string;\n threadId?: string;\n options?: ThreadViewOptions;\n markdown?: Pick<MarkdownProps, 'loadImage' | 'onFileLink'>;\n}) {\n useRenderTrace('NativeTranscript');\n useEffect(() => {\n if (threadId !== undefined) {\n subscribeThread(sessionId, threadId);\n return () => unsubscribeThread(sessionId, threadId);\n }\n // A transcript shown outside focus keeps its session's extension channels.\n return holdSessionChannels(sessionId);\n }, [sessionId, threadId]);\n const key = threadId === undefined ? sessionId : threadStoreKey(sessionId, threadId);\n const raw = useStore(sessionStoreFor(key), (state) => state.entries);\n const mapEntry = useMemo(createNativeEntryMapper, []);\n const entries = useMemo(() => raw.flatMap(mapEntry), [raw, mapEntry]);\n const limit = options?.limit;\n const visible = useMemo(\n () => (limit === undefined ? entries : limit <= 0 ? [] : entries.slice(-limit)),\n [entries, limit],\n );\n const renderItem = useCallback(\n (entry: TimelineEntry) => <MemoTimelineItem entry={entry} markdown={markdown} />,\n [markdown],\n );\n return (\n <ImageRefScope value={key}>\n <List\n data={visible}\n keyExtractor={entryKey}\n renderItem={renderItem}\n separators={false}\n accessibilityLabel=\"Transcript\"\n />\n </ImageRefScope>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoDA,MAAMoD,mBAAmB;AACzB,MAAMC,gBAA0C,CAAA;AAChD,MAAMC,iBAAmD,CAAC;AAC1D,MAAMG,mBAAmBtB,KAAKgB,YAAY;AAC1C,MAAMO,YAAYC,UAAyBA,MAAMC;;AAEjD,MAAMC,mBAAmB;;AA0CzB,SAASmB,qBAA6B;CACpC,MAAM,CAACC,SAASC,QAAQzC,YAAY0C,UAAkBA,QAAQ,GAAG,CAAC;CAClE5C,gBAAgB1B,2BAA2BqE,IAAI,GAAG,CAAA,CAAE;CACpD,OAAOD;AACT;AAEA,SAAgBG,cAAcC,OAA2B;CACvDrD,eAAe,eAAe;CAC9B,MAAM,EACJsD,WACAhB,UAAUjB,eACVkC,QACAC,qBACAC,KAC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iBwF;CAAS,IAC7E,CAACA,QAAQ,CACX;CACA,OACE,oBAAC,eAAD;EAAe,OAAOuI;YACpB,oBAAC,MAAD;GACE,MAAME;GACN,cAAclO;GACFkB;GACZ,YAAY;GACZ,oBAAmB;EAAY;CAEpB;AAEnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionsScreen.d.mts","names":[],"sources":["../../src/screens/SessionsScreen.tsx"],"mappings":";;;;wBAqEgB,QAAQ,eAAe,cAAc;;wBAidrC,gBACd,qBAAqB,4BACrB,eAAe,iDACf;;EASO;EACM,WAAA;EACF,SAAA;EACH,eAAS;;;wBAuCH,gBAAgB,UAAU,kBAAkB;;;;;;;;wBAU5C,oBACd,mBACA,iBACA,qBACA,qBACA,mBACA,iBACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;oBACD,IAAA;;;;;wBA+Be,iBACd,YACA,aACA,eACA,SACA,iBACA,kBACA,qBACA,wBACA,aACA,gBACA,SACA,gBACA,SACC;EAAgC;oBAAiB,IAAA;;wBAwgBpC,mBACd,MACA,MACA,SACA;EAEA;EACA,MAAM;EACN;EACA,WAAW,MAAM;oBAClB,IAAA"}
1
+ {"version":3,"file":"SessionsScreen.d.mts","names":[],"sources":["../../src/screens/SessionsScreen.tsx"],"mappings":";;;;wBAoEgB,QAAQ,eAAe,cAAc;;wBAidrC,gBACd,qBAAqB,4BACrB,eAAe,iDACf;;EASO;EACM,WAAA;EACF,SAAA;EACH,eAAS;;;wBAuCH,gBAAgB,UAAU,kBAAkB;;;;;;;;wBAU5C,oBACd,mBACA,iBACA,qBACA,qBACA,mBACA,iBACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;oBACD,IAAA;;;;;wBA+Be,iBACd,YACA,aACA,eACA,SACA,iBACA,kBACA,qBACA,wBACA,aACA,gBACA,SACA,gBACA,SACC;EAAgC;oBAAiB,IAAA;;wBA8gBpC,mBACd,MACA,MACA,SACA;EAEA;EACA,MAAM;EACN;EACA,WAAW,MAAM;oBAClB,IAAA"}
@@ -2,7 +2,7 @@ import { AddWorkspaceSheet, SessionGroupsSheet, SessionMenuSheet, SetupMenuSheet
2
2
  import { sessionTimeline as sessionTimeline$1 } from "../components/sessionTimeline.mjs";
3
3
  import { View } from "react-native-unistyles/components/native/View";
4
4
  import { Text } from "react-native-unistyles/components/native/Text";
5
- import { ActivityIcon, AlertIcon, Badge, BranchIcon, Button, CheckIcon, ChevronDownIcon, ChevronRightIcon, CountBadge, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, EmptyState, FolderIcon, ForkIcon, HostTag, InfoStrip, KebabIcon, ListRow, LiveDuration, MessageIcon, MonitorIcon, PlusIcon, SectionLabel, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, SlidersIcon, Spinner, UsersIcon, fontOf } from "@agimon-ai/po-native-components";
5
+ import { ActivityIcon, AlertIcon, Badge, BranchIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, ComputerRow, CountBadge, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, EmptyState, FolderIcon, ForkIcon, HostTag, InfoStrip, KebabIcon, ListRow, LiveDuration, MessageIcon, MonitorIcon, PlusIcon, SectionLabel, Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, SlidersIcon, Spinner, UsersIcon, fontOf } from "@agimon-ai/po-native-components";
6
6
  import { StyleSheet } from "react-native-unistyles";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { Pressable } from "react-native-unistyles/components/native/Pressable";
@@ -11,7 +11,6 @@ import { SectionList } from "react-native-unistyles/components/native/SectionLis
11
11
 
12
12
  //#region src/screens/SessionsScreen.tsx
13
13
  const NO_HOSTS = [];
14
- const UNAVAILABLE_LABEL = " · Unavailable";
15
14
  const MINUTE_MS = 6e4;
16
15
  const VIEWS = [{
17
16
  value: "workspaces",
@@ -619,9 +618,11 @@ function SessionsScreen({ workspaces, openSession, openWorkspace, actions, setHe
619
618
  setAdding(true);
620
619
  }, [hosts]);
621
620
  const generalAction = useRef(actions.createGeneralSession);
621
+ const coordinatorAction = useRef(actions.addCoordinator);
622
622
  useEffect(() => {
623
623
  generalAction.current = actions.createGeneralSession;
624
- }, [actions.createGeneralSession]);
624
+ coordinatorAction.current = actions.addCoordinator;
625
+ }, [actions.createGeneralSession, actions.addCoordinator]);
625
626
  const canGeneral = hosts.length > 0 ? hosts.some((host) => host.createGeneralSession !== void 0) : actions.createGeneralSession !== void 0;
626
627
  const beginGeneral = useCallback(() => {
627
628
  const host = hosts.find((host) => host.id === selected) ?? (hosts.length === 1 ? hosts[0] : void 0);
@@ -640,14 +641,14 @@ function SessionsScreen({ workspaces, openSession, openWorkspace, actions, setHe
640
641
  setCoordinatorBusy(true);
641
642
  setCoordinatorError("");
642
643
  try {
643
- const result = host ? await host.createCoordinator?.() : await actions.addCoordinator?.();
644
+ const result = host ? await host.createCoordinator?.() : await coordinatorAction.current?.();
644
645
  if (result) setCoordinatorError(result.error);
645
646
  } catch (cause) {
646
647
  setCoordinatorError(cause instanceof Error ? cause.message : "Could not create coordinator");
647
648
  } finally {
648
649
  setCoordinatorBusy(false);
649
650
  }
650
- }, [coordinatorBusy, actions]);
651
+ }, [coordinatorBusy]);
651
652
  const beginCoordinator = useCallback(() => {
652
653
  const host = hosts.find((entry) => entry.id === selected) ?? (hosts.length === 1 ? hosts[0] : void 0);
653
654
  if (host || hosts.length === 0) createCoordinator(host);
@@ -911,46 +912,42 @@ function SessionsScreen({ workspaces, openSession, openWorkspace, actions, setHe
911
912
  onOpenChange: (open) => {
912
913
  if (!open) setChoosing(null);
913
914
  },
914
- children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: "Which computer?" }) }), /* @__PURE__ */ jsx(SheetBody, { children: choosing === "coordinator" ? coordinatorHosts.map((host) => /* @__PURE__ */ jsxs(Button, {
915
- variant: "ghost",
915
+ children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsx(SheetHeader, { children: /* @__PURE__ */ jsx(SheetTitle, { children: choosing === "add" ? "Add a workspace on" : choosing === "coordinator" ? "Add a coordinator on" : choosing !== "general" && chooseAction === "open" ? "Open on" : choosing !== "general" && chooseAction === "menu" ? "Which computer?" : "Start a session on" }) }), /* @__PURE__ */ jsx(SheetBody, { children: choosing === "coordinator" ? coordinatorHosts.map((host) => /* @__PURE__ */ jsx(ComputerRow, {
916
+ name: host.label,
917
+ status: host.status,
916
918
  disabled: coordinatorBusy || host.status !== "connected",
917
919
  onPress: () => {
918
920
  setChoosing(null);
919
921
  createCoordinator(host);
920
- },
921
- children: [host.label, host.status !== "connected" ? UNAVAILABLE_LABEL : ""]
922
- }, host.id)) : choosing === "general" ? hosts.map((host) => /* @__PURE__ */ jsxs(Button, {
923
- variant: "ghost",
922
+ }
923
+ }, host.id)) : choosing === "general" ? hosts.map((host) => /* @__PURE__ */ jsx(ComputerRow, {
924
+ name: host.label,
925
+ status: host.status,
924
926
  disabled: host.status !== "connected" || !host.createGeneralSession,
925
927
  onPress: () => {
926
928
  setChoosing(null);
927
929
  host.createGeneralSession?.();
928
- },
929
- children: [host.label, host.status !== "connected" ? UNAVAILABLE_LABEL : ""]
930
- }, host.id)) : choosing === "add" ? hosts.map((host) => /* @__PURE__ */ jsxs(Button, {
931
- variant: "ghost",
930
+ }
931
+ }, host.id)) : choosing === "add" ? hosts.map((host) => /* @__PURE__ */ jsx(ComputerRow, {
932
+ name: host.label,
933
+ status: host.status,
932
934
  disabled: host.status !== "connected" || !host.addWorkspaceActions,
933
935
  onPress: () => {
934
936
  setAddHost(host.id);
935
937
  setChoosing(null);
936
938
  setAdding(true);
937
- },
938
- children: [host.label, host.status !== "connected" ? UNAVAILABLE_LABEL : ""]
939
- }, host.id)) : choosing?.map((workspace) => /* @__PURE__ */ jsxs(Button, {
940
- variant: "ghost",
939
+ }
940
+ }, host.id)) : choosing?.map((workspace) => /* @__PURE__ */ jsx(ComputerRow, {
941
+ name: hostOf(workspace.id)?.label ?? workspace.name,
942
+ path: workspace.root,
943
+ status: hostOf(workspace.id)?.status ?? "connected",
941
944
  disabled: chooseAction !== "open" && (stale(workspace.id) || !workspace.available),
942
945
  onPress: () => {
943
946
  setChoosing(null);
944
947
  if (chooseAction === "open") openWorkspace?.(workspace.id);
945
948
  else if (chooseAction === "menu") setWorkspaceMenu(workspace.id);
946
949
  else actions.createSession(workspace.id);
947
- },
948
- children: [
949
- hostOf(workspace.id)?.label ?? workspace.name,
950
- " · ",
951
- workspace.root,
952
- stale(workspace.id) ? UNAVAILABLE_LABEL : ""
953
- ]
950
+ }
954
951
  }, workspace.id)) })] })
955
952
  }),
956
953
  /* @__PURE__ */ jsx(SessionViewSheet, {