Skip to content

fix(tui): use current model for sidebar context limit after model switch#35287

Open
tiffanychum wants to merge 1 commit into
anomalyco:devfrom
tiffanychum:fix/35072-context-stale-model
Open

fix(tui): use current model for sidebar context limit after model switch#35287
tiffanychum wants to merge 1 commit into
anomalyco:devfrom
tiffanychum:fix/35072-context-stale-model

Conversation

@tiffanychum

Copy link
Copy Markdown

Issue for this PR

Closes #35072

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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's limit.context for 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?

  • Confirmed local.model.current() returns the live selected { providerID, modelID } (the same source the prompt and model dialogs use), and that the sidebar slot renders inside LocalProvider, so useLocal() is valid in this plugin (other sidebar/session feature-plugins already call it).
  • Ran the monorepo typecheck (the repo's pre-push hook runs 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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
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: context limit display uses stale model after model switch

1 participant