Skip to content

fix(sessions): scale context breakdown bar to the context window#2649

Draft
adboio wants to merge 1 commit into
mainfrom
posthog-code/context-bar-scale-to-window
Draft

fix(sessions): scale context breakdown bar to the context window#2649
adboio wants to merge 1 commit into
mainfrom
posthog-code/context-bar-scale-to-window

Conversation

@adboio

@adboio adboio commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

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 % full number or the ring above it — e.g. on a 1M-context model it could read ~75% full while % full said 19%. It looked like the segments should add up to the whole context window, but they didn't.

Changes

SegmentedBar now scales each segment to size (the context window) instead of used. The filled portion equals the % full figure 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

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from a Slack thread

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
@github-actions

Copy link
Copy Markdown

React Doctor could not complete this scan.

No React dependency found in /tmp/react-doctor-baseline-vjZXMz/package.json. Add "react" to dependencies (or peerDependencies) and re-run.

Reviewed by React Doctor for commit d3d9435.

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(sessions): scale context breakdown b..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant