{#if !session || session.messages.length === 0}
{:else} {#if hasToolCalls}
{#if showTree && session} {/if} {/if}
{#each session.messages as msg (msg.id)}
{#if msg.type === 'init'}
Session started {(msg.content as import('../../adapters/sdk-messages').InitContent).model}
{:else if msg.type === 'text'}
{(msg.content as TextContent).text}
{:else if msg.type === 'thinking'}
Thinking...
{(msg.content as ThinkingContent).text}
{:else if msg.type === 'tool_call'} {@const tc = msg.content as ToolCallContent}
{tc.name} {truncate(tc.toolUseId, 12)}
{formatToolInput(tc.input)}
{:else if msg.type === 'tool_result'} {@const tr = msg.content as ToolResultContent}
Tool result
{formatToolInput(tr.output)}
{:else if msg.type === 'cost'} {@const cost = msg.content as CostContent}
${cost.totalCostUsd.toFixed(4)} {cost.inputTokens + cost.outputTokens} tokens {cost.numTurns} turns {(cost.durationMs / 1000).toFixed(1)}s
{:else if msg.type === 'error'}
{(msg.content as ErrorContent).message}
{:else if msg.type === 'status'}
{JSON.stringify(msg.content)}
{/if}
{/each}
{/if}