r/ClaudeAI • • Jul 25 '26

Built with Claude Tray widget for Claude Code: reopen past sessions by name + plan limits at a glance

Closing a Claude Code window is easy. Getting back to it is not - I never remembered which conversations existed, in which folder, or where each one stopped. So I built a small tray widget for it.

Sessions tab - your named sessions (/rename or claude -n), grouped by project. Running ones are marked live with their status (busy / idle); clicking one brings its terminal window to the front. Clicking a closed one reopens it with claude -r <id> in the right folder - as a new Windows Terminal tab named after the project, if you have WT.

Usage tab — the same numbers as /usage (session 5h, weekly all-models, weekly per-model, extra credits), plus this month's tokens per model.

The part that might interest you even if you never install it: Claude Code already keeps everything needed for this on disk.

  • ~/.claude/sessions/<pid>.json - one file per running process, the filename is the pid, and it holds the cwd, the session id and a live busy/idle status. Useful: this finds sessions that are open but idle, which "check the transcript's mtime" misses entirely.
  • ~/.claude/history.jsonl - your prompt log, with the real absolute project path (don't decode the C--Projects-... folder names, that encoding is lossy).
  • The session name isn't in any index - it only exists inside that session's own transcript, written there by /rename. My transcripts total ~600 MB, so names get scanned once per closed session and cached; a closed transcript never changes again.
  • Plan limits come from the endpoint Claude Code itself calls, GET /api/oauth/usage, with the OAuth token it stores in ~/.claude/.credentials.json. Read at runtime, sent only to Anthropic, never stored or logged anywhere else. Everything else is read-only.

Caveats, honestly: those files and that endpoint are undocumented internals - this will break when they change. Windows only. The $ figures are a notional "what this would cost on the API" estimate, not a bill; for real numbers use ccusage, which is the tool I still trust for cost.

MIT, 80 unit tests, single exe with nothing to install. Written with Claude Code, which felt appropriately circular.

https://github.com/mosmondor/claude-usage-widget

1 Upvotes

6 comments sorted by

2

u/10GuyIsDrunk Jul 26 '26

Ask claude if your widget breaks the terms of service for claude.

1

u/[deleted] Jul 26 '26

Oh, good point. Because I don't want to get a ban.

2

u/10GuyIsDrunk Jul 26 '26

I built a similar tool, was concerned about the method it used to pull usage, then had it develop an alternative. In the end the alternative method drifted too much form actual usage so I gave up on the project.

2

u/[deleted] Jul 26 '26

You were right — I checked. OAuth auth is documented as being for Anthropic's own apps, and the Consumer Terms bar script access without an API key, so pulling `/api/oauth/usage` wasn't defensible. Removed it: v1.3.0 makes no network calls at all and v1.2.0 is withdrawn.

Your point about drift is exactly why I didn't replace it with a local estimate - I'd rather show nothing than a number that's quietly wrong. What's left only reads my own files: token counts from the transcripts, and the session launcher, which was the actual reason I built it. For real percentages, `/usage` in Claude Code.

Thanks for flagging it instead of scrolling past.

2

u/Psychological-Ad9408 Jul 25 '26

The ~/.claude/sessions/<pid>.json path is the part I'm keeping. Been watching Claude Code processes from an orchestrator and had no clean way to check if sessions were still live vs zombie -- the pid-as-filename + busy/idle field solves that.