(block: PersistedContentBlock)
| 64 | } |
| 65 | |
| 66 | function toDisplayBlockBody(block: PersistedContentBlock): ContentBlock | undefined { |
| 67 | switch (block.type) { |
| 68 | case MothershipStreamV1EventType.text: |
| 69 | if (block.lane === 'subagent') { |
| 70 | if (block.channel === 'thinking') { |
| 71 | return { type: ContentBlockType.subagent_thinking, content: block.content } |
| 72 | } |
| 73 | return { type: ContentBlockType.subagent_text, content: block.content } |
| 74 | } |
| 75 | if (block.channel === 'thinking') { |
| 76 | return { type: ContentBlockType.thinking, content: block.content } |
| 77 | } |
| 78 | return { type: ContentBlockType.text, content: block.content } |
| 79 | case MothershipStreamV1EventType.tool: |
| 80 | if (!toToolCallInfo(block)) return undefined |
| 81 | return { type: ContentBlockType.tool_call, toolCall: toToolCallInfo(block) } |
| 82 | case MothershipStreamV1EventType.span: |
| 83 | if (block.lifecycle === MothershipStreamV1SpanLifecycleEvent.end) { |
| 84 | return { type: ContentBlockType.subagent_end } |
| 85 | } |
| 86 | return { type: ContentBlockType.subagent, content: block.content } |
| 87 | case MothershipStreamV1EventType.complete: |
| 88 | if (block.status === MothershipStreamV1CompletionStatus.cancelled) { |
| 89 | return { type: ContentBlockType.stopped } |
| 90 | } |
| 91 | return { type: ContentBlockType.text, content: block.content } |
| 92 | default: |
| 93 | return { type: ContentBlockType.text, content: block.content } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | function toDisplayAttachment(f: PersistedMessage['fileAttachments']): ChatMessageAttachment[] { |
| 98 | if (!f || f.length === 0) return [] |
no test coverage detected