Spaces:
Paused
Paused
icebear0828 Claude Opus 4.6 commited on
Commit ·
247b874
1
Parent(s): 4f2220c
fix: window counter review issues — opacity modifier, catch-up spam, rounding
Browse files- text-dim color uses <alpha-value> interpolation so dark:text-text-dim/70 works
- Multi-window catch-up jumps to correct window in one step (no log spam)
- formatWindowDuration uses Math.floor instead of Math.round
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- src/auth/account-pool.ts +6 -3
- web/src/utils/format.ts +3 -3
- web/tailwind.config.ts +1 -1
src/auth/account-pool.ts
CHANGED
|
@@ -430,16 +430,19 @@ export class AccountPool {
|
|
| 430 |
|
| 431 |
// Auto-reset window counters when window has expired
|
| 432 |
const windowResetAt = entry.usage.window_reset_at;
|
| 433 |
-
|
|
|
|
| 434 |
console.log(`[AccountPool] Window expired for ${entry.id} (${entry.email ?? "?"}), resetting window counters`);
|
| 435 |
entry.usage.window_request_count = 0;
|
| 436 |
entry.usage.window_input_tokens = 0;
|
| 437 |
entry.usage.window_output_tokens = 0;
|
| 438 |
entry.usage.window_counters_reset_at = now.toISOString();
|
| 439 |
-
//
|
| 440 |
const windowSec = entry.usage.limit_window_seconds;
|
| 441 |
if (windowSec && windowSec > 0) {
|
| 442 |
-
|
|
|
|
|
|
|
| 443 |
} else {
|
| 444 |
entry.usage.window_reset_at = null; // Wait for backend sync to correct
|
| 445 |
}
|
|
|
|
| 430 |
|
| 431 |
// Auto-reset window counters when window has expired
|
| 432 |
const windowResetAt = entry.usage.window_reset_at;
|
| 433 |
+
const nowSec = now.getTime() / 1000;
|
| 434 |
+
if (windowResetAt != null && nowSec >= windowResetAt) {
|
| 435 |
console.log(`[AccountPool] Window expired for ${entry.id} (${entry.email ?? "?"}), resetting window counters`);
|
| 436 |
entry.usage.window_request_count = 0;
|
| 437 |
entry.usage.window_input_tokens = 0;
|
| 438 |
entry.usage.window_output_tokens = 0;
|
| 439 |
entry.usage.window_counters_reset_at = now.toISOString();
|
| 440 |
+
// Jump to the correct current window (handles multi-window catch-up in one step)
|
| 441 |
const windowSec = entry.usage.limit_window_seconds;
|
| 442 |
if (windowSec && windowSec > 0) {
|
| 443 |
+
let nextReset = windowResetAt + windowSec;
|
| 444 |
+
while (nextReset <= nowSec) nextReset += windowSec;
|
| 445 |
+
entry.usage.window_reset_at = nextReset;
|
| 446 |
} else {
|
| 447 |
entry.usage.window_reset_at = null; // Wait for backend sync to correct
|
| 448 |
}
|
web/src/utils/format.ts
CHANGED
|
@@ -6,14 +6,14 @@ export function formatNumber(n: number): string {
|
|
| 6 |
|
| 7 |
export function formatWindowDuration(seconds: number, isZh: boolean): string {
|
| 8 |
if (seconds >= 86400) {
|
| 9 |
-
const days = Math.
|
| 10 |
return isZh ? `${days}天` : `${days}d`;
|
| 11 |
}
|
| 12 |
if (seconds >= 3600) {
|
| 13 |
-
const hours = Math.
|
| 14 |
return isZh ? `${hours}小时` : `${hours}h`;
|
| 15 |
}
|
| 16 |
-
const minutes = Math.
|
| 17 |
return isZh ? `${minutes}分钟` : `${minutes}m`;
|
| 18 |
}
|
| 19 |
|
|
|
|
| 6 |
|
| 7 |
export function formatWindowDuration(seconds: number, isZh: boolean): string {
|
| 8 |
if (seconds >= 86400) {
|
| 9 |
+
const days = Math.floor(seconds / 86400);
|
| 10 |
return isZh ? `${days}天` : `${days}d`;
|
| 11 |
}
|
| 12 |
if (seconds >= 3600) {
|
| 13 |
+
const hours = Math.floor(seconds / 3600);
|
| 14 |
return isZh ? `${hours}小时` : `${hours}h`;
|
| 15 |
}
|
| 16 |
+
const minutes = Math.floor(seconds / 60);
|
| 17 |
return isZh ? `${minutes}分钟` : `${minutes}m`;
|
| 18 |
}
|
| 19 |
|
web/tailwind.config.ts
CHANGED
|
@@ -13,7 +13,7 @@ export default {
|
|
| 13 |
"card-dark": "#161b22",
|
| 14 |
"border-dark": "#30363d",
|
| 15 |
"text-main": "#e6edf3",
|
| 16 |
-
"text-dim": "
|
| 17 |
},
|
| 18 |
fontFamily: {
|
| 19 |
display: [
|
|
|
|
| 13 |
"card-dark": "#161b22",
|
| 14 |
"border-dark": "#30363d",
|
| 15 |
"text-main": "#e6edf3",
|
| 16 |
+
"text-dim": "rgb(139 148 158 / <alpha-value>)",
|
| 17 |
},
|
| 18 |
fontFamily: {
|
| 19 |
display: [
|