@agimon-ai/po-native-dashboard 0.0.0-alpha.2
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.
- package/LICENSE +149 -0
- package/README.md +5 -0
- package/dist/components/ActivityPanel.d.mts +10 -0
- package/dist/components/ActivityPanel.d.mts.map +1 -0
- package/dist/components/ActivityPanel.mjs +50 -0
- package/dist/components/ActivityPanel.mjs.map +1 -0
- package/dist/components/CaptureTray.d.mts +12 -0
- package/dist/components/CaptureTray.d.mts.map +1 -0
- package/dist/components/CaptureTray.mjs +112 -0
- package/dist/components/CaptureTray.mjs.map +1 -0
- package/dist/components/CompletionSheet.d.mts +44 -0
- package/dist/components/CompletionSheet.d.mts.map +1 -0
- package/dist/components/CompletionSheet.mjs +390 -0
- package/dist/components/CompletionSheet.mjs.map +1 -0
- package/dist/components/Composer.d.mts +47 -0
- package/dist/components/Composer.d.mts.map +1 -0
- package/dist/components/Composer.mjs +449 -0
- package/dist/components/Composer.mjs.map +1 -0
- package/dist/components/DialogSheet.d.mts +23 -0
- package/dist/components/DialogSheet.d.mts.map +1 -0
- package/dist/components/DialogSheet.mjs +115 -0
- package/dist/components/DialogSheet.mjs.map +1 -0
- package/dist/components/MessageActionsSheet.d.mts +16 -0
- package/dist/components/MessageActionsSheet.d.mts.map +1 -0
- package/dist/components/MessageActionsSheet.mjs +26 -0
- package/dist/components/MessageActionsSheet.mjs.map +1 -0
- package/dist/components/MoveSessionSheet.d.mts +17 -0
- package/dist/components/MoveSessionSheet.d.mts.map +1 -0
- package/dist/components/MoveSessionSheet.mjs +145 -0
- package/dist/components/MoveSessionSheet.mjs.map +1 -0
- package/dist/components/SessionMenus.d.mts +76 -0
- package/dist/components/SessionMenus.d.mts.map +1 -0
- package/dist/components/SessionMenus.mjs +1187 -0
- package/dist/components/SessionMenus.mjs.map +1 -0
- package/dist/components/TimelineItem.d.mts +39 -0
- package/dist/components/TimelineItem.d.mts.map +1 -0
- package/dist/components/TimelineItem.mjs +278 -0
- package/dist/components/TimelineItem.mjs.map +1 -0
- package/dist/components/sessionGroups.mjs +20 -0
- package/dist/components/sessionGroups.mjs.map +1 -0
- package/dist/components/sessionTimeline.mjs +20 -0
- package/dist/components/sessionTimeline.mjs.map +1 -0
- package/dist/components/slotProps.d.mts +23 -0
- package/dist/components/slotProps.d.mts.map +1 -0
- package/dist/components/slotProps.mjs +68 -0
- package/dist/components/slotProps.mjs.map +1 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +14 -0
- package/dist/screens/SessionScreen.d.mts +56 -0
- package/dist/screens/SessionScreen.d.mts.map +1 -0
- package/dist/screens/SessionScreen.mjs +551 -0
- package/dist/screens/SessionScreen.mjs.map +1 -0
- package/dist/screens/SessionsScreen.d.mts +47 -0
- package/dist/screens/SessionsScreen.d.mts.map +1 -0
- package/dist/screens/SessionsScreen.mjs +1436 -0
- package/dist/screens/SessionsScreen.mjs.map +1 -0
- package/dist/slotProps.d.mts +2 -0
- package/dist/slotProps.mjs +3 -0
- package/package.json +92 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { ActivityPanel } from "../components/ActivityPanel.mjs";
|
|
2
|
+
import { nativeSlotProps } from "../components/slotProps.mjs";
|
|
3
|
+
import { Composer } from "../components/Composer.mjs";
|
|
4
|
+
import { DialogSheet } from "../components/DialogSheet.mjs";
|
|
5
|
+
import { MessageActionsSheet } from "../components/MessageActionsSheet.mjs";
|
|
6
|
+
import { TimelineItem } from "../components/TimelineItem.mjs";
|
|
7
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
8
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
9
|
+
import { Button, List, Tabs, TabsList, TabsTrigger, fontOf } from "@agimon-ai/po-native-components";
|
|
10
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { HOST_SLOTS, ImageRefScope, ToolRendererBoundary, holdSessionChannels, personaInitials, pluginUserMessageActions, renderRegion, sessionStoreFor, slotFills, subscribeThread, subscribeWebPluginRegistry, threadStoreKey, toolMessageProps, toolPromptClaim, unsubscribeThread, useImageRefs, useRenderTrace, webTabs } from "@agimon-ai/po-web-dashboard/core";
|
|
13
|
+
import { memo, useCallback, useEffect, useMemo, useReducer, useState } from "react";
|
|
14
|
+
import { useStore } from "@tanstack/react-store";
|
|
15
|
+
import { AccessibilityInfo } from "react-native";
|
|
16
|
+
|
|
17
|
+
//#region src/screens/SessionScreen.tsx
|
|
18
|
+
const CONVERSATION_TAB = "conversation";
|
|
19
|
+
const EMPTY_ENTRIES = [];
|
|
20
|
+
const EMPTY_STATUSES = {};
|
|
21
|
+
const MemoTimelineItem = memo(TimelineItem);
|
|
22
|
+
const entryKey = (entry) => entry.id;
|
|
23
|
+
/** The most tool calls one transcript cell holds; a longer run splits into several groups. */
|
|
24
|
+
const TOOL_GROUP_LIMIT = 20;
|
|
25
|
+
/** Re-renders when plugin installs change what the registry resolves. */
|
|
26
|
+
function useRegistryVersion() {
|
|
27
|
+
const [version, bump] = useReducer((value) => value + 1, 0);
|
|
28
|
+
useEffect(() => subscribeWebPluginRegistry(bump), []);
|
|
29
|
+
return version;
|
|
30
|
+
}
|
|
31
|
+
function SessionScreen(props) {
|
|
32
|
+
useRenderTrace("SessionScreen");
|
|
33
|
+
const { sessionId, entries = EMPTY_ENTRIES, onSend, sessionToolRenderer, ask, onAnswer, onCancel, activity, error, composer, stopped, offline } = props;
|
|
34
|
+
const statuses = props.statuses ?? EMPTY_STATUSES;
|
|
35
|
+
const [activeTab, setActiveTab] = useState(CONVERSATION_TAB);
|
|
36
|
+
const [drafts, setDrafts] = useState({});
|
|
37
|
+
const [actionTarget, setActionTarget] = useState();
|
|
38
|
+
const messageActions = pluginUserMessageActions();
|
|
39
|
+
const updateDraft = props.onDraftChange ?? ((text) => setDrafts((current) => ({
|
|
40
|
+
...current,
|
|
41
|
+
[sessionId]: text
|
|
42
|
+
})));
|
|
43
|
+
useRegistryVersion();
|
|
44
|
+
const slotProps = props.slotProps ?? nativeSlotProps(sessionId, statuses, (tabId) => setActiveTab(tabId ?? CONVERSATION_TAB), (text) => {
|
|
45
|
+
const addition = text.trim();
|
|
46
|
+
if (!addition) return;
|
|
47
|
+
setDrafts((current) => {
|
|
48
|
+
const draft = current[sessionId] ?? composer?.initialText ?? "";
|
|
49
|
+
const separator = draft === "" || /\s$/.test(draft) ? "" : " ";
|
|
50
|
+
return {
|
|
51
|
+
...current,
|
|
52
|
+
[sessionId]: `${draft}${separator}${addition}`
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
const pluginTabs = webTabs(sessionId);
|
|
57
|
+
const tabs = [{
|
|
58
|
+
id: CONVERSATION_TAB,
|
|
59
|
+
label: "Conversation"
|
|
60
|
+
}, ...pluginTabs.map(({ id, label }) => ({
|
|
61
|
+
id,
|
|
62
|
+
label
|
|
63
|
+
}))];
|
|
64
|
+
const ActivePanel = pluginTabs.find((tab) => tab.id === activeTab)?.panel;
|
|
65
|
+
const prompt = !props.readOnly && props.promptInput && onAnswer && onCancel ? toolPromptClaim(props.promptInput, null, sessionId) : null;
|
|
66
|
+
const fallbackAsk = !props.readOnly && ask && onAnswer ? /* @__PURE__ */ jsx(DialogSheet, {
|
|
67
|
+
ask,
|
|
68
|
+
onAnswer,
|
|
69
|
+
onCancel,
|
|
70
|
+
value: props.dialogValue,
|
|
71
|
+
onChangeValue: props.onDialogValueChange
|
|
72
|
+
}) : null;
|
|
73
|
+
const asking = prompt && onAnswer && onCancel ? /* @__PURE__ */ jsx(ToolRendererBoundary, {
|
|
74
|
+
toolName: prompt.entry?.name ?? "dialog",
|
|
75
|
+
children: (failed) => failed ? fallbackAsk : prompt.entry ? /* @__PURE__ */ jsx(prompt.prompt.component, {
|
|
76
|
+
...toolMessageProps(slotProps, prompt.entry, statuses),
|
|
77
|
+
dialog: prompt.dialog,
|
|
78
|
+
answer: (value) => onAnswer(prompt.dialog.id, value),
|
|
79
|
+
cancel: () => onCancel(prompt.dialog.id)
|
|
80
|
+
}) : /* @__PURE__ */ jsx(prompt.prompt.component, {
|
|
81
|
+
...slotProps,
|
|
82
|
+
dialog: prompt.dialog,
|
|
83
|
+
answer: (value) => onAnswer(prompt.dialog.id, value),
|
|
84
|
+
cancel: () => onCancel(prompt.dialog.id)
|
|
85
|
+
})
|
|
86
|
+
}, `${sessionId}:${prompt.dialog.id}`) : fallbackAsk;
|
|
87
|
+
const askingId = asking === null ? void 0 : prompt?.dialog.id ?? ask?.id;
|
|
88
|
+
const askingTitle = prompt?.dialog.title ?? ask?.title;
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (askingId !== void 0) AccessibilityInfo.announceForAccessibility(`Po is asking: ${askingTitle ?? "a question"}`);
|
|
91
|
+
}, [askingId, askingTitle]);
|
|
92
|
+
const emptyRegion = entries.length === 0 ? renderRegion(HOST_SLOTS.emptyStateRegion, null, slotProps, sessionId) : null;
|
|
93
|
+
const composerShown = !props.readOnly && !stopped && !prompt && (props.panel === void 0 || props.retainComposer === true);
|
|
94
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
95
|
+
style: styles.screen,
|
|
96
|
+
children: [
|
|
97
|
+
!props.slotProps && tabs.length > 1 ? /* @__PURE__ */ jsx(Tabs, {
|
|
98
|
+
value: activeTab,
|
|
99
|
+
onValueChange: setActiveTab,
|
|
100
|
+
children: /* @__PURE__ */ jsx(TabsList, { children: tabs.map((tab) => /* @__PURE__ */ jsx(TabsTrigger, {
|
|
101
|
+
value: tab.id,
|
|
102
|
+
children: tab.label
|
|
103
|
+
}, tab.id)) })
|
|
104
|
+
}) : null,
|
|
105
|
+
props.panel !== void 0 ? /* @__PURE__ */ jsx(View, {
|
|
106
|
+
style: styles.list,
|
|
107
|
+
children: props.panel
|
|
108
|
+
}) : ActivePanel ? /* @__PURE__ */ jsx(View, {
|
|
109
|
+
style: styles.list,
|
|
110
|
+
children: /* @__PURE__ */ jsx(ActivePanel, { ...slotProps })
|
|
111
|
+
}) : emptyRegion ? /* @__PURE__ */ jsx(View, {
|
|
112
|
+
style: styles.list,
|
|
113
|
+
children: emptyRegion
|
|
114
|
+
}) : /* @__PURE__ */ jsx(SessionTimeline, {
|
|
115
|
+
sessionId,
|
|
116
|
+
entries,
|
|
117
|
+
live: props.liveTranscript,
|
|
118
|
+
slotProps,
|
|
119
|
+
statuses,
|
|
120
|
+
sessionToolRenderer,
|
|
121
|
+
onMessageActions: messageActions.length ? setActionTarget : void 0,
|
|
122
|
+
markdown: props.markdown,
|
|
123
|
+
transcript: props.transcript
|
|
124
|
+
}),
|
|
125
|
+
props.liveTranscript ? /* @__PURE__ */ jsx(LiveActivity, {
|
|
126
|
+
sessionId,
|
|
127
|
+
error
|
|
128
|
+
}) : /* @__PURE__ */ jsx(ActivityPanel, {
|
|
129
|
+
status: activity,
|
|
130
|
+
error
|
|
131
|
+
}),
|
|
132
|
+
offline && !props.readOnly && !stopped ? /* @__PURE__ */ jsxs(View, {
|
|
133
|
+
style: styles.offline,
|
|
134
|
+
accessibilityLiveRegion: "polite",
|
|
135
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
136
|
+
style: styles.offlineText,
|
|
137
|
+
children: "Po on your computer is not connected. Your message is kept."
|
|
138
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
139
|
+
variant: "ghost",
|
|
140
|
+
size: "sm",
|
|
141
|
+
loading: offline.restoring ?? false,
|
|
142
|
+
loadingLabel: "Restoring the connection",
|
|
143
|
+
onPress: offline.onRestore,
|
|
144
|
+
children: "Restore"
|
|
145
|
+
})]
|
|
146
|
+
}) : null,
|
|
147
|
+
asking ? /* @__PURE__ */ jsxs(View, {
|
|
148
|
+
style: [styles.promptDock, !composerShown && styles.promptInset],
|
|
149
|
+
children: [props.promptError ? /* @__PURE__ */ jsx(Text, {
|
|
150
|
+
style: styles.promptError,
|
|
151
|
+
accessibilityRole: "alert",
|
|
152
|
+
children: props.promptError
|
|
153
|
+
}) : null, asking]
|
|
154
|
+
}) : null,
|
|
155
|
+
props.contextItems?.length && (props.panel === void 0 || props.retainComposer) ? /* @__PURE__ */ jsx(View, {
|
|
156
|
+
style: styles.contextItems,
|
|
157
|
+
children: props.contextItems.map((item) => /* @__PURE__ */ jsxs(Button, {
|
|
158
|
+
variant: "ghost",
|
|
159
|
+
size: "sm",
|
|
160
|
+
accessibilityLabel: `Remove ${item.label}`,
|
|
161
|
+
onPress: () => props.onRemoveContext?.(item.source, item.id),
|
|
162
|
+
children: [item.label, " ×"]
|
|
163
|
+
}, `${item.source}:${item.id}`))
|
|
164
|
+
}) : null,
|
|
165
|
+
!props.readOnly && stopped ? /* @__PURE__ */ jsxs(View, {
|
|
166
|
+
style: styles.stopped,
|
|
167
|
+
children: [
|
|
168
|
+
/* @__PURE__ */ jsx(Text, {
|
|
169
|
+
style: styles.stoppedTitle,
|
|
170
|
+
children: "Session stopped"
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
173
|
+
style: styles.stoppedText,
|
|
174
|
+
children: ["Review the conversation above, then wake to continue.", stopped.folder ? ` History is on disk in ${stopped.folder}.` : " Your history is saved."]
|
|
175
|
+
}),
|
|
176
|
+
stopped.error ? /* @__PURE__ */ jsx(Text, {
|
|
177
|
+
style: styles.stoppedError,
|
|
178
|
+
accessibilityRole: "alert",
|
|
179
|
+
children: stopped.error
|
|
180
|
+
}) : null,
|
|
181
|
+
/* @__PURE__ */ jsx(Button, {
|
|
182
|
+
variant: "primary",
|
|
183
|
+
size: "md",
|
|
184
|
+
loading: stopped.waking,
|
|
185
|
+
loadingLabel: "Waking",
|
|
186
|
+
onPress: stopped.onWake,
|
|
187
|
+
children: "Wake session"
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
}) : composerShown ? /* @__PURE__ */ jsx(Composer, {
|
|
191
|
+
...composer,
|
|
192
|
+
onSend,
|
|
193
|
+
disabled: Boolean(ask),
|
|
194
|
+
value: props.draftStore ? void 0 : props.draft ?? drafts[sessionId] ?? composer?.initialText ?? "",
|
|
195
|
+
onChangeText: props.draftStore ? void 0 : updateDraft,
|
|
196
|
+
draftStore: props.draftStore,
|
|
197
|
+
sessionId,
|
|
198
|
+
slotProps
|
|
199
|
+
}) : null,
|
|
200
|
+
/* @__PURE__ */ jsx(MessageActionsSheet, {
|
|
201
|
+
sessionId,
|
|
202
|
+
message: actionTarget,
|
|
203
|
+
actions: messageActions,
|
|
204
|
+
onClose: () => setActionTarget(void 0)
|
|
205
|
+
}),
|
|
206
|
+
!props.readOnly && slotFills(HOST_SLOTS.overlay, sessionId).map(({ pluginId, id, component: Overlay }) => Overlay ? /* @__PURE__ */ jsx(Overlay, { ...slotProps }, `${pluginId}:${id}`) : null)
|
|
207
|
+
]
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/** A plugin renderer reads result images inline, so one the transcript sent by reference is filled in once read. */
|
|
211
|
+
function PluginToolMessage({ message: Message, props }) {
|
|
212
|
+
const result = useImageRefs(props.result);
|
|
213
|
+
return /* @__PURE__ */ jsx(Message, {
|
|
214
|
+
...props,
|
|
215
|
+
result
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function LiveActivity({ sessionId, error }) {
|
|
219
|
+
const streaming = useStore(sessionStoreFor(sessionId), (state) => state.streaming);
|
|
220
|
+
return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
221
|
+
status: streaming ? "Working..." : void 0,
|
|
222
|
+
error
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
const SessionTimeline = memo(function SessionTimeline({ sessionId, entries, live, slotProps, statuses, sessionToolRenderer, onMessageActions, markdown, transcript }) {
|
|
226
|
+
const raw = useStore(sessionStoreFor(sessionId), (state) => live ? state.entries : void 0);
|
|
227
|
+
const mapEntry = useMemo(createNativeEntryMapper, []);
|
|
228
|
+
const groupTools = useMemo(() => (transcript?.createGrouper ?? createToolGrouper)(), [transcript]);
|
|
229
|
+
const data = useMemo(() => groupTools(raw === void 0 ? entries : raw.flatMap(mapEntry)), [
|
|
230
|
+
raw,
|
|
231
|
+
entries,
|
|
232
|
+
mapEntry,
|
|
233
|
+
groupTools
|
|
234
|
+
]);
|
|
235
|
+
const registryVersion = useRegistryVersion();
|
|
236
|
+
const renderTool = useCallback((entry) => {
|
|
237
|
+
const toolName = entry.toolName;
|
|
238
|
+
const tool = entry.payload;
|
|
239
|
+
if (!toolName || !tool) return null;
|
|
240
|
+
const Message = sessionToolRenderer?.(sessionId, toolName, statuses, tool.result?.details)?.message;
|
|
241
|
+
if (!Message) return null;
|
|
242
|
+
const nested = (call) => {
|
|
243
|
+
const Nested = sessionToolRenderer?.(sessionId, call.toolName, statuses, call.result?.details)?.message;
|
|
244
|
+
if (!Nested) return null;
|
|
245
|
+
const output = (call.result?.content ?? []).flatMap((item) => {
|
|
246
|
+
const block = item;
|
|
247
|
+
return block.type === "text" && typeof block.text === "string" ? [block.text] : [];
|
|
248
|
+
}).join("\n");
|
|
249
|
+
return /* @__PURE__ */ jsx(ToolRendererBoundary, {
|
|
250
|
+
toolName: call.toolName,
|
|
251
|
+
children: (nestedFailed) => nestedFailed ? /* @__PURE__ */ jsx(Text, {
|
|
252
|
+
selectable: true,
|
|
253
|
+
children: output
|
|
254
|
+
}) : /* @__PURE__ */ jsx(PluginToolMessage, {
|
|
255
|
+
message: Nested,
|
|
256
|
+
props: {
|
|
257
|
+
...slotProps,
|
|
258
|
+
toolCallId: `${tool.toolCallId}:${call.toolName}`,
|
|
259
|
+
toolName: call.toolName,
|
|
260
|
+
args: call.args,
|
|
261
|
+
result: call.result,
|
|
262
|
+
output,
|
|
263
|
+
running: false,
|
|
264
|
+
isError: call.isError
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
return /* @__PURE__ */ jsx(ToolRendererBoundary, {
|
|
270
|
+
toolName,
|
|
271
|
+
children: (failed) => failed ? /* @__PURE__ */ jsx(TimelineItem, { entry }) : /* @__PURE__ */ jsx(PluginToolMessage, {
|
|
272
|
+
message: Message,
|
|
273
|
+
props: {
|
|
274
|
+
...slotProps,
|
|
275
|
+
toolName,
|
|
276
|
+
...tool,
|
|
277
|
+
renderTool: nested
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
}, entry.id);
|
|
281
|
+
}, [
|
|
282
|
+
sessionId,
|
|
283
|
+
statuses,
|
|
284
|
+
slotProps,
|
|
285
|
+
sessionToolRenderer,
|
|
286
|
+
registryVersion
|
|
287
|
+
]);
|
|
288
|
+
const renderItem = useCallback((entry) => {
|
|
289
|
+
const builtIn = (item) => /* @__PURE__ */ jsx(MemoTimelineItem, {
|
|
290
|
+
entry: item,
|
|
291
|
+
renderTool,
|
|
292
|
+
onMessageActions,
|
|
293
|
+
markdown
|
|
294
|
+
});
|
|
295
|
+
return transcript ? transcript.renderItem(entry, builtIn) : builtIn(entry);
|
|
296
|
+
}, [
|
|
297
|
+
renderTool,
|
|
298
|
+
onMessageActions,
|
|
299
|
+
markdown,
|
|
300
|
+
transcript
|
|
301
|
+
]);
|
|
302
|
+
return /* @__PURE__ */ jsx(ImageRefScope, {
|
|
303
|
+
value: sessionId,
|
|
304
|
+
children: /* @__PURE__ */ jsx(List, {
|
|
305
|
+
style: styles.list,
|
|
306
|
+
startAtBottom: true,
|
|
307
|
+
separators: false,
|
|
308
|
+
data,
|
|
309
|
+
keyExtractor: entryKey,
|
|
310
|
+
renderItem,
|
|
311
|
+
accessibilityLabel: "Transcript"
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
/** Each transcript owns its cache; removed dashboard entries are only weakly referenced. */
|
|
316
|
+
function createNativeEntryMapper() {
|
|
317
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
318
|
+
return (entry) => {
|
|
319
|
+
let mapped = cache.get(entry);
|
|
320
|
+
if (mapped === void 0) {
|
|
321
|
+
mapped = nativeEntry(entry);
|
|
322
|
+
cache.set(entry, mapped);
|
|
323
|
+
}
|
|
324
|
+
return mapped;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Folds each run of two or more consecutive tool calls into `tools` entries of
|
|
329
|
+
* at most TOOL_GROUP_LIMIT calls, so one list cell never mounts a whole long
|
|
330
|
+
* run. Chunks count from the run's start, so keys stay put as the run grows.
|
|
331
|
+
* A group whose calls are unchanged keeps its object, so the memoised row and
|
|
332
|
+
* the calls in it do not re-render while another entry streams.
|
|
333
|
+
*/
|
|
334
|
+
function createToolGrouper() {
|
|
335
|
+
let previous = /* @__PURE__ */ new Map();
|
|
336
|
+
return (entries) => {
|
|
337
|
+
const next = /* @__PURE__ */ new Map();
|
|
338
|
+
const out = [];
|
|
339
|
+
let run = [];
|
|
340
|
+
const flush = () => {
|
|
341
|
+
const first = run[0];
|
|
342
|
+
if (first === void 0 || run.length < 2) out.push(...run);
|
|
343
|
+
else {
|
|
344
|
+
const id = `tools:${first.id}`;
|
|
345
|
+
const old = previous.get(id);
|
|
346
|
+
const group = old?.calls?.length === run.length && run.every((call, index) => old.calls?.[index] === call) && old !== void 0 ? old : {
|
|
347
|
+
id,
|
|
348
|
+
role: "tools",
|
|
349
|
+
text: "",
|
|
350
|
+
calls: run
|
|
351
|
+
};
|
|
352
|
+
next.set(id, group);
|
|
353
|
+
out.push(group);
|
|
354
|
+
}
|
|
355
|
+
run = [];
|
|
356
|
+
};
|
|
357
|
+
for (const entry of entries) if (entry.role === "tool") {
|
|
358
|
+
run.push(entry);
|
|
359
|
+
if (run.length === TOOL_GROUP_LIMIT) flush();
|
|
360
|
+
} else {
|
|
361
|
+
flush();
|
|
362
|
+
out.push(entry);
|
|
363
|
+
}
|
|
364
|
+
flush();
|
|
365
|
+
previous = next;
|
|
366
|
+
return out;
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
const styles = StyleSheet.create((theme, rt) => ({
|
|
370
|
+
promptDock: { maxHeight: "70%" },
|
|
371
|
+
promptInset: {
|
|
372
|
+
paddingBottom: rt.insets.ime > 0 ? 0 : rt.insets.bottom,
|
|
373
|
+
uni__dependencies: [14, 9]
|
|
374
|
+
},
|
|
375
|
+
promptError: {
|
|
376
|
+
paddingHorizontal: theme.spacing(4),
|
|
377
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
378
|
+
fontSize: theme.fontSize.sm,
|
|
379
|
+
lineHeight: theme.lineHeight.sm,
|
|
380
|
+
color: theme.colors.red,
|
|
381
|
+
uni__dependencies: [0]
|
|
382
|
+
},
|
|
383
|
+
contextItems: {
|
|
384
|
+
flexDirection: "row",
|
|
385
|
+
flexWrap: "wrap",
|
|
386
|
+
paddingHorizontal: theme.spacing(3),
|
|
387
|
+
gap: theme.spacing(2),
|
|
388
|
+
uni__dependencies: [0]
|
|
389
|
+
},
|
|
390
|
+
screen: {
|
|
391
|
+
flex: 1,
|
|
392
|
+
backgroundColor: theme.colors.bg,
|
|
393
|
+
uni__dependencies: [0]
|
|
394
|
+
},
|
|
395
|
+
list: {
|
|
396
|
+
flex: 1,
|
|
397
|
+
paddingVertical: theme.spacing(2),
|
|
398
|
+
uni__dependencies: [0]
|
|
399
|
+
},
|
|
400
|
+
stopped: {
|
|
401
|
+
gap: theme.spacing(2),
|
|
402
|
+
margin: theme.spacing(3),
|
|
403
|
+
padding: theme.spacing(4),
|
|
404
|
+
borderRadius: theme.borderRadius.lg,
|
|
405
|
+
borderWidth: 1,
|
|
406
|
+
borderColor: theme.colors["border-soft"],
|
|
407
|
+
uni__dependencies: [0]
|
|
408
|
+
},
|
|
409
|
+
stoppedTitle: {
|
|
410
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
411
|
+
fontSize: theme.fontSize.base,
|
|
412
|
+
lineHeight: theme.lineHeight.base,
|
|
413
|
+
fontWeight: theme.fontWeight.semibold,
|
|
414
|
+
color: theme.colors.hi,
|
|
415
|
+
uni__dependencies: [0]
|
|
416
|
+
},
|
|
417
|
+
stoppedText: {
|
|
418
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
419
|
+
fontSize: theme.fontSize.sm,
|
|
420
|
+
lineHeight: theme.lineHeightRelaxed.sm,
|
|
421
|
+
color: theme.colors.dim,
|
|
422
|
+
uni__dependencies: [0]
|
|
423
|
+
},
|
|
424
|
+
stoppedError: {
|
|
425
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
426
|
+
fontSize: theme.fontSize.sm,
|
|
427
|
+
lineHeight: theme.lineHeightRelaxed.sm,
|
|
428
|
+
color: theme.colors.red,
|
|
429
|
+
uni__dependencies: [0]
|
|
430
|
+
},
|
|
431
|
+
offline: {
|
|
432
|
+
flexDirection: "row",
|
|
433
|
+
alignItems: "center",
|
|
434
|
+
gap: theme.spacing(2),
|
|
435
|
+
paddingLeft: theme.spacing(4),
|
|
436
|
+
paddingRight: theme.spacing(2),
|
|
437
|
+
uni__dependencies: [0]
|
|
438
|
+
},
|
|
439
|
+
offlineText: {
|
|
440
|
+
flex: 1,
|
|
441
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
442
|
+
fontSize: theme.fontSize.sm,
|
|
443
|
+
lineHeight: theme.lineHeight.sm,
|
|
444
|
+
color: theme.colors.dim,
|
|
445
|
+
uni__dependencies: [0]
|
|
446
|
+
}
|
|
447
|
+
}));
|
|
448
|
+
/** Maps dashboard transcript entries onto the native timeline; tool payload feeds plugin renderers. */
|
|
449
|
+
function nativeEntry(entry) {
|
|
450
|
+
const at = entry.timestamp === void 0 ? {} : { timestamp: entry.timestamp };
|
|
451
|
+
switch (entry.kind) {
|
|
452
|
+
case "user":
|
|
453
|
+
case "queued": return [{
|
|
454
|
+
id: entry.id,
|
|
455
|
+
role: "user",
|
|
456
|
+
text: entry.text,
|
|
457
|
+
...entry.images?.length ? { images: entry.images } : {},
|
|
458
|
+
...at
|
|
459
|
+
}];
|
|
460
|
+
case "assistant": {
|
|
461
|
+
if (!entry.text) return [];
|
|
462
|
+
const name = entry.identity?.name ?? entry.identity?.profile;
|
|
463
|
+
const author = name === void 0 ? {} : { author: {
|
|
464
|
+
name,
|
|
465
|
+
initials: personaInitials(name)
|
|
466
|
+
} };
|
|
467
|
+
return [{
|
|
468
|
+
id: entry.id,
|
|
469
|
+
role: "assistant",
|
|
470
|
+
text: entry.text,
|
|
471
|
+
...author,
|
|
472
|
+
...at
|
|
473
|
+
}];
|
|
474
|
+
}
|
|
475
|
+
case "intercom": return [{
|
|
476
|
+
id: entry.id,
|
|
477
|
+
role: "assistant",
|
|
478
|
+
text: entry.text,
|
|
479
|
+
author: {
|
|
480
|
+
name: entry.name,
|
|
481
|
+
initials: personaInitials(entry.name)
|
|
482
|
+
},
|
|
483
|
+
...at
|
|
484
|
+
}];
|
|
485
|
+
case "notice": return [{
|
|
486
|
+
id: entry.id,
|
|
487
|
+
role: "notice",
|
|
488
|
+
text: entry.text,
|
|
489
|
+
tone: entry.tone,
|
|
490
|
+
...at
|
|
491
|
+
}];
|
|
492
|
+
case "settled": return [{
|
|
493
|
+
id: entry.id,
|
|
494
|
+
role: "settled",
|
|
495
|
+
text: "",
|
|
496
|
+
tools: entry.tools,
|
|
497
|
+
...at
|
|
498
|
+
}];
|
|
499
|
+
case "tool": return [{
|
|
500
|
+
id: entry.id,
|
|
501
|
+
role: "tool",
|
|
502
|
+
toolName: entry.name,
|
|
503
|
+
text: entry.output || entry.argSummary,
|
|
504
|
+
...at,
|
|
505
|
+
payload: {
|
|
506
|
+
toolCallId: entry.toolCallId,
|
|
507
|
+
args: entry.args,
|
|
508
|
+
result: entry.result,
|
|
509
|
+
output: entry.output,
|
|
510
|
+
running: entry.running,
|
|
511
|
+
isError: entry.isError
|
|
512
|
+
}
|
|
513
|
+
}];
|
|
514
|
+
default: return [];
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
/** Host-owned native transcript adapters, using the same session/thread folds as the conversation. */
|
|
518
|
+
function NativeTranscript({ sessionId, threadId, options, markdown }) {
|
|
519
|
+
useRenderTrace("NativeTranscript");
|
|
520
|
+
useEffect(() => {
|
|
521
|
+
if (threadId !== void 0) {
|
|
522
|
+
subscribeThread(sessionId, threadId);
|
|
523
|
+
return () => unsubscribeThread(sessionId, threadId);
|
|
524
|
+
}
|
|
525
|
+
return holdSessionChannels(sessionId);
|
|
526
|
+
}, [sessionId, threadId]);
|
|
527
|
+
const key = threadId === void 0 ? sessionId : threadStoreKey(sessionId, threadId);
|
|
528
|
+
const raw = useStore(sessionStoreFor(key), (state) => state.entries);
|
|
529
|
+
const mapEntry = useMemo(createNativeEntryMapper, []);
|
|
530
|
+
const entries = useMemo(() => raw.flatMap(mapEntry), [raw, mapEntry]);
|
|
531
|
+
const limit = options?.limit;
|
|
532
|
+
const visible = useMemo(() => limit === void 0 ? entries : limit <= 0 ? [] : entries.slice(-limit), [entries, limit]);
|
|
533
|
+
const renderItem = useCallback((entry) => /* @__PURE__ */ jsx(MemoTimelineItem, {
|
|
534
|
+
entry,
|
|
535
|
+
markdown
|
|
536
|
+
}), [markdown]);
|
|
537
|
+
return /* @__PURE__ */ jsx(ImageRefScope, {
|
|
538
|
+
value: key,
|
|
539
|
+
children: /* @__PURE__ */ jsx(List, {
|
|
540
|
+
data: visible,
|
|
541
|
+
keyExtractor: entryKey,
|
|
542
|
+
renderItem,
|
|
543
|
+
separators: false,
|
|
544
|
+
accessibilityLabel: "Transcript"
|
|
545
|
+
})
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
//#endregion
|
|
550
|
+
export { NativeTranscript, SessionScreen, createNativeEntryMapper, createToolGrouper, nativeEntry };
|
|
551
|
+
//# sourceMappingURL=SessionScreen.mjs.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;;;;AAoDA,MAAMoD,mBAAmB;AACzB,MAAMC,gBAA0C,CAAA;AAChD,MAAMC,iBAAmD,CAAC;AAC1D,MAAMG,mBAAmBtB,KAAKgB,YAAY;AAC1C,MAAMO,YAAYC,UAAyBA,MAAMC;;AAEjD,MAAMC,mBAAmB;;AAgCzB,SAASiB,qBAA6B;CACpC,MAAM,CAACC,SAASC,QAAQvC,YAAYwC,UAAkBA,QAAQ,GAAG,CAAC;CAClE1C,gBAAgB1B,2BAA2BmE,IAAI,GAAG,CAAA,CAAE;CACpD,OAAOD;AACT;AAEA,SAAgB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