fix(tui): use current model for sidebar context limit after model switch#35287
Open
tiffanychum wants to merge 1 commit into
Open
fix(tui): use current model for sidebar context limit after model switch#35287tiffanychum wants to merge 1 commit into
tiffanychum wants to merge 1 commit into
Conversation
The sidebar Context percentage was computed from the model of the last assistant message (last.providerID/last.modelID). After switching models mid-session, it kept using the previous model's context window, so the percentage was wrong (e.g. still 50% when the new, smaller model should read far higher). Prefer the currently selected model via useLocal().model.current(), and fall back to the last assistant message's model when no model is selected yet. Token count still comes from the last message; only the limit basis changes. Fixes anomalyco#35072
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.
Issue for this PR
Closes #35072
Type of change
What does this PR do?
The sidebar "Context" percentage is computed from the model of the last assistant message (
last.providerID/last.modelID). After switching models mid-session, it keeps dividing the token count by the previous model's context window, so the percentage is wrong (e.g. it stays at 50% even after switching to a smaller-context model where it should read much higher).The fix reads the currently selected model from
useLocal().model.current()and uses that model'slimit.contextfor the percentage, falling back to the last assistant message's model when nothing is selected yet. The token count is unchanged — only which model's context limit we divide by changes.How did you verify your code works?
local.model.current()returns the live selected{ providerID, modelID }(the same source the prompt and model dialogs use), and that the sidebar slot renders insideLocalProvider, souseLocal()is valid in this plugin (other sidebar/session feature-plugins already call it).turbo typecheck); all packages pass.Screenshots / recordings
This is a TUI numeric readout, not a visual component. Behavior change: start a session on a model, switch to a model with a different context window, and the "% used" in the sidebar now recalculates against the newly selected model's limit instead of staying pinned to the old model's.
Checklist