feat: composer context chip recalculates live — task selector and model switches - #319
Merged
Conversation
Two gaps between the context panel and the chip under it: - Working the panel's task selector reprojected every figure inside the panel and left the composer chip on the last built prompt, so the one readout that survives closing the panel never showed the number just chosen. The chip now renders the same projection the panel does (selectComposerContextUsage): stepping the dial moves the minibar gauge, token pair and task count on the same render, and the draft keeps driving the chip until a prompt is actually built against it. - Switching the active chat model (or provider) left the chip gauging against the window the *previous* model's prompt was built with, because resolveWindow prefers the prompt-derived window over every live source. A providers_refresh that changes the active text route now drops that stale window, so the chip re-gauges from the health poller / catalogue for the newly chosen model immediately instead of one prompt build later.
This was referenced Sep 2, 2026
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.
What
The composer's context chip (the minibar readout) now re-renders instantly when anything that changes the context math happens, instead of waiting for the next prompt build:
Task selector. The context panel's selector already reprojected every figure inside the panel, but the chip under it kept showing the last built prompt — so the one readout that survives closing the panel never reflected the number just chosen. The chip now renders the same projection the panel uses (
usageAtPairs, via a newselectComposerContextUsageselector): every step of the dial immediately moves the chip's gauge, theN/M tasksfigure, and the token pair. The draft keeps driving the chip until a prompt is actually built against it (prompt_builtalready retires the draft on that match), so the chip and panel tell one story.Model / provider switch.
resolveWindowprefers the window the last prompt was built against over every live source, so after switching the active chat model the chip kept gauging against the previous model's window until the next message. Aproviders_refreshthat changes the active text route (provider id or chat model) now drops the stale prompt-derived window, letting the chip fall through to the health poller / catalogue and re-gauge for the new model on the very render that shows the switch. Ordinary refreshes and the first population of the rows keep the measured window.Tests
selectComposerContextUsage: no draft → measured view; draft above the session's real task count → projection clamps to the tasks that exist; draft below → oldest task priced out; draft equal to the cap → measured view (no estimate swap on a no-op).providers_refresh: model change and provider handover drop the window (measured token count untouched); same-route refresh and first population keep it.tsc --noEmitclean; context-chip, context-panel, tui-app, reducer suites pass.Related: #318 fixes the measurement itself (KV-cached prompt tokens were dropped from the readout); this PR makes the surfaces react. The two are independent.