Ignore 'last-prompt' message type#112
Conversation
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for your first contributed line ;-) |
|
"This branch has conflicts that must be resolved" - at first, I was puzzled by that, but there's an explanation:
So, basically, #102 is already fixed. I'll add a regression test, instead. |
Claude Code now writes a trailing {type:last-prompt,...} line as the
last entry of session .jsonl files. Add it to the silent-skip list
alongside file-history-snapshot and progress, so it does not print a
'not a recognised message type' warning.
Fixes daaain#102
…elds Before PR daaain#97's DAG refactor, load_transcript explicitly listed internal message types (file-history-snapshot, progress) as silent skips, and warned about anything else. The refactor replaced that with an unknown → PassthroughTranscriptEntry fallback for entries with uuid+sessionId, and an implicit drop for everything else — which also silently drops types like custom-title and agent-name that Claude Code introduced later, so they never show up for maintainers to notice. Restore the old signal by reintroducing an explicit SILENT_SKIP_TYPES frozenset and an else-branch warning: - file-history-snapshot and last-prompt (fixes daaain#102) are listed and dropped without warning. Both lack uuid/sessionId in the wild. - progress is intentionally NOT in the skip list — it has uuid, so the uuid+sessionId branch keeps it as PassthroughTranscriptEntry for DAG continuity (the existing test coverage in test_dag_integration.py relies on that). - Everything else that reaches the else-branch prints a single-line warning quoting the unknown type so future metadata surfaces. Update test_multiple_passthrough_types to use a generic "unknown-future-type" label instead of "file-history-snapshot" for its synthetic passthrough entry — the test was never representative of real file-history-snapshot data (which has no uuid) and conflicted with the silent-skip list.
Covers the four paths through load_transcript's non-conversation type handling: - file-history-snapshot, last-prompt: silent-skip path. No output on stderr/stdout, zero messages. Direct regression for daaain#102. - progress: uuid+sessionId path. Preserved as PassthroughTranscriptEntry, silently (verifies it stays out of SILENT_SKIP_TYPES). - custom-title, agent-name, future-metadata-type: else-branch warning path. Parameterised to make "what's on this path" explicit. Also checks that silent=True suppresses the warning. - Unknown type with uuid: PassthroughTranscriptEntry fallback path, no warning.
16c3b0d to
a2f9b4c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
claude_code_log/converter.py (1)
343-360: Preserve DAG nodes before applying silent skips.
SILENT_SKIP_TYPESis documented as non-DAG, but this branch now runs before theuuid+sessionIdpassthrough path. If Claude adds DAG fields to one of these metadata types later, it would be dropped and could create false roots. Prefer preserving DAG-bearing entries first, then silently skipping non-DAG metadata.Proposed branch-order tweak
- elif entry_type in SILENT_SKIP_TYPES: - # Internal Claude Code entries with no DAG fields. - pass - elif entry_dict.get("uuid") and entry_dict.get("sessionId"): + elif entry_dict.get("uuid") and entry_dict.get("sessionId"): # Unknown type with DAG-relevant fields — create a # PassthroughTranscriptEntry to preserve DAG chain # continuity (e.g. "attachment", "permission-mode"). messages.append( PassthroughTranscriptEntry( uuid=entry_dict["uuid"], parentUuid=entry_dict.get("parentUuid"), sessionId=entry_dict["sessionId"], timestamp=entry_dict.get("timestamp", ""), type=entry_type, isSidechain=entry_dict.get("isSidechain", False), agentId=entry_dict.get("agentId"), ) ) + elif entry_type in SILENT_SKIP_TYPES: + # Internal Claude Code entries with no DAG fields. + pass🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@claude_code_log/converter.py` around lines 343 - 360, The current branch checks SILENT_SKIP_TYPES before the passthrough DAG-preserving branch, which can drop entries that actually carry DAG fields; update the condition order in converter.py so the branch that detects DAG-relevant entries (the check using entry_dict.get("uuid") and entry_dict.get("sessionId") that constructs a PassthroughTranscriptEntry and appends to messages) runs before the SILENT_SKIP_TYPES check (entry_type in SILENT_SKIP_TYPES), or alternatively enhance the SILENT_SKIP_TYPES branch to skip only when uuid/sessionId are absent; ensure you reference entry_type, entry_dict, PassthroughTranscriptEntry and messages when making the change so DAG-bearing entries are preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@claude_code_log/converter.py`:
- Around line 343-360: The current branch checks SILENT_SKIP_TYPES before the
passthrough DAG-preserving branch, which can drop entries that actually carry
DAG fields; update the condition order in converter.py so the branch that
detects DAG-relevant entries (the check using entry_dict.get("uuid") and
entry_dict.get("sessionId") that constructs a PassthroughTranscriptEntry and
appends to messages) runs before the SILENT_SKIP_TYPES check (entry_type in
SILENT_SKIP_TYPES), or alternatively enhance the SILENT_SKIP_TYPES branch to
skip only when uuid/sessionId are absent; ensure you reference entry_type,
entry_dict, PassthroughTranscriptEntry and messages when making the change so
DAG-bearing entries are preserved.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d7905d07-dfac-4e0b-8570-64821e18ac38
📒 Files selected for processing (3)
claude_code_log/converter.pytest/test_dag_integration.pytest/test_silent_skip.py
✅ Files skipped from review due to trivial changes (1)
- test/test_dag_integration.py
|
Sorry for the "force push" ;-) I believe it was either that or closing the PR and recreating a new one.
Net effect: fixes #102, restores the "notice new Claude Code types" signal that went dark after PR #97, and adds the first explicit test coverage for the non-conversation type dispatch. Local just test passes 871/871 (excluding pre-existing pagination env failures). |
Claude Code writes per-session state snapshots to the transcript with no uuid/parentUuid/timestamp — they are positional markers, not DAG nodes. They arrive frequently (e.g. a `permission-mode` after every mode toggle, an `agent-name`+`custom-title` pair after every /rename) and would otherwise drown the unrecognised-type warning introduced on top of daaain#112. Four types land in the silent-skip list: - permission-mode : {permissionMode} - custom-title : {customTitle} - agent-name : {agentName} - agent-color : {agentColor} All four will become load-bearing once we propagate their state onto conversational messages in a follow-up (see daaain#94). Dropping them silently for now is a strict improvement over the current state: either noisy warnings (reinstated warning branch on top of daaain#112) or silent loss (main). Extend test_silent_skip with a parameterised case covering all four and repoint the unrecognised-type parametrisation onto two hypothetical future types, since the original custom-title / agent-name samples now land on the silent path.
…es (#113) * Handle custom-title, agent-name, and agent-color transcript entry types These session metadata entry types are generated by Claude Code but were not recognized by the parser, causing 'Unknown transcript entry type' errors. Changes: - Make uuid and timestamp optional in PassthroughTranscriptEntry to support entry types that lack these fields - Add custom-title, agent-name, and agent-color to ENTRY_CREATORS registry - Update fallback in create_transcript_entry to handle any unknown type with a sessionId gracefully * Extend SILENT_SKIP_TYPES with session-metadata types (#94) Claude Code writes per-session state snapshots to the transcript with no uuid/parentUuid/timestamp — they are positional markers, not DAG nodes. They arrive frequently (e.g. a `permission-mode` after every mode toggle, an `agent-name`+`custom-title` pair after every /rename) and would otherwise drown the unrecognised-type warning introduced on top of #112. Four types land in the silent-skip list: - permission-mode : {permissionMode} - custom-title : {customTitle} - agent-name : {agentName} - agent-color : {agentColor} All four will become load-bearing once we propagate their state onto conversational messages in a follow-up (see #94). Dropping them silently for now is a strict improvement over the current state: either noisy warnings (reinstated warning branch on top of #112) or silent loss (main). Extend test_silent_skip with a parameterised case covering all four and repoint the unrecognised-type parametrisation onto two hypothetical future types, since the original custom-title / agent-name samples now land on the silent path. * Document session-state propagation plan for #94 follow-up Spells out the deferred half of issue #94 — turning the now-silent session-metadata types into a visible "Assistant · CCL (Monk)" decoration on conversational messages, with colour tinting from agent-color. Covers: data shape (no uuid/timestamp, pure positional markers), file-position propagation semantics (single self-contained session file), six concrete change sites (MessageMeta fields, load_transcript state tracker, private-attr channel onto pydantic entries, create_meta forwarding, title_AssistantTextMessage decoration, CSS), cache concerns, open questions (separator, colour palette, permission-mode surfacing, session nav integration), and risks (snapshot churn, private-attr subtlety, markdown heading compactor). This PR does NOT complete #94. Wording here is deliberately free of GitHub close keywords: #94 stays open as the tracker for the state-propagation implementation documented in work/session-state-propagation.md. The PR description should also be edited to use a plain `#94` reference rather than a closing keyword so merging does not auto-close the issue. * Switch warning text to American spelling; tighten silent-skip tests Two small follow-ups on top of the SILENT_SKIP_TYPES work. The "unrecognised message type" warning landed in the prior PR using the British spelling, matching the pre-#97 original phrasing. #94 explicitly called out the preferred `s/recognised/recognized/`, so flip it here. Single user-facing string; the else-branch is only reached for unknown types, so unlikely to bite anyone scraping logs. CodeRabbit flagged the silent-skip test assertions — they used the weak form `"unrecognised" not in captured.out`, which only catches a specific substring and silently tolerates any other output the loader might accidentally start printing. Switch every silent-path test to call `load_transcript(..., silent=True)` and assert `captured.out == ""`; the warn-path test keeps `silent=False` and now matches the new American spelling. --------- Co-authored-by: fuleinist <fuleinist@gmail.com> Co-authored-by: Christian Boos <christian.boos@bct-technology.com>
Fixes #102. Added
last-promptto the silent-skip list inconverter.pyalongsidefile-history-snapshotandprogress, so Claude Code's new trailing{type:last-prompt,...}line no longer triggers a 'not a recognised message type' warning.Also maintain a small open source tool in the Claude Code space, happy to contribute more if useful.
Summary by CodeRabbit