Surface context window usage in the UI#1351
Merged
juliusmarminge merged 5 commits intomainfrom Mar 24, 2026
Merged
Conversation
- Normalize provider token-usage events into thread activities - Add a compact context window meter to chat - Handle context compaction markers in the timeline
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
- Let the tooltip width fit its content instead of wrapping - Keep the usage line on one row for readability
- Replace timeline marker treatment with normal grouped work rows - Switch context window meter to an SVG ring and show auto-compaction
- Increase ring stroke thickness for better visibility - Shrink the center badge to keep the meter balanced
- Replace the tooltip wrapper with a hover popover - Preserve the context window details popup behavior
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.
Summary
Testing
ClaudeAdapter,CodexAdapter,ProviderRuntimeIngestion,contextWindow,MessagesTimeline, and session logic.bun fmt,bun lint,bun typecheck, andbun run testbefore merge.Note
Surface context window usage in the chat UI with a token meter
ContextWindowMetercomponent to the chat composer bar that shows a circular SVG progress arc with used/remaining tokens and a popover with full details.ThreadTokenUsageSnapshotcontract, emittingthread.token-usage.updatedprovider runtime events at task progress and turn completion.thread.token-usage.updatedandthread.state.changed(statecompacted) runtime events to newcontext-window.updatedandcontext-compactionthread activities inProviderRuntimeIngestion.deriveLatestContextWindowSnapshotin contextWindow.ts to scan activities backwards for the latest usage snapshot, andformatContextWindowTokensfor compact k/m display.context-window.updatedactivities are excluded from the work log;context-compactionentries remain visible with their label.ThreadTokenUsageUpdatedPayloadnow validates usage against a strictThreadTokenUsageSnapshotschema — events that don't conform will fail decoding.Macroscope summarized 4747000.
Note
Medium Risk
Introduces a new validated
ThreadTokenUsageSnapshotschema and changesthread.token-usage.updatedpayload decoding/normalization; any producers sending unstructured usage data may now fail validation or be dropped. Also adds new activity kinds that affect timeline/work-log rendering, so regressions are possible if consumers assume the previous activity set.Overview
Projects provider runtime signals into new thread activities:
thread.token-usage.updatedbecomescontext-window.updated(with a structuredThreadTokenUsageSnapshotpayload) andthread.state.changedwithstate: "compacted"becomescontext-compaction.Updates Claude and Codex adapters to emit/unwrap normalized token-usage snapshots (handling multiple payload shapes and deriving Claude context-window size from
modelUsage), and updates the contracts schema sothread.token-usage.updatedis no longerSchema.Unknown.Adds a compact context window meter (
ContextWindowMeter) toChatViewdriven by the latestcontext-window.updatedactivity, plus UI/session-logic tweaks so context-window updates are excluded from the work log while compaction entries remain visible, with new test coverage across adapters, ingestion, and UI helpers.Written by Cursor Bugbot for commit 4747000. This will update automatically on new commits. Configure here.