Fix SnapshotState decoders dropping ChatState#290
Merged
Conversation
The SnapshotState union decoders in the Swift, Kotlin, and Go generators discriminated variants on a `summary` field that was removed when commit 80454fd flattened SessionState. As a result: - Swift and Kotlin never attempted ChatState at all, so chat snapshots failed to decode (Swift threw; Kotlin fell through to Root). - Go probed for `summary` on both the session and chat branches, so both silently fell through to the Root catch-all. Switch disambiguation to the real distinctive required fields — session on `lifecycle`, chat on `turns` — and add the missing chat branch to Swift and Kotlin. Rust already decoded correctly via its untagged enum; only its stale doc comment is updated. Adds a Go regression test covering every SnapshotState variant. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
connor4312
approved these changes
Jun 30, 2026
pwang347
approved these changes
Jun 30, 2026
roblourens
approved these changes
Jun 30, 2026
auto-merge was automatically disabled
June 30, 2026 17:25
Pull request was closed
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.
Why
SnapshotStateis an untagged union; each client distinguishes its variants structurally by probing for distinctive required fields. Those probes still keyed off asummaryfield that was removed whenSessionStatewas flattened (commit80454fd), breaking snapshot decoding:ChatState, so chat snapshots failed to decode (Swift threw; Kotlin fell through toRoot).summaryon both the session and chat branches, so both silently decoded asRoot.Approach
Fixed the decoders in the generators (
scripts/generate-*.ts) and regenerated the clients. Disambiguation now uses real required fields: session ->lifecycle, chat ->turns, terminal ->content, changeset ->status+files, resource-watch ->root+recursive, annotations ->annotations, root -> catch-all. Swift and Kotlin gained the missingchatbranch. Rust already decoded correctly via its#[serde(untagged)]enum, so only its stale doc comment changed.Notes for reviewers
SessionStatecarries an optionalannotationssummary that reuses the same key.TestSnapshotStateVariants) round-tripping every variant.