'
for t in turns:
arc = t.get("arc", "setup")
icon = ARC_ICONS.get(arc, "◎")
label = ARC_LABELS.get(arc, arc)
secs = t.get("think_secs", "")
steps = t.get("think_steps", [])
def _think_block(thinking, output_html):
out = ""
if thinking:
escaped = _html.escape(thinking).replace("\n", "
")
out += f'
{escaped}
'
out += f'
{output_html}
'
return out
steps_html = ""
for s in steps:
if s["t"] == "arc":
inner = _think_block(
s.get("thinking", ""),
f'
output {_html.escape(s["arc"])} · {_html.escape(s["label"])}',
)
steps_html += f'
'
elif s["t"] == "extract":
pairs = "".join(
f'
'
f'{_html.escape(p.split(": ",1)[0])}'
f'{_html.escape(p.split(": ",1)[1] if ": " in p else p)}'
f'
'
for p in s["items"]
)
inner = _think_block(s.get("thinking", ""), f'
output{pairs}')
steps_html += f'
'
elif s["t"] == "question":
inner = _think_block(
s.get("thinking", ""),
f'
output{_html.escape(s["text"])}',
)
steps_html += f'
follow-up composer
{inner}
'
elif s["t"] == "chapter":
inner = _think_block(
s.get("thinking", ""),
f'
output chapter {s["num"]} drafted to notebook',
)
steps_html += f'
'
thought_html = f'''
Thought for {secs}s ›
{steps_html}
''' if secs else ""
html += f'''
{t["user"]}
{icon}{label}
{thought_html}
{t["question"]}
'''
html += '
'
html += ''
return html
def build_notes_html(notes):
if not notes:
return ''
html = '