fix(compat): guard .meta.json parser against missing optional fields from older sessions#109
Merged
Conversation
…ta.json parsing Replaces the ad-hoc serde_json::Value navigation in read_agent_type with a typed SidecarMeta struct where every field carries #[serde(default)] or is Option<T>. This ensures that sessions written before a field was introduced continue to parse without error as Claude Code adds new optional fields to the sidecar schema. Adds a doc-comment on SidecarMeta that documents the backwards-compatibility rule so future contributors cannot accidentally add a bare required field. Adds 6 regression tests (minimal file, empty object, unknown future fields, missing file, and round-trip for known and future-extra-field files). Fixes #107
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
Fixes #107 — session-meta sidecar files (
.meta.json) written by older Claude Code builds were missing the optional fields that newer builds add. Any strict typed parser would error on these older files.Changes
src-tauri/src/parser/subagent.rsSidecarMeta— a typed serde struct for.meta.jsonsidecar files. Every field carries#[serde(default)]or isOption<T>, so files written by older Claude Code builds (which omit new fields) continue to parse without error.serde_json::Valuenavigation inread_agent_typewith a clean deserialisation intoSidecarMeta.SidecarMetaencoding the backwards-compatibility rule: new fields from meta files must always be optional to preserve backwards compatibility with sessions written by older Claude Code builds.Regression tests (6 new)
sidecar_meta_minimal_json_parses_without_erroragentType) parses without errorsidecar_meta_empty_object_parses_without_error{}does not panicsidecar_meta_unknown_new_fields_are_ignoredread_agent_type_returns_empty_for_missing_meta_fileread_agent_type_returns_empty_for_empty_objectread_agent_type_parses_known_fieldagentTypefield is read correctlyread_agent_type_tolerates_extra_fields_from_new_claude_code_versionTest results