Problem
cmd/precompact_test.go only tests looksLikeFilePath. The three functions that do the real work of building the session snapshot have no unit tests:
buildSnapshotContent (cmd/precompact.go:96) — orchestrates transcript parsing, deduplication, and trimming
buildSnapshotMarkdown (cmd/precompact.go:176) — formats the final Markdown output
extractMessageText (cmd/precompact.go:214) — handles both string and []contentBlock content shapes
These functions contain non-trivial logic (last-5 user messages, last-10 files-in-focus, reverse-deduplication of file paths, Unicode-aware truncation at 200 runes) that is easy to break silently. The recent perf commit f6ad83d streamed the transcript line-by-line but added no new test coverage for this logic.
What to add
Tests in cmd/precompact_test.go covering:
extractMessageText — plain string content returns the string as-is
extractMessageText — structured []interface{} content block array joins text blocks
extractMessageText — non-text blocks (e.g. tool_use) are skipped
buildSnapshotMarkdown — with user messages and files: both sections appear in output
buildSnapshotMarkdown — with no messages and no files: fallback placeholder appears
buildSnapshotContent — given a JSONL fixture with more than 5 user messages, only the last 5 are retained
buildSnapshotContent — file paths mentioned multiple times are deduplicated, keeping only the last occurrence
Files
cmd/precompact_test.go (file to extend)
cmd/precompact.go:96,176,214 (functions under test)
@claude please implement this