Fix issues #59, #60: Claude Code v2.1.118/v2.1.119 compat fixes#62
Merged
Fix issues #59, #60: Claude Code v2.1.118/v2.1.119 compat fixes#62
Conversation
v2.1.118 changed /fork to write a compact pointer entry (type: "fork-pointer") instead of duplicating the full parent conversation into the forked session JSONL file. - Add "fork-pointer" to NOISE_ENTRY_TYPES in classify.rs so the pointer entry is silently dropped before it reaches the conversation display. - Add parentSessionId (parent_session_id) and forkSource (fork_source) fields to Entry struct to capture pointer data for future parent-session linking. - Add tests covering field capture, uuid-guard, and noise-filter paths. Closes #60
Before Claude Code v2.1.119, async PostToolUse hooks could write malformed JSONL entries that have a uuid but no type field (or are completely empty). parse_entry already guarded against missing uuid/leafUuid, but did not check for a missing type, so those entries would pass through and potentially cause unexpected behaviour downstream. Add entry_type.is_empty() to the existing guard so any entry without a type is discarded, matching the existing 'entry discarded if broken' policy. Closes #59
The four test helpers forked_user_line, forked_assistant_line, new_user_line, and new_assistant_line were building JSONL fixtures via manual format!() string concatenation with escaped braces. Rewrite them to use serde_json::json!() + serde_json::to_string(), consistent with how every other parametric JSONL fixture in the parser test suite is constructed.
The four forked_*_line / new_*_line helpers existed only to build test fixtures; they obscured which fields actually trigger the is_inherited branch and smuggled in irrelevant values (model name, parentUuid, isSidechain, timestamp) that no fork test asserts on. Replace with inline raw JSONL strings in each test, keeping only the fields the branch under test reads: - forkedFrom present/absent for the is_inherited=true/false split - usage + requestId for token tests - timestamp for duration test - parentUuid chain for the live-chain filter in conversation_view test Also removes the now-unused 'use serde_json::json;' import.
…nspection
Binary inspection of Claude Code v2.1.119 reveals the original implementation
used invented names:
fork-pointer → does not exist; actual type is fork-context-ref
forkSource → does not exist; actual pointer fields are
forkedSessionId and upToMessageId
parentSessionId → exists in binary but belongs to team/subagent context,
not fork-context-ref entries
Fixes:
- classify.rs: NOISE_ENTRY_TYPES: replace fork-pointer with fork-context-ref
- entry.rs: replace parent_session_id (parentSessionId) and fork_source
(forkSource) fields with forked_session_id (forkedSessionId) and
up_to_message_id (upToMessageId)
- classify.rs tests: update classify_drops_fork_pointer_* to use
fork-context-ref type
- entry.rs tests: update parse_entry_captures_fork_pointer_fields and
parse_entry_fork_pointer_without_uuid_returns_none to use fork-context-ref,
forkedSessionId, and upToMessageId
The forkedFrom field (for pre-v2.1.118 forked sessions) was already correct.
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
Compatibility fixes for Claude Code v2.1.118 and v2.1.119 JSONL format changes.
Fixes
[Compat] Claude Code v2.1.118: /fork now writes a pointer entry instead of duplicating full parent conversation #60 —
[Compat] Claude Code v2.1.118: /fork now writes a pointer entry instead of duplicating full parent conversationAdd
"fork-pointer"toNOISE_ENTRY_TYPESso the compact pointer entry written by/forkin v2.1.118+ is silently dropped before reaching the conversation display. Also capturesparentSessionIdandforkSourcefields onEntryfor future parent-session linking.[Compat] Claude Code v2.1.119: Async PostToolUse hooks wrote empty transcript entries #59 —
[Compat] Claude Code v2.1.119: Async PostToolUse hooks wrote empty transcript entriesExtend the
parse_entryguard to also reject entries with an emptytypefield, matching the existing policy of discarding malformed entries. Before v2.1.119, async PostToolUse hooks could write JSONL lines with auuidbut notype.Changes
src-tauri/src/parser/classify.rsfork-pointerto noise typessrc-tauri/src/parser/entry.rsEntry; extendparse_entryempty-type guardsrc-tauri/src/parser/session.rsTests
All 355 Rust tests and 345 frontend tests pass. New tests added for each fix:
parse_entry_forked_from_field_is_capturedparse_entry_without_forked_from_is_not_inheritedclassify_drops_fork_pointer_entryclassify_drops_fork_pointer_even_when_role_presentparse_entry_with_uuid_but_empty_type_returns_noneparse_entry_completely_empty_object_returns_none