Add per-message timestamps to markdown and HTML output#57
Open
madorian wants to merge 1 commit into
Open
Conversation
The JSONL source data already contains ISO 8601 timestamps on every message entry, but save_as_markdown() and save_as_html() were only using the first message's timestamp for the file header metadata. This adds the timestamp to each message heading in the exported output: - Markdown: ## 👤 User [2026-05-18 21:00:05] - HTML: inline <span> after the role label When a message has no timestamp, the heading renders without one, maintaining backward compatibility with older JSONL files. Per-message timestamps enable: - Correlating conversation events with external logs - Disambiguating ordering across concurrent sessions - Forensic analysis without parsing raw JSONL
|
Great PR! This per-message timestamp is very helpful. One suggestion to make it even better: add timezone conversion for users outside UTC+0. Would you be open to adding that, or should I file a separate issue for it? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The JSONL source data already contains ISO 8601 timestamps on every message entry (
entry.get("timestamp")), andextract_conversation()correctly preserves them in the conversation dicts. However,save_as_markdown()andsave_as_html()only use the first message's timestamp for the file-level header metadata -- individual message headings have no temporal information.This PR appends the formatted timestamp to each message heading:
## 👤 User [2026-05-18 21:00:05]<span>after the role label, styled in subdued grayWhen a message has no timestamp field, the heading renders exactly as before (no brackets), maintaining backward compatibility.
Motivation
Per-message timestamps enable correlating conversation events with external systems (git commits, file modifications, CI logs) without parsing raw JSONL. This is especially valuable for forensic analysis across concurrent sessions.
Changes
_format_timestamp()static method for consistent ISO-to-display formattingsave_as_markdown()to include[timestamp]on each role headingsave_as_html()to include timestamp span on each role headingExample output