feat(quota): show remaining hours and live reset countdown (v1.0.1)
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-19 02:46:20
Commit065f3fac
Parentsb5ec2c15
Changed files
README.md+2−2■■■■
plugin.json+1−0■
src/plugin_google_quota.c+105−7■■■■■
src/ui.html+64−15■■■■■
src/ui_html.h+64−15■■■■■
tests/mock_quota.sh+12−9■■■■■
tests/run.sh+10−10■■■■■
7 files+258−58
Diff
README.md+2−2■■■■
index 209efcb..9b30545 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ account list (`antigravity_accounts.json`) and active selection
88 click.
99
1010 * `--meta` -> `{"name":"google quota","desc":"Account quotas"}`
11-* `--version` -> `plugin_google_quota 1.0.0`
11+* `--version` -> `plugin_google_quota 1.0.1`
1212 * Catalog slug `google-quota`, category `devtools`
1313 * Public source: <https://plugingit.scorpiox.net/scorpiox-bot-plugin-google-quota.git>
1414 * Prebuilt binaries: <https://dist.scorpiox.net/bot-plugins/google-quota/>
@@ -59,7 +59,7 @@ extracted; token strings are never copied or emitted.
5959 All actions accept `X-Bot-Password`, `Authorization: Bearer`, or `?pwd=`.
6060
6161 * `GET ?action=status` — fast local read of configured accounts, `selected`, paths, and `cli_present`
62-* `GET ?action=quota` (or `?format=json`) — queries all accounts concurrently and returns Gemini/Claude pool summaries, reset times, per-model buckets, `best_gemini`, and `best_claude`
62+* `GET ?action=quota` (or `?format=json`) — queries all accounts concurrently and returns Gemini/Claude pool summaries, reset times (`reset_time`, `reset_in_seconds`, `reset_in_hours`, `reset_remaining`), per-model buckets, `best_gemini`, and `best_claude`
6363 * `GET ?action=quota&account=<email>` — queries a single account
6464 * `GET/POST ?action=switch&account=<email>` (or JSON body `{"account":"..."}`) — validates the email against `antigravity_accounts.json` and writes `selected_account.txt`
6565
plugin.json+1−0■
index 58d102f..49f1b9a 100644
--- a/plugin.json
+++ b/plugin.json
@@ -2,6 +2,7 @@
22 "slug": "google-quota",
33 "id": "plugin_google_quota",
44 "title": "Google Account Quotas",
5+ "version": "1.0.1",
56 "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.",
67 "category": "devtools",
78 "license": "MIT",
src/plugin_google_quota.c+105−7■■■■■
index 97e4490..b1bbb8e 100644
--- a/src/plugin_google_quota.c
+++ b/src/plugin_google_quota.c
@@ -51,11 +51,13 @@
5151 #include <ctype.h>
5252 #include <errno.h>
5353 #include <stdarg.h>
54+#include <time.h>
5455
5556 #if defined(_WIN32)
5657 # define WIN32_LEAN_AND_MEAN
5758 # include <windows.h>
5859 # include <direct.h>
60+# include <fcntl.h>
5961 # include <io.h>
6062 # define popen _popen
6163 # define pclose _pclose
@@ -75,10 +77,9 @@
7577
7678 #define PLUGIN_SLUG "google-quota"
7779 #define PLUGIN_ID "plugin_google_quota"
78-#define PLUGIN_VER "1.0.0"
80+#define PLUGIN_VER "1.0.1"
7981 #define PLUGIN_NAME "google quota"
8082 #define PLUGIN_DESC "Account quotas"
81-
8283 #define DEFAULT_QUOTA_BIN "scorpiox-google-quota"
8384
8485 #define PATH_SZ 1024
@@ -885,7 +886,7 @@ static void pool_add(pool_summary_t *p, double pct, int exhausted, const char *r
885886 if (!p->present || pct < p->pct) p->pct = pct;
886887 p->present = 1;
887888 if (exhausted || pct <= 0.0) p->exhausted = 1;
888- if (!p->reset_time[0] && reset && reset[0])
889+ if (reset && reset[0] && (!p->reset_time[0] || strcmp(reset, p->reset_time) < 0))
889890 snprintf(p->reset_time, sizeof(p->reset_time), "%s", reset);
890891 p->count++;
891892 }
@@ -1186,21 +1187,107 @@ static void emit_error(int code, const char *status, const char *err, const char
11861187 buf_free(&b);
11871188 }
11881189
1189-static void emit_pool_json(buf_t *b, const pool_summary_t *p)
1190+static long long days_from_civil(int y, unsigned m, unsigned d)
1191+{
1192+ y -= (m <= 2) ? 1 : 0;
1193+ {
1194+ long long era = (y >= 0 ? y : y - 399) / 400;
1195+ unsigned yoe = (unsigned)(y - era * 400);
1196+ unsigned doy = (153U * (m + (m > 2 ? (unsigned)-3 : 9U)) + 2U) / 5U + d - 1U;
1197+ unsigned doe = yoe * 365U + yoe / 4U - yoe / 100U + doy;
1198+ return era * 146097LL + (long long)doe - 719468LL;
1199+ }
1200+}
1201+
1202+static int parse_iso_utc_epoch(const char *iso, long long *out_epoch)
1203+{
1204+ int y = 0, mo = 0, d = 0, hh = 0, mm = 0, ss = 0;
1205+ const char *t;
1206+ const char *tz;
1207+
1208+ if (!iso || !*iso) return 0;
1209+ if (sscanf(iso, "%d-%d-%dT%d:%d:%d", &y, &mo, &d, &hh, &mm, &ss) != 6)
1210+ return 0;
1211+ if (mo < 1 || mo > 12 || d < 1 || d > 31 ||
1212+ hh < 0 || hh > 23 || mm < 0 || mm > 59 || ss < 0 || ss > 60)
1213+ return 0;
1214+ t = strchr(iso, 'T');
1215+ if (!t) return 0;
1216+ {
1217+ long long days = days_from_civil(y, (unsigned)mo, (unsigned)d);
1218+ long long epoch = days * 86400LL + (long long)hh * 3600LL +
1219+ (long long)mm * 60LL + (long long)ss;
1220+ tz = strpbrk(t, "Z+-");
1221+ if (tz && (*tz == '+' || *tz == '-')) {
1222+ int oh = 0, om = 0;
1223+ if (sscanf(tz + 1, "%2d:%2d", &oh, &om) >= 1) {
1224+ long long off = (long long)oh * 3600LL + (long long)om * 60LL;
1225+ epoch += (*tz == '+') ? -off : off;
1226+ }
1227+ }
1228+ *out_epoch = epoch;
1229+ return 1;
1230+ }
1231+}
1232+
1233+static void compute_reset_fields(const char *iso, long long now_epoch,
1234+ long long *secs_out, double *hrs_out,
1235+ char *rem_out, size_t rem_sz)
1236+{
1237+ long long target = 0;
1238+ long long diff;
1239+
1240+ if (!iso || !iso[0] || !parse_iso_utc_epoch(iso, &target)) {
1241+ *secs_out = -1;
1242+ *hrs_out = -1.0;
1243+ if (rem_sz) rem_out[0] = '\0';
1244+ return;
1245+ }
1246+ diff = target - now_epoch;
1247+ if (diff <= 0) {
1248+ *secs_out = 0;
1249+ *hrs_out = 0.0;
1250+ snprintf(rem_out, rem_sz, "due");
1251+ return;
1252+ }
1253+ *secs_out = diff;
1254+ *hrs_out = (double)diff / 3600.0;
1255+ {
1256+ long long hrs = diff / 3600LL;
1257+ long long mins = (diff % 3600LL) / 60LL;
1258+ if (hrs > 0)
1259+ snprintf(rem_out, rem_sz, "%lldh %02lldm", hrs, mins);
1260+ else
1261+ snprintf(rem_out, rem_sz, "%lldm", mins > 0 ? mins : 1LL);
1262+ }
1263+}
1264+
1265+static void emit_pool_json(buf_t *b, const pool_summary_t *p, long long now_epoch)
11901266 {
1267+ long long rsecs = -1;
1268+ double rhrs = -1.0;
1269+ char rrem[32] = {0};
1270+
11911271 if (!p->present) {
1192- buf_adds(b, "{\"pct\":-1,\"exhausted\":false,\"reset_time\":\"\",\"count\":0}");
1272+ buf_adds(b, "{\"pct\":-1,\"exhausted\":false,\"reset_time\":\"\","
1273+ "\"reset_in_seconds\":-1,\"reset_in_hours\":-1.00,"
1274+ "\"reset_remaining\":\"\",\"count\":0}");
11931275 return;
11941276 }
1277+ compute_reset_fields(p->reset_time, now_epoch, &rsecs, &rhrs, rrem, sizeof(rrem));
11951278 buf_addf(b, "{\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":",
11961279 p->pct, p->exhausted ? "true" : "false");
11971280 buf_json(b, p->reset_time);
1281+ buf_addf(b, ",\"reset_in_seconds\":%lld,\"reset_in_hours\":%.2f,\"reset_remaining\":",
1282+ rsecs, rhrs);
1283+ buf_json(b, rrem);
11981284 buf_addf(b, ",\"count\":%d}", p->count);
11991285 }
12001286
12011287 static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quota_t *q)
12021288 {
12031289 int i;
1290+ long long now_epoch = (long long)time(NULL);
12041291
12051292 buf_adds(b, "{\"email\":");
12061293 buf_json(b, a->email);
@@ -1223,12 +1310,16 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo
12231310 buf_adds(b, ",\"project\":");
12241311 buf_json(b, q->project);
12251312 buf_adds(b, ",\"gemini\":");
1226- emit_pool_json(b, &q->gemini);
1313+ emit_pool_json(b, &q->gemini, now_epoch);
12271314 buf_adds(b, ",\"claude\":");
1228- emit_pool_json(b, &q->claude);
1315+ emit_pool_json(b, &q->claude, now_epoch);
12291316 buf_adds(b, ",\"models\":[");
12301317 for (i = 0; i < q->model_count; i++) {
12311318 const model_quota_t *m = &q->models[i];
1319+ long long rsecs = -1;
1320+ double rhrs = -1.0;
1321+ char rrem[32] = {0};
1322+ compute_reset_fields(m->reset_time, now_epoch, &rsecs, &rhrs, rrem, sizeof(rrem));
12321323 if (i > 0) buf_addc(b, ',');
12331324 buf_adds(b, "{\"id\":");
12341325 buf_json(b, m->id);
@@ -1237,6 +1328,9 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo
12371328 buf_addf(b, ",\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":",
12381329 m->pct, m->exhausted ? "true" : "false");
12391330 buf_json(b, m->reset_time);
1331+ buf_addf(b, ",\"reset_in_seconds\":%lld,\"reset_in_hours\":%.2f,\"reset_remaining\":",
1332+ rsecs, rhrs);
1333+ buf_json(b, rrem);
12401334 buf_addc(b, '}');
12411335 }
12421336 buf_adds(b, "]}");
@@ -1495,6 +1589,10 @@ int main(int argc, char **argv)
14951589 const char *qs;
14961590 char action[64] = {0};
14971591
1592+#if defined(_WIN32)
1593+ _setmode(_fileno(stdout), _O_BINARY);
1594+#endif
1595+
14981596 /* 1. Discovery metadata. Must stay unauthenticated. */
14991597 if ((argc > 1 && strcmp(argv[1], "--meta") == 0) || getenv("SX_PLUGIN_META")) {
15001598 puts("{\"name\":\"" PLUGIN_NAME "\",\"desc\":\"" PLUGIN_DESC "\"}");
src/ui.html+64−15■■■■■
index 9d356fa..f291e1b 100644
--- a/src/ui.html
+++ b/src/ui.html
@@ -75,12 +75,13 @@ body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14
7575 grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}
7676 .models.show{display:grid}
7777 .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}
78+.mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
79+.mrow .mright{display:inline-flex;align-items:center;gap:8px;flex:0 0 auto}
80+.mrow .mrst{font-family:var(--mono);font-size:11px;color:var(--text-2);white-space:nowrap}
7981 .mrow .mpct{font-family:var(--mono);font-weight:650;flex:0 0 auto}
8082 .mrow .mpct.ok{color:var(--green)}
8183 .mrow .mpct.warn{color:var(--orange)}
8284 .mrow .mpct.bad{color:var(--red)}
83-.err-msg{font-size:12px;color:var(--red);padding:4px 0}
8485 .empty{padding:18px 16px;text-align:center;color:var(--text-2);font-size:13px}
8586 .kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:5px 12px;font-size:12px}
8687 .kv .k{color:var(--text-2)}
@@ -208,18 +209,51 @@ function fmtPct(pool){
208209 if(pool.pct<0)return 'N/A';
209210 return pool.pct.toFixed(1)+'%';
210211 }
212+function pad2(n){return n<10?('0'+n):String(n);}
213+function fmtClock(ms){
214+ var d=new Date(ms),now=new Date();
215+ var hm=pad2(d.getHours())+':'+pad2(d.getMinutes());
216+ if(d.getFullYear()===now.getFullYear()&&d.getMonth()===now.getMonth()&&d.getDate()===now.getDate())return hm;
217+ var mon=d.toLocaleString(undefined,{month:'short'});
218+ return mon+' '+d.getDate()+' '+hm;
219+}
220+function fmtResetShort(iso){
221+ if(!iso)return '-';
222+ var t=Date.parse(iso);
223+ if(isNaN(t))return iso;
224+ var diff=Math.floor((t-Date.now())/1000);
225+ if(diff<=0)return 'due';
226+ var totalH=Math.floor(diff/3600);
227+ var m=Math.floor((diff%3600)/60);
228+ if(totalH>0)return totalH+'h '+pad2(m)+'m';
229+ return Math.max(1,m)+'m';
230+}
211231 function fmtReset(iso){
212232 if(!iso)return 'Reset: -';
213233 var t=Date.parse(iso);
214234 if(isNaN(t))return 'Reset: '+iso;
215235 var diff=Math.floor((t-Date.now())/1000);
216- if(diff<=0)return 'Resets soon';
236+ var clk=fmtClock(t);
237+ if(diff<=0)return 'Resets soon · '+clk;
238+ var totalH=Math.floor(diff/3600);
217239 var d=Math.floor(diff/86400);
218240 var h=Math.floor((diff%86400)/3600);
219241 var m=Math.floor((diff%3600)/60);
220- if(d>0)return 'Resets in '+d+'d '+h+'h';
221- if(h>0)return 'Resets in '+h+'h '+m+'m';
222- return 'Resets in '+Math.max(1,m)+'m';
242+ if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk;
243+ if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk;
244+ return 'Resets in '+Math.max(1,m)+'m · '+clk;
245+}
246+function refreshResetLabels(){
247+ var els=document.querySelectorAll('[data-reset]');
248+ for(var i=0;i<els.length;i++){
249+ var node=els[i];
250+ var iso=node.getAttribute('data-reset');
251+ if(!iso)continue;
252+ var mode=node.getAttribute('data-reset-mode')||'full';
253+ node.textContent=(mode==='short')?fmtResetShort(iso):fmtReset(iso);
254+ var t=Date.parse(iso);
255+ if(!isNaN(t))node.title='Resets at '+fmtClock(t)+' ('+iso+')';
256+ }
223257 }
224258 function el(tag,cls,txt){
225259 var n=document.createElement(tag);
@@ -229,18 +263,18 @@ function el(tag,cls,txt){
229263 }
230264
231265 function computeBest(){
232- var bestG=null,bestGP=-1,bestC=null,bestCP=-1;
266+ var bestG=null,bestGP=-1,bestGR='',bestC=null,bestCP=-1,bestCR='';
233267 state.accounts.forEach(function(a){
234268 var qd=state.quotas[a.email];
235269 if(!qd||!qd.ok)return;
236270 if(qd.gemini&&!qd.gemini.exhausted&&qd.gemini.pct>bestGP){
237- bestGP=qd.gemini.pct;bestG=a.email;
271+ bestGP=qd.gemini.pct;bestG=a.email;bestGR=qd.gemini.reset_time||'';
238272 }
239273 if(qd.claude&&!qd.claude.exhausted&&qd.claude.pct>bestCP){
240- bestCP=qd.claude.pct;bestC=a.email;
274+ bestCP=qd.claude.pct;bestC=a.email;bestCR=qd.claude.reset_time||'';
241275 }
242276 });
243- return {gemini:bestG,geminiPct:bestGP,claude:bestC,claudePct:bestCP};
277+ return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,claude:bestC,claudePct:bestCP,claudeReset:bestCR};
244278 }
245279
246280 function renderPool(label,pool,loading){
@@ -270,6 +304,12 @@ function renderPool(label,pool,loading){
270304 fill.className=cls;
271305 fill.style.width=w.toFixed(1)+'%';
272306 rst.textContent=fmtReset(pool.reset_time);
307+ if(pool.reset_time){
308+ rst.setAttribute('data-reset',pool.reset_time);
309+ rst.setAttribute('data-reset-mode','full');
310+ var rt=Date.parse(pool.reset_time);
311+ if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+pool.reset_time+')';
312+ }
273313 }
274314 hd.appendChild(pctEl);
275315 bar.appendChild(fill);
@@ -287,12 +327,11 @@ function render(){
287327
288328 $('kpiGemini').textContent=best.gemini?shortEmail(best.gemini):'-';
289329 $('kpiGemini').title=best.gemini||'';
290- $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');
330+ $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'+(best.geminiReset?(' · resets in '+fmtResetShort(best.geminiReset)):'')):(state.loading?'Checking...':'No quota data');
291331
292332 $('kpiClaude').textContent=best.claude?shortEmail(best.claude):'-';
293333 $('kpiClaude').title=best.claude||'';
294- $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');
295-
334+ $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'+(best.claudeReset?(' · resets in '+fmtResetShort(best.claudeReset)):'')):(state.loading?'Checking...':'No quota data');
296335 var wrap=$('accounts');
297336 wrap.innerHTML='';
298337 if(!state.accounts.length){
@@ -336,8 +375,18 @@ function render(){
336375 qd.models.forEach(function(m){
337376 var row=el('div','mrow');
338377 row.appendChild(el('span','mid',m.id));
378+ var right=el('span','mright');
379+ if(m.reset_time){
380+ var mr=el('span','mrst',fmtResetShort(m.reset_time));
381+ mr.setAttribute('data-reset',m.reset_time);
382+ mr.setAttribute('data-reset-mode','short');
383+ var mt=Date.parse(m.reset_time);
384+ if(!isNaN(mt))mr.title='Resets at '+fmtClock(mt)+' ('+m.reset_time+')';
385+ right.appendChild(mr);
386+ }
339387 var cls=pctClass(m.pct,m.exhausted);
340- row.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));
388+ right.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));
389+ row.appendChild(right);
341390 mgrid.appendChild(row);
342391 });
343392 card.appendChild(mgrid);
@@ -346,7 +395,6 @@ function render(){
346395 wrap.appendChild(card);
347396 });
348397 }
349-
350398 function switchAccount(email,btn){
351399 btn.disabled=true;
352400 btn.textContent='Switching...';
@@ -457,6 +505,7 @@ $('themeToggle').onclick=function(){
457505 window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');
458506 }
459507 };
508+setInterval(refreshResetLabels,30000);
460509 load();
461510 </script>
462511 </body></html>
src/ui_html.h+64−15■■■■■
index e0c2767..eb9099c 100644
--- a/src/ui_html.h
+++ b/src/ui_html.h
@@ -80,12 +80,13 @@ static const char *UI_HTML =
8080 " grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}\n"
8181 ".models.show{display:grid}\n"
8282 ".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}\n"
83+ ".mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}\n"
84+ ".mrow .mright{display:inline-flex;align-items:center;gap:8px;flex:0 0 auto}\n"
85+ ".mrow .mrst{font-family:var(--mono);font-size:11px;color:var(--text-2);white-space:nowrap}\n"
8486 ".mrow .mpct{font-family:var(--mono);font-weight:650;flex:0 0 auto}\n"
8587 ".mrow .mpct.ok{color:var(--green)}\n"
8688 ".mrow .mpct.warn{color:var(--orange)}\n"
8789 ".mrow .mpct.bad{color:var(--red)}\n"
88- ".err-msg{font-size:12px;color:var(--red);padding:4px 0}\n"
8990 ".empty{padding:18px 16px;text-align:center;color:var(--text-2);font-size:13px}\n"
9091 ".kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:5px 12px;font-size:12px}\n"
9192 ".kv .k{color:var(--text-2)}\n"
@@ -213,18 +214,51 @@ static const char *UI_HTML =
213214 " if(pool.pct<0)return 'N/A';\n"
214215 " return pool.pct.toFixed(1)+'%';\n"
215216 "}\n"
217+ "function pad2(n){return n<10?('0'+n):String(n);}\n"
218+ "function fmtClock(ms){\n"
219+ " var d=new Date(ms),now=new Date();\n"
220+ " var hm=pad2(d.getHours())+':'+pad2(d.getMinutes());\n"
221+ " if(d.getFullYear()===now.getFullYear()&&d.getMonth()===now.getMonth()&&d.getDate()===now.getDate())return hm;\n"
222+ " var mon=d.toLocaleString(undefined,{month:'short'});\n"
223+ " return mon+' '+d.getDate()+' '+hm;\n"
224+ "}\n"
225+ "function fmtResetShort(iso){\n"
226+ " if(!iso)return '-';\n"
227+ " var t=Date.parse(iso);\n"
228+ " if(isNaN(t))return iso;\n"
229+ " var diff=Math.floor((t-Date.now())/1000);\n"
230+ " if(diff<=0)return 'due';\n"
231+ " var totalH=Math.floor(diff/3600);\n"
232+ " var m=Math.floor((diff%3600)/60);\n"
233+ " if(totalH>0)return totalH+'h '+pad2(m)+'m';\n"
234+ " return Math.max(1,m)+'m';\n"
235+ "}\n"
216236 "function fmtReset(iso){\n"
217237 " if(!iso)return 'Reset: -';\n"
218238 " var t=Date.parse(iso);\n"
219239 " if(isNaN(t))return 'Reset: '+iso;\n"
220240 " var diff=Math.floor((t-Date.now())/1000);\n"
221- " if(diff<=0)return 'Resets soon';\n"
241+ " var clk=fmtClock(t);\n"
242+ " if(diff<=0)return 'Resets soon · '+clk;\n"
243+ " var totalH=Math.floor(diff/3600);\n"
222244 " var d=Math.floor(diff/86400);\n"
223245 " var h=Math.floor((diff%86400)/3600);\n"
224246 " var m=Math.floor((diff%3600)/60);\n"
225- " if(d>0)return 'Resets in '+d+'d '+h+'h';\n"
226- " if(h>0)return 'Resets in '+h+'h '+m+'m';\n"
227- " return 'Resets in '+Math.max(1,m)+'m';\n"
247+ " if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk;\n"
248+ " if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk;\n"
249+ " return 'Resets in '+Math.max(1,m)+'m · '+clk;\n"
250+ "}\n"
251+ "function refreshResetLabels(){\n"
252+ " var els=document.querySelectorAll('[data-reset]');\n"
253+ " for(var i=0;i<els.length;i++){\n"
254+ " var node=els[i];\n"
255+ " var iso=node.getAttribute('data-reset');\n"
256+ " if(!iso)continue;\n"
257+ " var mode=node.getAttribute('data-reset-mode')||'full';\n"
258+ " node.textContent=(mode==='short')?fmtResetShort(iso):fmtReset(iso);\n"
259+ " var t=Date.parse(iso);\n"
260+ " if(!isNaN(t))node.title='Resets at '+fmtClock(t)+' ('+iso+')';\n"
261+ " }\n"
228262 "}\n"
229263 "function el(tag,cls,txt){\n"
230264 " var n=document.createElement(tag);\n"
@@ -234,18 +268,18 @@ static const char *UI_HTML =
234268 "}\n"
235269 "\n"
236270 "function computeBest(){\n"
237- " var bestG=null,bestGP=-1,bestC=null,bestCP=-1;\n"
271+ " var bestG=null,bestGP=-1,bestGR='',bestC=null,bestCP=-1,bestCR='';\n"
238272 " state.accounts.forEach(function(a){\n"
239273 " var qd=state.quotas[a.email];\n"
240274 " if(!qd||!qd.ok)return;\n"
241275 " if(qd.gemini&&!qd.gemini.exhausted&&qd.gemini.pct>bestGP){\n"
242- " bestGP=qd.gemini.pct;bestG=a.email;\n"
276+ " bestGP=qd.gemini.pct;bestG=a.email;bestGR=qd.gemini.reset_time||'';\n"
243277 " }\n"
244278 " if(qd.claude&&!qd.claude.exhausted&&qd.claude.pct>bestCP){\n"
245- " bestCP=qd.claude.pct;bestC=a.email;\n"
279+ " bestCP=qd.claude.pct;bestC=a.email;bestCR=qd.claude.reset_time||'';\n"
246280 " }\n"
247281 " });\n"
248- " return {gemini:bestG,geminiPct:bestGP,claude:bestC,claudePct:bestCP};\n"
282+ " return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,claude:bestC,claudePct:bestCP,claudeReset:bestCR};\n"
249283 "}\n"
250284 "\n"
251285 "function renderPool(label,pool,loading){\n"
@@ -275,6 +309,12 @@ static const char *UI_HTML =
275309 " fill.className=cls;\n"
276310 " fill.style.width=w.toFixed(1)+'%';\n"
277311 " rst.textContent=fmtReset(pool.reset_time);\n"
312+ " if(pool.reset_time){\n"
313+ " rst.setAttribute('data-reset',pool.reset_time);\n"
314+ " rst.setAttribute('data-reset-mode','full');\n"
315+ " var rt=Date.parse(pool.reset_time);\n"
316+ " if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+pool.reset_time+')';\n"
317+ " }\n"
278318 " }\n"
279319 " hd.appendChild(pctEl);\n"
280320 " bar.appendChild(fill);\n"
@@ -292,12 +332,11 @@ static const char *UI_HTML =
292332 "\n"
293333 " $('kpiGemini').textContent=best.gemini?shortEmail(best.gemini):'-';\n"
294334 " $('kpiGemini').title=best.gemini||'';\n"
295- " $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');\n"
335+ " $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'+(best.geminiReset?(' · resets in '+fmtResetShort(best.geminiReset)):'')):(state.loading?'Checking...':'No quota data');\n"
296336 "\n"
297337 " $('kpiClaude').textContent=best.claude?shortEmail(best.claude):'-';\n"
298338 " $('kpiClaude').title=best.claude||'';\n"
299- " $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');\n"
300- "\n"
339+ " $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'+(best.claudeReset?(' · resets in '+fmtResetShort(best.claudeReset)):'')):(state.loading?'Checking...':'No quota data');\n"
301340 " var wrap=$('accounts');\n"
302341 " wrap.innerHTML='';\n"
303342 " if(!state.accounts.length){\n"
@@ -341,8 +380,18 @@ static const char *UI_HTML =
341380 " qd.models.forEach(function(m){\n"
342381 " var row=el('div','mrow');\n"
343382 " row.appendChild(el('span','mid',m.id));\n"
383+ " var right=el('span','mright');\n"
384+ " if(m.reset_time){\n"
385+ " var mr=el('span','mrst',fmtResetShort(m.reset_time));\n"
386+ " mr.setAttribute('data-reset',m.reset_time);\n"
387+ " mr.setAttribute('data-reset-mode','short');\n"
388+ " var mt=Date.parse(m.reset_time);\n"
389+ " if(!isNaN(mt))mr.title='Resets at '+fmtClock(mt)+' ('+m.reset_time+')';\n"
390+ " right.appendChild(mr);\n"
391+ " }\n"
344392 " var cls=pctClass(m.pct,m.exhausted);\n"
345- " row.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));\n"
393+ " right.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));\n"
394+ " row.appendChild(right);\n"
346395 " mgrid.appendChild(row);\n"
347396 " });\n"
348397 " card.appendChild(mgrid);\n"
@@ -351,7 +400,6 @@ static const char *UI_HTML =
351400 " wrap.appendChild(card);\n"
352401 " });\n"
353402 "}\n"
354- "\n"
355403 "function switchAccount(email,btn){\n"
356404 " btn.disabled=true;\n"
357405 " btn.textContent='Switching...';\n"
@@ -462,6 +510,7 @@ static const char *UI_HTML =
462510 " window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');\n"
463511 " }\n"
464512 "};\n"
513+ "setInterval(refreshResetLabels,30000);\n"
465514 "load();\n"
466515 "</script>\n"
467516 "\002</body></html>\n"
tests/mock_quota.sh+12−9■■■■■
index 1169c80..33af6e9 100755
--- a/tests/mock_quota.sh
+++ b/tests/mock_quota.sh
@@ -21,9 +21,12 @@ fi
2121
2222 echo "INFO : ya29.MOCK-TOKEN-MUST-NOT-LEAK" >&2
2323
24+RST_CLAUDE="${MOCK_RESET_CLAUDE:-2026-11-25T06:00:00Z}"
25+RST_GEMINI="${MOCK_RESET_GEMINI:-2026-11-25T03:00:00Z}"
26+
2427 case "$acct" in
2528 alpha@example.com)
26- cat <<'EOF'
29+ cat <<EOF
2730 {
2831 "ok": true,
2932 "email": "alpha@example.com",
@@ -31,10 +34,10 @@ case "$acct" in
3134 "endpoint": "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota",
3235 "buckets": [
3336 {"tokenType": "WTUS", "modelId": "chat_20706", "remainingFraction": 1},
34- {"resetTime": "2026-11-25T06:00:00Z", "tokenType": "WTUS", "modelId": "claude-opus-4-6-thinking", "remainingFraction": 1},
35- {"resetTime": "2026-11-25T06:00:00Z", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 1},
36- {"resetTime": "2026-11-25T03:00:00Z", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": 0.855},
37- {"resetTime": "2026-11-25T03:00:00Z", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar", "remainingFraction": 0.855},
37+ {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-opus-4-6-thinking", "remainingFraction": 1},
38+ {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 1},
39+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": 0.855},
40+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar", "remainingFraction": 0.855},
3841 {"tokenType": "WTUS", "modelId": "tab_flash_lite_preview", "remainingFraction": 1}
3942 ]
4043 }
@@ -42,16 +45,16 @@ EOF
4245 exit 0
4346 ;;
4447 beta@example.com)
45- cat <<'EOF'
48+ cat <<EOF
4649 {
4750 "ok": true,
4851 "email": "beta@example.com",
4952 "project": "aicode-consumers",
5053 "endpoint": "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota",
5154 "buckets": [
52- {"resetTime": "2026-11-25T08:00:00Z", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 0.42},
53- {"resetTime": "2026-11-25T04:00:00Z", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": null},
54- {"resetTime": "2026-11-25T04:00:00Z", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar"}
55+ {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 0.42},
56+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": null},
57+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar"}
5558 ]
5659 }
5760 EOF
tests/run.sh+10−10■■■■■
index fc73f17..cc47abc 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -81,8 +81,8 @@ mkdir -p "$FIX/none" "$FIX/empty" "$FIX/full"
8181 chmod +x "$ROOT/tests/mock_quota.sh"
8282 export GOOGLE_QUOTA_BIN="$ROOT/tests/mock_quota.sh"
8383 export GOOGLE_ACCESS_TOKEN="ya29.INHERITED-TOKEN-MUST-BE-CLEARED"
84-
85-: > "$FIX/empty/antigravity_accounts.json"
84+export MOCK_RESET_CLAUDE=$(python3 -c "from datetime import datetime,timedelta,timezone; print((datetime.now(timezone.utc)+timedelta(hours=2,minutes=15)).strftime('%Y-%m-%dT%H:%M:%SZ'))")
85+export MOCK_RESET_GEMINI=$(python3 -c "from datetime import datetime,timedelta,timezone; print((datetime.now(timezone.utc)+timedelta(hours=144,minutes=30)).strftime('%Y-%m-%dT%H:%M:%SZ'))")
8686
8787 cat > "$FIX/full/antigravity_accounts.json" <<'EOF'
8888 [
@@ -102,8 +102,7 @@ META_ENV=$(BOT_PASSWORD=secret-pass SX_PLUGIN_META=1 $BIN)
102102 check "SX_PLUGIN_META=1 works without auth" '{"name":"google quota","desc":"Account quotas"}' "$META_ENV"
103103
104104 VER=$($BIN --version)
105-check "--version prints plugin id and version" "plugin_google_quota 1.0.0" "$VER"
106-
105+check "--version prints plugin id and version" "plugin_google_quota 1.0.1" "$VER"
107106 UNAUTH=$(BOT_PASSWORD=secret-pass QUERY_STRING="action=status" $BIN)
108107 check "missing password returns 401" "Status: 401 Unauthorized" "$UNAUTH"
109108
@@ -135,15 +134,14 @@ json_ok "missing CLI sets cli_present false" "$ST_NOCLI" "d['ok'] is True and d[
135134 # ---------------------------------------------------------------- quota
136135 section "quota"
137136 Q_ONE=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=alpha@example.com")
138-json_ok "single account quota parses gemini and claude pools" "$Q_ONE" \
139- "d['ok'] is True and d['account']['ok'] is True and abs(d['account']['gemini']['pct'] - 85.5) < 0.01 and abs(d['account']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 4"
137+json_ok "single account quota parses gemini 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']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 4 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'])"
140139 check_not "single quota never leaks token" "MOCK-TOKEN" "$Q_ONE"
141140 check_not "single quota never leaks refresh token" "MOCK-REFRESH-TOKEN" "$Q_ONE"
142141
143142 Q_EXH=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=beta@example.com")
144-json_ok "null/missing remainingFraction marks gemini pool exhausted" "$Q_EXH" \
145- "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"
146-
143+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']"
147145 Q_ALL=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota")
148146 json_ok "all-accounts quota aggregates best_gemini, best_claude, and broken account" "$Q_ALL" \
149147 "d['ok'] is True and d['count'] == 3 and d['best_gemini'] == 'alpha@example.com' and d['best_claude'] == 'alpha@example.com' and d['accounts'][2]['ok'] is False"
@@ -182,11 +180,13 @@ check "HTML includes bot theme prepaint" "bot_theme" "$HTML"
182180 check "HTML includes theme handoff" "sx-theme-request" "$HTML"
183181 check "HTML uses two-route API helper" "plugin_google_quota" "$HTML"
184182 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"
184+check "HTML renders per-model reset remaining hours" "fmtResetShort" "$HTML"
185+check "HTML includes live reset countdown attributes" "data-reset" "$HTML"
185186 check "HTML hides theme toggle in embed mode" "embed-hide" "$HTML"
186187 check_not "HTML loads no CDN script" "<script src=" "$HTML"
187188 check_not "HTML references no external host script" "cdnjs" "$HTML"
188189 check_not "HTML makes no outbound fetch to googleapis" "googleapis.com" "$HTML"
189-
190190 printf '%s' "$HTML" > "$FIX/page.html"
191191 if python3 - "$FIX/page.html" <<'PY'
192192 import re, sys
193193
README.md+2−2■■■■
index 209efcb..9b30545 100644index 209efcb..9b30545 100644
--- a/README.md--- a/README.md
+++ b/README.md+++ b/README.md
@@ -8,7 +8,7 @@ account list (`antigravity_accounts.json`) and active selection@@ -8,7 +8,7 @@ account list (`antigravity_accounts.json`) and active selection
8 click.8 click.
9 9
10 * `--meta` -> `{"name":"google quota","desc":"Account quotas"}`10 * `--meta` -> `{"name":"google quota","desc":"Account quotas"}`
11-* `--version` -> `plugin_google_quota 1.0.0`11+* `--version` -> `plugin_google_quota 1.0.1`
12 * Catalog slug `google-quota`, category `devtools`12 * Catalog slug `google-quota`, category `devtools`
13 * Public source: <https://plugingit.scorpiox.net/scorpiox-bot-plugin-google-quota.git>13 * Public source: <https://plugingit.scorpiox.net/scorpiox-bot-plugin-google-quota.git>
14 * Prebuilt binaries: <https://dist.scorpiox.net/bot-plugins/google-quota/>14 * Prebuilt binaries: <https://dist.scorpiox.net/bot-plugins/google-quota/>
@@ -59,7 +59,7 @@ extracted; token strings are never copied or emitted.@@ -59,7 +59,7 @@ extracted; token strings are never copied or emitted.
59 All actions accept `X-Bot-Password`, `Authorization: Bearer`, or `?pwd=`.59 All actions accept `X-Bot-Password`, `Authorization: Bearer`, or `?pwd=`.
60 60
61 * `GET ?action=status` — fast local read of configured accounts, `selected`, paths, and `cli_present`61 * `GET ?action=status` — fast local read of configured accounts, `selected`, paths, and `cli_present`
62-* `GET ?action=quota` (or `?format=json`) — queries all accounts concurrently and returns Gemini/Claude pool summaries, reset times, per-model buckets, `best_gemini`, and `best_claude`62+* `GET ?action=quota` (or `?format=json`) — queries all accounts concurrently and returns Gemini/Claude pool summaries, reset times (`reset_time`, `reset_in_seconds`, `reset_in_hours`, `reset_remaining`), per-model buckets, `best_gemini`, and `best_claude`
63 * `GET ?action=quota&account=<email>` — queries a single account63 * `GET ?action=quota&account=<email>` — queries a single account
64 * `GET/POST ?action=switch&account=<email>` (or JSON body `{"account":"..."}`) — validates the email against `antigravity_accounts.json` and writes `selected_account.txt`64 * `GET/POST ?action=switch&account=<email>` (or JSON body `{"account":"..."}`) — validates the email against `antigravity_accounts.json` and writes `selected_account.txt`
65 65
plugin.json+1−0■
index 58d102f..49f1b9a 100644index 58d102f..49f1b9a 100644
--- a/plugin.json--- a/plugin.json
+++ b/plugin.json+++ b/plugin.json
@@ -2,6 +2,7 @@@@ -2,6 +2,7 @@
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.1",
5 "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 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 "category": "devtools",7 "category": "devtools",
7 "license": "MIT",8 "license": "MIT",
src/plugin_google_quota.c+105−7■■■■■
index 97e4490..b1bbb8e 100644index 97e4490..b1bbb8e 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
@@ -51,11 +51,13 @@@@ -51,11 +51,13 @@
51 #include <ctype.h>51 #include <ctype.h>
52 #include <errno.h>52 #include <errno.h>
53 #include <stdarg.h>53 #include <stdarg.h>
54+#include <time.h>
54 55
55 #if defined(_WIN32)56 #if defined(_WIN32)
56 # define WIN32_LEAN_AND_MEAN57 # define WIN32_LEAN_AND_MEAN
57 # include <windows.h>58 # include <windows.h>
58 # include <direct.h>59 # include <direct.h>
60+# include <fcntl.h>
59 # include <io.h>61 # include <io.h>
60 # define popen _popen62 # define popen _popen
61 # define pclose _pclose63 # define pclose _pclose
@@ -75,10 +77,9 @@@@ -75,10 +77,9 @@
75 77
76 #define PLUGIN_SLUG "google-quota"78 #define PLUGIN_SLUG "google-quota"
77 #define PLUGIN_ID "plugin_google_quota"79 #define PLUGIN_ID "plugin_google_quota"
78-#define PLUGIN_VER "1.0.0"80+#define PLUGIN_VER "1.0.1"
79 #define PLUGIN_NAME "google quota"81 #define PLUGIN_NAME "google quota"
80 #define PLUGIN_DESC "Account quotas"82 #define PLUGIN_DESC "Account quotas"
81-
82 #define DEFAULT_QUOTA_BIN "scorpiox-google-quota"83 #define DEFAULT_QUOTA_BIN "scorpiox-google-quota"
83 84
84 #define PATH_SZ 102485 #define PATH_SZ 1024
@@ -885,7 +886,7 @@ static void pool_add(pool_summary_t *p, double pct, int exhausted, const char *r@@ -885,7 +886,7 @@ static void pool_add(pool_summary_t *p, double pct, int exhausted, const char *r
885 if (!p->present || pct < p->pct) p->pct = pct;886 if (!p->present || pct < p->pct) p->pct = pct;
886 p->present = 1;887 p->present = 1;
887 if (exhausted || pct <= 0.0) p->exhausted = 1;888 if (exhausted || pct <= 0.0) p->exhausted = 1;
888- if (!p->reset_time[0] && reset && reset[0])889+ if (reset && reset[0] && (!p->reset_time[0] || strcmp(reset, p->reset_time) < 0))
889 snprintf(p->reset_time, sizeof(p->reset_time), "%s", reset);890 snprintf(p->reset_time, sizeof(p->reset_time), "%s", reset);
890 p->count++;891 p->count++;
891 }892 }
@@ -1186,21 +1187,107 @@ static void emit_error(int code, const char *status, const char *err, const char@@ -1186,21 +1187,107 @@ static void emit_error(int code, const char *status, const char *err, const char
1186 buf_free(&b);1187 buf_free(&b);
1187 }1188 }
1188 1189
1189-static void emit_pool_json(buf_t *b, const pool_summary_t *p)1190+static long long days_from_civil(int y, unsigned m, unsigned d)
1191+{
1192+ y -= (m <= 2) ? 1 : 0;
1193+ {
1194+ long long era = (y >= 0 ? y : y - 399) / 400;
1195+ unsigned yoe = (unsigned)(y - era * 400);
1196+ unsigned doy = (153U * (m + (m > 2 ? (unsigned)-3 : 9U)) + 2U) / 5U + d - 1U;
1197+ unsigned doe = yoe * 365U + yoe / 4U - yoe / 100U + doy;
1198+ return era * 146097LL + (long long)doe - 719468LL;
1199+ }
1200+}
1201+
1202+static int parse_iso_utc_epoch(const char *iso, long long *out_epoch)
1203+{
1204+ int y = 0, mo = 0, d = 0, hh = 0, mm = 0, ss = 0;
1205+ const char *t;
1206+ const char *tz;
1207+
1208+ if (!iso || !*iso) return 0;
1209+ if (sscanf(iso, "%d-%d-%dT%d:%d:%d", &y, &mo, &d, &hh, &mm, &ss) != 6)
1210+ return 0;
1211+ if (mo < 1 || mo > 12 || d < 1 || d > 31 ||
1212+ hh < 0 || hh > 23 || mm < 0 || mm > 59 || ss < 0 || ss > 60)
1213+ return 0;
1214+ t = strchr(iso, 'T');
1215+ if (!t) return 0;
1216+ {
1217+ long long days = days_from_civil(y, (unsigned)mo, (unsigned)d);
1218+ long long epoch = days * 86400LL + (long long)hh * 3600LL +
1219+ (long long)mm * 60LL + (long long)ss;
1220+ tz = strpbrk(t, "Z+-");
1221+ if (tz && (*tz == '+' || *tz == '-')) {
1222+ int oh = 0, om = 0;
1223+ if (sscanf(tz + 1, "%2d:%2d", &oh, &om) >= 1) {
1224+ long long off = (long long)oh * 3600LL + (long long)om * 60LL;
1225+ epoch += (*tz == '+') ? -off : off;
1226+ }
1227+ }
1228+ *out_epoch = epoch;
1229+ return 1;
1230+ }
1231+}
1232+
1233+static void compute_reset_fields(const char *iso, long long now_epoch,
1234+ long long *secs_out, double *hrs_out,
1235+ char *rem_out, size_t rem_sz)
1236+{
1237+ long long target = 0;
1238+ long long diff;
1239+
1240+ if (!iso || !iso[0] || !parse_iso_utc_epoch(iso, &target)) {
1241+ *secs_out = -1;
1242+ *hrs_out = -1.0;
1243+ if (rem_sz) rem_out[0] = '\0';
1244+ return;
1245+ }
1246+ diff = target - now_epoch;
1247+ if (diff <= 0) {
1248+ *secs_out = 0;
1249+ *hrs_out = 0.0;
1250+ snprintf(rem_out, rem_sz, "due");
1251+ return;
1252+ }
1253+ *secs_out = diff;
1254+ *hrs_out = (double)diff / 3600.0;
1255+ {
1256+ long long hrs = diff / 3600LL;
1257+ long long mins = (diff % 3600LL) / 60LL;
1258+ if (hrs > 0)
1259+ snprintf(rem_out, rem_sz, "%lldh %02lldm", hrs, mins);
1260+ else
1261+ snprintf(rem_out, rem_sz, "%lldm", mins > 0 ? mins : 1LL);
1262+ }
1263+}
1264+
1265+static void emit_pool_json(buf_t *b, const pool_summary_t *p, long long now_epoch)
1190 {1266 {
1267+ long long rsecs = -1;
1268+ double rhrs = -1.0;
1269+ char rrem[32] = {0};
1270+
1191 if (!p->present) {1271 if (!p->present) {
1192- buf_adds(b, "{\"pct\":-1,\"exhausted\":false,\"reset_time\":\"\",\"count\":0}");1272+ buf_adds(b, "{\"pct\":-1,\"exhausted\":false,\"reset_time\":\"\","
1273+ "\"reset_in_seconds\":-1,\"reset_in_hours\":-1.00,"
1274+ "\"reset_remaining\":\"\",\"count\":0}");
1193 return;1275 return;
1194 }1276 }
1277+ compute_reset_fields(p->reset_time, now_epoch, &rsecs, &rhrs, rrem, sizeof(rrem));
1195 buf_addf(b, "{\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":",1278 buf_addf(b, "{\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":",
1196 p->pct, p->exhausted ? "true" : "false");1279 p->pct, p->exhausted ? "true" : "false");
1197 buf_json(b, p->reset_time);1280 buf_json(b, p->reset_time);
1281+ buf_addf(b, ",\"reset_in_seconds\":%lld,\"reset_in_hours\":%.2f,\"reset_remaining\":",
1282+ rsecs, rhrs);
1283+ buf_json(b, rrem);
1198 buf_addf(b, ",\"count\":%d}", p->count);1284 buf_addf(b, ",\"count\":%d}", p->count);
1199 }1285 }
1200 1286
1201 static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quota_t *q)1287 static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quota_t *q)
1202 {1288 {
1203 int i;1289 int i;
1290+ long long now_epoch = (long long)time(NULL);
1204 1291
1205 buf_adds(b, "{\"email\":");1292 buf_adds(b, "{\"email\":");
1206 buf_json(b, a->email);1293 buf_json(b, a->email);
@@ -1223,12 +1310,16 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo@@ -1223,12 +1310,16 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo
1223 buf_adds(b, ",\"project\":");1310 buf_adds(b, ",\"project\":");
1224 buf_json(b, q->project);1311 buf_json(b, q->project);
1225 buf_adds(b, ",\"gemini\":");1312 buf_adds(b, ",\"gemini\":");
1226- emit_pool_json(b, &q->gemini);1313+ emit_pool_json(b, &q->gemini, now_epoch);
1227 buf_adds(b, ",\"claude\":");1314 buf_adds(b, ",\"claude\":");
1228- emit_pool_json(b, &q->claude);1315+ emit_pool_json(b, &q->claude, now_epoch);
1229 buf_adds(b, ",\"models\":[");1316 buf_adds(b, ",\"models\":[");
1230 for (i = 0; i < q->model_count; i++) {1317 for (i = 0; i < q->model_count; i++) {
1231 const model_quota_t *m = &q->models[i];1318 const model_quota_t *m = &q->models[i];
1319+ long long rsecs = -1;
1320+ double rhrs = -1.0;
1321+ char rrem[32] = {0};
1322+ compute_reset_fields(m->reset_time, now_epoch, &rsecs, &rhrs, rrem, sizeof(rrem));
1232 if (i > 0) buf_addc(b, ',');1323 if (i > 0) buf_addc(b, ',');
1233 buf_adds(b, "{\"id\":");1324 buf_adds(b, "{\"id\":");
1234 buf_json(b, m->id);1325 buf_json(b, m->id);
@@ -1237,6 +1328,9 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo@@ -1237,6 +1328,9 @@ static void emit_acct_quota_json(buf_t *b, const acct_entry_t *a, const acct_quo
1237 buf_addf(b, ",\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":",1328 buf_addf(b, ",\"pct\":%.2f,\"exhausted\":%s,\"reset_time\":",
1238 m->pct, m->exhausted ? "true" : "false");1329 m->pct, m->exhausted ? "true" : "false");
1239 buf_json(b, m->reset_time);1330 buf_json(b, m->reset_time);
1331+ buf_addf(b, ",\"reset_in_seconds\":%lld,\"reset_in_hours\":%.2f,\"reset_remaining\":",
1332+ rsecs, rhrs);
1333+ buf_json(b, rrem);
1240 buf_addc(b, '}');1334 buf_addc(b, '}');
1241 }1335 }
1242 buf_adds(b, "]}");1336 buf_adds(b, "]}");
@@ -1495,6 +1589,10 @@ int main(int argc, char **argv)@@ -1495,6 +1589,10 @@ int main(int argc, char **argv)
1495 const char *qs;1589 const char *qs;
1496 char action[64] = {0};1590 char action[64] = {0};
1497 1591
1592+#if defined(_WIN32)
1593+ _setmode(_fileno(stdout), _O_BINARY);
1594+#endif
1595+
1498 /* 1. Discovery metadata. Must stay unauthenticated. */1596 /* 1. Discovery metadata. Must stay unauthenticated. */
1499 if ((argc > 1 && strcmp(argv[1], "--meta") == 0) || getenv("SX_PLUGIN_META")) {1597 if ((argc > 1 && strcmp(argv[1], "--meta") == 0) || getenv("SX_PLUGIN_META")) {
1500 puts("{\"name\":\"" PLUGIN_NAME "\",\"desc\":\"" PLUGIN_DESC "\"}");1598 puts("{\"name\":\"" PLUGIN_NAME "\",\"desc\":\"" PLUGIN_DESC "\"}");
src/ui.html+64−15■■■■■
index 9d356fa..f291e1b 100644index 9d356fa..f291e1b 100644
--- a/src/ui.html--- a/src/ui.html
+++ b/src/ui.html+++ b/src/ui.html
@@ -75,12 +75,13 @@ body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14@@ -75,12 +75,13 @@ body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14
75 grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}75 grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}
76 .models.show{display:grid}76 .models.show{display:grid}
77 .mrow{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11.5px;padding:2px 0}77 .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}78+.mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
79+.mrow .mright{display:inline-flex;align-items:center;gap:8px;flex:0 0 auto}
80+.mrow .mrst{font-family:var(--mono);font-size:11px;color:var(--text-2);white-space:nowrap}
79 .mrow .mpct{font-family:var(--mono);font-weight:650;flex:0 0 auto}81 .mrow .mpct{font-family:var(--mono);font-weight:650;flex:0 0 auto}
80 .mrow .mpct.ok{color:var(--green)}82 .mrow .mpct.ok{color:var(--green)}
81 .mrow .mpct.warn{color:var(--orange)}83 .mrow .mpct.warn{color:var(--orange)}
82 .mrow .mpct.bad{color:var(--red)}84 .mrow .mpct.bad{color:var(--red)}
83-.err-msg{font-size:12px;color:var(--red);padding:4px 0}
84 .empty{padding:18px 16px;text-align:center;color:var(--text-2);font-size:13px}85 .empty{padding:18px 16px;text-align:center;color:var(--text-2);font-size:13px}
85 .kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:5px 12px;font-size:12px}86 .kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:5px 12px;font-size:12px}
86 .kv .k{color:var(--text-2)}87 .kv .k{color:var(--text-2)}
@@ -208,18 +209,51 @@ function fmtPct(pool){@@ -208,18 +209,51 @@ function fmtPct(pool){
208 if(pool.pct<0)return 'N/A';209 if(pool.pct<0)return 'N/A';
209 return pool.pct.toFixed(1)+'%';210 return pool.pct.toFixed(1)+'%';
210 }211 }
212+function pad2(n){return n<10?('0'+n):String(n);}
213+function fmtClock(ms){
214+ var d=new Date(ms),now=new Date();
215+ var hm=pad2(d.getHours())+':'+pad2(d.getMinutes());
216+ if(d.getFullYear()===now.getFullYear()&&d.getMonth()===now.getMonth()&&d.getDate()===now.getDate())return hm;
217+ var mon=d.toLocaleString(undefined,{month:'short'});
218+ return mon+' '+d.getDate()+' '+hm;
219+}
220+function fmtResetShort(iso){
221+ if(!iso)return '-';
222+ var t=Date.parse(iso);
223+ if(isNaN(t))return iso;
224+ var diff=Math.floor((t-Date.now())/1000);
225+ if(diff<=0)return 'due';
226+ var totalH=Math.floor(diff/3600);
227+ var m=Math.floor((diff%3600)/60);
228+ if(totalH>0)return totalH+'h '+pad2(m)+'m';
229+ return Math.max(1,m)+'m';
230+}
211 function fmtReset(iso){231 function fmtReset(iso){
212 if(!iso)return 'Reset: -';232 if(!iso)return 'Reset: -';
213 var t=Date.parse(iso);233 var t=Date.parse(iso);
214 if(isNaN(t))return 'Reset: '+iso;234 if(isNaN(t))return 'Reset: '+iso;
215 var diff=Math.floor((t-Date.now())/1000);235 var diff=Math.floor((t-Date.now())/1000);
216- if(diff<=0)return 'Resets soon';236+ var clk=fmtClock(t);
237+ if(diff<=0)return 'Resets soon · '+clk;
238+ var totalH=Math.floor(diff/3600);
217 var d=Math.floor(diff/86400);239 var d=Math.floor(diff/86400);
218 var h=Math.floor((diff%86400)/3600);240 var h=Math.floor((diff%86400)/3600);
219 var m=Math.floor((diff%3600)/60);241 var m=Math.floor((diff%3600)/60);
220- if(d>0)return 'Resets in '+d+'d '+h+'h';242+ if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk;
221- if(h>0)return 'Resets in '+h+'h '+m+'m';243+ if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk;
222- return 'Resets in '+Math.max(1,m)+'m';244+ return 'Resets in '+Math.max(1,m)+'m · '+clk;
245+}
246+function refreshResetLabels(){
247+ var els=document.querySelectorAll('[data-reset]');
248+ for(var i=0;i<els.length;i++){
249+ var node=els[i];
250+ var iso=node.getAttribute('data-reset');
251+ if(!iso)continue;
252+ var mode=node.getAttribute('data-reset-mode')||'full';
253+ node.textContent=(mode==='short')?fmtResetShort(iso):fmtReset(iso);
254+ var t=Date.parse(iso);
255+ if(!isNaN(t))node.title='Resets at '+fmtClock(t)+' ('+iso+')';
256+ }
223 }257 }
224 function el(tag,cls,txt){258 function el(tag,cls,txt){
225 var n=document.createElement(tag);259 var n=document.createElement(tag);
@@ -229,18 +263,18 @@ function el(tag,cls,txt){@@ -229,18 +263,18 @@ function el(tag,cls,txt){
229 }263 }
230 264
231 function computeBest(){265 function computeBest(){
232- var bestG=null,bestGP=-1,bestC=null,bestCP=-1;266+ var bestG=null,bestGP=-1,bestGR='',bestC=null,bestCP=-1,bestCR='';
233 state.accounts.forEach(function(a){267 state.accounts.forEach(function(a){
234 var qd=state.quotas[a.email];268 var qd=state.quotas[a.email];
235 if(!qd||!qd.ok)return;269 if(!qd||!qd.ok)return;
236 if(qd.gemini&&!qd.gemini.exhausted&&qd.gemini.pct>bestGP){270 if(qd.gemini&&!qd.gemini.exhausted&&qd.gemini.pct>bestGP){
237- bestGP=qd.gemini.pct;bestG=a.email;271+ bestGP=qd.gemini.pct;bestG=a.email;bestGR=qd.gemini.reset_time||'';
238 }272 }
239 if(qd.claude&&!qd.claude.exhausted&&qd.claude.pct>bestCP){273 if(qd.claude&&!qd.claude.exhausted&&qd.claude.pct>bestCP){
240- bestCP=qd.claude.pct;bestC=a.email;274+ bestCP=qd.claude.pct;bestC=a.email;bestCR=qd.claude.reset_time||'';
241 }275 }
242 });276 });
243- return {gemini:bestG,geminiPct:bestGP,claude:bestC,claudePct:bestCP};277+ return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,claude:bestC,claudePct:bestCP,claudeReset:bestCR};
244 }278 }
245 279
246 function renderPool(label,pool,loading){280 function renderPool(label,pool,loading){
@@ -270,6 +304,12 @@ function renderPool(label,pool,loading){@@ -270,6 +304,12 @@ function renderPool(label,pool,loading){
270 fill.className=cls;304 fill.className=cls;
271 fill.style.width=w.toFixed(1)+'%';305 fill.style.width=w.toFixed(1)+'%';
272 rst.textContent=fmtReset(pool.reset_time);306 rst.textContent=fmtReset(pool.reset_time);
307+ if(pool.reset_time){
308+ rst.setAttribute('data-reset',pool.reset_time);
309+ rst.setAttribute('data-reset-mode','full');
310+ var rt=Date.parse(pool.reset_time);
311+ if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+pool.reset_time+')';
312+ }
273 }313 }
274 hd.appendChild(pctEl);314 hd.appendChild(pctEl);
275 bar.appendChild(fill);315 bar.appendChild(fill);
@@ -287,12 +327,11 @@ function render(){@@ -287,12 +327,11 @@ function render(){
287 327
288 $('kpiGemini').textContent=best.gemini?shortEmail(best.gemini):'-';328 $('kpiGemini').textContent=best.gemini?shortEmail(best.gemini):'-';
289 $('kpiGemini').title=best.gemini||'';329 $('kpiGemini').title=best.gemini||'';
290- $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');330+ $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'+(best.geminiReset?(' · resets in '+fmtResetShort(best.geminiReset)):'')):(state.loading?'Checking...':'No quota data');
291 331
292 $('kpiClaude').textContent=best.claude?shortEmail(best.claude):'-';332 $('kpiClaude').textContent=best.claude?shortEmail(best.claude):'-';
293 $('kpiClaude').title=best.claude||'';333 $('kpiClaude').title=best.claude||'';
294- $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');334+ $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'+(best.claudeReset?(' · resets in '+fmtResetShort(best.claudeReset)):'')):(state.loading?'Checking...':'No quota data');
295-
296 var wrap=$('accounts');335 var wrap=$('accounts');
297 wrap.innerHTML='';336 wrap.innerHTML='';
298 if(!state.accounts.length){337 if(!state.accounts.length){
@@ -336,8 +375,18 @@ function render(){@@ -336,8 +375,18 @@ function render(){
336 qd.models.forEach(function(m){375 qd.models.forEach(function(m){
337 var row=el('div','mrow');376 var row=el('div','mrow');
338 row.appendChild(el('span','mid',m.id));377 row.appendChild(el('span','mid',m.id));
378+ var right=el('span','mright');
379+ if(m.reset_time){
380+ var mr=el('span','mrst',fmtResetShort(m.reset_time));
381+ mr.setAttribute('data-reset',m.reset_time);
382+ mr.setAttribute('data-reset-mode','short');
383+ var mt=Date.parse(m.reset_time);
384+ if(!isNaN(mt))mr.title='Resets at '+fmtClock(mt)+' ('+m.reset_time+')';
385+ right.appendChild(mr);
386+ }
339 var cls=pctClass(m.pct,m.exhausted);387 var cls=pctClass(m.pct,m.exhausted);
340- row.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));388+ right.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));
389+ row.appendChild(right);
341 mgrid.appendChild(row);390 mgrid.appendChild(row);
342 });391 });
343 card.appendChild(mgrid);392 card.appendChild(mgrid);
@@ -346,7 +395,6 @@ function render(){@@ -346,7 +395,6 @@ function render(){
346 wrap.appendChild(card);395 wrap.appendChild(card);
347 });396 });
348 }397 }
349-
350 function switchAccount(email,btn){398 function switchAccount(email,btn){
351 btn.disabled=true;399 btn.disabled=true;
352 btn.textContent='Switching...';400 btn.textContent='Switching...';
@@ -457,6 +505,7 @@ $('themeToggle').onclick=function(){@@ -457,6 +505,7 @@ $('themeToggle').onclick=function(){
457 window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');505 window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');
458 }506 }
459 };507 };
508+setInterval(refreshResetLabels,30000);
460 load();509 load();
461 </script>510 </script>
462 </body></html>511 </body></html>
src/ui_html.h+64−15■■■■■
index e0c2767..eb9099c 100644index e0c2767..eb9099c 100644
--- a/src/ui_html.h--- a/src/ui_html.h
+++ b/src/ui_html.h+++ b/src/ui_html.h
@@ -80,12 +80,13 @@ static const char *UI_HTML =@@ -80,12 +80,13 @@ static const char *UI_HTML =
80 " grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}\n"80 " grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 14px}\n"
81 ".models.show{display:grid}\n"81 ".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"82 ".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}\n"83+ ".mrow .mid{font-family:var(--mono);color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}\n"
84+ ".mrow .mright{display:inline-flex;align-items:center;gap:8px;flex:0 0 auto}\n"
85+ ".mrow .mrst{font-family:var(--mono);font-size:11px;color:var(--text-2);white-space:nowrap}\n"
84 ".mrow .mpct{font-family:var(--mono);font-weight:650;flex:0 0 auto}\n"86 ".mrow .mpct{font-family:var(--mono);font-weight:650;flex:0 0 auto}\n"
85 ".mrow .mpct.ok{color:var(--green)}\n"87 ".mrow .mpct.ok{color:var(--green)}\n"
86 ".mrow .mpct.warn{color:var(--orange)}\n"88 ".mrow .mpct.warn{color:var(--orange)}\n"
87 ".mrow .mpct.bad{color:var(--red)}\n"89 ".mrow .mpct.bad{color:var(--red)}\n"
88- ".err-msg{font-size:12px;color:var(--red);padding:4px 0}\n"
89 ".empty{padding:18px 16px;text-align:center;color:var(--text-2);font-size:13px}\n"90 ".empty{padding:18px 16px;text-align:center;color:var(--text-2);font-size:13px}\n"
90 ".kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:5px 12px;font-size:12px}\n"91 ".kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:5px 12px;font-size:12px}\n"
91 ".kv .k{color:var(--text-2)}\n"92 ".kv .k{color:var(--text-2)}\n"
@@ -213,18 +214,51 @@ static const char *UI_HTML =@@ -213,18 +214,51 @@ static const char *UI_HTML =
213 " if(pool.pct<0)return 'N/A';\n"214 " if(pool.pct<0)return 'N/A';\n"
214 " return pool.pct.toFixed(1)+'%';\n"215 " return pool.pct.toFixed(1)+'%';\n"
215 "}\n"216 "}\n"
217+ "function pad2(n){return n<10?('0'+n):String(n);}\n"
218+ "function fmtClock(ms){\n"
219+ " var d=new Date(ms),now=new Date();\n"
220+ " var hm=pad2(d.getHours())+':'+pad2(d.getMinutes());\n"
221+ " if(d.getFullYear()===now.getFullYear()&&d.getMonth()===now.getMonth()&&d.getDate()===now.getDate())return hm;\n"
222+ " var mon=d.toLocaleString(undefined,{month:'short'});\n"
223+ " return mon+' '+d.getDate()+' '+hm;\n"
224+ "}\n"
225+ "function fmtResetShort(iso){\n"
226+ " if(!iso)return '-';\n"
227+ " var t=Date.parse(iso);\n"
228+ " if(isNaN(t))return iso;\n"
229+ " var diff=Math.floor((t-Date.now())/1000);\n"
230+ " if(diff<=0)return 'due';\n"
231+ " var totalH=Math.floor(diff/3600);\n"
232+ " var m=Math.floor((diff%3600)/60);\n"
233+ " if(totalH>0)return totalH+'h '+pad2(m)+'m';\n"
234+ " return Math.max(1,m)+'m';\n"
235+ "}\n"
216 "function fmtReset(iso){\n"236 "function fmtReset(iso){\n"
217 " if(!iso)return 'Reset: -';\n"237 " if(!iso)return 'Reset: -';\n"
218 " var t=Date.parse(iso);\n"238 " var t=Date.parse(iso);\n"
219 " if(isNaN(t))return 'Reset: '+iso;\n"239 " if(isNaN(t))return 'Reset: '+iso;\n"
220 " var diff=Math.floor((t-Date.now())/1000);\n"240 " var diff=Math.floor((t-Date.now())/1000);\n"
221- " if(diff<=0)return 'Resets soon';\n"241+ " var clk=fmtClock(t);\n"
242+ " if(diff<=0)return 'Resets soon · '+clk;\n"
243+ " var totalH=Math.floor(diff/3600);\n"
222 " var d=Math.floor(diff/86400);\n"244 " var d=Math.floor(diff/86400);\n"
223 " var h=Math.floor((diff%86400)/3600);\n"245 " var h=Math.floor((diff%86400)/3600);\n"
224 " var m=Math.floor((diff%3600)/60);\n"246 " var m=Math.floor((diff%3600)/60);\n"
225- " if(d>0)return 'Resets in '+d+'d '+h+'h';\n"247+ " if(totalH>=24)return 'Resets in '+totalH+'h '+pad2(m)+'m ('+d+'d '+h+'h) · '+clk;\n"
226- " if(h>0)return 'Resets in '+h+'h '+m+'m';\n"248+ " if(totalH>0)return 'Resets in '+totalH+'h '+pad2(m)+'m · '+clk;\n"
227- " return 'Resets in '+Math.max(1,m)+'m';\n"249+ " return 'Resets in '+Math.max(1,m)+'m · '+clk;\n"
250+ "}\n"
251+ "function refreshResetLabels(){\n"
252+ " var els=document.querySelectorAll('[data-reset]');\n"
253+ " for(var i=0;i<els.length;i++){\n"
254+ " var node=els[i];\n"
255+ " var iso=node.getAttribute('data-reset');\n"
256+ " if(!iso)continue;\n"
257+ " var mode=node.getAttribute('data-reset-mode')||'full';\n"
258+ " node.textContent=(mode==='short')?fmtResetShort(iso):fmtReset(iso);\n"
259+ " var t=Date.parse(iso);\n"
260+ " if(!isNaN(t))node.title='Resets at '+fmtClock(t)+' ('+iso+')';\n"
261+ " }\n"
228 "}\n"262 "}\n"
229 "function el(tag,cls,txt){\n"263 "function el(tag,cls,txt){\n"
230 " var n=document.createElement(tag);\n"264 " var n=document.createElement(tag);\n"
@@ -234,18 +268,18 @@ static const char *UI_HTML =@@ -234,18 +268,18 @@ static const char *UI_HTML =
234 "}\n"268 "}\n"
235 "\n"269 "\n"
236 "function computeBest(){\n"270 "function computeBest(){\n"
237- " var bestG=null,bestGP=-1,bestC=null,bestCP=-1;\n"271+ " var bestG=null,bestGP=-1,bestGR='',bestC=null,bestCP=-1,bestCR='';\n"
238 " state.accounts.forEach(function(a){\n"272 " state.accounts.forEach(function(a){\n"
239 " var qd=state.quotas[a.email];\n"273 " var qd=state.quotas[a.email];\n"
240 " if(!qd||!qd.ok)return;\n"274 " if(!qd||!qd.ok)return;\n"
241 " if(qd.gemini&&!qd.gemini.exhausted&&qd.gemini.pct>bestGP){\n"275 " if(qd.gemini&&!qd.gemini.exhausted&&qd.gemini.pct>bestGP){\n"
242- " bestGP=qd.gemini.pct;bestG=a.email;\n"276+ " bestGP=qd.gemini.pct;bestG=a.email;bestGR=qd.gemini.reset_time||'';\n"
243 " }\n"277 " }\n"
244 " if(qd.claude&&!qd.claude.exhausted&&qd.claude.pct>bestCP){\n"278 " if(qd.claude&&!qd.claude.exhausted&&qd.claude.pct>bestCP){\n"
245- " bestCP=qd.claude.pct;bestC=a.email;\n"279+ " bestCP=qd.claude.pct;bestC=a.email;bestCR=qd.claude.reset_time||'';\n"
246 " }\n"280 " }\n"
247 " });\n"281 " });\n"
248- " return {gemini:bestG,geminiPct:bestGP,claude:bestC,claudePct:bestCP};\n"282+ " return {gemini:bestG,geminiPct:bestGP,geminiReset:bestGR,claude:bestC,claudePct:bestCP,claudeReset:bestCR};\n"
249 "}\n"283 "}\n"
250 "\n"284 "\n"
251 "function renderPool(label,pool,loading){\n"285 "function renderPool(label,pool,loading){\n"
@@ -275,6 +309,12 @@ static const char *UI_HTML =@@ -275,6 +309,12 @@ static const char *UI_HTML =
275 " fill.className=cls;\n"309 " fill.className=cls;\n"
276 " fill.style.width=w.toFixed(1)+'%';\n"310 " fill.style.width=w.toFixed(1)+'%';\n"
277 " rst.textContent=fmtReset(pool.reset_time);\n"311 " rst.textContent=fmtReset(pool.reset_time);\n"
312+ " if(pool.reset_time){\n"
313+ " rst.setAttribute('data-reset',pool.reset_time);\n"
314+ " rst.setAttribute('data-reset-mode','full');\n"
315+ " var rt=Date.parse(pool.reset_time);\n"
316+ " if(!isNaN(rt))rst.title='Resets at '+fmtClock(rt)+' ('+pool.reset_time+')';\n"
317+ " }\n"
278 " }\n"318 " }\n"
279 " hd.appendChild(pctEl);\n"319 " hd.appendChild(pctEl);\n"
280 " bar.appendChild(fill);\n"320 " bar.appendChild(fill);\n"
@@ -292,12 +332,11 @@ static const char *UI_HTML =@@ -292,12 +332,11 @@ static const char *UI_HTML =
292 "\n"332 "\n"
293 " $('kpiGemini').textContent=best.gemini?shortEmail(best.gemini):'-';\n"333 " $('kpiGemini').textContent=best.gemini?shortEmail(best.gemini):'-';\n"
294 " $('kpiGemini').title=best.gemini||'';\n"334 " $('kpiGemini').title=best.gemini||'';\n"
295- " $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');\n"335+ " $('kpiGeminiMeta').textContent=best.gemini?(best.geminiPct.toFixed(1)+'% remaining'+(best.geminiReset?(' · resets in '+fmtResetShort(best.geminiReset)):'')):(state.loading?'Checking...':'No quota data');\n"
296 "\n"336 "\n"
297 " $('kpiClaude').textContent=best.claude?shortEmail(best.claude):'-';\n"337 " $('kpiClaude').textContent=best.claude?shortEmail(best.claude):'-';\n"
298 " $('kpiClaude').title=best.claude||'';\n"338 " $('kpiClaude').title=best.claude||'';\n"
299- " $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'):(state.loading?'Checking...':'No quota data');\n"339+ " $('kpiClaudeMeta').textContent=best.claude?(best.claudePct.toFixed(1)+'% remaining'+(best.claudeReset?(' · resets in '+fmtResetShort(best.claudeReset)):'')):(state.loading?'Checking...':'No quota data');\n"
300- "\n"
301 " var wrap=$('accounts');\n"340 " var wrap=$('accounts');\n"
302 " wrap.innerHTML='';\n"341 " wrap.innerHTML='';\n"
303 " if(!state.accounts.length){\n"342 " if(!state.accounts.length){\n"
@@ -341,8 +380,18 @@ static const char *UI_HTML =@@ -341,8 +380,18 @@ static const char *UI_HTML =
341 " qd.models.forEach(function(m){\n"380 " qd.models.forEach(function(m){\n"
342 " var row=el('div','mrow');\n"381 " var row=el('div','mrow');\n"
343 " row.appendChild(el('span','mid',m.id));\n"382 " row.appendChild(el('span','mid',m.id));\n"
383+ " var right=el('span','mright');\n"
384+ " if(m.reset_time){\n"
385+ " var mr=el('span','mrst',fmtResetShort(m.reset_time));\n"
386+ " mr.setAttribute('data-reset',m.reset_time);\n"
387+ " mr.setAttribute('data-reset-mode','short');\n"
388+ " var mt=Date.parse(m.reset_time);\n"
389+ " if(!isNaN(mt))mr.title='Resets at '+fmtClock(mt)+' ('+m.reset_time+')';\n"
390+ " right.appendChild(mr);\n"
391+ " }\n"
344 " var cls=pctClass(m.pct,m.exhausted);\n"392 " var cls=pctClass(m.pct,m.exhausted);\n"
345- " row.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));\n"393+ " right.appendChild(el('span','mpct '+cls,m.exhausted?'EXH':(m.pct.toFixed(1)+'%')));\n"
394+ " row.appendChild(right);\n"
346 " mgrid.appendChild(row);\n"395 " mgrid.appendChild(row);\n"
347 " });\n"396 " });\n"
348 " card.appendChild(mgrid);\n"397 " card.appendChild(mgrid);\n"
@@ -351,7 +400,6 @@ static const char *UI_HTML =@@ -351,7 +400,6 @@ static const char *UI_HTML =
351 " wrap.appendChild(card);\n"400 " wrap.appendChild(card);\n"
352 " });\n"401 " });\n"
353 "}\n"402 "}\n"
354- "\n"
355 "function switchAccount(email,btn){\n"403 "function switchAccount(email,btn){\n"
356 " btn.disabled=true;\n"404 " btn.disabled=true;\n"
357 " btn.textContent='Switching...';\n"405 " btn.textContent='Switching...';\n"
@@ -462,6 +510,7 @@ static const char *UI_HTML =@@ -462,6 +510,7 @@ static const char *UI_HTML =
462 " window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');\n"510 " window.sxApplyTheme(window.sxTheme()==='dark'?'light':'dark');\n"
463 " }\n"511 " }\n"
464 "};\n"512 "};\n"
513+ "setInterval(refreshResetLabels,30000);\n"
465 "load();\n"514 "load();\n"
466 "</script>\n"515 "</script>\n"
467 "\002</body></html>\n"516 "\002</body></html>\n"
tests/mock_quota.sh+12−9■■■■■
index 1169c80..33af6e9 100755index 1169c80..33af6e9 100755
--- a/tests/mock_quota.sh--- a/tests/mock_quota.sh
+++ b/tests/mock_quota.sh+++ b/tests/mock_quota.sh
@@ -21,9 +21,12 @@ fi@@ -21,9 +21,12 @@ fi
21 21
22 echo "INFO : ya29.MOCK-TOKEN-MUST-NOT-LEAK" >&222 echo "INFO : ya29.MOCK-TOKEN-MUST-NOT-LEAK" >&2
23 23
24+RST_CLAUDE="${MOCK_RESET_CLAUDE:-2026-11-25T06:00:00Z}"
25+RST_GEMINI="${MOCK_RESET_GEMINI:-2026-11-25T03:00:00Z}"
26+
24 case "$acct" in27 case "$acct" in
25 alpha@example.com)28 alpha@example.com)
26- cat <<'EOF'29+ cat <<EOF
27 {30 {
28 "ok": true,31 "ok": true,
29 "email": "alpha@example.com",32 "email": "alpha@example.com",
@@ -31,10 +34,10 @@ case "$acct" in@@ -31,10 +34,10 @@ case "$acct" in
31 "endpoint": "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota",34 "endpoint": "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota",
32 "buckets": [35 "buckets": [
33 {"tokenType": "WTUS", "modelId": "chat_20706", "remainingFraction": 1},36 {"tokenType": "WTUS", "modelId": "chat_20706", "remainingFraction": 1},
34- {"resetTime": "2026-11-25T06:00:00Z", "tokenType": "WTUS", "modelId": "claude-opus-4-6-thinking", "remainingFraction": 1},37+ {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-opus-4-6-thinking", "remainingFraction": 1},
35- {"resetTime": "2026-11-25T06:00:00Z", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 1},38+ {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 1},
36- {"resetTime": "2026-11-25T03:00:00Z", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": 0.855},39+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": 0.855},
37- {"resetTime": "2026-11-25T03:00:00Z", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar", "remainingFraction": 0.855},40+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar", "remainingFraction": 0.855},
38 {"tokenType": "WTUS", "modelId": "tab_flash_lite_preview", "remainingFraction": 1}41 {"tokenType": "WTUS", "modelId": "tab_flash_lite_preview", "remainingFraction": 1}
39 ]42 ]
40 }43 }
@@ -42,16 +45,16 @@ EOF@@ -42,16 +45,16 @@ EOF
42 exit 045 exit 0
43 ;;46 ;;
44 beta@example.com)47 beta@example.com)
45- cat <<'EOF'48+ cat <<EOF
46 {49 {
47 "ok": true,50 "ok": true,
48 "email": "beta@example.com",51 "email": "beta@example.com",
49 "project": "aicode-consumers",52 "project": "aicode-consumers",
50 "endpoint": "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota",53 "endpoint": "https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota",
51 "buckets": [54 "buckets": [
52- {"resetTime": "2026-11-25T08:00:00Z", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 0.42},55+ {"resetTime": "$RST_CLAUDE", "tokenType": "WTUS", "modelId": "claude-sonnet-4-6", "remainingFraction": 0.42},
53- {"resetTime": "2026-11-25T04:00:00Z", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": null},56+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-3.8-flash-tiered", "remainingFraction": null},
54- {"resetTime": "2026-11-25T04:00:00Z", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar"}57+ {"resetTime": "$RST_GEMINI", "tokenType": "WTUS", "modelId": "gemini-4-hydrogen-sonar"}
55 ]58 ]
56 }59 }
57 EOF60 EOF
tests/run.sh+10−10■■■■■
index fc73f17..cc47abc 100755index fc73f17..cc47abc 100755
--- a/tests/run.sh--- a/tests/run.sh
+++ b/tests/run.sh+++ b/tests/run.sh
@@ -81,8 +81,8 @@ mkdir -p "$FIX/none" "$FIX/empty" "$FIX/full"@@ -81,8 +81,8 @@ mkdir -p "$FIX/none" "$FIX/empty" "$FIX/full"
81 chmod +x "$ROOT/tests/mock_quota.sh"81 chmod +x "$ROOT/tests/mock_quota.sh"
82 export GOOGLE_QUOTA_BIN="$ROOT/tests/mock_quota.sh"82 export GOOGLE_QUOTA_BIN="$ROOT/tests/mock_quota.sh"
83 export GOOGLE_ACCESS_TOKEN="ya29.INHERITED-TOKEN-MUST-BE-CLEARED"83 export GOOGLE_ACCESS_TOKEN="ya29.INHERITED-TOKEN-MUST-BE-CLEARED"
84-84+export MOCK_RESET_CLAUDE=$(python3 -c "from datetime import datetime,timedelta,timezone; print((datetime.now(timezone.utc)+timedelta(hours=2,minutes=15)).strftime('%Y-%m-%dT%H:%M:%SZ'))")
85-: > "$FIX/empty/antigravity_accounts.json"85+export MOCK_RESET_GEMINI=$(python3 -c "from datetime import datetime,timedelta,timezone; print((datetime.now(timezone.utc)+timedelta(hours=144,minutes=30)).strftime('%Y-%m-%dT%H:%M:%SZ'))")
86 86
87 cat > "$FIX/full/antigravity_accounts.json" <<'EOF'87 cat > "$FIX/full/antigravity_accounts.json" <<'EOF'
88 [88 [
@@ -102,8 +102,7 @@ META_ENV=$(BOT_PASSWORD=secret-pass SX_PLUGIN_META=1 $BIN)@@ -102,8 +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.0" "$VER"105+check "--version prints plugin id and version" "plugin_google_quota 1.0.1" "$VER"
106-
107 UNAUTH=$(BOT_PASSWORD=secret-pass QUERY_STRING="action=status" $BIN)106 UNAUTH=$(BOT_PASSWORD=secret-pass QUERY_STRING="action=status" $BIN)
108 check "missing password returns 401" "Status: 401 Unauthorized" "$UNAUTH"107 check "missing password returns 401" "Status: 401 Unauthorized" "$UNAUTH"
109 108
@@ -135,15 +134,14 @@ json_ok "missing CLI sets cli_present false" "$ST_NOCLI" "d['ok'] is True and d[@@ -135,15 +134,14 @@ json_ok "missing CLI sets cli_present false" "$ST_NOCLI" "d['ok'] is True and d[
135 # ---------------------------------------------------------------- quota134 # ---------------------------------------------------------------- quota
136 section "quota"135 section "quota"
137 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")
138-json_ok "single account quota parses gemini and claude pools" "$Q_ONE" \137+json_ok "single account quota parses gemini and claude pools and remaining hours" "$Q_ONE" \
139- "d['ok'] is True and d['account']['ok'] is True and abs(d['account']['gemini']['pct'] - 85.5) < 0.01 and abs(d['account']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 4"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']['claude']['pct'] - 100.0) < 0.01 and len(d['account']['models']) == 4 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'])"
140 check_not "single quota never leaks token" "MOCK-TOKEN" "$Q_ONE"139 check_not "single quota never leaks token" "MOCK-TOKEN" "$Q_ONE"
141 check_not "single quota never leaks refresh token" "MOCK-REFRESH-TOKEN" "$Q_ONE"140 check_not "single quota never leaks refresh token" "MOCK-REFRESH-TOKEN" "$Q_ONE"
142 141
143 Q_EXH=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=beta@example.com")142 Q_EXH=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota&account=beta@example.com")
144-json_ok "null/missing remainingFraction marks gemini pool exhausted" "$Q_EXH" \143+json_ok "null/missing remainingFraction marks gemini pool exhausted with reset remaining" "$Q_EXH" \
145- "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"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-
147 Q_ALL=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota")145 Q_ALL=$(GOOGLE_ACCOUNTS_FILE="$FIX/full/antigravity_accounts.json" api "action=quota")
148 json_ok "all-accounts quota aggregates best_gemini, best_claude, and broken account" "$Q_ALL" \146 json_ok "all-accounts quota aggregates best_gemini, best_claude, and broken account" "$Q_ALL" \
149 "d['ok'] is True and d['count'] == 3 and d['best_gemini'] == 'alpha@example.com' and d['best_claude'] == 'alpha@example.com' and d['accounts'][2]['ok'] is False"147 "d['ok'] is True and d['count'] == 3 and d['best_gemini'] == 'alpha@example.com' and d['best_claude'] == 'alpha@example.com' and d['accounts'][2]['ok'] is False"
@@ -182,11 +180,13 @@ check "HTML includes bot theme prepaint" "bot_theme" "$HTML"@@ -182,11 +180,13 @@ check "HTML includes bot theme prepaint" "bot_theme" "$HTML"
182 check "HTML includes theme handoff" "sx-theme-request" "$HTML"180 check "HTML includes theme handoff" "sx-theme-request" "$HTML"
183 check "HTML uses two-route API helper" "plugin_google_quota" "$HTML"181 check "HTML uses two-route API helper" "plugin_google_quota" "$HTML"
184 check "HTML hub proxy URL uses &action= separator" "'/plugins?plugin='+encodeURIComponent(HUB)+'&'" "$HTML"182 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"
184+check "HTML renders per-model reset remaining hours" "fmtResetShort" "$HTML"
185+check "HTML includes live reset countdown attributes" "data-reset" "$HTML"
185 check "HTML hides theme toggle in embed mode" "embed-hide" "$HTML"186 check "HTML hides theme toggle in embed mode" "embed-hide" "$HTML"
186 check_not "HTML loads no CDN script" "<script src=" "$HTML"187 check_not "HTML loads no CDN script" "<script src=" "$HTML"
187 check_not "HTML references no external host script" "cdnjs" "$HTML"188 check_not "HTML references no external host script" "cdnjs" "$HTML"
188 check_not "HTML makes no outbound fetch to googleapis" "googleapis.com" "$HTML"189 check_not "HTML makes no outbound fetch to googleapis" "googleapis.com" "$HTML"
189-
190 printf '%s' "$HTML" > "$FIX/page.html"190 printf '%s' "$HTML" > "$FIX/page.html"
191 if python3 - "$FIX/page.html" <<'PY'191 if python3 - "$FIX/page.html" <<'PY'
192 import re, sys192 import re, sys
193193