fix(tui): use current model for context-limit display after switch#35542
Open
chethanuk wants to merge 1 commit into
Open
fix(tui): use current model for context-limit display after switch#35542chethanuk wants to merge 1 commit into
chethanuk wants to merge 1 commit into
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: POTENTIAL DUPLICATE FOUND:
Why it's related: PR #35287 appears to address the same issue (issue #35072) with nearly identical scope: fixing the context-limit display in the TUI sidebar to use the current model after a model switch. The title is extremely similar to PR #35542, and both target the same files and fix the same root cause. Please check PR #35287 to determine if it's already merged or if PR #35542 is a duplicate submission. |
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
Addresses upstream #35072. Opened against my own fork first as a staging/review step — not raised upstream yet.
Type of change
What does this PR do?
The context-limit percentage derived its denominator from the last assistant message's model. After a mid-session model switch it kept showing the previous model's limit until a new assistant message arrived — e.g. switching from a 128k model to a 32k model still displayed the 128k-based percentage.
The fix uses the currently-selected model (
local.model.current()) as the denominator, falling back to the last assistant message's model when nothing is selected yet:packages/tui/src/component/prompt/index.tsx— composer footer usage memo.packages/tui/src/feature-plugins/sidebar/context.tsx— the sidebar meter named in the issue. The sidebar can display a subagent session, where the global model picker is unrelated to the subagent's own model, so it usescurrent()only for top-level sessions (via asession()?.parentIDguard) and otherwise keeps the session's own last-message model.Token count still comes from the last message (real occupancy); only the limit denominator changed.
subagent-footer.tsxis intentionally left unchanged — a completed subagent's model is fixed, so its last-message model is already the correct denominator there.How did you verify your code works?
bun run typecheck(tsgo) inpackages/tuipasses clean.local.model.current()resolves to the just-selected model, so the denominator updates on the next render instead of waiting for an assistant reply. The?? last-message fallback preserves the pre-existing behavior when no model is selected yet, and both call sites readcurrent()inside acreateMemo, so reactive tracking is preserved.Screenshots / recordings
TUI-only change; no screenshot.
Checklist