Skip to content

feat: ✨ Add context and quota gauges to the status bar. - #72

Merged
abasiri merged 4 commits into
doctly:mainfrom
Flaykz:features/quota
Aug 1, 2026
Merged

feat: ✨ Add context and quota gauges to the status bar.#72
abasiri merged 4 commits into
doctly:mainfrom
Flaykz:features/quota

Conversation

@Flaykz

@Flaykz Flaykz commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds two lightweight usage indicators to the status bar to make session monitoring easier without opening the stats view.

  • add a context gauge for the active session based on the latest assistant usage entry found in the session .jsonl
  • add a 5h quota gauge using the existing usage data, with a shortcut to the Stats tab
  • expose the new session token IPC bridge from Electron main to the renderer
  • style both gauges and integrate them into the existing status bar layout
  • ignore local JetBrains .idea metadata files

Why

The goal is to surface the most useful runtime limits directly in the main UI:

  • current context consumption for the selected session
  • current 5h quota usage at a glance
    This reduces friction when deciding whether to continue in the same session or switch context.

Notes

  • the context gauge refreshes when a session becomes active and when Claude finishes responding
  • the quota gauge refreshes automatically every 5 minutes
  • both gauges stay hidden when no data is available

Testing

  • UI change only
  • not manually tested in this branch

Flaykz and others added 2 commits June 17, 2026 17:10
abasiri added a commit that referenced this pull request Aug 1, 2026
The `windows-latest` label rolled over to Windows Server 2025, whose image no longer ships the Visual Studio C++ toolchain node-gyp needs, so every Windows build failed in electron-builder's install-app-deps while rebuilding node-pty. Pinning to windows-2022 restores an image that still carries the toolchain.

Same fix @Flaykz independently included in #72; split out so it lands on its own.
Only conflict was .github/workflows/build.yml: this branch pinned the Windows
runner to windows-2022, and doctly#85 landed the same fix on main (credited to
@Flaykz, who found it independently) with a fuller comment explaining the
Windows Server 2025 toolchain removal. Took main's version, so the line is
identical and no longer carried here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@abasiri

abasiri commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Merging this — thanks. Two notes on what happens next, so nothing is a surprise.

I pushed a merge commit (a64d468) resolving the only conflict. Your windows-latestwindows-2022 pin was correct and landed separately as #85, where you're credited — you found that break independently, and it turned out to be why every Windows build had been failing. This branch now just takes main's copy of the line.

The context gauge is coming out in a follow-up, for two reasons.

Claude Code already renders the context window in its own statusline (/statusline), and it does it better than we can: it knows its actual limit, whereas we have to guess. Right now that guess is a constant —

const { contextTokens } = result;   // `model` is returned by the IPC handler, then dropped
const CTX_MAX = 200000;

— and on a 1M-context model that reads about 500% and stays pinned red. The handler already returns model, so it's fixable, but duplicating what /statusline shows natively isn't worth the maintenance.

The quota gauge is the good idea here, and I want to extend it. While reviewing this I went digging in the usage API and found the Stats tab was also missing data — /usage shows a per-model weekly bar that Switchboard never rendered:

Current session      1% used
Current week (all)  13% used
Current week (Fable) 8% used   ← this one

The cause: transformUsageResponse asked for bucket keys by name (seven_day_sonnet, seven_day_opus), and those now return null server-side, along with nine codenamed buckets. The live data moved into a self-describing limits array where each row carries its own kind, percent, reset time, and — for model-scoped windows — the model's display name. Fixed on main in 43ab0d0, so the Stats tab renders whatever rows come back and new models appear without a code change.

That matters for your gauge: it reads usage.session, the 5-hour bucket, which is usually the least informative of the three. Mine sits at 1% and resets in a few hours, while the weekly ones are at 13% and 8% — those are what actually constrain you. So the follow-up will point the status-bar gauge at the limits rows instead, most likely showing whichever window is fullest.

Net: your quota gauge is the part that survives and gets better. Appreciate the contribution — the status bar was the right place for this.

@abasiri
abasiri merged commit 57dee95 into doctly:main Aug 1, 2026
abasiri added a commit that referenced this pull request Aug 1, 2026
Follow-up to #72.

Quota: the gauge showed only the 5-hour window, which is usually the emptiest
and resets within the day — it reads "plenty left" while a weekly window is the
one actually running out. It now renders a bar per row of the usage API's
`limits` array (43ab0d0): a 5-hour session window, a weekly all-models window,
and a weekly window per model. Rows are self-describing, so shortQuotaLabel only
maps the two fixed kinds and otherwise uses the model's display name — a newly
launched model gets a bar with no code change here, which is precisely the
failure that had lost Sonnet and Opus. Each bar carries its own tooltip with the
full label and reset time; the group still clicks through to Stats. Tracks
narrowed 48px → 34px so several fit.

Context gauge: removed. Claude Code already renders context usage in its own
statusline (/statusline) and knows its real limit, where this had to guess —
the guess was a hardcoded 200000, so on a 1M-context model it read ~500% and sat
pinned red. Duplicating a native display isn't worth carrying, so this removes
refreshCtxGauge, CTX_MAX, fmtTokens, both call sites (setActiveSession and the
onCliBusyState handler — left in place they would have thrown ReferenceError on
every session switch), the #status-bar-ctx markup and CSS, the
get-session-tokens IPC handler, and its preload binding.

Also replaces the five individually-enumerated /.idea/ entries #72 added to
.gitignore with `.idea/` itself, so the whole JetBrains directory is covered
rather than the handful of files that happened to exist at the time.

Net -102/+68 while adding windows.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

2 participants