Skip malformed turns lines in display-only resume hydrate (CL-5935) - #563
Merged
TheGreatAxios merged 1 commit intoAug 23, 2026
Merged
Conversation
loadRecentTurns is the TUI resume path that only needs a recent window of history for display. A non-null malformed or schema-invalid line anywhere in any segment used to abort the whole load, painting a one-line error instead of the surrounding transcript. Pass skipMalformed=true there so bad lines are logged and skipped while the rest of the history still loads. The reactor's own load() is unchanged: history there is live conversation state, so a bad line must still throw. Adds tests covering a non-tail malformed line in the newest segment, a malformed line in an older sealed segment, a line that fails the turn schema, and confirms store.load() still throws and names the segment.
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.
Closes CL-5935.
Problem
Operators resuming a TUI session sometimes saw the whole transcript replaced by a one-line error block: "Could not load prior session transcript: turns segment has malformed JSON at line N". A single non-null malformed or schema-invalid line anywhere in any segment aborted the entire display-only hydrate.
Why display and reactor differ
loadRecentTurns(TUI resume hydration) only needs a recent window for display, so a hole in it is a cosmetic loss — showing the surrounding history with one turn missing beats blanking the transcript. The reactor's ownContextStore.load()stays strict and unchanged: there, the turn history is the live conversation state, and silently dropping a turn would corrupt it.Change
parseSegmentTurnsgains askipMalformedparameter.loadRecentTurnsnow passes the real segment file name plusskipMalformed = true, so a bad line is logged and skipped instead of throwing.load()keeps the default (false) and throws as before.Tests
Added to the existing
loadRecentTurnsdescribe block:store.load()on the same corrupt fixture still throws, naming the segment fileContext
PR #479 attempted this fix before and was closed as superseded by #480, which fixed the writer root cause (null-padding) and reactor load recovery. The closure note explicitly named the remaining gap as display resilience for non-null mid-file garbage — that is exactly this change, nothing more.