Skip to content

fix(chat): show the Claude model /model and /effort set before the next answer - #2305

Merged
devswha merged 2 commits into
mainfrom
fix/model-pill-after-model-command
Oct 29, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/model-pill-after-model-command

Conversation

@devswha

@devswha devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner

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, because parseConversationMetadata read a Claude model only from an answer's message.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

  • Only the command's own output counts: a system / local_command entry (for its own command when commandRun names one), or a user entry that is the whole <local-command-stdout> output and carries no origin / 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 to claude-<family>-<major>[-<minor>], the inverse of modelLabel's rule; the family list and version rule are now shared with start-screen.ts. Set effort level to <low|medium|high|xhigh|max> and … with \` effort` set the effort.
  • Everything else fails closed and keeps the pill as it was: 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.
  • The next answer still names what it ran at and wins.

Tests

  • server/fixtures/claude-model-2.1.311.jsonl is a real Claude Code 2.1.311 recording (/model sonnet, /effort xhigh, a refused /model nosuchmodel, /effort ultracode, /model haiku, the /model picker closed), made with its own temporary config dir; paths are anonymized.
  • server/conversation-metadata.test.ts replays 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.
  • Real read path: transcriptPage("claude-transcript", …) on a growing transcript reads claude-opus-5-5 → claude-sonnet-5-5 right after /model sonnet (main stays on claude-opus-5-5).
  • bun run check fast green.

Reviews

  • omo-native-code-reviewer: PASS, no CRITICAL/HIGH/MEDIUM. Its LOWs: an unmapped name applied the line's effort beside the old model (fixed in 9cbf58d); the family list was duplicated with 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 no origin/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 (by modelLabel's rule).
  • Codex (gpt-6.1-sol, fast, xhigh): one MEDIUM: the value goes back to an older one once its record leaves the newest page (many records with no answer after it). Reproduced, and it happens the same way for an answer's message.model on main: the history scan indexes no Claude setting record for metadataHead(). 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

  • The pill shows the model Claude Code names (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.

…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.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1404433 and 9cbf58d.

Files selected for processing: 6
  • changelog.d/claude-model-pill-after-model.md
  • server/claude-transcript.ts
  • server/conversation-metadata.test.ts
  • server/conversation-metadata.ts
  • server/fixtures/claude-model-2.1.311.jsonl
  • server/start-screen.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Improvements
    • The Claude Code model and effort indicators now reflect confirmed /model and /effort changes. When a model name isn’t recognized, the existing model indicator remains until the next answer.
  • Bug Fixes
    • Model and effort information is now taken from relevant command results, while unrelated commands and responses don’t overwrite the displayed settings.

Claude transcript parsing now reads eligible /model and /effort command output and updates conversation metadata when the response matches supported forms. Tests cover recorded transcripts and unrecognized or unrelated output. A changelog entry describes when the composer’s model pill updates.

Changes: Claude transcript metadata

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: Normal

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: Passed 5
Check name Status Explanation
Description check Passed 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 heading…
Title check Passed The title clearly and concisely describes the main change: showing Claude /model and /effort selections before the next answer.
Linked Issues check Passed Issue [#2273] requires immediate Claude model-pill updates after confirmed /model and /effort changes. claudeCommandSetting reads eligible Claude command output, maps supported model names, appl…
Out of Scope Changes check Passed 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 produc…
Docstring Coverage Passed 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. Documentat…
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 /model and /effort changes. claudeCommandSetting reads 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.

❤️ Share

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

@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

CI note for the merge pass: on run 40804072759 attempt 1, Fast checks failed in scripts/plugin.test.ts:277 ("starts at the same moment > open one server between them, whose record stop finds": the stopped server's pid still answered kill(pid, 0)). This PR does not touch the plugin; the test passes locally (three check fast runs and a targeted run), and the one rerun of the failed job passed (attempt 2). All three required checks are green on 9cbf58d. CodeRabbit reviewed this head with no actionable comments.

@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Merging 9cbf58d (closes #2273). After /model or /effort in Claude Code, the chat's model pill now follows the new setting at once instead of at the next answer. parseConversationMetadata reads it from the command's own record in the transcript only: a local_command entry for that command, or a user entry that is the whole command output and was not typed (no origin/permissionMode); sidechains never count. The display name maps back to an id by the inverse of the start screen's rule (CLAUDE_FAMILY/VERSION now shared from start-screen.ts); a name of another form, a kept or refused answer, or an effort no answer records sets nothing, so the old value stays. Tested against a real Claude Code 2.1.311 recording (server/fixtures/claude-model-2.1.311.jsonl). The lane's evidence: check fast green, omo PASS, Codex PASS but for a MEDIUM that is pre-existing history paging, tracked as #2303; the merge pass read the diff.

@devswha
devswha merged commit 5d3b515 into main Oct 29, 2026
27 of 28 checks passed
@devswha
devswha deleted the fix/model-pill-after-model-command branch October 29, 2026 02:30
devswha added a commit that referenced this pull request Oct 29, 2026
#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.
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): the model pill keeps the old Claude model after /model until the next answer

1 participant