Skip to content

Studio: optional Chart view with labelled axes for weekly and cumulative token activity - #13558

Merged
danielhanchen merged 7 commits into
mainfrom
studio-usage-chart-axes
Oct 13, 2026
Merged

danielhanchen merged 7 commits into
mainfrom
studio-usage-chart-axes

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #10807

Problem

Settings > Profile > Token activity has three modes. Daily is a heatmap, which works well as a calendar. Weekly and Cumulative reuse the same 7-row block grid: each week becomes a column of 0 to 7 filled squares, with no y-axis, tick marks or scale, so you cannot read how many tokens a week or the running total actually was without hovering every column.

Change

This is opt-in. Nothing changes by default.

  • In Weekly and Cumulative mode the card header now has a Chart toggle next to the Daily / Weekly / Cumulative switch. It is off by default, so the block grid stays exactly as it is today.
  • With Chart on, Weekly is drawn as a bar chart and Cumulative as a line chart, using the recharts setup the training charts already use (no new dependency). Both have a y-axis with compact token ticks (12K, 1.2M, localized) and an x-axis labelled with each week's start date.
  • The choice is remembered in local storage (unsloth_profile_activity_chart) and is cleared by Settings > General > Reset all like the other UI preferences.
  • Daily never shows the toggle and is unchanged. The chart plots the exact weeks the grid shows, so toggling never changes the time range.
  • The hover tooltip reuses the existing "Week of {date} · {tokens}" text: the week's total for Weekly, the running total for Cumulative.
  • New strings chartToggle / chartToggleHint are added to all 14 locales.
  • The card header now wraps its controls on narrow screens, so the extra toggle never pushes them past the card edge.

The per-week values come from a small weekChartPoints helper in stats-format.ts (the week total for Weekly, the end-of-week running total for Cumulative), covered by a new case in tests/profile-stats-format.test.ts.

About "Average tokens per chat"

The issue also asked why this reads 138K when chats top out at 20K to 30K. It is not caching. Every turn re-sends the whole conversation, so the stat counts tokens processed across all turns, not the final length of the chat. A chat that grows to a 24.5K context over 8 turns adds up to about 112K. This is the same way API providers count usage, so the number is left as is.

Testing

  • npm test: 11811 of 11814 pass; the 3 failures (reasoning-source-render, training-dataset-source-transitions) are unrelated and pass when rerun on their own.
  • tsc -b, tsc -p tsconfig.test.json clean; eslint and biome check clean on the changed files; tests/studio/test_ui_font_scale_contract.py passes (chart axis text follows the UI font scale through the existing .recharts-text rule).
  • Before / after on two separate Studio installs (main vs this branch) with the same seeded history (16 chats over 10 weeks, 195.6K tokens): the default view is the same block grid on both sides; with Chart on, both modes draw the charts, and the choice survives a reload.
  • At a 320 px settings width the header controls wrap instead of running past the card edge (overflow 0 px on main and on this branch).

Before and after

Screenshots from this branch's build (dcb9613) with the same seeded history (16 chats over 10 weeks, 195.6K tokens).

Default view, main vs this branch: the same block grid, plus the new Chart toggle (off):

Default view before and after

The opt-in on this branch, Chart off (default) vs Chart on, for Weekly and Cumulative:

Chart off vs Chart on

At a 320 px settings width with Chart on, the controls wrap inside the card:

Narrow width with Chart on

@danielhanchen danielhanchen self-assigned this Oct 13, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T11:48:34.323740Z dcb9613 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 34be53e3d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@danielhanchen danielhanchen changed the title Studio: draw weekly and cumulative token activity as charts with labelled axes Studio: optional Chart view with labelled axes for weekly and cumulative token activity Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37bcef8750

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +446 to +448
<div className="flex items-center gap-2">
{shaded ? null : (
<div className="hub-tab-toggle inline-flex h-8 w-fit items-center rounded-full">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Let the activity controls wrap on narrow screens

When Weekly or Cumulative is selected, this non-wrapping row contains the Chart button plus all three mode buttons. In the mobile settings layout, settings-dialog.tsx applies p-6 and StatsCard adds px-5, leaving only about 232px on a 320px viewport; these controls exceed that even in English and are wider in several translations. Because the action is also rendered as shrink-0, this causes horizontal scrolling or clipped controls, so the action/header should wrap or stack at narrow widths.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8ac687e: the card header now wraps and the action is capped to the card width, so at 320 px the controls stack (overflow 44 px before, 0 px after).

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 8ac687e338

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: dcb9613600

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
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.

[Feature] Unsloth Cumulative Token Usage Tracker needs Actual Line Graphs

1 participant