fix(sessions): scale context breakdown bar to the context window#2649
Draft
adboio wants to merge 1 commit into
Draft
fix(sessions): scale context breakdown bar to the context window#2649adboio wants to merge 1 commit into
adboio wants to merge 1 commit into
Conversation
The segmented bar in the context usage popover scaled each segment by the used token count, so it sat partially filled with no clear meaning for the empty portion and never matched the "% full" figure or the ring. Scale segments to the model's context window instead, so the filled portion equals the percentage and the empty track reads as remaining context. Generated-By: PostHog Code Task-Id: 0f255a6d-d48f-48cd-86fe-f18974414c9c
|
React Doctor could not complete this scan.
Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(sessions): scale context breakdown b..." | Re-trigger Greptile |
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.
Problem
The context-usage popover (opened by clicking the token percentage on a task) renders a segmented bar whose segments were scaled to the used token count rather than the model's context window. That made the bar sit partially filled with no clear meaning for the empty portion, and it never matched the
% fullnumber or the ring above it — e.g. on a 1M-context model it could read ~75% full while% fullsaid 19%. It looked like the segments should add up to the whole context window, but they didn't.Changes
SegmentedBarnow scales each segment tosize(the context window) instead ofused. The filled portion equals the% fullfigure and the ring, and the leftover empty track genuinely reads as remaining context. Added a test asserting a 50K-of-200K segment fills a quarter of the bar.How did you test this?
pnpm --filter @posthog/ui exec vitest run ContextBreakdownPopover— 4 passed (including the new scaling test).Automatic notifications
Created with PostHog Code from a Slack thread