Skip to content

Commit 8ad0b39

Browse files
committed
feat: reorganize threshold config with dot-notation grouping and enabled toggle
- Rename warningThreshold → threshold.warning, criticalThreshold → threshold.critical - Add threshold.enabled (default: true) to allow disabling status bar coloring - Add order fields to control display order in VS Code Settings editor - Add order 0 to refreshIntervalMinutes for consistent ordering
1 parent 150947a commit 8ad0b39

2 files changed

Lines changed: 26 additions & 13 deletions

File tree

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,29 @@
4949
"default": 5,
5050
"minimum": 1,
5151
"maximum": 60,
52+
"order": 0,
5253
"description": "Auto-refresh interval in minutes."
5354
},
54-
"githubCopilotUsage.warningThreshold": {
55+
"githubCopilotUsage.threshold.enabled": {
56+
"type": "boolean",
57+
"default": true,
58+
"order": 0,
59+
"description": "Enable warning/critical threshold coloring in the status bar."
60+
},
61+
"githubCopilotUsage.threshold.warning": {
5562
"type": "number",
5663
"default": 75,
5764
"minimum": 1,
5865
"maximum": 100,
66+
"order": 1,
5967
"description": "Usage percentage at which the status bar text turns yellow."
6068
},
61-
"githubCopilotUsage.criticalThreshold": {
69+
"githubCopilotUsage.threshold.critical": {
6270
"type": "number",
6371
"default": 90,
6472
"minimum": 1,
6573
"maximum": 100,
74+
"order": 2,
6675
"description": "Usage percentage at which the status bar text turns red."
6776
}
6877
}

src/extension.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@ function updateStatusBar(data, isRateLimited = false) {
146146

147147
const pct = data.usedPct;
148148
let color;
149-
if (pct >= cfg.criticalThreshold) {
150-
color = new vscode.ThemeColor('editorError.foreground');
151-
} else if (pct >= cfg.warningThreshold) {
152-
color = new vscode.ThemeColor('editorWarning.foreground');
149+
if (cfg.thresholdEnabled) {
150+
if (pct >= cfg.thresholdCritical) {
151+
color = new vscode.ThemeColor('editorError.foreground');
152+
} else if (pct >= cfg.thresholdWarning) {
153+
color = new vscode.ThemeColor('editorWarning.foreground');
154+
}
153155
}
154156

155157
renderStatus({ text: `${pct}%`, tooltip: buildTooltip(data, isRateLimited), color });
@@ -171,9 +173,10 @@ function buildTooltip(data, isRateLimited) {
171173
md.appendMarkdown('Quota: Unlimited\n\n');
172174
} else {
173175
const cfg = vscode.workspace.getConfiguration('githubCopilotUsage');
174-
const warnPct = cfg.get('warningThreshold', 75);
175-
const critPct = cfg.get('criticalThreshold', 90);
176-
const dot = data.usedPct >= critPct ? '🔴' : data.usedPct >= warnPct ? '🟡' : '🟢';
176+
const thresholdEnabled = cfg.get('threshold.enabled', true);
177+
const warnPct = cfg.get('threshold.warning', 75);
178+
const critPct = cfg.get('threshold.critical', 90);
179+
const dot = thresholdEnabled ? (data.usedPct >= critPct ? '🔴' : data.usedPct >= warnPct ? '🟡' : '🟢') : '🟢';
177180
md.appendMarkdown(`Used: ${data.used} / ${data.quota} (${data.usedPct}%) ${dot}\n\n`);
178181
if (data.overageEnabled && data.overageUsed > 0) {
179182
md.appendMarkdown(`Overage: ${data.overageUsed} requests\n\n`);
@@ -256,13 +259,14 @@ function clearTimer() {
256259

257260
function getConfig() {
258261
const cfg = vscode.workspace.getConfiguration('githubCopilotUsage');
259-
const warning = cfg.get('warningThreshold', 75);
260-
const critical = cfg.get('criticalThreshold', 90);
262+
const warning = cfg.get('threshold.warning', 75);
263+
const critical = cfg.get('threshold.critical', 90);
261264
return {
262265
refreshIntervalMinutes: cfg.get('refreshIntervalMinutes', 5),
266+
thresholdEnabled: cfg.get('threshold.enabled', true),
263267
// Clamp warning to at most critical so misconfiguration (warning > critical) degrades gracefully.
264-
warningThreshold: Math.min(warning, critical),
265-
criticalThreshold: critical,
268+
thresholdWarning: Math.min(warning, critical),
269+
thresholdCritical: critical,
266270
};
267271
}
268272

0 commit comments

Comments
 (0)