Repository navigation
feat: show a conversation's context size and token usage - #74
Merged
Merged
Conversation
A line under the composer shows the current context size, against the selected model's window when the catalog states one, and the tokens the conversation has used. Image analysis reports its vision model usage on the tool result so the total includes it. A reader's own custom endpoint now declares an unknown context window instead of a guessed 128k. The attachment, model and effort controls move under the input box, beside the token usage, so the box holds only the text and the send button. Selects draw their own chevron, since the native one sits against the edge, and the model select fits the chosen option.
This was referenced Oct 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
A line under the composer shows two numbers, e.g.
9.1K / 1M · 35.3K used:estimateContextTokens, against the selected model'scontextWindowwhen the catalog states one.Hovering shows exact numbers, the context percentage, and input/output. Both are computed from the saved messages, so a reopened conversation shows them straight away.
Related changes
analyze_imageandanalyze_pdf_pagecall the vision model themselves. They now report its usage on the tool result (Meteredintool.ts). Pi keeps it out of the context, and the "used" total includes it.contextWindowwas a guessed 128k. Pi 1.0 uses it to capmaxTokensonce a conversation nears it. It is now0, which pi reads as unknown, and no window is shown.field-sizing: contentso its width fits the chosen option rather than the longest one.Verification
pnpm checkpasses.