Skip to content

fix(chat): keep the Claude model and effort set before the newest page (#2303) - #2319

Merged
devswha merged 3 commits into
mainfrom
fix/claude-model-older-record
Oct 29, 2026
Merged

devswha merged 3 commits into
mainfrom
fix/claude-model-older-record

Conversation

@devswha

@devswha devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Summary

In a Claude Code pane, the composer's model pill and effort went back to an older model once the record that set the current one was neither in the transcript's first 64 KiB nor on the newest page: for example after a run of bash-mode commands, or a long tool output, with no answer after the change. This happened both for the model an answer names and for the /model / /effort output read since #2305.

Closes #2303.

Cause

When the newest page starts past METADATA_HEAD_BYTES, metadataHead() rebuilds the metadata from the head plus the setting records the history scan kept. applyHistoryBoundarySteps() kept model_change / thinking_level_change and Copilot's settings but no Claude record, so a Claude setting between the head and the page was lost.

Fix

  • claudeSetting(entry) (server/conversation-metadata.ts) is what one Claude record sets: an answer's message.model and effort (an explicit null too), or a /model / /effort answer. parseConversationMetadata now uses it, so the scan and the page read the same records the same way.
  • followClaudeBranch returns the record it parsed, and the history scan keeps every Claude record that set the model or effort since the last clear, with where it lies and a small line that sets the value again.
  • metadataHead() replays each field's latest record before the page that a /rewind fork (stream.hidden, including a slash-command echo fork) has not left off the branch, when the head does not hold it whole. A clear resets what is kept.
  • A record too long for the branch to follow (over 1 MiB without its pictures) is still read for its model and effort.

Tests

  • server/chat-history.test.ts: the model and effort an answer set, and those /model + /effort set, past the head stay when 130 answerless prompts follow, on warm, cold and incremental reads; a later answer wins until a rewind leaves it off the branch; a clear forgets them. A second test covers a value whose every record two rewinds left off the branch (with a visible record between them) and an answer over 1 MiB. All of these fail on main 010a44d; removing the fork check or the replay fails them too.
  • The issue's own reproduction through transcriptPage("claude-transcript", …): main prints claude-opus-5-5 / medium on the warm and cold read, this branch claude-sonnet-5-5 / xhigh (the whole-file parse).
  • bun run check fast green on 26f0918 (8428 pass, 0 fail).

Reviews

  • omo-native-code-reviewer and Codex (gpt-6.1-sol, fast, xhigh), adversarial and read-only, three rounds.
  • Round 1 (62ded61): both found the same MEDIUM. Records of one value were merged into one run, so a value whose every record two rewinds left off the branch came back when a visible record lay between them. Codex also found a MEDIUM: an answer over 1 MiB (after its pictures) was not read for its settings. Both fixed in 0594a6c, each with a test that fails without the fix.
  • Round 2 (0594a6c): both PASSed those fixes and found the same new MEDIUM. The head walked back one record at a time and sorted the hidden ranges again for each, so a newest-page read after many rewound answers took up to 1.5 s (500 forks x 100 answers). Fixed in 26f0918: the ranges are merged once per read and a hidden range is skipped with one binary search. The same case now takes 3.3 ms warm (main: 2.7 ms), and omo's per-append probe 1-2 ms.
  • Round 3 (26f0918, Codex): PASS, no findings; 50,000 randomized comparisons against the per-record rule of 0594a6c agree.
  • LOWs left (omo): a rewind made right after an answer over 1 MiB is not seen as a fork (that answer cannot be followed on the branch, which was so before; it now also names the model shown); parsing such a line for its settings costs one more parse, bounded by the scan's carry.

Known limits

  • Memory grows by one small entry per setting record (per field) since the last clear, as the branch's answer list already does: about 3.5 MB of heap for 20k alternating answers, per cached transcript (at most 32).
  • A record longer than the scan's carry (a picture past the largest the chat shows) is skipped whole, as for every other source, and its setting with it.

#2303)

When the newest transcript page starts past the 64 KiB metadata head, the head is rebuilt from the setting records the history scan kept, and the scan kept none for Claude: an answer's model and effort, or /model and /effort output, that was neither in the head nor on the page was lost and the pill went back to the head's older model.

The scan now keeps, per field, each value the Claude records took since the last clear (one run per value), and the head replays the latest one before the page that a /rewind fork has not left off the branch, as a small synthesized line. claudeSetting() is shared with parseConversationMetadata so both read the same records.

Closes #2303
…nd a long answer's

Review of #2303's fix: merging records of the same value into one run let a value every rewind left off the branch come back when a visible record lay between them; each setting record now counts by its own bytes. A record too long for the branch to follow (over 1 MiB without its pictures) still names its model and effort.
…etting

Review of #2303's fix: the head walked back one setting record at a time and sorted the hidden ranges again for each, so a newest-page read after many rewound answers blocked the event loop for up to 1.5 s. The ranges are merged once per read and a hidden range is skipped with a binary search.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 010a44d and 26f0918.

Files selected for processing: 5
  • changelog.d/claude-model-pill-older-record.md
  • server/chat-history.test.ts
  • server/conversation-metadata.ts
  • server/conversation.ts
  • server/transcript-turns.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Merging 26f0918 (closes #2303). The chat's model and effort pill could show the wrong values once a long Claude transcript paged past its setting records, or after a /rewind hid the newest one: the issue's transcript read opus/medium on main where Claude was on sonnet/xhigh. The scan now keeps each Claude model and effort record since the last clear (one small entry per record, sharing the string while a value repeats), and the metadata head replays the latest one that a /rewind did not leave off the branch. The lane's evidence: new tests fail on main; the issue's repro now reads sonnet/xhigh; check fast green; three review rounds (three MEDIUMs fixed), final Codex PASS and omo PASS. The merge pass read the diff.

@devswha
devswha merged commit f545c87 into main Oct 29, 2026
19 checks passed
@devswha
devswha deleted the fix/claude-model-older-record branch October 29, 2026 04:35
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.

fix(chat): a Claude model or effort goes back to an older one once its record leaves the newest page

1 participant