Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ upstream release: 1.0.8). Format follows [Keep a Changelog](https://keepachangel
## [Unreleased]

### Added
- **`claudeCodeUsage.showOpusWeekly` setting** — opt-in (default off) that
appends the weekly Opus limit (`opus:NN%`) to the status-bar quota item,
after the 5-hour and weekly figures. Only shown when the account has a live
weekly-Opus window.
- **Context-window indicator** in the status bar — shows the current
session's context fill as a percentage (like `/context`), estimated from
the latest log record (`input + cache read + cache write` tokens vs the
Expand Down
1 change: 1 addition & 0 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Open Settings (`Ctrl+,`) and search for **`Claude Code Usage`**. All settings ar
- `language` — UI language (`auto` / `en` / `zh-TW` / `zh-CN` / `ja` / `ko`).
- `timezone` — IANA timezone for date display (e.g. `Asia/Hong_Kong`).
- `usageLimitTracking` — show the real 5h / weekly quota indicator.
- `showOpusWeekly` — also append the weekly Opus limit (`opus:NN%`) after the 5h / weekly figures (off by default).
- `showCost` / `showContext` — toggle the cost item and the context-window fill indicator (like `/context`) in the status bar.
- Each of these status-bar items is opt-out — set `usageLimitTracking`, `showCost`, or `showContext` to `false` to hide just that one.
- `advice.apiKey` — API key for the AI advice feature (OpenAI-compatible).
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ reasonable.
| `compactNumbers` | `false` | Show `1.2M` / `345K` instead of full numbers. |
| `timezone` | `""` | IANA timezone for date display (e.g. `Asia/Hong_Kong`). |
| `usageLimitTracking` | `true` | Show real 5h / weekly quota in the status bar. |
| `showOpusWeekly` | `false` | Also show the weekly Opus limit (`opus:NN%`) in the status bar, after the 5h / weekly figures. |
| `showCost` | `true` | Show today's cost item in the status bar. |
| `showContext` | `true` | Show the current session's context-window fill (like `/context`). Set this, `showCost`, or `usageLimitTracking` to `false` to hide that status-bar item. |
| `enableContentAnalysis` | `true` | Run the Content tab token analysis. |
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
"default": true,
"description": "Show real 5-hour and weekly limit utilisation in the status bar. Uses Claude Code's existing sign-in (~/.claude/.credentials.json or macOS Keychain) — no configuration needed."
},
"claudeCodeUsage.showOpusWeekly": {
"type": "boolean",
"default": false,
"description": "Also show the weekly Opus limit (opus:NN%) in the status bar, after the 5-hour and weekly figures. Requires usage-limit tracking to be enabled."
},
"claudeCodeUsage.advice.apiKey": {
"type": "string",
"default": "",
Expand Down
5 changes: 3 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class ClaudeCodeUsageExtension {
I18n.setDecimalPlaces(config.decimalPlaces);
I18n.setCompactNumbers(config.compactNumbers);
I18n.setTimezone(config.timezone);
this.statusBar.setVisibility(config.showCost, config.showContext);
this.statusBar.setVisibility(config.showCost, config.showContext, config.showOpusWeekly);

// Listen for configuration changes
vscode.workspace.onDidChangeConfiguration(e => {
Expand All @@ -299,6 +299,7 @@ export class ClaudeCodeUsageExtension {
showCost: config.get('showCost', true),
showContext: config.get('showContext', true),
usageLimitTracking: config.get('usageLimitTracking', true),
showOpusWeekly: config.get('showOpusWeekly', false),
// apiKey is the gate for the advice feature: ONLY read the new dotted
// key. We deliberately do NOT fall back to the pre-2.0 flat
// `adviceApiKey` here — otherwise users who clear the new key in
Expand Down Expand Up @@ -326,7 +327,7 @@ export class ClaudeCodeUsageExtension {
I18n.setDecimalPlaces(config.decimalPlaces);
I18n.setCompactNumbers(config.compactNumbers);
I18n.setTimezone(config.timezone);
this.statusBar.setVisibility(config.showCost, config.showContext);
this.statusBar.setVisibility(config.showCost, config.showContext, config.showOpusWeekly);

// Restart auto-refresh with new interval
this.startAutoRefresh();
Expand Down
12 changes: 10 additions & 2 deletions src/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class StatusBarManager {
// Per-item visibility, driven by the showCost / showContext settings.
private showCost: boolean = true;
private showContext: boolean = true;
// When true, append the weekly Opus limit (opus:NN%) to the quota item.
private showOpusWeekly: boolean = false;

constructor() {
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
Expand Down Expand Up @@ -39,9 +41,10 @@ export class StatusBarManager {
/** Apply the showCost / showContext settings. Hiding takes effect
* immediately; re-showing happens on the next data update (the caller
* triggers a refresh right after a config change). */
setVisibility(showCost: boolean, showContext: boolean): void {
setVisibility(showCost: boolean, showContext: boolean, showOpusWeekly: boolean = false): void {
this.showCost = showCost;
this.showContext = showContext;
this.showOpusWeekly = showOpusWeekly;
if (!showCost) {
this.statusBarItem.hide();
}
Expand Down Expand Up @@ -172,7 +175,8 @@ export class StatusBarManager {
const live = this.liveWindows(usageLimits);
const fiveHour = live?.five_hour;
const weekly = live?.seven_day;
if (!fiveHour && !weekly) {
const opus = live?.seven_day_opus;
if (!fiveHour && !weekly && !(this.showOpusWeekly && opus)) {
Comment on lines 175 to +179
this.quotaItem.hide();
return;
}
Expand All @@ -187,6 +191,10 @@ export class StatusBarManager {
worstPct = Math.max(worstPct, weekly.utilization);
parts.push(`wk:${Math.round(weekly.utilization)}%`);
}
if (this.showOpusWeekly && opus) {
worstPct = Math.max(worstPct, opus.utilization);
parts.push(`opus:${Math.round(opus.utilization)}%`);
}

this.quotaItem.text = `$(dashboard) ${parts.join(' ')}`;

Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ export interface ExtensionConfig {
showContext: boolean;
// Fetch real 5-hour / weekly limit utilisation via Claude Code's OAuth session.
usageLimitTracking: boolean;
// Append the weekly Opus limit (opus:NN%) to the status-bar quota item.
// Independent of the 5h/weekly figures; requires usageLimitTracking.
showOpusWeekly: boolean;
// LLM "usage advice" feature (OpenAI-compatible endpoint, e.g. DeepSeek).
adviceApiKey: string;
adviceApiUrl: string;
Expand Down
Loading