Skip to content

ShareTranscriptBuilder

Category: Share

Source: share_transcript_builder.dart

Classes

ShareTranscriptBuilder

Methods

ShareTranscript build(List<Map<String, dynamic>> events)

Builds a share transcript from persisted conversation.jsonl rows.

Top-level user/assistant/tool events become flat entries. Subagent activity is grouped into nested [ShareEntryKind.subagentGroup] entries keyed by subagent_id, with each forwarded inner event rendered as a child [ShareEntryKind.subagentMessage] / [ShareEntryKind.toolCall] / [ShareEntryKind.toolResult] under the group.

Open groups are tracked in a [Map] keyed by subagent_id (not a stack) so parallel siblings render as siblings, every event is routed to the matching group, and completions in any order pop the right group.

Subagent events that arrive without a matching open group (rare — truncated or malformed sessions) are skipped rather than promoted to the top level, so the transcript shape never silently inflates.

ShareTranscript fromEntries(List<ShareEntry> entries)

Builds a share transcript from already-normalized entries.

Retained as a fixture seam for tests that want to construct exact transcript shapes without round-tripping through JSONL.

Released under the MIT License.