feat(web): expand context meter into a session context tab#2799
feat(web): expand context meter into a session context tab#2799imabdulazeez wants to merge 7 commits into
Conversation
- SessionContextTab component displays token usage, distribution by role, and raw messages - Utilities for extracting metrics from thread state and estimating token breakdown - Wire context tab into chat UI via onOpenContextTab callback
- Add fallback to cumulative token fields (input, output, etc) - Prefer usedTokens for total calculation - Filter empty, zero, and dash values from metrics display - Enhance button accessibility with focus-visible styles - Remove cacheWrite field from metrics
Use group/meter to prevent hover state conflicts with nested elements
- Make ContextWindowMeter callback required and remove popover fallback - Add total processed tokens and auto-compaction status to metrics - Update context tab title and improve stat layout
|
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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review Unable to check for correctness in 6bbad50. This PR introduces a new feature with significant new UI components (SessionContextTab, metrics, breakdown logic) and new user-facing navigation behavior. New features introducing new user-facing capabilities warrant human review. You can customize Macroscope's approvability policy. Learn more. |
|
CI passes locally, not sure how to fix this without modifying the ci.yml file |
What Changed
Adds a "Session context" tab that opens from the context window meter in the composer (Inspired by OpenCode).
Why
Today the only context-window signal in the UI is the small ring in the composer footer. For long sessions it's hard to answer:
Surfacing this in a dedicated tab (rather than a hover popover) keeps the composer footer compact while giving an auditable view when the user actually wants to inspect a session. The breakdown is explicitly an estimate, useful for "where is my context going?" intuition without claiming provider-exact accounting.
Click the context ring to trigger this
Related: #2518 (compact per-turn session stats footer) asks for a related but per-turn view; this PR adds the session-level counterpart. Not intended to close that issue.
Distinct from #1732, which surfaces account-level provider quota (session/weekly plan usage) in Settings; this PR is about per-thread context-window usage shown off the composer.
UI Changes
Context Tab
Checklist
Note
Expand context meter into a session context tab in the chat thread route
SessionContextTabright-hand panel that displays token usage, a per-role breakdown bar, and a collapsible raw messages list, driven by newgetSessionContextMetricsandestimateSessionContextBreakdownutilities.tab=contextURL search param that opens the panel inline (resizable sidebar) or in a sheet on narrow layouts, with width persisted to local storage.ContextWindowMeterfrom a hover popover to a clickable button that setstab=contextin the URL.ContextWindowMeteris now only rendered when anonOpenContextTabhandler is provided, so it is hidden in contexts that don't support the tab.tabsearch param, and vice versa;stripDiffSearchParamsalso stripstab.Macroscope summarized 6bbad50.