Repository navigation
fix(chat): show the Claude model /model and /effort set before the next answer - #2305
Conversation
…xt answer Claude Code records a /model or /effort change only as the command's own output. Read that record so the composer pill follows it at once; a display name that does not map back to one claude-<family>-<major>[-<minor>] id, and every other answer, keeps the old value. Tested from a recorded Claude Code 2.1.311 transcript. Closes #2273
An unmapped name no longer applies the effort its line names beside the old model. Share Claude's family list and version rule with the start screen.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Command output and model-name inputs server/claude-transcript.ts, server/start-screen.ts |
localCommandStdout extracts trimmed stdout streams and excludes stderr. CLAUDE_FAMILY and VERSION are now exported without value changes. |
Parse and apply command settings server/conversation-metadata.ts |
The parser recognizes eligible /model and /effort command answers. Matching model output updates the model and may update effort; effort output updates effort. Unmatched output leaves existing metadata unchanged. |
Transcript validation and changelog server/fixtures/claude-model-2.1.311.jsonl, server/conversation-metadata.test.ts, changelog.d/claude-model-pill-after-model.md |
The fixture and tests cover model and effort updates, along with refused, unrecognized, malformed, or unrelated output. The changelog describes model-pill behavior after command confirmation. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: diegolhambi
Merge Risk: 
Low · up to 9cbf5
-
A pasted command confirmation can briefly show an incorrect model or effort in older Claude transcripts. The change is mergeable with that limitation.
Pre-merge checks: 
5
-
Full details: Description check
-
Explanation
The description explains the problem, resulting behavior, scope, linked issue, tests, and validation results. It uses Summary and Tests headings instead of the template’s Change and Validation headings, but the required information is present.
Full details: Linked Issues check
-
Explanation
Issue [
#2273] requires immediate Claude model-pill updates after confirmed/modeland/effortchanges.claudeCommandSettingreads eligible Claude command output, maps supported model names, applies supported effort values, and preserves prior values for refused, unrelated, or unsupported output. Existing assistant model and effort records still update metadata. The added fixture and tests cover accepted forms, fail-closed forms, filtering, and pre-answer updates.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within [
#2273]. The stdout helper and shared Claude model constants support parsing. The fixture, tests, and changelog document and verify the model-pill behavior. No unrelated product behavior is demonstrated.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 4 files. (2 skipped: 2 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- 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.
Comment @coderabbitai help to get the list of available commands.
|
CI note for the merge pass: on run 40804072759 attempt 1, Fast checks failed in |
|
Merging 9cbf58d (closes #2273). After |
#2303) (#2319) ## 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.
Summary
In a Claude Code pane, the composer's model pill kept the old model after
/model(and the old effort after/effort) until the next answer, becauseparseConversationMetadataread a Claude model only from an answer'smessage.model. It now also reads the command's own output record, so the pill follows the change as soon as Claude Code confirms it.Closes #2273. Thanks @jpcarranza94 for the report and the list of output forms.
How it reads the record
system/local_commandentry (for its own command whencommandRunnames one), or auserentry that is the whole<local-command-stdout>output and carries noorigin/permissionMode(a typed prompt does). Subagent entries, answers, other commands' output and a tag quoted in a prompt or in<command-args>set nothing.Set model to <name>maps only a plain<Family> <major>[.<minor>]name (optionally(1M context)/(default)) back toclaude-<family>-<major>[-<minor>], the inverse ofmodelLabel's rule; the family list and version rule are now shared withstart-screen.ts.Set effort level to <low|medium|high|xhigh|max>and… with \` effort` set the effort.Kept model as …,Model '…' not found, a refused model,Default (recommended)or any other name form (then the effort on the same line is not applied either),ultracode.Tests
server/fixtures/claude-model-2.1.311.jsonlis a real Claude Code 2.1.311 recording (/model sonnet,/effort xhigh, a refused/model nosuchmodel,/effort ultracode,/model haiku, the/modelpicker closed), made with its own temporary config dir; paths are anonymized.server/conversation-metadata.test.tsreplays it line by line and covers the reporter's forms (backticked, bare,(1M context),(default), ANSI bold,with \xhigh` effort`) and the fail-closed cases. Both new tests fail on main; each guard, removed on its own, fails a test.transcriptPage("claude-transcript", …)on a growing transcript readsclaude-opus-5-5→claude-sonnet-5-5right after/model sonnet(main stays onclaude-opus-5-5).bun run check fastgreen.Reviews
start-screen.ts(shared in 9cbf58d); an effort not at the end of the line or without backticks is not read (fails closed, no Claude Code version known to print it); a prompt that is exactly the output tag with noorigin/permissionMode(negligible); the 1M window stays after switching to a smaller model (pre-existing, now visible sooner); a dated id shows as the raw id after the next answer (bymodelLabel's rule).message.modelon main: the history scan indexes no Claude setting record formetadataHead(). Pre-existing and wider than this change, so filed as fix(chat): a Claude model or effort goes back to an older one once its record leaves the newest page #2303 with the reproduction and a suggested fix.Known limits
Haiku 4.5→claude-haiku-4-5); when the next answer names a dated id (claude-haiku-4-5-20251001), the pill shows that id as received.