| index 71cfa44..645fe87 100644 | ||
| --- a/plugin.json | ||
| +++ b/plugin.json | ||
| @@ -2,8 +2,8 @@ | ||
| 2 | 2 | "slug": "google-quota", |
| 3 | 3 | "id": "plugin_google_quota", |
| 4 | 4 | "title": "Google Account Quotas", |
| 5 | - "version": "1.0.2", | |
| 6 | - "summary": "Zero-dependency Google Antigravity multi-account quota monitor and active-account switcher for your node. Reads the local antigravity_accounts.json and selected_account.txt files, queries per-model quota pools through the node's scorpiox-google-quota CLI, and lets you switch the active account in one click. Holds no OAuth client secret and never prints, logs or returns any refresh or access token.", | |
| 5 | + "version": "1.0.3", | |
| 6 | + "summary": "Zero-dependency Google Antigravity multi-account quota monitor and active-account switcher for your node. Reads the local antigravity_accounts.json and selected_account.txt files, queries per-model quota pools plus weekly and 5-hour limits through the node's scorpiox-google-quota CLI, and lets you switch the active account in one click. Holds no OAuth client secret and never prints, logs or returns any refresh or access token.", | |
| 7 | 7 | "category": "devtools", |
| 8 | 8 | "license": "MIT", |
| 9 | 9 | "capabilities": [ |
| index 496d539..d652a66 100644 | ||
| --- a/src/plugin_google_quota.c | ||
| +++ b/src/plugin_google_quota.c | ||
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | |
| 78 | 78 | #define PLUGIN_SLUG "google-quota" |
| 79 | 79 | #define PLUGIN_ID "plugin_google_quota" |
| 80 | -#define PLUGIN_VER "1.0.2" | |
| 80 | +#define PLUGIN_VER "1.0.3" | |
| 81 | 81 | #define PLUGIN_NAME "google quota" |
| 82 | 82 | #define PLUGIN_DESC "Account quotas" |
| 83 | 83 | #define DEFAULT_QUOTA_BIN "scorpiox-google-quota" |
| @@ -861,6 +861,19 @@ typedef struct { | ||
| 861 | 861 | int count; |
| 862 | 862 | } pool_summary_t; |
| 863 | 863 | |
| 864 | +typedef struct { | |
| 865 | + int present; | |
| 866 | + char bucket_id[64]; | |
| 867 | + double pct; | |
| 868 | + int exhausted; | |
| 869 | + char reset_time[RESET_SZ]; | |
| 870 | +} window_limit_t; | |
| 871 | + | |
| 872 | +typedef struct { | |
| 873 | + window_limit_t five_hour; | |
| 874 | + window_limit_t weekly; | |
| 875 | +} pool_limits_t; | |
| 876 | + | |
| 864 | 877 | typedef struct { |
| 865 | 878 | int ok; |
| 866 | 879 | int cli_missing; |
| @@ -869,10 +882,11 @@ typedef struct { | ||
| 869 | 882 | pool_summary_t gemini; |
| 870 | 883 | pool_summary_t argon; |
| 871 | 884 | pool_summary_t claude; |
| 885 | + pool_limits_t gemini_limits; | |
| 886 | + pool_limits_t claude_limits; | |
| 872 | 887 | model_quota_t models[MAX_MODELS]; |
| 873 | 888 | int model_count; |
| 874 | 889 | } acct_quota_t; |
| 875 | - | |
| 876 | 890 | static void pool_init(pool_summary_t *p) |
| 877 | 891 | { |
| 878 | 892 | p->present = 0; |
| @@ -1007,9 +1021,98 @@ static void parse_quota_output(const buf_t *raw, int run_rc, acct_quota_t *q) | ||
| 1007 | 1021 | p = end; |
| 1008 | 1022 | } |
| 1009 | 1023 | |
| 1024 | + /* Optional: parse summary.groups (from retrieveUserQuotaSummary) for | |
| 1025 | + * explicit 5-hour and weekly quota limits. */ | |
| 1026 | + { | |
| 1027 | + const char *sum = json_find_key(root, root_end, "summary"); | |
| 1028 | + if (sum && *sum == '{') { | |
| 1029 | + const char *sum_end = json_skip_value(sum); | |
| 1030 | + const char *groups = (sum_end && sum_end > sum) | |
| 1031 | + ? json_find_key(sum, sum_end, "groups") : NULL; | |
| 1032 | + if (groups && *groups == '[') { | |
| 1033 | + const char *groups_end = json_skip_value(groups); | |
| 1034 | + const char *gp = groups + 1; | |
| 1035 | + while (gp && groups_end && gp < groups_end) { | |
| 1036 | + const char *gopen = strchr(gp, '{'); | |
| 1037 | + const char *gend; | |
| 1038 | + char gname[128] = {0}; | |
| 1039 | + const char *gb; | |
| 1040 | + const char *gb_end; | |
| 1041 | + if (!gopen || gopen >= groups_end) break; | |
| 1042 | + gend = json_skip_value(gopen); | |
| 1043 | + if (!gend || gend <= gopen || gend > groups_end) break; | |
| 1044 | + | |
| 1045 | + json_str_field(gopen, gend, "displayName", gname, sizeof(gname)); | |
| 1046 | + gb = json_find_key(gopen, gend, "buckets"); | |
| 1047 | + if (gb && *gb == '[') { | |
| 1048 | + gb_end = json_skip_value(gb); | |
| 1049 | + if (gb_end && gb_end > gb && gb_end <= gend) { | |
| 1050 | + const char *bp = gb + 1; | |
| 1051 | + while (bp && bp < gb_end) { | |
| 1052 | + const char *bopen = strchr(bp, '{'); | |
| 1053 | + const char *bend; | |
| 1054 | + char bid[64] = {0}; | |
| 1055 | + char win[32] = {0}; | |
| 1056 | + char rst[RESET_SZ] = {0}; | |
| 1057 | + double frac = 0.0; | |
| 1058 | + double pct = -1.0; | |
| 1059 | + int exhausted = 0; | |
| 1060 | + pool_limits_t *target_pool = NULL; | |
| 1061 | + window_limit_t *target_win = NULL; | |
| 1062 | + | |
| 1063 | + if (!bopen || bopen >= gb_end) break; | |
| 1064 | + bend = json_skip_value(bopen); | |
| 1065 | + if (!bend || bend <= bopen || bend > gb_end) break; | |
| 1066 | + | |
| 1067 | + json_str_field(bopen, bend, "bucketId", bid, sizeof(bid)); | |
| 1068 | + json_str_field(bopen, bend, "window", win, sizeof(win)); | |
| 1069 | + json_str_field(bopen, bend, "resetTime", rst, sizeof(rst)); | |
| 1070 | + | |
| 1071 | + if (json_double_field(bopen, bend, "remainingFraction", &frac)) { | |
| 1072 | + pct = frac * 100.0; | |
| 1073 | + if (pct < 0.0) pct = 0.0; | |
| 1074 | + if (pct > 100.0) pct = 100.0; | |
| 1075 | + if (frac <= 0.0) exhausted = 1; | |
| 1076 | + } else if (rst[0]) { | |
| 1077 | + pct = 0.0; | |
| 1078 | + exhausted = 1; | |
| 1079 | + } | |
| 1080 | + | |
| 1081 | + if (strncmp(bid, "gemini-", 7) == 0 || | |
| 1082 | + strstr(gname, "Gemini") || strstr(gname, "gemini")) { | |
| 1083 | + target_pool = &q->gemini_limits; | |
| 1084 | + } else if (strncmp(bid, "3p-", 3) == 0 || | |
| 1085 | + strstr(gname, "Claude") || strstr(gname, "claude") || | |
| 1086 | + strstr(gname, "GPT")) { | |
| 1087 | + target_pool = &q->claude_limits; | |
| 1088 | + } | |
| 1089 | + | |
| 1090 | + if (target_pool && pct >= 0.0) { | |
| 1091 | + if (strcmp(win, "5h") == 0 || strstr(bid, "-5h")) | |
| 1092 | + target_win = &target_pool->five_hour; | |
| 1093 | + else if (strcmp(win, "weekly") == 0 || strstr(bid, "-weekly")) | |
| 1094 | + target_win = &target_pool->weekly; | |
| 1095 | + } | |
| 1096 | + | |
| 1097 | + if (target_win) { | |
| 1098 | + target_win->present = 1; | |
| 1099 | + snprintf(target_win->bucket_id, sizeof(target_win->bucket_id), "%s", bid); | |
| 1100 | + target_win->pct = pct; | |
| 1101 | + target_win->exhausted = exhausted; | |
| 1102 | + snprintf(target_win->reset_time, sizeof(target_win->reset_time), "%s", rst); | |
| 1103 | + } | |
| 1104 | + bp = bend; | |
| 1105 | + } | |
| 1106 | + } | |
| 1107 | + } | |
| 1108 | + gp = gend; | |
| 1109 | + } | |
| 1110 | + } | |
| 1111 | + } | |
| 1112 | + } | |
| 1113 | + | |
| 1010 | 1114 | q->ok = 1; |
| 1011 | 1115 | } |
| 1012 | - | |
| 1013 | 1116 | static void fetch_all_quotas(const char *bin, const acct_entry_t *accts, int count, |
| 1014 | 1117 | acct_quota_t *out_q) |
| 1015 | 1118 | { |
| @@ -1258,9 +1361,12 @@ static void compute_reset_fields(const char *iso, long long now_epoch, | ||
| 1258 | 1361 | *secs_out = diff; |
| 1259 | 1362 | *hrs_out = (double)diff / 3600.0; |
| 1260 | 1363 | { |
| 1261 | - long long hrs = diff / 3600LL; | |
| 1364 | + long long days = diff / 86400LL; | |
| 1365 | + long long hrs = (diff % 86400LL) / 3600LL; | |
| 1262 | 1366 | long long mins = (diff % 3600LL) / 60LL; |
| 1263 | - if (hrs > 0) | |
| 1367 | + if (days > 0) | |
| 1368 | + snprintf(rem_out, rem_sz, "%lldd %lldh", days, hrs); | |
| 1369 | + else if (hrs > 0) | |
| 1264 | 1370 | snprintf(rem_out, rem_sz, "%lldh %02lldm", hrs, mins); |
| 1265 | 1371 | else |
| 1266 | 1372 | snprintf(rem_out, rem_sz, "%lldm", mins > 0 ? mins : 1LL); |
| @@ -1289,6 +1395,27 @@ static void emit_pool_json(buf_t *b, const pool_summary_t *p, long long now_epoc | ||
| 1289 | 1395 | buf_addf(b, ",\"count\":%d}", p->count); |
| 1290 | 1396 | } |
| 1291 | 1397 | |
| 1398 | +static void emit_window_limit_json(buf_t *b, const window_limit_t *w, long long now_epoch) | |
| 1399 | +{ | |
| 1400 | + long long rsecs = -1; | |
| 1401 | + double rhrs = -1.0; | |
| 1402 | + char rrem[32] = {0}; | |
| 1403 | + | |
| 1404 | + if (!w || !w->present) { | |
| 1405 | + buf_adds(b, "null"); | |
| 1406 | + return; | |
| 1407 | + } | |
| 1408 | + compute_reset_fields(w->reset_time, now_epoch, &rsecs, &rhrs, rrem, sizeof(rrem)); | |
| 1409 | + buf_adds(b, "{\"bucket_id\":"); | |
| 1410 | + buf_json(b, w->bucket_id); | |
| 1411 | + buf_addf(b, ",\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":", | |
| 1412 | + w->pct, w->exhausted ? "true" : "false"); | |
| 1413 | + buf_json(b, w->reset_time); | |
| 1414 | + buf_addf(b, ",\"reset_in_seconds\":%lld,\"reset_in_hours\":%.2f,\"reset_remaining\":", | |
| 1415 | + rsecs, rhrs); | |
| 1416 | + buf_json(b, rrem); | |
| 1417 | + buf_addc(b, '}'); | |
| 1418 | +} | |
| 1292 | 1419 | static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quota_t *q) |
| 1293 | 1420 | { |
| 1294 | 1421 | int i; |
| @@ -1320,6 +1447,15 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo | ||
| 1320 | 1447 | emit_pool_json(b, &q->argon, now_epoch); |
| 1321 | 1448 | buf_adds(b, ",\"claude\":"); |
| 1322 | 1449 | emit_pool_json(b, &q->claude, now_epoch); |
| 1450 | + buf_adds(b, ",\"limits\":{\"gemini\":{\"five_hour\":"); | |
| 1451 | + emit_window_limit_json(b, &q->gemini_limits.five_hour, now_epoch); | |
| 1452 | + buf_adds(b, ",\"weekly\":"); | |
| 1453 | + emit_window_limit_json(b, &q->gemini_limits.weekly, now_epoch); | |
| 1454 | + buf_adds(b, "},\"claude\":{\"five_hour\":"); | |
| 1455 | + emit_window_limit_json(b, &q->claude_limits.five_hour, now_epoch); | |
| 1456 | + buf_adds(b, ",\"weekly\":"); | |
| 1457 | + emit_window_limit_json(b, &q->claude_limits.weekly, now_epoch); | |
| 1458 | + buf_adds(b, "}}"); | |
| 1323 | 1459 | buf_adds(b, ",\"models\":["); |
| 1324 | 1460 | for (i = 0; i < q->model_count; i++) { |
| 1325 | 1461 | const model_quota_t *m = &q->models[i]; |
| index 02dcd58..ff3ea23 100644 | ||
| --- a/src/ui.html | ||
| +++ b/src/ui.html | ||
| @@ -71,8 +71,12 @@ body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14 | ||
| 71 | 71 | .meter > i.warn{background:var(--orange)} |
| 72 | 72 | .meter > i.bad{background:var(--red)} |
| 73 | 73 | .pool-reset{margin-top:6px;font-size:11.5px;color:var(--text-2)} |
| 74 | +.pool-win{margin-top:8px;padding-top:8px;border-top:1px solid var(--line)} | |
| 75 | +.pool-win:first-of-type{margin-top:4px;padding-top:0;border-top:0} | |
| 76 | +.pool-win-hd{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:4px} | |
| 77 | +.pool-win-lbl{font-size:11px;font-weight:650;color:var(--text-2);text-transform:uppercase;letter-spacing:.04em} | |
| 78 | +.pool-win-rst{margin-top:4px;font-size:11px;color:var(--text-2)} | |
| 74 | 79 | .models{display:none;margin-top:10px;padding-top:10px;border-top:1px solid var(--line); |
| 75 | - grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px} | |
| 76 | 80 | .models.show{display:grid} |
| 77 | 81 | .mrow{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11.5px;padding:2px 0} |
| 78 | 82 | .mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0} |
| @@ -228,9 +232,11 @@ function fmtResetShort(iso){ | ||
| 228 | 232 | if(isNaN(t))return iso; |
| 229 | 233 | var diff=Math.floor((t-Date.now())/1000); |
| 230 | 234 | if(diff<=0)return 'due'; |
| 231 | - var totalH=Math.floor(diff/3600); | |
| 235 | + var d=Math.floor(diff/86400); | |
| 236 | + var h=Math.floor((diff%86400)/3600); | |
| 232 | 237 | var m=Math.floor((diff%3600)/60); |
| 233 | - if(totalH>0)return totalH+'h '+pad2(m)+'m'; | |
| 238 | + if(d>0)return d+'d '+h+'h'; | |
| 239 | + if(h>0)return h+'h '+pad2(m)+'m'; | |
| 234 | 240 | return Math.max(1,m)+'m'; |
| 235 | 241 | } |
| 236 | 242 | function fmtReset(iso){ |
| @@ -240,12 +246,11 @@ function fmtReset(iso){ | ||
| 240 | 246 | var diff=Math.floor((t-Date.now())/1000); |
| 241 | 247 | var clk=fmtClock(t); |
| 242 | 248 | if(diff<=0)return 'Resets soon · '+clk; |
| 243 | - var totalH=Math.floor(diff/3600); | |
| 244 | 249 | var d=Math.floor(diff/86400); |
| 245 | 250 | var h=Math.floor((diff%86400)/3600); |
| 246 | 251 | var m=Math.floor((diff%3600)/60); |
| 247 | - if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk; | |
| 248 | - if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk; | |
| 252 | + if(d>0)return 'Resets in '+d+'d '+h+'h · '+clk; | |
| 253 | + if(h>0)return 'Resets in '+h+'h '+pad2(m)+'m · '+clk; | |
| 249 | 254 | return 'Resets in '+Math.max(1,m)+'m · '+clk; |
| 250 | 255 | } |
| 251 | 256 | function refreshResetLabels(){ |
| @@ -285,8 +290,58 @@ function computeBest(){ | ||
| 285 | 290 | return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,argon:bestA,argonPct:bestAP,argonReset:bestAR,claude:bestC,claudePct:bestCP,claudeReset:bestCR}; |
| 286 | 291 | } |
| 287 | 292 | |
| 288 | -function renderPool(label,pool,loading){ | |
| 293 | +function renderWindowRow(winLabel,lim){ | |
| 294 | + var row=el('div','pool-win'); | |
| 295 | + var hd=el('div','pool-win-hd'); | |
| 296 | + hd.appendChild(el('span','pool-win-lbl',winLabel)); | |
| 297 | + var pctEl=el('span','pool-pct'); | |
| 298 | + var bar=el('div','meter'); | |
| 299 | + var fill=el('i'); | |
| 300 | + var rst=el('div','pool-win-rst'); | |
| 301 | + | |
| 302 | + if(!lim||lim.pct<0){ | |
| 303 | + pctEl.className='pool-pct dim'; | |
| 304 | + pctEl.textContent='N/A'; | |
| 305 | + fill.style.width='0%'; | |
| 306 | + rst.textContent='Not reported for this tier'; | |
| 307 | + }else{ | |
| 308 | + var cls=pctClass(lim.pct,lim.exhausted); | |
| 309 | + pctEl.className='pool-pct '+cls; | |
| 310 | + pctEl.textContent=fmtPct(lim); | |
| 311 | + var w=lim.exhausted?0:Math.max(0,Math.min(100,lim.pct)); | |
| 312 | + fill.className=cls; | |
| 313 | + fill.style.width=w.toFixed(1)+'%'; | |
| 314 | + if(lim.reset_time){ | |
| 315 | + rst.textContent=fmtReset(lim.reset_time); | |
| 316 | + rst.setAttribute('data-reset',lim.reset_time); | |
| 317 | + rst.setAttribute('data-reset-mode','full'); | |
| 318 | + var rt=Date.parse(lim.reset_time); | |
| 319 | + if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+lim.reset_time+')'; | |
| 320 | + }else if(lim.pct>=99.95){ | |
| 321 | + rst.textContent='Full quota'; | |
| 322 | + }else{ | |
| 323 | + rst.textContent='Reset: -'; | |
| 324 | + } | |
| 325 | + } | |
| 326 | + hd.appendChild(pctEl); | |
| 327 | + bar.appendChild(fill); | |
| 328 | + row.appendChild(hd); | |
| 329 | + row.appendChild(bar); | |
| 330 | + row.appendChild(rst); | |
| 331 | + return row; | |
| 332 | +} | |
| 333 | + | |
| 334 | +function renderPool(label,pool,loading,limits){ | |
| 289 | 335 | var box=el('div','pool'); |
| 336 | + var hasLimits=limits&&(limits.five_hour||limits.weekly); | |
| 337 | + if(hasLimits){ | |
| 338 | + var hd=el('div','pool-hd'); | |
| 339 | + hd.appendChild(el('span','pool-name',label)); | |
| 340 | + box.appendChild(hd); | |
| 341 | + box.appendChild(renderWindowRow('5-Hour Limit',limits.five_hour)); | |
| 342 | + box.appendChild(renderWindowRow('Weekly Limit',limits.weekly)); | |
| 343 | + return box; | |
| 344 | + } | |
| 290 | 345 | var hd=el('div','pool-hd'); |
| 291 | 346 | hd.appendChild(el('span','pool-name',label)); |
| 292 | 347 | var pctEl=el('span','pool-pct'); |
| @@ -326,7 +381,6 @@ function renderPool(label,pool,loading){ | ||
| 326 | 381 | box.appendChild(rst); |
| 327 | 382 | return box; |
| 328 | 383 | } |
| 329 | - | |
| 330 | 384 | function render(){ |
| 331 | 385 | var best=computeBest(); |
| 332 | 386 | $('kpiSelected').textContent=shortEmail(state.selected); |
| @@ -379,13 +433,14 @@ function render(){ | ||
| 379 | 433 | card.appendChild(el('div','err-msg','Error: '+(qd.detail||qd.error||'quota fetch failed'))); |
| 380 | 434 | }else{ |
| 381 | 435 | var pools=el('div','pools'); |
| 382 | - pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading)); | |
| 436 | + var glim=qd&&qd.limits?qd.limits.gemini:null; | |
| 437 | + var clim=qd&&qd.limits?qd.limits.claude:null; | |
| 438 | + pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading,glim)); | |
| 383 | 439 | if(qd&&qd.argon&&qd.argon.count>0){ |
| 384 | - pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading)); | |
| 440 | + pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading,null)); | |
| 385 | 441 | } |
| 386 | - pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading)); | |
| 442 | + pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading,clim)); | |
| 387 | 443 | card.appendChild(pools); |
| 388 | - | |
| 389 | 444 | if(qd&&qd.models&&qd.models.length){ |
| 390 | 445 | var mgrid=el('div','models'+(state.showModels?' show':'')); |
| 391 | 446 | qd.models.forEach(function(m){ |
| index d605958..1992012 100644 | ||
| --- a/src/ui_html.h | ||
| +++ b/src/ui_html.h | ||
| @@ -76,8 +76,12 @@ static const char *UI_HTML = | ||
| 76 | 76 | ".meter > i.warn{background:var(--orange)}\n" |
| 77 | 77 | ".meter > i.bad{background:var(--red)}\n" |
| 78 | 78 | ".pool-reset{margin-top:6px;font-size:11.5px;color:var(--text-2)}\n" |
| 79 | + ".pool-win{margin-top:8px;padding-top:8px;border-top:1px solid var(--line)}\n" | |
| 80 | + ".pool-win:first-of-type{margin-top:4px;padding-top:0;border-top:0}\n" | |
| 81 | + ".pool-win-hd{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:4px}\n" | |
| 82 | + ".pool-win-lbl{font-size:11px;font-weight:650;color:var(--text-2);text-transform:uppercase;letter-spacing:.04em}\n" | |
| 83 | + ".pool-win-rst{margin-top:4px;font-size:11px;color:var(--text-2)}\n" | |
| 79 | 84 | ".models{display:none;margin-top:10px;padding-top:10px;border-top:1px solid var(--line);\n" |
| 80 | - " grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}\n" | |
| 81 | 85 | ".models.show{display:grid}\n" |
| 82 | 86 | ".mrow{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11.5px;padding:2px 0}\n" |
| 83 | 87 | ".mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}\n" |
| @@ -233,9 +237,11 @@ static const char *UI_HTML = | ||
| 233 | 237 | " if(isNaN(t))return iso;\n" |
| 234 | 238 | " var diff=Math.floor((t-Date.now())/1000);\n" |
| 235 | 239 | " if(diff<=0)return 'due';\n" |
| 236 | - " var totalH=Math.floor(diff/3600);\n" | |
| 240 | + " var d=Math.floor(diff/86400);\n" | |
| 241 | + " var h=Math.floor((diff%86400)/3600);\n" | |
| 237 | 242 | " var m=Math.floor((diff%3600)/60);\n" |
| 238 | - " if(totalH>0)return totalH+'h '+pad2(m)+'m';\n" | |
| 243 | + " if(d>0)return d+'d '+h+'h';\n" | |
| 244 | + " if(h>0)return h+'h '+pad2(m)+'m';\n" | |
| 239 | 245 | " return Math.max(1,m)+'m';\n" |
| 240 | 246 | "}\n" |
| 241 | 247 | "function fmtReset(iso){\n" |
| @@ -245,12 +251,11 @@ static const char *UI_HTML = | ||
| 245 | 251 | " var diff=Math.floor((t-Date.now())/1000);\n" |
| 246 | 252 | " var clk=fmtClock(t);\n" |
| 247 | 253 | " if(diff<=0)return 'Resets soon · '+clk;\n" |
| 248 | - " var totalH=Math.floor(diff/3600);\n" | |
| 249 | 254 | " var d=Math.floor(diff/86400);\n" |
| 250 | 255 | " var h=Math.floor((diff%86400)/3600);\n" |
| 251 | 256 | " var m=Math.floor((diff%3600)/60);\n" |
| 252 | - " if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk;\n" | |
| 253 | - " if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk;\n" | |
| 257 | + " if(d>0)return 'Resets in '+d+'d '+h+'h · '+clk;\n" | |
| 258 | + " if(h>0)return 'Resets in '+h+'h '+pad2(m)+'m · '+clk;\n" | |
| 254 | 259 | " return 'Resets in '+Math.max(1,m)+'m · '+clk;\n" |
| 255 | 260 | "}\n" |
| 256 | 261 | "function refreshResetLabels(){\n" |
| @@ -290,8 +295,58 @@ static const char *UI_HTML = | ||
| 290 | 295 | " return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,argon:bestA,argonPct:bestAP,argonReset:bestAR,claude:bestC,claudePct:bestCP,claudeReset:bestCR};\n" |
| 291 | 296 | "}\n" |
| 292 | 297 | "\n" |
| 293 | - "function renderPool(label,pool,loading){\n" | |
| 298 | + "function renderWindowRow(winLabel,lim){\n" | |
| 299 | + " var row=el('div','pool-win');\n" | |
| 300 | + " var hd=el('div','pool-win-hd');\n" | |
| 301 | + " hd.appendChild(el('span','pool-win-lbl',winLabel));\n" | |
| 302 | + " var pctEl=el('span','pool-pct');\n" | |
| 303 | + " var bar=el('div','meter');\n" | |
| 304 | + " var fill=el('i');\n" | |
| 305 | + " var rst=el('div','pool-win-rst');\n" | |
| 306 | + "\n" | |
| 307 | + " if(!lim||lim.pct<0){\n" | |
| 308 | + " pctEl.className='pool-pct dim';\n" | |
| 309 | + " pctEl.textContent='N/A';\n" | |
| 310 | + " fill.style.width='0%';\n" | |
| 311 | + " rst.textContent='Not reported for this tier';\n" | |
| 312 | + " }else{\n" | |
| 313 | + " var cls=pctClass(lim.pct,lim.exhausted);\n" | |
| 314 | + " pctEl.className='pool-pct '+cls;\n" | |
| 315 | + " pctEl.textContent=fmtPct(lim);\n" | |
| 316 | + " var w=lim.exhausted?0:Math.max(0,Math.min(100,lim.pct));\n" | |
| 317 | + " fill.className=cls;\n" | |
| 318 | + " fill.style.width=w.toFixed(1)+'%';\n" | |
| 319 | + " if(lim.reset_time){\n" | |
| 320 | + " rst.textContent=fmtReset(lim.reset_time);\n" | |
| 321 | + " rst.setAttribute('data-reset',lim.reset_time);\n" | |
| 322 | + " rst.setAttribute('data-reset-mode','full');\n" | |
| 323 | + " var rt=Date.parse(lim.reset_time);\n" | |
| 324 | + " if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+lim.reset_time+')';\n" | |
| 325 | + " }else if(lim.pct>=99.95){\n" | |
| 326 | + " rst.textContent='Full quota';\n" | |
| 327 | + " }else{\n" | |
| 328 | + " rst.textContent='Reset: -';\n" | |
| 329 | + " }\n" | |
| 330 | + " }\n" | |
| 331 | + " hd.appendChild(pctEl);\n" | |
| 332 | + " bar.appendChild(fill);\n" | |
| 333 | + " row.appendChild(hd);\n" | |
| 334 | + " row.appendChild(bar);\n" | |
| 335 | + " row.appendChild(rst);\n" | |
| 336 | + " return row;\n" | |
| 337 | + "}\n" | |
| 338 | + "\n" | |
| 339 | + "function renderPool(label,pool,loading,limits){\n" | |
| 294 | 340 | " var box=el('div','pool');\n" |
| 341 | + " var hasLimits=limits&&(limits.five_hour||limits.weekly);\n" | |
| 342 | + " if(hasLimits){\n" | |
| 343 | + " var hd=el('div','pool-hd');\n" | |
| 344 | + " hd.appendChild(el('span','pool-name',label));\n" | |
| 345 | + " box.appendChild(hd);\n" | |
| 346 | + " box.appendChild(renderWindowRow('5-Hour Limit',limits.five_hour));\n" | |
| 347 | + " box.appendChild(renderWindowRow('Weekly Limit',limits.weekly));\n" | |
| 348 | + " return box;\n" | |
| 349 | + " }\n" | |
| 295 | 350 | " var hd=el('div','pool-hd');\n" |
| 296 | 351 | " hd.appendChild(el('span','pool-name',label));\n" |
| 297 | 352 | " var pctEl=el('span','pool-pct');\n" |
| @@ -331,7 +386,6 @@ static const char *UI_HTML = | ||
| 331 | 386 | " box.appendChild(rst);\n" |
| 332 | 387 | " return box;\n" |
| 333 | 388 | "}\n" |
| 334 | - "\n" | |
| 335 | 389 | "function render(){\n" |
| 336 | 390 | " var best=computeBest();\n" |
| 337 | 391 | " $('kpiSelected').textContent=shortEmail(state.selected);\n" |
| @@ -384,13 +438,14 @@ static const char *UI_HTML = | ||
| 384 | 438 | " card.appendChild(el('div','err-msg','Error: '+(qd.detail||qd.error||'quota fetch failed')));\n" |
| 385 | 439 | " }else{\n" |
| 386 | 440 | " var pools=el('div','pools');\n" |
| 387 | - " pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading));\n" | |
| 441 | + " var glim=qd&&qd.limits?qd.limits.gemini:null;\n" | |
| 442 | + " var clim=qd&&qd.limits?qd.limits.claude:null;\n" | |
| 443 | + " pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading,glim));\n" | |
| 388 | 444 | " if(qd&&qd.argon&&qd.argon.count>0){\n" |
| 389 | - " pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading));\n" | |
| 445 | + " pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading,null));\n" | |
| 390 | 446 | " }\n" |
| 391 | - " pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading));\n" | |
| 447 | + " pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading,clim));\n" | |
| 392 | 448 | " card.appendChild(pools);\n" |
| 393 | - "\n" | |
| 394 | 449 | " if(qd&&qd.models&&qd.models.length){\n" |
| 395 | 450 | " var mgrid=el('div','models'+(state.showModels?' show':''));\n" |
| 396 | 451 | " qd.models.forEach(function(m){\n" |
| index 875750e..baa5962 100755 | ||
| --- a/tests/mock_quota.sh | ||
| +++ b/tests/mock_quota.sh | ||
| @@ -44,7 +44,25 @@ case "$acct" in | ||
| 44 | 44 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar", "remainingFraction": 0.855}, |
| 45 | 45 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-neon-high", "remainingFraction": 0.855}, |
| 46 | 46 | {"tokenType": "WTUS", "modelId": "tab_flash_lite_preview", "remainingFraction": 1} |
| 47 | - ] | |
| 47 | + ], | |
| 48 | + "summary": { | |
| 49 | + "groups": [ | |
| 50 | + { | |
| 51 | + "displayName": "Gemini Models", | |
| 52 | + "buckets": [ | |
| 53 | + {"bucketId": "gemini-weekly", "window": "weekly", "remainingFraction": 0.855, "resetTime": "$RST_GEMINI"}, | |
| 54 | + {"bucketId": "gemini-5h", "window": "5h", "remainingFraction": 0.375, "resetTime": "$RST_CLAUDE"} | |
| 55 | + ] | |
| 56 | + }, | |
| 57 | + { | |
| 58 | + "displayName": "Claude and GPT models", | |
| 59 | + "buckets": [ | |
| 60 | + {"bucketId": "3p-weekly", "window": "weekly", "remainingFraction": 0.99, "resetTime": "$RST_GEMINI"}, | |
| 61 | + {"bucketId": "3p-5h", "window": "5h", "remainingFraction": 1} | |
| 62 | + ] | |
| 63 | + } | |
| 64 | + ] | |
| 65 | + } | |
| 48 | 66 | } |
| 49 | 67 | EOF |
| 50 | 68 | exit 0 |
| @@ -60,7 +78,24 @@ EOF | ||
| 60 | 78 | {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 0.42}, |
| 61 | 79 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": null}, |
| 62 | 80 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar"} |
| 63 | - ] | |
| 81 | + ], | |
| 82 | + "summary": { | |
| 83 | + "groups": [ | |
| 84 | + { | |
| 85 | + "displayName": "Gemini Models", | |
| 86 | + "buckets": [ | |
| 87 | + {"bucketId": "gemini-weekly", "window": "weekly", "resetTime": "$RST_GEMINI"} | |
| 88 | + ] | |
| 89 | + }, | |
| 90 | + { | |
| 91 | + "displayName": "Claude and GPT models", | |
| 92 | + "buckets": [ | |
| 93 | + {"bucketId": "3p-weekly", "window": "weekly", "remainingFraction": 0.42, "resetTime": "$RST_GEMINI"}, | |
| 94 | + {"bucketId": "3p-5h", "window": "5h", "remainingFraction": 0.50, "resetTime": "$RST_CLAUDE"} | |
| 95 | + ] | |
| 96 | + } | |
| 97 | + ] | |
| 98 | + } | |
| 64 | 99 | } |
| 65 | 100 | EOF |
| 66 | 101 | exit 0 |
| index 6f4d62d..fbc306d 100755 | ||
| --- a/tests/run.sh | ||
| +++ b/tests/run.sh | ||
| @@ -102,7 +102,7 @@ META_ENV=$(BOT_PASSWORD=secret-pass SX_PLUGIN_META=1 $BIN) | ||
| 102 | 102 | check "SX_PLUGIN_META=1 works without auth" '{"name":"google quota","desc":"Account quotas"}' "$META_ENV" |
| 103 | 103 | |
| 104 | 104 | VER=$($BIN --version) |
| 105 | -check "--version prints plugin id and version" "plugin_google_quota 1.0.2" "$VER" | |
| 105 | +check "--version prints plugin id and version" "plugin_google_quota 1.0.3" "$VER" | |
| 106 | 106 | UNAUTH=$(BOT_PASSWORD=secret-pass QUERY_STRING="action=status" $BIN) |
| 107 | 107 | check "missing password returns 401" "Status: 401 Unauthorized" "$UNAUTH" |
| 108 | 108 | |
| @@ -135,17 +135,20 @@ json_ok "missing CLI sets cli_present false" "$ST_NOCLI" "d['ok'] is True and d[ | ||
| 135 | 135 | section "quota" |
| 136 | 136 | Q_ONE=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=alpha@example.com") |
| 137 | 137 | json_ok "single account quota parses gemini, argon, and claude pools and remaining hours" "$Q_ONE" \ |
| 138 | - "d['ok'] is True and d['account']['ok'] is True and abs(d['account']['gemini']['pct'] - 85.5) < 0.01 and abs(d['account']['argon']['pct'] - 100.0) < 0.01 and abs(d['account']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 9 and d['account']['gemini']['reset_in_seconds'] > 500000 and d['account']['gemini']['reset_in_hours'] > 140 and 'h ' in d['account']['gemini']['reset_remaining'] and d['account']['claude']['reset_in_seconds'] > 7000 and 'h ' in d['account']['claude']['reset_remaining'] and all('reset_remaining' in m and 'reset_in_hours' in m for m in d['account']['models'])" | |
| 138 | + "d['ok'] is True and d['account']['ok'] is True and abs(d['account']['gemini']['pct'] - 85.5) < 0.01 and abs(d['account']['argon']['pct'] - 100.0) < 0.01 and abs(d['account']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 9 and d['account']['gemini']['reset_in_seconds'] > 500000 and d['account']['gemini']['reset_in_hours'] > 140 and 'd ' in d['account']['gemini']['reset_remaining'] and d['account']['claude']['reset_in_seconds'] > 7000 and 'h ' in d['account']['claude']['reset_remaining'] and all('reset_remaining' in m and 'reset_in_hours' in m for m in d['account']['models'])" | |
| 139 | +json_ok "single account quota parses both 5-hour and weekly limits" "$Q_ONE" \ | |
| 140 | + "abs(d['account']['limits']['gemini']['five_hour']['pct'] - 37.5) < 0.01 and abs(d['account']['limits']['gemini']['weekly']['pct'] - 85.5) < 0.01 and 'd ' in d['account']['limits']['gemini']['weekly']['reset_remaining'] and 'h ' in d['account']['limits']['gemini']['five_hour']['reset_remaining'] and abs(d['account']['limits']['claude']['five_hour']['pct'] - 100.0) < 0.01 and abs(d['account']['limits']['claude']['weekly']['pct'] - 99.0) < 0.01" | |
| 139 | 141 | check_not "single quota never leaks token" "MOCK-TOKEN" "$Q_ONE" |
| 140 | 142 | check_not "single quota never leaks refresh token" "MOCK-REFRESH-TOKEN" "$Q_ONE" |
| 141 | 143 | |
| 142 | 144 | Q_EXH=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=beta@example.com") |
| 143 | 145 | json_ok "null/missing remainingFraction marks gemini pool exhausted with reset remaining" "$Q_EXH" \ |
| 144 | - "d['ok'] is True and d['account']['gemini']['exhausted'] is True and d['account']['gemini']['pct'] == 0.0 and abs(d['account']['claude']['pct'] - 42.0) < 0.01 and d['account']['gemini']['reset_in_hours'] > 140 and 'h ' in d['account']['gemini']['reset_remaining']" | |
| 146 | + "d['ok'] is True and d['account']['gemini']['exhausted'] is True and d['account']['gemini']['pct'] == 0.0 and abs(d['account']['claude']['pct'] - 42.0) < 0.01 and d['account']['gemini']['reset_in_hours'] > 140 and 'd ' in d['account']['gemini']['reset_remaining']" | |
| 147 | +json_ok "free account missing gemini 5h returns null five_hour and exhausted weekly" "$Q_EXH" \ | |
| 148 | + "d['account']['limits']['gemini']['five_hour'] is None and d['account']['limits']['gemini']['weekly']['exhausted'] is True and d['account']['limits']['gemini']['weekly']['pct'] == 0.0 and abs(d['account']['limits']['claude']['five_hour']['pct'] - 50.0) < 0.01 and abs(d['account']['limits']['claude']['weekly']['pct'] - 42.0) < 0.01" | |
| 145 | 149 | Q_ALL=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota") |
| 146 | 150 | json_ok "all-accounts quota aggregates best_gemini, best_argon, best_claude, and broken account" "$Q_ALL" \ |
| 147 | 151 | "d['ok'] is True and d['count'] == 3 and d['best_gemini'] == 'alpha@example.com' and d['best_argon'] == 'alpha@example.com' and d['best_claude'] == 'alpha@example.com' and d['accounts'][2]['ok'] is False" |
| 148 | -check_not "all-accounts quota never leaks token" "MOCK-TOKEN" "$Q_ALL" | |
| 149 | 152 | |
| 150 | 153 | Q_FMT=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "format=json") |
| 151 | 154 | json_ok "?format=json returns full quota JSON" "$Q_FMT" "d['ok'] is True and d['count'] == 3 and 'best_gemini' in d" |
| @@ -180,10 +183,11 @@ check "HTML includes bot theme prepaint" "bot_theme" "$HTML" | ||
| 180 | 183 | check "HTML includes theme handoff" "sx-theme-request" "$HTML" |
| 181 | 184 | check "HTML uses two-route API helper" "plugin_google_quota" "$HTML" |
| 182 | 185 | check "HTML hub proxy URL uses &action= separator" "'/plugins?plugin='+encodeURIComponent(HUB)+'&'" "$HTML" |
| 183 | -check "HTML formats total remaining hours even >= 24h" "totalH>=24" "$HTML" | |
| 186 | +check "HTML formats multi-day remaining resets cleanly" "d+'d '+h+'h'" "$HTML" | |
| 187 | +check "HTML renders both 5-hour and weekly limit sections" "5-Hour Limit" "$HTML" | |
| 188 | +check "HTML renders weekly limit label" "Weekly Limit" "$HTML" | |
| 184 | 189 | check "HTML renders per-model reset remaining hours" "fmtResetShort" "$HTML" |
| 185 | 190 | check "HTML includes live reset countdown attributes" "data-reset" "$HTML" |
| 186 | -check "HTML hides theme toggle in embed mode" "embed-hide" "$HTML" | |
| 187 | 191 | check_not "HTML loads no CDN script" "<script src=" "$HTML" |
| 188 | 192 | check_not "HTML references no external host script" "cdnjs" "$HTML" |
| 189 | 193 | check_not "HTML makes no outbound fetch to googleapis" "googleapis.com" "$HTML" |
| 190 | 194 |
| index 71cfa44..645fe87 100644 | index 71cfa44..645fe87 100644 | ||
| --- a/plugin.json | --- a/plugin.json | ||
| +++ b/plugin.json | +++ b/plugin.json | ||
| @@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
| 2 | "slug": "google-quota", | 2 | "slug": "google-quota", |
| 3 | "id": "plugin_google_quota", | 3 | "id": "plugin_google_quota", |
| 4 | "title": "Google Account Quotas", | 4 | "title": "Google Account Quotas", |
| 5 | - "version": "1.0.2", | 5 | + "version": "1.0.3", |
| 6 | - "summary": "Zero-dependency Google Antigravity multi-account quota monitor and active-account switcher for your node. Reads the local antigravity_accounts.json and selected_account.txt files, queries per-model quota pools through the node's scorpiox-google-quota CLI, and lets you switch the active account in one click. Holds no OAuth client secret and never prints, logs or returns any refresh or access token.", | 6 | + "summary": "Zero-dependency Google Antigravity multi-account quota monitor and active-account switcher for your node. Reads the local antigravity_accounts.json and selected_account.txt files, queries per-model quota pools plus weekly and 5-hour limits through the node's scorpiox-google-quota CLI, and lets you switch the active account in one click. Holds no OAuth client secret and never prints, logs or returns any refresh or access token.", |
| 7 | "category": "devtools", | 7 | "category": "devtools", |
| 8 | "license": "MIT", | 8 | "license": "MIT", |
| 9 | "capabilities": [ | 9 | "capabilities": [ |
| index 496d539..d652a66 100644 | index 496d539..d652a66 100644 | ||
| --- a/src/plugin_google_quota.c | --- a/src/plugin_google_quota.c | ||
| +++ b/src/plugin_google_quota.c | +++ b/src/plugin_google_quota.c | ||
| @@ -77,7 +77,7 @@ | @@ -77,7 +77,7 @@ | ||
| 77 | 77 | ||
| 78 | #define PLUGIN_SLUG "google-quota" | 78 | #define PLUGIN_SLUG "google-quota" |
| 79 | #define PLUGIN_ID "plugin_google_quota" | 79 | #define PLUGIN_ID "plugin_google_quota" |
| 80 | -#define PLUGIN_VER "1.0.2" | 80 | +#define PLUGIN_VER "1.0.3" |
| 81 | #define PLUGIN_NAME "google quota" | 81 | #define PLUGIN_NAME "google quota" |
| 82 | #define PLUGIN_DESC "Account quotas" | 82 | #define PLUGIN_DESC "Account quotas" |
| 83 | #define DEFAULT_QUOTA_BIN "scorpiox-google-quota" | 83 | #define DEFAULT_QUOTA_BIN "scorpiox-google-quota" |
| @@ -861,6 +861,19 @@ typedef struct { | @@ -861,6 +861,19 @@ typedef struct { | ||
| 861 | int count; | 861 | int count; |
| 862 | } pool_summary_t; | 862 | } pool_summary_t; |
| 863 | 863 | ||
| 864 | +typedef struct { | ||
| 865 | + int present; | ||
| 866 | + char bucket_id[64]; | ||
| 867 | + double pct; | ||
| 868 | + int exhausted; | ||
| 869 | + char reset_time[RESET_SZ]; | ||
| 870 | +} window_limit_t; | ||
| 871 | + | ||
| 872 | +typedef struct { | ||
| 873 | + window_limit_t five_hour; | ||
| 874 | + window_limit_t weekly; | ||
| 875 | +} pool_limits_t; | ||
| 876 | + | ||
| 864 | typedef struct { | 877 | typedef struct { |
| 865 | int ok; | 878 | int ok; |
| 866 | int cli_missing; | 879 | int cli_missing; |
| @@ -869,10 +882,11 @@ typedef struct { | @@ -869,10 +882,11 @@ typedef struct { | ||
| 869 | pool_summary_t gemini; | 882 | pool_summary_t gemini; |
| 870 | pool_summary_t argon; | 883 | pool_summary_t argon; |
| 871 | pool_summary_t claude; | 884 | pool_summary_t claude; |
| 885 | + pool_limits_t gemini_limits; | ||
| 886 | + pool_limits_t claude_limits; | ||
| 872 | model_quota_t models[MAX_MODELS]; | 887 | model_quota_t models[MAX_MODELS]; |
| 873 | int model_count; | 888 | int model_count; |
| 874 | } acct_quota_t; | 889 | } acct_quota_t; |
| 875 | - | ||
| 876 | static void pool_init(pool_summary_t *p) | 890 | static void pool_init(pool_summary_t *p) |
| 877 | { | 891 | { |
| 878 | p->present = 0; | 892 | p->present = 0; |
| @@ -1007,9 +1021,98 @@ static void parse_quota_output(const buf_t *raw, int run_rc, acct_quota_t *q) | @@ -1007,9 +1021,98 @@ static void parse_quota_output(const buf_t *raw, int run_rc, acct_quota_t *q) | ||
| 1007 | p = end; | 1021 | p = end; |
| 1008 | } | 1022 | } |
| 1009 | 1023 | ||
| 1024 | + /* Optional: parse summary.groups (from retrieveUserQuotaSummary) for | ||
| 1025 | + * explicit 5-hour and weekly quota limits. */ | ||
| 1026 | + { | ||
| 1027 | + const char *sum = json_find_key(root, root_end, "summary"); | ||
| 1028 | + if (sum && *sum == '{') { | ||
| 1029 | + const char *sum_end = json_skip_value(sum); | ||
| 1030 | + const char *groups = (sum_end && sum_end > sum) | ||
| 1031 | + ? json_find_key(sum, sum_end, "groups") : NULL; | ||
| 1032 | + if (groups && *groups == '[') { | ||
| 1033 | + const char *groups_end = json_skip_value(groups); | ||
| 1034 | + const char *gp = groups + 1; | ||
| 1035 | + while (gp && groups_end && gp < groups_end) { | ||
| 1036 | + const char *gopen = strchr(gp, '{'); | ||
| 1037 | + const char *gend; | ||
| 1038 | + char gname[128] = {0}; | ||
| 1039 | + const char *gb; | ||
| 1040 | + const char *gb_end; | ||
| 1041 | + if (!gopen || gopen >= groups_end) break; | ||
| 1042 | + gend = json_skip_value(gopen); | ||
| 1043 | + if (!gend || gend <= gopen || gend > groups_end) break; | ||
| 1044 | + | ||
| 1045 | + json_str_field(gopen, gend, "displayName", gname, sizeof(gname)); | ||
| 1046 | + gb = json_find_key(gopen, gend, "buckets"); | ||
| 1047 | + if (gb && *gb == '[') { | ||
| 1048 | + gb_end = json_skip_value(gb); | ||
| 1049 | + if (gb_end && gb_end > gb && gb_end <= gend) { | ||
| 1050 | + const char *bp = gb + 1; | ||
| 1051 | + while (bp && bp < gb_end) { | ||
| 1052 | + const char *bopen = strchr(bp, '{'); | ||
| 1053 | + const char *bend; | ||
| 1054 | + char bid[64] = {0}; | ||
| 1055 | + char win[32] = {0}; | ||
| 1056 | + char rst[RESET_SZ] = {0}; | ||
| 1057 | + double frac = 0.0; | ||
| 1058 | + double pct = -1.0; | ||
| 1059 | + int exhausted = 0; | ||
| 1060 | + pool_limits_t *target_pool = NULL; | ||
| 1061 | + window_limit_t *target_win = NULL; | ||
| 1062 | + | ||
| 1063 | + if (!bopen || bopen >= gb_end) break; | ||
| 1064 | + bend = json_skip_value(bopen); | ||
| 1065 | + if (!bend || bend <= bopen || bend > gb_end) break; | ||
| 1066 | + | ||
| 1067 | + json_str_field(bopen, bend, "bucketId", bid, sizeof(bid)); | ||
| 1068 | + json_str_field(bopen, bend, "window", win, sizeof(win)); | ||
| 1069 | + json_str_field(bopen, bend, "resetTime", rst, sizeof(rst)); | ||
| 1070 | + | ||
| 1071 | + if (json_double_field(bopen, bend, "remainingFraction", &frac)) { | ||
| 1072 | + pct = frac * 100.0; | ||
| 1073 | + if (pct < 0.0) pct = 0.0; | ||
| 1074 | + if (pct > 100.0) pct = 100.0; | ||
| 1075 | + if (frac <= 0.0) exhausted = 1; | ||
| 1076 | + } else if (rst[0]) { | ||
| 1077 | + pct = 0.0; | ||
| 1078 | + exhausted = 1; | ||
| 1079 | + } | ||
| 1080 | + | ||
| 1081 | + if (strncmp(bid, "gemini-", 7) == 0 || | ||
| 1082 | + strstr(gname, "Gemini") || strstr(gname, "gemini")) { | ||
| 1083 | + target_pool = &q->gemini_limits; | ||
| 1084 | + } else if (strncmp(bid, "3p-", 3) == 0 || | ||
| 1085 | + strstr(gname, "Claude") || strstr(gname, "claude") || | ||
| 1086 | + strstr(gname, "GPT")) { | ||
| 1087 | + target_pool = &q->claude_limits; | ||
| 1088 | + } | ||
| 1089 | + | ||
| 1090 | + if (target_pool && pct >= 0.0) { | ||
| 1091 | + if (strcmp(win, "5h") == 0 || strstr(bid, "-5h")) | ||
| 1092 | + target_win = &target_pool->five_hour; | ||
| 1093 | + else if (strcmp(win, "weekly") == 0 || strstr(bid, "-weekly")) | ||
| 1094 | + target_win = &target_pool->weekly; | ||
| 1095 | + } | ||
| 1096 | + | ||
| 1097 | + if (target_win) { | ||
| 1098 | + target_win->present = 1; | ||
| 1099 | + snprintf(target_win->bucket_id, sizeof(target_win->bucket_id), "%s", bid); | ||
| 1100 | + target_win->pct = pct; | ||
| 1101 | + target_win->exhausted = exhausted; | ||
| 1102 | + snprintf(target_win->reset_time, sizeof(target_win->reset_time), "%s", rst); | ||
| 1103 | + } | ||
| 1104 | + bp = bend; | ||
| 1105 | + } | ||
| 1106 | + } | ||
| 1107 | + } | ||
| 1108 | + gp = gend; | ||
| 1109 | + } | ||
| 1110 | + } | ||
| 1111 | + } | ||
| 1112 | + } | ||
| 1113 | + | ||
| 1010 | q->ok = 1; | 1114 | q->ok = 1; |
| 1011 | } | 1115 | } |
| 1012 | - | ||
| 1013 | static void fetch_all_quotas(const char *bin, const acct_entry_t *accts, int count, | 1116 | static void fetch_all_quotas(const char *bin, const acct_entry_t *accts, int count, |
| 1014 | acct_quota_t *out_q) | 1117 | acct_quota_t *out_q) |
| 1015 | { | 1118 | { |
| @@ -1258,9 +1361,12 @@ static void compute_reset_fields(const char *iso, long long now_epoch, | @@ -1258,9 +1361,12 @@ static void compute_reset_fields(const char *iso, long long now_epoch, | ||
| 1258 | *secs_out = diff; | 1361 | *secs_out = diff; |
| 1259 | *hrs_out = (double)diff / 3600.0; | 1362 | *hrs_out = (double)diff / 3600.0; |
| 1260 | { | 1363 | { |
| 1261 | - long long hrs = diff / 3600LL; | 1364 | + long long days = diff / 86400LL; |
| 1365 | + long long hrs = (diff % 86400LL) / 3600LL; | ||
| 1262 | long long mins = (diff % 3600LL) / 60LL; | 1366 | long long mins = (diff % 3600LL) / 60LL; |
| 1263 | - if (hrs > 0) | 1367 | + if (days > 0) |
| 1368 | + snprintf(rem_out, rem_sz, "%lldd %lldh", days, hrs); | ||
| 1369 | + else if (hrs > 0) | ||
| 1264 | snprintf(rem_out, rem_sz, "%lldh %02lldm", hrs, mins); | 1370 | snprintf(rem_out, rem_sz, "%lldh %02lldm", hrs, mins); |
| 1265 | else | 1371 | else |
| 1266 | snprintf(rem_out, rem_sz, "%lldm", mins > 0 ? mins : 1LL); | 1372 | snprintf(rem_out, rem_sz, "%lldm", mins > 0 ? mins : 1LL); |
| @@ -1289,6 +1395,27 @@ static void emit_pool_json(buf_t *b, const pool_summary_t *p, long long now_epoc | @@ -1289,6 +1395,27 @@ static void emit_pool_json(buf_t *b, const pool_summary_t *p, long long now_epoc | ||
| 1289 | buf_addf(b, ",\"count\":%d}", p->count); | 1395 | buf_addf(b, ",\"count\":%d}", p->count); |
| 1290 | } | 1396 | } |
| 1291 | 1397 | ||
| 1398 | +static void emit_window_limit_json(buf_t *b, const window_limit_t *w, long long now_epoch) | ||
| 1399 | +{ | ||
| 1400 | + long long rsecs = -1; | ||
| 1401 | + double rhrs = -1.0; | ||
| 1402 | + char rrem[32] = {0}; | ||
| 1403 | + | ||
| 1404 | + if (!w || !w->present) { | ||
| 1405 | + buf_adds(b, "null"); | ||
| 1406 | + return; | ||
| 1407 | + } | ||
| 1408 | + compute_reset_fields(w->reset_time, now_epoch, &rsecs, &rhrs, rrem, sizeof(rrem)); | ||
| 1409 | + buf_adds(b, "{\"bucket_id\":"); | ||
| 1410 | + buf_json(b, w->bucket_id); | ||
| 1411 | + buf_addf(b, ",\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":", | ||
| 1412 | + w->pct, w->exhausted ? "true" : "false"); | ||
| 1413 | + buf_json(b, w->reset_time); | ||
| 1414 | + buf_addf(b, ",\"reset_in_seconds\":%lld,\"reset_in_hours\":%.2f,\"reset_remaining\":", | ||
| 1415 | + rsecs, rhrs); | ||
| 1416 | + buf_json(b, rrem); | ||
| 1417 | + buf_addc(b, '}'); | ||
| 1418 | +} | ||
| 1292 | static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quota_t *q) | 1419 | static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quota_t *q) |
| 1293 | { | 1420 | { |
| 1294 | int i; | 1421 | int i; |
| @@ -1320,6 +1447,15 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo | @@ -1320,6 +1447,15 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo | ||
| 1320 | emit_pool_json(b, &q->argon, now_epoch); | 1447 | emit_pool_json(b, &q->argon, now_epoch); |
| 1321 | buf_adds(b, ",\"claude\":"); | 1448 | buf_adds(b, ",\"claude\":"); |
| 1322 | emit_pool_json(b, &q->claude, now_epoch); | 1449 | emit_pool_json(b, &q->claude, now_epoch); |
| 1450 | + buf_adds(b, ",\"limits\":{\"gemini\":{\"five_hour\":"); | ||
| 1451 | + emit_window_limit_json(b, &q->gemini_limits.five_hour, now_epoch); | ||
| 1452 | + buf_adds(b, ",\"weekly\":"); | ||
| 1453 | + emit_window_limit_json(b, &q->gemini_limits.weekly, now_epoch); | ||
| 1454 | + buf_adds(b, "},\"claude\":{\"five_hour\":"); | ||
| 1455 | + emit_window_limit_json(b, &q->claude_limits.five_hour, now_epoch); | ||
| 1456 | + buf_adds(b, ",\"weekly\":"); | ||
| 1457 | + emit_window_limit_json(b, &q->claude_limits.weekly, now_epoch); | ||
| 1458 | + buf_adds(b, "}}"); | ||
| 1323 | buf_adds(b, ",\"models\":["); | 1459 | buf_adds(b, ",\"models\":["); |
| 1324 | for (i = 0; i < q->model_count; i++) { | 1460 | for (i = 0; i < q->model_count; i++) { |
| 1325 | const model_quota_t *m = &q->models[i]; | 1461 | const model_quota_t *m = &q->models[i]; |
| index 02dcd58..ff3ea23 100644 | index 02dcd58..ff3ea23 100644 | ||
| --- a/src/ui.html | --- a/src/ui.html | ||
| +++ b/src/ui.html | +++ b/src/ui.html | ||
| @@ -71,8 +71,12 @@ body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14 | @@ -71,8 +71,12 @@ body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14 | ||
| 71 | .meter > i.warn{background:var(--orange)} | 71 | .meter > i.warn{background:var(--orange)} |
| 72 | .meter > i.bad{background:var(--red)} | 72 | .meter > i.bad{background:var(--red)} |
| 73 | .pool-reset{margin-top:6px;font-size:11.5px;color:var(--text-2)} | 73 | .pool-reset{margin-top:6px;font-size:11.5px;color:var(--text-2)} |
| 74 | +.pool-win{margin-top:8px;padding-top:8px;border-top:1px solid var(--line)} | ||
| 75 | +.pool-win:first-of-type{margin-top:4px;padding-top:0;border-top:0} | ||
| 76 | +.pool-win-hd{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:4px} | ||
| 77 | +.pool-win-lbl{font-size:11px;font-weight:650;color:var(--text-2);text-transform:uppercase;letter-spacing:.04em} | ||
| 78 | +.pool-win-rst{margin-top:4px;font-size:11px;color:var(--text-2)} | ||
| 74 | .models{display:none;margin-top:10px;padding-top:10px;border-top:1px solid var(--line); | 79 | .models{display:none;margin-top:10px;padding-top:10px;border-top:1px solid var(--line); |
| 75 | - grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px} | ||
| 76 | .models.show{display:grid} | 80 | .models.show{display:grid} |
| 77 | .mrow{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11.5px;padding:2px 0} | 81 | .mrow{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11.5px;padding:2px 0} |
| 78 | .mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0} | 82 | .mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0} |
| @@ -228,9 +232,11 @@ function fmtResetShort(iso){ | @@ -228,9 +232,11 @@ function fmtResetShort(iso){ | ||
| 228 | if(isNaN(t))return iso; | 232 | if(isNaN(t))return iso; |
| 229 | var diff=Math.floor((t-Date.now())/1000); | 233 | var diff=Math.floor((t-Date.now())/1000); |
| 230 | if(diff<=0)return 'due'; | 234 | if(diff<=0)return 'due'; |
| 231 | - var totalH=Math.floor(diff/3600); | 235 | + var d=Math.floor(diff/86400); |
| 236 | + var h=Math.floor((diff%86400)/3600); | ||
| 232 | var m=Math.floor((diff%3600)/60); | 237 | var m=Math.floor((diff%3600)/60); |
| 233 | - if(totalH>0)return totalH+'h '+pad2(m)+'m'; | 238 | + if(d>0)return d+'d '+h+'h'; |
| 239 | + if(h>0)return h+'h '+pad2(m)+'m'; | ||
| 234 | return Math.max(1,m)+'m'; | 240 | return Math.max(1,m)+'m'; |
| 235 | } | 241 | } |
| 236 | function fmtReset(iso){ | 242 | function fmtReset(iso){ |
| @@ -240,12 +246,11 @@ function fmtReset(iso){ | @@ -240,12 +246,11 @@ function fmtReset(iso){ | ||
| 240 | var diff=Math.floor((t-Date.now())/1000); | 246 | var diff=Math.floor((t-Date.now())/1000); |
| 241 | var clk=fmtClock(t); | 247 | var clk=fmtClock(t); |
| 242 | if(diff<=0)return 'Resets soon · '+clk; | 248 | if(diff<=0)return 'Resets soon · '+clk; |
| 243 | - var totalH=Math.floor(diff/3600); | ||
| 244 | var d=Math.floor(diff/86400); | 249 | var d=Math.floor(diff/86400); |
| 245 | var h=Math.floor((diff%86400)/3600); | 250 | var h=Math.floor((diff%86400)/3600); |
| 246 | var m=Math.floor((diff%3600)/60); | 251 | var m=Math.floor((diff%3600)/60); |
| 247 | - if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk; | 252 | + if(d>0)return 'Resets in '+d+'d '+h+'h · '+clk; |
| 248 | - if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk; | 253 | + if(h>0)return 'Resets in '+h+'h '+pad2(m)+'m · '+clk; |
| 249 | return 'Resets in '+Math.max(1,m)+'m · '+clk; | 254 | return 'Resets in '+Math.max(1,m)+'m · '+clk; |
| 250 | } | 255 | } |
| 251 | function refreshResetLabels(){ | 256 | function refreshResetLabels(){ |
| @@ -285,8 +290,58 @@ function computeBest(){ | @@ -285,8 +290,58 @@ function computeBest(){ | ||
| 285 | return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,argon:bestA,argonPct:bestAP,argonReset:bestAR,claude:bestC,claudePct:bestCP,claudeReset:bestCR}; | 290 | return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,argon:bestA,argonPct:bestAP,argonReset:bestAR,claude:bestC,claudePct:bestCP,claudeReset:bestCR}; |
| 286 | } | 291 | } |
| 287 | 292 | ||
| 288 | -function renderPool(label,pool,loading){ | 293 | +function renderWindowRow(winLabel,lim){ |
| 294 | + var row=el('div','pool-win'); | ||
| 295 | + var hd=el('div','pool-win-hd'); | ||
| 296 | + hd.appendChild(el('span','pool-win-lbl',winLabel)); | ||
| 297 | + var pctEl=el('span','pool-pct'); | ||
| 298 | + var bar=el('div','meter'); | ||
| 299 | + var fill=el('i'); | ||
| 300 | + var rst=el('div','pool-win-rst'); | ||
| 301 | + | ||
| 302 | + if(!lim||lim.pct<0){ | ||
| 303 | + pctEl.className='pool-pct dim'; | ||
| 304 | + pctEl.textContent='N/A'; | ||
| 305 | + fill.style.width='0%'; | ||
| 306 | + rst.textContent='Not reported for this tier'; | ||
| 307 | + }else{ | ||
| 308 | + var cls=pctClass(lim.pct,lim.exhausted); | ||
| 309 | + pctEl.className='pool-pct '+cls; | ||
| 310 | + pctEl.textContent=fmtPct(lim); | ||
| 311 | + var w=lim.exhausted?0:Math.max(0,Math.min(100,lim.pct)); | ||
| 312 | + fill.className=cls; | ||
| 313 | + fill.style.width=w.toFixed(1)+'%'; | ||
| 314 | + if(lim.reset_time){ | ||
| 315 | + rst.textContent=fmtReset(lim.reset_time); | ||
| 316 | + rst.setAttribute('data-reset',lim.reset_time); | ||
| 317 | + rst.setAttribute('data-reset-mode','full'); | ||
| 318 | + var rt=Date.parse(lim.reset_time); | ||
| 319 | + if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+lim.reset_time+')'; | ||
| 320 | + }else if(lim.pct>=99.95){ | ||
| 321 | + rst.textContent='Full quota'; | ||
| 322 | + }else{ | ||
| 323 | + rst.textContent='Reset: -'; | ||
| 324 | + } | ||
| 325 | + } | ||
| 326 | + hd.appendChild(pctEl); | ||
| 327 | + bar.appendChild(fill); | ||
| 328 | + row.appendChild(hd); | ||
| 329 | + row.appendChild(bar); | ||
| 330 | + row.appendChild(rst); | ||
| 331 | + return row; | ||
| 332 | +} | ||
| 333 | + | ||
| 334 | +function renderPool(label,pool,loading,limits){ | ||
| 289 | var box=el('div','pool'); | 335 | var box=el('div','pool'); |
| 336 | + var hasLimits=limits&&(limits.five_hour||limits.weekly); | ||
| 337 | + if(hasLimits){ | ||
| 338 | + var hd=el('div','pool-hd'); | ||
| 339 | + hd.appendChild(el('span','pool-name',label)); | ||
| 340 | + box.appendChild(hd); | ||
| 341 | + box.appendChild(renderWindowRow('5-Hour Limit',limits.five_hour)); | ||
| 342 | + box.appendChild(renderWindowRow('Weekly Limit',limits.weekly)); | ||
| 343 | + return box; | ||
| 344 | + } | ||
| 290 | var hd=el('div','pool-hd'); | 345 | var hd=el('div','pool-hd'); |
| 291 | hd.appendChild(el('span','pool-name',label)); | 346 | hd.appendChild(el('span','pool-name',label)); |
| 292 | var pctEl=el('span','pool-pct'); | 347 | var pctEl=el('span','pool-pct'); |
| @@ -326,7 +381,6 @@ function renderPool(label,pool,loading){ | @@ -326,7 +381,6 @@ function renderPool(label,pool,loading){ | ||
| 326 | box.appendChild(rst); | 381 | box.appendChild(rst); |
| 327 | return box; | 382 | return box; |
| 328 | } | 383 | } |
| 329 | - | ||
| 330 | function render(){ | 384 | function render(){ |
| 331 | var best=computeBest(); | 385 | var best=computeBest(); |
| 332 | $('kpiSelected').textContent=shortEmail(state.selected); | 386 | $('kpiSelected').textContent=shortEmail(state.selected); |
| @@ -379,13 +433,14 @@ function render(){ | @@ -379,13 +433,14 @@ function render(){ | ||
| 379 | card.appendChild(el('div','err-msg','Error: '+(qd.detail||qd.error||'quota fetch failed'))); | 433 | card.appendChild(el('div','err-msg','Error: '+(qd.detail||qd.error||'quota fetch failed'))); |
| 380 | }else{ | 434 | }else{ |
| 381 | var pools=el('div','pools'); | 435 | var pools=el('div','pools'); |
| 382 | - pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading)); | 436 | + var glim=qd&&qd.limits?qd.limits.gemini:null; |
| 437 | + var clim=qd&&qd.limits?qd.limits.claude:null; | ||
| 438 | + pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading,glim)); | ||
| 383 | if(qd&&qd.argon&&qd.argon.count>0){ | 439 | if(qd&&qd.argon&&qd.argon.count>0){ |
| 384 | - pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading)); | 440 | + pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading,null)); |
| 385 | } | 441 | } |
| 386 | - pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading)); | 442 | + pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading,clim)); |
| 387 | card.appendChild(pools); | 443 | card.appendChild(pools); |
| 388 | - | ||
| 389 | if(qd&&qd.models&&qd.models.length){ | 444 | if(qd&&qd.models&&qd.models.length){ |
| 390 | var mgrid=el('div','models'+(state.showModels?' show':'')); | 445 | var mgrid=el('div','models'+(state.showModels?' show':'')); |
| 391 | qd.models.forEach(function(m){ | 446 | qd.models.forEach(function(m){ |
| index d605958..1992012 100644 | index d605958..1992012 100644 | ||
| --- a/src/ui_html.h | --- a/src/ui_html.h | ||
| +++ b/src/ui_html.h | +++ b/src/ui_html.h | ||
| @@ -76,8 +76,12 @@ static const char *UI_HTML = | @@ -76,8 +76,12 @@ static const char *UI_HTML = | ||
| 76 | ".meter > i.warn{background:var(--orange)}\n" | 76 | ".meter > i.warn{background:var(--orange)}\n" |
| 77 | ".meter > i.bad{background:var(--red)}\n" | 77 | ".meter > i.bad{background:var(--red)}\n" |
| 78 | ".pool-reset{margin-top:6px;font-size:11.5px;color:var(--text-2)}\n" | 78 | ".pool-reset{margin-top:6px;font-size:11.5px;color:var(--text-2)}\n" |
| 79 | + ".pool-win{margin-top:8px;padding-top:8px;border-top:1px solid var(--line)}\n" | ||
| 80 | + ".pool-win:first-of-type{margin-top:4px;padding-top:0;border-top:0}\n" | ||
| 81 | + ".pool-win-hd{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:4px}\n" | ||
| 82 | + ".pool-win-lbl{font-size:11px;font-weight:650;color:var(--text-2);text-transform:uppercase;letter-spacing:.04em}\n" | ||
| 83 | + ".pool-win-rst{margin-top:4px;font-size:11px;color:var(--text-2)}\n" | ||
| 79 | ".models{display:none;margin-top:10px;padding-top:10px;border-top:1px solid var(--line);\n" | 84 | ".models{display:none;margin-top:10px;padding-top:10px;border-top:1px solid var(--line);\n" |
| 80 | - " grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}\n" | ||
| 81 | ".models.show{display:grid}\n" | 85 | ".models.show{display:grid}\n" |
| 82 | ".mrow{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11.5px;padding:2px 0}\n" | 86 | ".mrow{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11.5px;padding:2px 0}\n" |
| 83 | ".mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}\n" | 87 | ".mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}\n" |
| @@ -233,9 +237,11 @@ static const char *UI_HTML = | @@ -233,9 +237,11 @@ static const char *UI_HTML = | ||
| 233 | " if(isNaN(t))return iso;\n" | 237 | " if(isNaN(t))return iso;\n" |
| 234 | " var diff=Math.floor((t-Date.now())/1000);\n" | 238 | " var diff=Math.floor((t-Date.now())/1000);\n" |
| 235 | " if(diff<=0)return 'due';\n" | 239 | " if(diff<=0)return 'due';\n" |
| 236 | - " var totalH=Math.floor(diff/3600);\n" | 240 | + " var d=Math.floor(diff/86400);\n" |
| 241 | + " var h=Math.floor((diff%86400)/3600);\n" | ||
| 237 | " var m=Math.floor((diff%3600)/60);\n" | 242 | " var m=Math.floor((diff%3600)/60);\n" |
| 238 | - " if(totalH>0)return totalH+'h '+pad2(m)+'m';\n" | 243 | + " if(d>0)return d+'d '+h+'h';\n" |
| 244 | + " if(h>0)return h+'h '+pad2(m)+'m';\n" | ||
| 239 | " return Math.max(1,m)+'m';\n" | 245 | " return Math.max(1,m)+'m';\n" |
| 240 | "}\n" | 246 | "}\n" |
| 241 | "function fmtReset(iso){\n" | 247 | "function fmtReset(iso){\n" |
| @@ -245,12 +251,11 @@ static const char *UI_HTML = | @@ -245,12 +251,11 @@ static const char *UI_HTML = | ||
| 245 | " var diff=Math.floor((t-Date.now())/1000);\n" | 251 | " var diff=Math.floor((t-Date.now())/1000);\n" |
| 246 | " var clk=fmtClock(t);\n" | 252 | " var clk=fmtClock(t);\n" |
| 247 | " if(diff<=0)return 'Resets soon · '+clk;\n" | 253 | " if(diff<=0)return 'Resets soon · '+clk;\n" |
| 248 | - " var totalH=Math.floor(diff/3600);\n" | ||
| 249 | " var d=Math.floor(diff/86400);\n" | 254 | " var d=Math.floor(diff/86400);\n" |
| 250 | " var h=Math.floor((diff%86400)/3600);\n" | 255 | " var h=Math.floor((diff%86400)/3600);\n" |
| 251 | " var m=Math.floor((diff%3600)/60);\n" | 256 | " var m=Math.floor((diff%3600)/60);\n" |
| 252 | - " if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk;\n" | 257 | + " if(d>0)return 'Resets in '+d+'d '+h+'h · '+clk;\n" |
| 253 | - " if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk;\n" | 258 | + " if(h>0)return 'Resets in '+h+'h '+pad2(m)+'m · '+clk;\n" |
| 254 | " return 'Resets in '+Math.max(1,m)+'m · '+clk;\n" | 259 | " return 'Resets in '+Math.max(1,m)+'m · '+clk;\n" |
| 255 | "}\n" | 260 | "}\n" |
| 256 | "function refreshResetLabels(){\n" | 261 | "function refreshResetLabels(){\n" |
| @@ -290,8 +295,58 @@ static const char *UI_HTML = | @@ -290,8 +295,58 @@ static const char *UI_HTML = | ||
| 290 | " return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,argon:bestA,argonPct:bestAP,argonReset:bestAR,claude:bestC,claudePct:bestCP,claudeReset:bestCR};\n" | 295 | " return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,argon:bestA,argonPct:bestAP,argonReset:bestAR,claude:bestC,claudePct:bestCP,claudeReset:bestCR};\n" |
| 291 | "}\n" | 296 | "}\n" |
| 292 | "\n" | 297 | "\n" |
| 293 | - "function renderPool(label,pool,loading){\n" | 298 | + "function renderWindowRow(winLabel,lim){\n" |
| 299 | + " var row=el('div','pool-win');\n" | ||
| 300 | + " var hd=el('div','pool-win-hd');\n" | ||
| 301 | + " hd.appendChild(el('span','pool-win-lbl',winLabel));\n" | ||
| 302 | + " var pctEl=el('span','pool-pct');\n" | ||
| 303 | + " var bar=el('div','meter');\n" | ||
| 304 | + " var fill=el('i');\n" | ||
| 305 | + " var rst=el('div','pool-win-rst');\n" | ||
| 306 | + "\n" | ||
| 307 | + " if(!lim||lim.pct<0){\n" | ||
| 308 | + " pctEl.className='pool-pct dim';\n" | ||
| 309 | + " pctEl.textContent='N/A';\n" | ||
| 310 | + " fill.style.width='0%';\n" | ||
| 311 | + " rst.textContent='Not reported for this tier';\n" | ||
| 312 | + " }else{\n" | ||
| 313 | + " var cls=pctClass(lim.pct,lim.exhausted);\n" | ||
| 314 | + " pctEl.className='pool-pct '+cls;\n" | ||
| 315 | + " pctEl.textContent=fmtPct(lim);\n" | ||
| 316 | + " var w=lim.exhausted?0:Math.max(0,Math.min(100,lim.pct));\n" | ||
| 317 | + " fill.className=cls;\n" | ||
| 318 | + " fill.style.width=w.toFixed(1)+'%';\n" | ||
| 319 | + " if(lim.reset_time){\n" | ||
| 320 | + " rst.textContent=fmtReset(lim.reset_time);\n" | ||
| 321 | + " rst.setAttribute('data-reset',lim.reset_time);\n" | ||
| 322 | + " rst.setAttribute('data-reset-mode','full');\n" | ||
| 323 | + " var rt=Date.parse(lim.reset_time);\n" | ||
| 324 | + " if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+lim.reset_time+')';\n" | ||
| 325 | + " }else if(lim.pct>=99.95){\n" | ||
| 326 | + " rst.textContent='Full quota';\n" | ||
| 327 | + " }else{\n" | ||
| 328 | + " rst.textContent='Reset: -';\n" | ||
| 329 | + " }\n" | ||
| 330 | + " }\n" | ||
| 331 | + " hd.appendChild(pctEl);\n" | ||
| 332 | + " bar.appendChild(fill);\n" | ||
| 333 | + " row.appendChild(hd);\n" | ||
| 334 | + " row.appendChild(bar);\n" | ||
| 335 | + " row.appendChild(rst);\n" | ||
| 336 | + " return row;\n" | ||
| 337 | + "}\n" | ||
| 338 | + "\n" | ||
| 339 | + "function renderPool(label,pool,loading,limits){\n" | ||
| 294 | " var box=el('div','pool');\n" | 340 | " var box=el('div','pool');\n" |
| 341 | + " var hasLimits=limits&&(limits.five_hour||limits.weekly);\n" | ||
| 342 | + " if(hasLimits){\n" | ||
| 343 | + " var hd=el('div','pool-hd');\n" | ||
| 344 | + " hd.appendChild(el('span','pool-name',label));\n" | ||
| 345 | + " box.appendChild(hd);\n" | ||
| 346 | + " box.appendChild(renderWindowRow('5-Hour Limit',limits.five_hour));\n" | ||
| 347 | + " box.appendChild(renderWindowRow('Weekly Limit',limits.weekly));\n" | ||
| 348 | + " return box;\n" | ||
| 349 | + " }\n" | ||
| 295 | " var hd=el('div','pool-hd');\n" | 350 | " var hd=el('div','pool-hd');\n" |
| 296 | " hd.appendChild(el('span','pool-name',label));\n" | 351 | " hd.appendChild(el('span','pool-name',label));\n" |
| 297 | " var pctEl=el('span','pool-pct');\n" | 352 | " var pctEl=el('span','pool-pct');\n" |
| @@ -331,7 +386,6 @@ static const char *UI_HTML = | @@ -331,7 +386,6 @@ static const char *UI_HTML = | ||
| 331 | " box.appendChild(rst);\n" | 386 | " box.appendChild(rst);\n" |
| 332 | " return box;\n" | 387 | " return box;\n" |
| 333 | "}\n" | 388 | "}\n" |
| 334 | - "\n" | ||
| 335 | "function render(){\n" | 389 | "function render(){\n" |
| 336 | " var best=computeBest();\n" | 390 | " var best=computeBest();\n" |
| 337 | " $('kpiSelected').textContent=shortEmail(state.selected);\n" | 391 | " $('kpiSelected').textContent=shortEmail(state.selected);\n" |
| @@ -384,13 +438,14 @@ static const char *UI_HTML = | @@ -384,13 +438,14 @@ static const char *UI_HTML = | ||
| 384 | " card.appendChild(el('div','err-msg','Error: '+(qd.detail||qd.error||'quota fetch failed')));\n" | 438 | " card.appendChild(el('div','err-msg','Error: '+(qd.detail||qd.error||'quota fetch failed')));\n" |
| 385 | " }else{\n" | 439 | " }else{\n" |
| 386 | " var pools=el('div','pools');\n" | 440 | " var pools=el('div','pools');\n" |
| 387 | - " pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading));\n" | 441 | + " var glim=qd&&qd.limits?qd.limits.gemini:null;\n" |
| 442 | + " var clim=qd&&qd.limits?qd.limits.claude:null;\n" | ||
| 443 | + " pools.appendChild(renderPool('Gemini Pool',qd?qd.gemini:null,state.loading,glim));\n" | ||
| 388 | " if(qd&&qd.argon&&qd.argon.count>0){\n" | 444 | " if(qd&&qd.argon&&qd.argon.count>0){\n" |
| 389 | - " pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading));\n" | 445 | + " pools.appendChild(renderPool('Argon Pool',qd.argon,state.loading,null));\n" |
| 390 | " }\n" | 446 | " }\n" |
| 391 | - " pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading));\n" | 447 | + " pools.appendChild(renderPool('Claude Pool',qd?qd.claude:null,state.loading,clim));\n" |
| 392 | " card.appendChild(pools);\n" | 448 | " card.appendChild(pools);\n" |
| 393 | - "\n" | ||
| 394 | " if(qd&&qd.models&&qd.models.length){\n" | 449 | " if(qd&&qd.models&&qd.models.length){\n" |
| 395 | " var mgrid=el('div','models'+(state.showModels?' show':''));\n" | 450 | " var mgrid=el('div','models'+(state.showModels?' show':''));\n" |
| 396 | " qd.models.forEach(function(m){\n" | 451 | " qd.models.forEach(function(m){\n" |
| index 875750e..baa5962 100755 | index 875750e..baa5962 100755 | ||
| --- a/tests/mock_quota.sh | --- a/tests/mock_quota.sh | ||
| +++ b/tests/mock_quota.sh | +++ b/tests/mock_quota.sh | ||
| @@ -44,7 +44,25 @@ case "$acct" in | @@ -44,7 +44,25 @@ case "$acct" in | ||
| 44 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar", "remainingFraction": 0.855}, | 44 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar", "remainingFraction": 0.855}, |
| 45 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-neon-high", "remainingFraction": 0.855}, | 45 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-neon-high", "remainingFraction": 0.855}, |
| 46 | {"tokenType": "WTUS", "modelId": "tab_flash_lite_preview", "remainingFraction": 1} | 46 | {"tokenType": "WTUS", "modelId": "tab_flash_lite_preview", "remainingFraction": 1} |
| 47 | - ] | 47 | + ], |
| 48 | + "summary": { | ||
| 49 | + "groups": [ | ||
| 50 | + { | ||
| 51 | + "displayName": "Gemini Models", | ||
| 52 | + "buckets": [ | ||
| 53 | + {"bucketId": "gemini-weekly", "window": "weekly", "remainingFraction": 0.855, "resetTime": "$RST_GEMINI"}, | ||
| 54 | + {"bucketId": "gemini-5h", "window": "5h", "remainingFraction": 0.375, "resetTime": "$RST_CLAUDE"} | ||
| 55 | + ] | ||
| 56 | + }, | ||
| 57 | + { | ||
| 58 | + "displayName": "Claude and GPT models", | ||
| 59 | + "buckets": [ | ||
| 60 | + {"bucketId": "3p-weekly", "window": "weekly", "remainingFraction": 0.99, "resetTime": "$RST_GEMINI"}, | ||
| 61 | + {"bucketId": "3p-5h", "window": "5h", "remainingFraction": 1} | ||
| 62 | + ] | ||
| 63 | + } | ||
| 64 | + ] | ||
| 65 | + } | ||
| 48 | } | 66 | } |
| 49 | EOF | 67 | EOF |
| 50 | exit 0 | 68 | exit 0 |
| @@ -60,7 +78,24 @@ EOF | @@ -60,7 +78,24 @@ EOF | ||
| 60 | {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 0.42}, | 78 | {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 0.42}, |
| 61 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": null}, | 79 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": null}, |
| 62 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar"} | 80 | {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar"} |
| 63 | - ] | 81 | + ], |
| 82 | + "summary": { | ||
| 83 | + "groups": [ | ||
| 84 | + { | ||
| 85 | + "displayName": "Gemini Models", | ||
| 86 | + "buckets": [ | ||
| 87 | + {"bucketId": "gemini-weekly", "window": "weekly", "resetTime": "$RST_GEMINI"} | ||
| 88 | + ] | ||
| 89 | + }, | ||
| 90 | + { | ||
| 91 | + "displayName": "Claude and GPT models", | ||
| 92 | + "buckets": [ | ||
| 93 | + {"bucketId": "3p-weekly", "window": "weekly", "remainingFraction": 0.42, "resetTime": "$RST_GEMINI"}, | ||
| 94 | + {"bucketId": "3p-5h", "window": "5h", "remainingFraction": 0.50, "resetTime": "$RST_CLAUDE"} | ||
| 95 | + ] | ||
| 96 | + } | ||
| 97 | + ] | ||
| 98 | + } | ||
| 64 | } | 99 | } |
| 65 | EOF | 100 | EOF |
| 66 | exit 0 | 101 | exit 0 |
| index 6f4d62d..fbc306d 100755 | index 6f4d62d..fbc306d 100755 | ||
| --- a/tests/run.sh | --- a/tests/run.sh | ||
| +++ b/tests/run.sh | +++ b/tests/run.sh | ||
| @@ -102,7 +102,7 @@ META_ENV=$(BOT_PASSWORD=secret-pass SX_PLUGIN_META=1 $BIN) | @@ -102,7 +102,7 @@ META_ENV=$(BOT_PASSWORD=secret-pass SX_PLUGIN_META=1 $BIN) | ||
| 102 | check "SX_PLUGIN_META=1 works without auth" '{"name":"google quota","desc":"Account quotas"}' "$META_ENV" | 102 | check "SX_PLUGIN_META=1 works without auth" '{"name":"google quota","desc":"Account quotas"}' "$META_ENV" |
| 103 | 103 | ||
| 104 | VER=$($BIN --version) | 104 | VER=$($BIN --version) |
| 105 | -check "--version prints plugin id and version" "plugin_google_quota 1.0.2" "$VER" | 105 | +check "--version prints plugin id and version" "plugin_google_quota 1.0.3" "$VER" |
| 106 | UNAUTH=$(BOT_PASSWORD=secret-pass QUERY_STRING="action=status" $BIN) | 106 | UNAUTH=$(BOT_PASSWORD=secret-pass QUERY_STRING="action=status" $BIN) |
| 107 | check "missing password returns 401" "Status: 401 Unauthorized" "$UNAUTH" | 107 | check "missing password returns 401" "Status: 401 Unauthorized" "$UNAUTH" |
| 108 | 108 | ||
| @@ -135,17 +135,20 @@ json_ok "missing CLI sets cli_present false" "$ST_NOCLI" "d['ok'] is True and d[ | @@ -135,17 +135,20 @@ json_ok "missing CLI sets cli_present false" "$ST_NOCLI" "d['ok'] is True and d[ | ||
| 135 | section "quota" | 135 | section "quota" |
| 136 | Q_ONE=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=alpha@example.com") | 136 | Q_ONE=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=alpha@example.com") |
| 137 | json_ok "single account quota parses gemini, argon, and claude pools and remaining hours" "$Q_ONE" \ | 137 | json_ok "single account quota parses gemini, argon, and claude pools and remaining hours" "$Q_ONE" \ |
| 138 | - "d['ok'] is True and d['account']['ok'] is True and abs(d['account']['gemini']['pct'] - 85.5) < 0.01 and abs(d['account']['argon']['pct'] - 100.0) < 0.01 and abs(d['account']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 9 and d['account']['gemini']['reset_in_seconds'] > 500000 and d['account']['gemini']['reset_in_hours'] > 140 and 'h ' in d['account']['gemini']['reset_remaining'] and d['account']['claude']['reset_in_seconds'] > 7000 and 'h ' in d['account']['claude']['reset_remaining'] and all('reset_remaining' in m and 'reset_in_hours' in m for m in d['account']['models'])" | 138 | + "d['ok'] is True and d['account']['ok'] is True and abs(d['account']['gemini']['pct'] - 85.5) < 0.01 and abs(d['account']['argon']['pct'] - 100.0) < 0.01 and abs(d['account']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 9 and d['account']['gemini']['reset_in_seconds'] > 500000 and d['account']['gemini']['reset_in_hours'] > 140 and 'd ' in d['account']['gemini']['reset_remaining'] and d['account']['claude']['reset_in_seconds'] > 7000 and 'h ' in d['account']['claude']['reset_remaining'] and all('reset_remaining' in m and 'reset_in_hours' in m for m in d['account']['models'])" |
| 139 | +json_ok "single account quota parses both 5-hour and weekly limits" "$Q_ONE" \ | ||
| 140 | + "abs(d['account']['limits']['gemini']['five_hour']['pct'] - 37.5) < 0.01 and abs(d['account']['limits']['gemini']['weekly']['pct'] - 85.5) < 0.01 and 'd ' in d['account']['limits']['gemini']['weekly']['reset_remaining'] and 'h ' in d['account']['limits']['gemini']['five_hour']['reset_remaining'] and abs(d['account']['limits']['claude']['five_hour']['pct'] - 100.0) < 0.01 and abs(d['account']['limits']['claude']['weekly']['pct'] - 99.0) < 0.01" | ||
| 139 | check_not "single quota never leaks token" "MOCK-TOKEN" "$Q_ONE" | 141 | check_not "single quota never leaks token" "MOCK-TOKEN" "$Q_ONE" |
| 140 | check_not "single quota never leaks refresh token" "MOCK-REFRESH-TOKEN" "$Q_ONE" | 142 | check_not "single quota never leaks refresh token" "MOCK-REFRESH-TOKEN" "$Q_ONE" |
| 141 | 143 | ||
| 142 | Q_EXH=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=beta@example.com") | 144 | Q_EXH=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=beta@example.com") |
| 143 | json_ok "null/missing remainingFraction marks gemini pool exhausted with reset remaining" "$Q_EXH" \ | 145 | json_ok "null/missing remainingFraction marks gemini pool exhausted with reset remaining" "$Q_EXH" \ |
| 144 | - "d['ok'] is True and d['account']['gemini']['exhausted'] is True and d['account']['gemini']['pct'] == 0.0 and abs(d['account']['claude']['pct'] - 42.0) < 0.01 and d['account']['gemini']['reset_in_hours'] > 140 and 'h ' in d['account']['gemini']['reset_remaining']" | 146 | + "d['ok'] is True and d['account']['gemini']['exhausted'] is True and d['account']['gemini']['pct'] == 0.0 and abs(d['account']['claude']['pct'] - 42.0) < 0.01 and d['account']['gemini']['reset_in_hours'] > 140 and 'd ' in d['account']['gemini']['reset_remaining']" |
| 147 | +json_ok "free account missing gemini 5h returns null five_hour and exhausted weekly" "$Q_EXH" \ | ||
| 148 | + "d['account']['limits']['gemini']['five_hour'] is None and d['account']['limits']['gemini']['weekly']['exhausted'] is True and d['account']['limits']['gemini']['weekly']['pct'] == 0.0 and abs(d['account']['limits']['claude']['five_hour']['pct'] - 50.0) < 0.01 and abs(d['account']['limits']['claude']['weekly']['pct'] - 42.0) < 0.01" | ||
| 145 | Q_ALL=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota") | 149 | Q_ALL=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota") |
| 146 | json_ok "all-accounts quota aggregates best_gemini, best_argon, best_claude, and broken account" "$Q_ALL" \ | 150 | json_ok "all-accounts quota aggregates best_gemini, best_argon, best_claude, and broken account" "$Q_ALL" \ |
| 147 | "d['ok'] is True and d['count'] == 3 and d['best_gemini'] == 'alpha@example.com' and d['best_argon'] == 'alpha@example.com' and d['best_claude'] == 'alpha@example.com' and d['accounts'][2]['ok'] is False" | 151 | "d['ok'] is True and d['count'] == 3 and d['best_gemini'] == 'alpha@example.com' and d['best_argon'] == 'alpha@example.com' and d['best_claude'] == 'alpha@example.com' and d['accounts'][2]['ok'] is False" |
| 148 | -check_not "all-accounts quota never leaks token" "MOCK-TOKEN" "$Q_ALL" | ||
| 149 | 152 | ||
| 150 | Q_FMT=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "format=json") | 153 | Q_FMT=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "format=json") |
| 151 | json_ok "?format=json returns full quota JSON" "$Q_FMT" "d['ok'] is True and d['count'] == 3 and 'best_gemini' in d" | 154 | json_ok "?format=json returns full quota JSON" "$Q_FMT" "d['ok'] is True and d['count'] == 3 and 'best_gemini' in d" |
| @@ -180,10 +183,11 @@ check "HTML includes bot theme prepaint" "bot_theme" "$HTML" | @@ -180,10 +183,11 @@ check "HTML includes bot theme prepaint" "bot_theme" "$HTML" | ||
| 180 | check "HTML includes theme handoff" "sx-theme-request" "$HTML" | 183 | check "HTML includes theme handoff" "sx-theme-request" "$HTML" |
| 181 | check "HTML uses two-route API helper" "plugin_google_quota" "$HTML" | 184 | check "HTML uses two-route API helper" "plugin_google_quota" "$HTML" |
| 182 | check "HTML hub proxy URL uses &action= separator" "'/plugins?plugin='+encodeURIComponent(HUB)+'&'" "$HTML" | 185 | check "HTML hub proxy URL uses &action= separator" "'/plugins?plugin='+encodeURIComponent(HUB)+'&'" "$HTML" |
| 183 | -check "HTML formats total remaining hours even >= 24h" "totalH>=24" "$HTML" | 186 | +check "HTML formats multi-day remaining resets cleanly" "d+'d '+h+'h'" "$HTML" |
| 187 | +check "HTML renders both 5-hour and weekly limit sections" "5-Hour Limit" "$HTML" | ||
| 188 | +check "HTML renders weekly limit label" "Weekly Limit" "$HTML" | ||
| 184 | check "HTML renders per-model reset remaining hours" "fmtResetShort" "$HTML" | 189 | check "HTML renders per-model reset remaining hours" "fmtResetShort" "$HTML" |
| 185 | check "HTML includes live reset countdown attributes" "data-reset" "$HTML" | 190 | check "HTML includes live reset countdown attributes" "data-reset" "$HTML" |
| 186 | -check "HTML hides theme toggle in embed mode" "embed-hide" "$HTML" | ||
| 187 | check_not "HTML loads no CDN script" "<script src=" "$HTML" | 191 | check_not "HTML loads no CDN script" "<script src=" "$HTML" |
| 188 | check_not "HTML references no external host script" "cdnjs" "$HTML" | 192 | check_not "HTML references no external host script" "cdnjs" "$HTML" |
| 189 | check_not "HTML makes no outbound fetch to googleapis" "googleapis.com" "$HTML" | 193 | check_not "HTML makes no outbound fetch to googleapis" "googleapis.com" "$HTML" |
| 190 | 194 |