tiennm99 ee4e1c9b26 feat: redesign bubble as two-bar rounded rect, finish port wiring
Bubble shape changes from circle to rounded rectangle showing two stacked
horizontal bars — top: session (5h), bottom: weekly (7d) — each followed
by a right-aligned "X% · Yh Zm" string (percent + countdown).

Bubble surface:
- BubbleConfig/BubbleState carry session+weekly percents and texts (mirrors
  PanelData); update_percentage renamed to update_data
- Aspect ratio fixed at 3:1; size_logical is interpreted as width with
  height derived. Clamp is 120..360 (was 32..128 square)
- Hit-testing uses a rounded-rect predicate (point_in_rounded_rect) shared
  with the alpha mask so paint and click area can't drift
- New rgb_to_dib helper for direct DIB writes — BI_RGB 32bpp stores B,G,R,X
  in memory which is the opposite of COLORREF. The previous code wrote
  COLORREF-packed u32 straight into DIB pixels; invisible while every color
  was gray, but the new orange/red bar fills would have rendered blue
- bar_h capped at h/4 (range 6..18) so the text font derived from it stays
  small enough that "100% · 23h" fits in right_text_w (= 6×bar_h, min 56);
  the first iteration had a 19-px font in a 60-px column and ellipsized
  away the countdown
- Initial session_text/weekly_text seeded with "…" so the bubble has
  visible feedback during the first poll instead of two empty grey tracks

Compile + cleanup needed to make the port build at all:
- Color::from_hex added back as an infallible wrapper around parse_hex
  (15 call sites in bubble.rs/panel.rs assumed the old infallible API)
- Color::to_colorref → into_colorref at 5 call sites
- GetModuleFileNameW added to the LibraryLoader import in bubble.rs
- usage::Error gains Creds(#[from] creds::Error) so `?` works in the
  Anthropic and ChatGPT providers
- FlattenBoxed::flatten renamed to flatten_box — the std Option::flatten
  was shadowing it and yielding Option<Box<T>> instead of Option<T>
- PanelState marked unsafe Send (HWND has *mut c_void; state is only
  touched from the UI thread, Mutex is for OnceLock satisfaction)
- Crate-level #![allow(dead_code)] for in-progress port API surface
  (creds, usage, update, os::dpi); unused pub-use re-exports removed

App wiring:
- propagate_to_ui now feeds both windows + their formatted texts into
  update_data (was a single percent)
2026-05-16 11:11:34 +07:00

Windows License: Apache 2.0

Claude Code Usage Bubble

A floating, draggable circular bubble that shows your Claude Code and/or Codex usage on Windows — inspired by the floating "memory boost ball" UX of 360 Security and IObit Advanced SystemCare.

Drop it anywhere on screen, drag it around, snap it to a monitor edge, left-click for a panel with both your 5-hour and 7-day windows, right-click for the menu.

Acknowledgements

Inspired by CodeZeno/Claude-Code-Usage-Monitor, which solves the same "how close am I to the Claude Code limit?" problem with a horizontal taskbar widget. This project takes the UX in a different direction — a floating, draggable circular bubble that the user can place anywhere on screen — and is a clean-room implementation: the HTTP client, provider polling, credential discovery, localisation, tray rendering, and self-updater are all written from scratch against the same public APIs (Anthropic, ChatGPT, GitHub Releases).

What you get

  • A circular floating bubble showing your current 5-hour Claude Code or Codex usage as a percentage and a colored progress ring
  • Drag anywhere — the bubble snaps to monitor work-area edges when released
  • Resize with Ctrl + MouseWheel on the bubble (32128 pixels)
  • Left-click the bubble for an expanded panel with both 5h and 7d bars plus reset countdowns
  • Right-click for refresh, displayed models, update frequency, language, startup, updates, exit
  • Optional system tray icons (one per enabled model)
  • Auto-hide when a fullscreen app is in the foreground (games, video, presentations) — reappears when you leave fullscreen

Who this is for

Windows 10/11 users who already have Claude Code (CLI or App) installed and signed in. Codex support is optional — install and sign in to the Codex CLI, then enable Codex from the right-click Models menu.

If you use Claude Code through WSL, that is supported too. The monitor can read your Claude Code credentials from Windows or from your WSL environment.

Requirements

  • Windows 10 or Windows 11
  • Claude Code (CLI or App) installed and authenticated
  • Optional: Codex CLI installed and authenticated, if you want Codex usage

Install

Until packaged binaries are published, build from source:

git clone https://github.com/<your-fork>/claude-code-usage-bubble
cd claude-code-usage-bubble
cargo build --release

The binary lands at target/release/claude-code-usage-bubble.exe.

Use

Run claude-code-usage-bubble.exe. The bubble appears near the bottom-right corner of your primary monitor on first launch. Drag it where you want it, release to snap to the nearest edge if you let go close to one.

  • Left-click the bubble to open the expanded panel (5h + 7d + countdowns)
  • Right-click for refresh, models, update frequency, language, "Start with Windows", updates, exit
  • Drag anywhere — it floats on top of all other windows
  • Ctrl + MouseWheel on the bubble to resize it
  • Tray icon (if enabled): left-click toggles the bubble visibility, right-click opens the same menu

Models

Use the right-click Models menu to choose what is shown:

  • Claude Code is enabled by default
  • Codex can be enabled alongside Claude Code or shown by itself

When both models are shown, each gets its own bubble that you can position independently.

Diagnostics

claude-code-usage-bubble.exe --diagnose

This writes a log file to:

%TEMP%\claude-code-usage-bubble.log

Settings are saved to:

%APPDATA%\ClaudeCodeUsageBubble\settings.json

Privacy and security

What the app reads:

  • Your local Claude Code OAuth credentials from ~/.claude/.credentials.json
  • If needed, the same credentials file inside an installed WSL distro
  • If Codex is enabled, your local Codex credentials from $CODEX_HOME/auth.json or ~/.codex/auth.json

What the app sends over the network:

  • Requests to Anthropic's Claude endpoints to read your usage
  • Requests to ChatGPT's Codex usage endpoint, if Codex is enabled
  • Requests to GitHub only if you use the app's update-check feature

What the app stores locally:

  • Bubble position(s) per model
  • Bubble size
  • Polling frequency
  • Language preference
  • Last update check time
  • Displayed model preferences

What it does not do: send credentials to any third-party server, run a backend service, collect analytics, upload your project files, or write to your Codex auth.json directly.

License

Apache License 2.0 — see LICENSE.

S
Description
Floating, draggable bubble showing Claude Code and Codex usage on Windows. Drag anywhere, snap to edges, click to expand.
Readme Apache-2.0 1.4 MiB
Languages
Rust 100%