+ {#each chatItems as item (chatItemKey(item))}
+ {#if item.kind === 'group'}
+
+ {:else}
+ {@render messageRow(item.message, item.index, false)}
+ {/if}
+ {/each}
+ {#if waiting}
+
+
+
+ {/if}
+
diff --git a/frontend/src/lib/components/recording/agentRecording.ts b/frontend/src/lib/components/recording/agentRecording.ts
new file mode 100644
index 0000000000000..43ba87b3fea99
--- /dev/null
+++ b/frontend/src/lib/components/recording/agentRecording.ts
@@ -0,0 +1,28 @@
+import type { DisplayMessage } from '$lib/components/copilot/chat/shared'
+import type { AgentTurn } from './types'
+
+/**
+ * A recorded conversation as the AI chat draws one: each turn's message, the tools the agent
+ * called, then its answer. The recorder and the Hub page both draw from this, so what is
+ * recorded is what a visitor reads, tool arguments and results included.
+ */
+export function agentRecordingMessages(turns: AgentTurn[]): DisplayMessage[] {
+ const out: DisplayMessage[] = []
+ turns.forEach((turn, i) => {
+ out.push({ role: 'user', index: out.length, content: turn.user_message })
+ ;(turn.tool_calls ?? []).forEach((call, j) =>
+ out.push({
+ role: 'tool',
+ tool_call_id: `${i}-${j}`,
+ content: call.name,
+ toolName: call.name,
+ parameters: call.args,
+ result: call.result,
+ // As the agent chat does: the row opens on what the tool got and returned.
+ showDetails: call.args != null || call.result != null
+ })
+ )
+ out.push({ role: 'assistant', content: turn.answer })
+ })
+ return out
+}
diff --git a/frontend/src/lib/components/recording/types.ts b/frontend/src/lib/components/recording/types.ts
index dd85585768342..9c110d6623fd9 100644
--- a/frontend/src/lib/components/recording/types.ts
+++ b/frontend/src/lib/components/recording/types.ts
@@ -143,6 +143,33 @@ export type RawAppRecording = {
truncated?: boolean
}
+/** One tool an agent called during a turn, read off the turn's result. */
+export type AgentToolCall = {
+ name: string
+ args?: unknown
+ result?: unknown
+}
+
+/** One message to an agent, what it called, and its answer. The run behind a turn is not
+ * kept: it names who ran it and holds the agent as its workspace stores it. */
+export type AgentTurn = {
+ user_message: string
+ answer: string
+ duration_ms: number
+ tool_calls: AgentToolCall[]
+}
+
+/** A recorded conversation with a saved AI agent (`ai_agent` resource): the demo of an
+ * agent on its Hub page. */
+export type AgentRecording = {
+ version: 1
+ type: 'agent'
+ recorded_at: string
+ agent_path: string
+ total_duration_ms: number
+ turns: AgentTurn[]
+}
+
/** Shape needed by JobLoader replay — a map of job ID to its replay stream */
export interface ActiveReplayData {
jobs: Record