Skip to content

Skip malformed turns lines in display-only resume hydrate (CL-5935) - #563

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-5935-display-hydrate-skips-non-null-malformed-turns-lines
Aug 23, 2026
Merged

Skip malformed turns lines in display-only resume hydrate (CL-5935)#563
TheGreatAxios merged 1 commit into
mainfrom
cl-5935-display-hydrate-skips-non-null-malformed-turns-lines

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

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 own ContextStore.load() stays strict and unchanged: there, the turn history is the live conversation state, and silently dropping a turn would corrupt it.

Change

parseSegmentTurns gains a skipMalformed parameter. loadRecentTurns now passes the real segment file name plus skipMalformed = 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 loadRecentTurns describe block:

  • non-tail malformed line in the newest segment: surrounding turns still load
  • malformed line in an older sealed segment: same
  • a line that parses as JSON but fails the turn schema: skipped the same way
  • reactor path unaffected: store.load() on the same corrupt fixture still throws, naming the segment file

Context

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.

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.
@linear-code

linear-code Bot commented Aug 23, 2026

Copy link
Copy Markdown

CL-5935

@TheGreatAxios
TheGreatAxios merged commit 1c59069 into main Aug 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant