#74 Diffs: per-file cards, dual line numbers, visual diffstat, drop mbox preamble
Commit detail and PR patch sections dump raw git show / git format-patch output into one <pre>. This is where GitHub/GitLab/Forgejo look most polished and we look like less.
Current
Commit page (commit/<sha>.html):
commit ec5b1f0bcaeacfd169d48a27bee83a414a639e46
Author: gl0w <gl0w@world>
Date: Thu Sep 10 05:26:49 2026 +0100
land #7 forge-readers + f0rge state
diff --git a/.forge/issues/f8c1…/issue.md b/.forge/issues/f8c1…/issue.md
index 2a46910..97d6ad7 100644
--- a/…
+++ b/…
@@ -1,13 +1,13 @@
PR page patch starts with the mbox preamble From 4eabe68… Mon Sep 17 00:00:00 2001, From:, Subject: [PATCH] …, then a text diffstat (src/commits.rs | 30 +++++…).
Problems:
- No per-file grouping/cards — one giant block.
- No line numbers (neither old nor new side).
diff --git/index/---/+++are colored with--diff-file, which equals--fg→ visually indistinguishable from body text.- Hunk headers (
@@ … @@) are plain; no function context emphasis. - Long paths wrap mid-token instead of scrolling per file.
- Mbox/patch preamble is pure noise on the PR page.
- Commit header (
Author:,Date:) duplicates the meta shown above the diff.
Scope
- Emit one card per file: sticky file header (path,
+n −mcounts in green/red, "view file" link), collapse-all via<details open>. - Two-column line numbers (old/new) in a gutter,
--fg-dim,user-select:none, monospace alignment with the code lines. - Diffstat bar: a real visual bar (green/red proportional divs) replacing
++++---ASCII. - Color
---/+++/diff --gitwith a distinct--diff-filetoken (not--fg), hunk headers--diff-hunkon a--surface-2strip. - Strip the
From …mbox preamble andFrom:/Subject:lines on the PR page (they duplicate the PR title); keep the commit message body only. - Per-file horizontal scroll (
overflow-x:auto) instead of wrapping paths. - Rust:
commits.rsalready emitsdiff-file/diff-hunkspans; extend to file boundaries + line numbers rather than re-parsing.
Acceptance
- every changed file renders as its own card with path + counts
- old/new line numbers align with code lines
-
diff --git/---/+++visibly distinct from code text - PR patch has no mbox preamble
- no mid-token wrapping of long paths (scroll instead)
Uunknown ·
Fixed in a5d3c785: diff_html emits one card per file with path, +n/-m, proportional bar, dual old/new line numbers, distinct --diff-file color and add/del row backgrounds; mbox preamble dropped; non-unified fallback kept. Commit header uses monogram + relative time; tests updated (249 passing).