Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/claude_code_transcripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,17 @@ def render_markdown_text(text):
return markdown.markdown(text, extensions=["fenced_code", "tables"])


def render_user_text(text):
"""Render a user prompt as the plain text that was typed.

Prompts often contain pasted code or config, where # starts a comment
rather than a heading, so they are not rendered as Markdown.
"""
if not text:
return ""
return f'<p class="user-text">{html.escape(text)}</p>'


def is_json_like(text):
if not text or not isinstance(text, str):
return False
Expand Down Expand Up @@ -840,14 +851,20 @@ def render_content_block(block):
return format_json(block)


def render_user_content_block(block):
if isinstance(block, dict) and block.get("type") == "text":
return _macros.user_content(render_user_text(block.get("text", "")))
return render_content_block(block)


def render_user_message_content(message_data):
content = message_data.get("content", "")
if isinstance(content, str):
if is_json_like(content):
return _macros.user_content(format_json(content))
return _macros.user_content(render_markdown_text(content))
return _macros.user_content(render_user_text(content))
elif isinstance(content, list):
return "".join(render_content_block(block) for block in content)
return "".join(render_user_content_block(block) for block in content)
return f"<p>{html.escape(str(content))}</p>"


Expand Down Expand Up @@ -1046,6 +1063,7 @@ def render_message(log_type, message_json, timestamp):
code { background: rgba(0,0,0,0.08); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
pre code { background: none; padding: 0; }
.user-content { margin: 0; }
.user-text { margin: 0; white-space: pre-wrap; }
.truncatable { position: relative; }
.truncatable.truncated .truncatable-content { max-height: 200px; overflow: hidden; }
.truncatable.truncated::after { content: ''; position: absolute; bottom: 32px; left: 0; right: 0; height: 60px; background: linear-gradient(to bottom, transparent, var(--card-bg)); pointer-events: none; }
Expand Down Expand Up @@ -1413,7 +1431,7 @@ def generate_html(json_path, output_dir, github_repo=None):
page_num = (i // PROMPTS_PER_PAGE) + 1
msg_id = make_msg_id(conv["timestamp"])
link = f"page-{page_num:03d}.html#{msg_id}"
rendered_content = render_markdown_text(conv["user_text"])
rendered_content = render_user_text(conv["user_text"])

# Collect all messages including from subsequent continuation conversations
# This ensures long_texts from continuations appear with the original prompt
Expand Down Expand Up @@ -1887,7 +1905,7 @@ def generate_html_from_session_data(session_data, output_dir, github_repo=None):
page_num = (i // PROMPTS_PER_PAGE) + 1
msg_id = make_msg_id(conv["timestamp"])
link = f"page-{page_num:03d}.html#{msg_id}"
rendered_content = render_markdown_text(conv["user_text"])
rendered_content = render_user_text(conv["user_text"])

# Collect all messages including from subsequent continuation conversations
# This ensures long_texts from continuations appear with the original prompt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
code { background: rgba(0,0,0,0.08); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
pre code { background: none; padding: 0; }
.user-content { margin: 0; }
.user-text { margin: 0; white-space: pre-wrap; }
.truncatable { position: relative; }
.truncatable.truncated .truncatable-content { max-height: 200px; overflow: hidden; }
.truncatable.truncated::after { content: ''; position: absolute; bottom: 32px; left: 0; right: 0; height: 60px; background: linear-gradient(to bottom, transparent, var(--card-bg)); pointer-events: none; }
Expand Down Expand Up @@ -166,15 +167,15 @@ <h1>Claude Code transcript</h1>

<p style="color: var(--text-muted); margin-bottom: 24px;">5 prompts · 33 messages · 12 tool calls · 2 commits · 2 pages</p>

<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-00-00-000Z"><div class="index-item-header"><span class="index-item-number">#1</span><time datetime="2025-12-24T10:00:00.000Z" data-timestamp="2025-12-24T10:00:00.000Z">2025-12-24T10:00:00.000Z</time></div><div class="index-item-content"><p>Create a simple Python function to add two numbers</p></div></a><div class="index-item-stats"><span>3 bash · 1 write · 1 todo</span>
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-00-00-000Z"><div class="index-item-header"><span class="index-item-number">#1</span><time datetime="2025-12-24T10:00:00.000Z" data-timestamp="2025-12-24T10:00:00.000Z">2025-12-24T10:00:00.000Z</time></div><div class="index-item-content"><p class="user-text">Create a simple Python function to add two numbers</p></div></a><div class="index-item-stats"><span>3 bash · 1 write · 1 todo</span>
</div></div><div class="index-commit"><a href="https://github.com/example/project/commit/abc1234"><div class="index-commit-header"><span class="index-commit-hash">abc1234</span><time datetime="2025-12-24T10:00:40.000Z" data-timestamp="2025-12-24T10:00:40.000Z">2025-12-24T10:00:40.000Z</time></div><div class="index-commit-msg">Add math_utils with add function</div></a></div>
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-01-00-000Z"><div class="index-item-header"><span class="index-item-number">#2</span><time datetime="2025-12-24T10:01:00.000Z" data-timestamp="2025-12-24T10:01:00.000Z">2025-12-24T10:01:00.000Z</time></div><div class="index-item-content"><p>Now edit the file to add a subtract function</p></div></a><div class="index-item-stats"><span>1 glob · 1 edit · 1 grep</span>
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-01-00-000Z"><div class="index-item-header"><span class="index-item-number">#2</span><time datetime="2025-12-24T10:01:00.000Z" data-timestamp="2025-12-24T10:01:00.000Z">2025-12-24T10:01:00.000Z</time></div><div class="index-item-content"><p class="user-text">Now edit the file to add a subtract function</p></div></a><div class="index-item-stats"><span>1 glob · 1 edit · 1 grep</span>
</div></div>
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-02-00-000Z"><div class="index-item-header"><span class="index-item-number">#3</span><time datetime="2025-12-24T10:02:00.000Z" data-timestamp="2025-12-24T10:02:00.000Z">2025-12-24T10:02:00.000Z</time></div><div class="index-item-content"><p>Run the tests again</p></div></a><div class="index-item-stats"><span>1 bash</span>
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-02-00-000Z"><div class="index-item-header"><span class="index-item-number">#3</span><time datetime="2025-12-24T10:02:00.000Z" data-timestamp="2025-12-24T10:02:00.000Z">2025-12-24T10:02:00.000Z</time></div><div class="index-item-content"><p class="user-text">Run the tests again</p></div></a><div class="index-item-stats"><span>1 bash</span>
</div></div>
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-03-00-000Z"><div class="index-item-header"><span class="index-item-number">#4</span><time datetime="2025-12-24T10:03:00.000Z" data-timestamp="2025-12-24T10:03:00.000Z">2025-12-24T10:03:00.000Z</time></div><div class="index-item-content"><p>Fix the issue and commit</p></div></a><div class="index-item-stats"><span>1 edit · 1 bash</span>
<div class="index-item"><a href="page-001.html#msg-2025-12-24T10-03-00-000Z"><div class="index-item-header"><span class="index-item-number">#4</span><time datetime="2025-12-24T10:03:00.000Z" data-timestamp="2025-12-24T10:03:00.000Z">2025-12-24T10:03:00.000Z</time></div><div class="index-item-content"><p class="user-text">Fix the issue and commit</p></div></a><div class="index-item-stats"><span>1 edit · 1 bash</span>
</div></div><div class="index-commit"><a href="https://github.com/example/project/commit/def5678"><div class="index-commit-header"><span class="index-commit-hash">def5678</span><time datetime="2025-12-24T10:03:20.000Z" data-timestamp="2025-12-24T10:03:20.000Z">2025-12-24T10:03:20.000Z</time></div><div class="index-commit-msg">Add subtract function and fix tests</div></a></div>
<div class="index-item"><a href="page-002.html#msg-2025-12-24T10-05-00-000Z"><div class="index-item-header"><span class="index-item-number">#5</span><time datetime="2025-12-24T10:05:00.000Z" data-timestamp="2025-12-24T10:05:00.000Z">2025-12-24T10:05:00.000Z</time></div><div class="index-item-content"><p>Add a multiply function too</p></div></a><div class="index-item-stats"><span>1 edit</span>
<div class="index-item"><a href="page-002.html#msg-2025-12-24T10-05-00-000Z"><div class="index-item-header"><span class="index-item-number">#5</span><time datetime="2025-12-24T10:05:00.000Z" data-timestamp="2025-12-24T10:05:00.000Z">2025-12-24T10:05:00.000Z</time></div><div class="index-item-content"><p class="user-text">Add a multiply function too</p></div></a><div class="index-item-stats"><span>1 edit</span>
</div></div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
code { background: rgba(0,0,0,0.08); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
pre code { background: none; padding: 0; }
.user-content { margin: 0; }
.user-text { margin: 0; white-space: pre-wrap; }
.truncatable { position: relative; }
.truncatable.truncated .truncatable-content { max-height: 200px; overflow: hidden; }
.truncatable.truncated::after { content: ''; position: absolute; bottom: 32px; left: 0; right: 0; height: 60px; background: linear-gradient(to bottom, transparent, var(--card-bg)); pointer-events: none; }
Expand Down Expand Up @@ -158,7 +159,7 @@ <h1><a href="index.html" style="color: inherit; text-decoration: none;">Claude C


<div class="message user" id="msg-2025-12-24T10-00-00-000Z"><div class="message-header"><span class="role-label">User</span><a href="#msg-2025-12-24T10-00-00-000Z" class="timestamp-link"><time datetime="2025-12-24T10:00:00.000Z" data-timestamp="2025-12-24T10:00:00.000Z">2025-12-24T10:00:00.000Z</time></a></div><div class="message-content">
<div class="user-content"><p>Create a simple Python function to add two numbers</p></div></div></div>
<div class="user-content"><p class="user-text">Create a simple Python function to add two numbers</p></div></div></div>
<div class="message assistant" id="msg-2025-12-24T10-00-05-000Z"><div class="message-header"><span class="role-label">Assistant</span><a href="#msg-2025-12-24T10-00-05-000Z" class="timestamp-link"><time datetime="2025-12-24T10:00:05.000Z" data-timestamp="2025-12-24T10:00:05.000Z">2025-12-24T10:00:05.000Z</time></a></div><div class="message-content">
<div class="thinking"><div class="thinking-label">Thinking</div><p>The user wants a simple addition function. I should:
1. Create the function
Expand Down Expand Up @@ -208,7 +209,7 @@ <h1><a href="index.html" style="color: inherit; text-decoration: none;">Claude C
To github.com:example/project.git
def5678..abc1234 main -&gt; main</pre></div><button class="expand-btn">Show more</button></div></div></div></div>
<div class="message user" id="msg-2025-12-24T10-01-00-000Z"><div class="message-header"><span class="role-label">User</span><a href="#msg-2025-12-24T10-01-00-000Z" class="timestamp-link"><time datetime="2025-12-24T10:01:00.000Z" data-timestamp="2025-12-24T10:01:00.000Z">2025-12-24T10:01:00.000Z</time></a></div><div class="message-content">
<div class="user-content"><p>Now edit the file to add a subtract function</p></div></div></div>
<div class="user-content"><p class="user-text">Now edit the file to add a subtract function</p></div></div></div>
<div class="message assistant" id="msg-2025-12-24T10-01-05-000Z"><div class="message-header"><span class="role-label">Assistant</span><a href="#msg-2025-12-24T10-01-05-000Z" class="timestamp-link"><time datetime="2025-12-24T10:01:05.000Z" data-timestamp="2025-12-24T10:01:05.000Z">2025-12-24T10:01:05.000Z</time></a></div><div class="message-content">
<div class="tool-use" data-tool-id="toolu_glob_001"><div class="tool-header"><span class="tool-icon">⚙</span> Glob</div><div class="truncatable"><div class="truncatable-content"><pre class="json">{
&#34;pattern&#34;: &#34;**/*.py&#34;,
Expand Down Expand Up @@ -241,7 +242,7 @@ <h1><a href="index.html" style="color: inherit; text-decoration: none;">Claude C
}</pre></div><button class="expand-btn">Show more</button></div></div></div></div>
<div class="message tool-reply" id="msg-2025-12-24T10-01-30-000Z"><div class="message-header"><span class="role-label">Tool reply</span><a href="#msg-2025-12-24T10-01-30-000Z" class="timestamp-link"><time datetime="2025-12-24T10:01:30.000Z" data-timestamp="2025-12-24T10:01:30.000Z">2025-12-24T10:01:30.000Z</time></a></div><div class="message-content"><div class="tool-result"><div class="truncatable"><div class="truncatable-content"><pre>/project/math_utils.py:6:def subtract(a: int, b: int) -&gt; int:</pre></div><button class="expand-btn">Show more</button></div></div></div></div>
<div class="message user" id="msg-2025-12-24T10-02-00-000Z"><div class="message-header"><span class="role-label">User</span><a href="#msg-2025-12-24T10-02-00-000Z" class="timestamp-link"><time datetime="2025-12-24T10:02:00.000Z" data-timestamp="2025-12-24T10:02:00.000Z">2025-12-24T10:02:00.000Z</time></a></div><div class="message-content">
<div class="user-content"><p>Run the tests again</p></div></div></div>
<div class="user-content"><p class="user-text">Run the tests again</p></div></div></div>
<div class="message assistant" id="msg-2025-12-24T10-02-05-000Z"><div class="message-header"><span class="role-label">Assistant</span><a href="#msg-2025-12-24T10-02-05-000Z" class="timestamp-link"><time datetime="2025-12-24T10:02:05.000Z" data-timestamp="2025-12-24T10:02:05.000Z">2025-12-24T10:02:05.000Z</time></a></div><div class="message-content">
<div class="tool-use bash-tool" data-tool-id="toolu_bash_004">
<div class="tool-header"><span class="tool-icon">$</span> Bash</div>
Expand All @@ -260,7 +261,7 @@ <h1><a href="index.html" style="color: inherit; text-decoration: none;">Claude C
return 42
</code></pre></div></div></div>
<div class="message user" id="msg-2025-12-24T10-03-00-000Z"><div class="message-header"><span class="role-label">User</span><a href="#msg-2025-12-24T10-03-00-000Z" class="timestamp-link"><time datetime="2025-12-24T10:03:00.000Z" data-timestamp="2025-12-24T10:03:00.000Z">2025-12-24T10:03:00.000Z</time></a></div><div class="message-content">
<div class="user-content"><p>Fix the issue and commit</p></div></div></div>
<div class="user-content"><p class="user-text">Fix the issue and commit</p></div></div></div>
<div class="message assistant" id="msg-2025-12-24T10-03-05-000Z"><div class="message-header"><span class="role-label">Assistant</span><a href="#msg-2025-12-24T10-03-05-000Z" class="timestamp-link"><time datetime="2025-12-24T10:03:05.000Z" data-timestamp="2025-12-24T10:03:05.000Z">2025-12-24T10:03:05.000Z</time></a></div><div class="message-content"><div class="file-tool edit-tool" data-tool-id="toolu_edit_002">
<div class="file-tool-header edit-header"><span class="file-tool-icon">✏️</span> Edit <span class="file-tool-path">test_math.py</span> <span class="edit-replace-all">(replace all)</span></div>
<div class="file-tool-fullpath">/project/tests/test_math.py</div>
Expand All @@ -279,7 +280,7 @@ <h1><a href="index.html" style="color: inherit; text-decoration: none;">Claude C
<div class="message assistant" id="msg-2025-12-24T10-03-25-000Z"><div class="message-header"><span class="role-label">Assistant</span><a href="#msg-2025-12-24T10-03-25-000Z" class="timestamp-link"><time datetime="2025-12-24T10:03:25.000Z" data-timestamp="2025-12-24T10:03:25.000Z">2025-12-24T10:03:25.000Z</time></a></div><div class="message-content">
<div class="assistant-text"><p>Done! The subtract function is now working and committed.</p></div></div></div><details class="continuation"><summary>Session continuation summary</summary>
<div class="message user" id="msg-2025-12-24T10-04-00-000Z"><div class="message-header"><span class="role-label">User</span><a href="#msg-2025-12-24T10-04-00-000Z" class="timestamp-link"><time datetime="2025-12-24T10:04:00.000Z" data-timestamp="2025-12-24T10:04:00.000Z">2025-12-24T10:04:00.000Z</time></a></div><div class="message-content">
<div class="user-content"><p>This is a session continuation summary from a previous context. The user was working on a math utilities library.</p></div></div></div></details>
<div class="user-content"><p class="user-text">This is a session continuation summary from a previous context. The user was working on a math utilities library.</p></div></div></div></details>


<div class="pagination">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
code { background: rgba(0,0,0,0.08); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
pre code { background: none; padding: 0; }
.user-content { margin: 0; }
.user-text { margin: 0; white-space: pre-wrap; }
.truncatable { position: relative; }
.truncatable.truncated .truncatable-content { max-height: 200px; overflow: hidden; }
.truncatable.truncated::after { content: ''; position: absolute; bottom: 32px; left: 0; right: 0; height: 60px; background: linear-gradient(to bottom, transparent, var(--card-bg)); pointer-events: none; }
Expand Down Expand Up @@ -158,7 +159,7 @@ <h1><a href="index.html" style="color: inherit; text-decoration: none;">Claude C


<div class="message user" id="msg-2025-12-24T10-05-00-000Z"><div class="message-header"><span class="role-label">User</span><a href="#msg-2025-12-24T10-05-00-000Z" class="timestamp-link"><time datetime="2025-12-24T10:05:00.000Z" data-timestamp="2025-12-24T10:05:00.000Z">2025-12-24T10:05:00.000Z</time></a></div><div class="message-content">
<div class="user-content"><p>Add a multiply function too</p></div></div></div>
<div class="user-content"><p class="user-text">Add a multiply function too</p></div></div></div>
<div class="message assistant" id="msg-2025-12-24T10-05-05-000Z"><div class="message-header"><span class="role-label">Assistant</span><a href="#msg-2025-12-24T10-05-05-000Z" class="timestamp-link"><time datetime="2025-12-24T10:05:05.000Z" data-timestamp="2025-12-24T10:05:05.000Z">2025-12-24T10:05:05.000Z</time></a></div><div class="message-content"><div class="file-tool edit-tool" data-tool-id="toolu_edit_003">
<div class="file-tool-header edit-header"><span class="file-tool-icon">✏️</span> Edit <span class="file-tool-path">math_utils.py</span></div>
<div class="file-tool-fullpath">/project/math_utils.py</div>
Expand Down
Loading