sideby 0.35.9 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +12 -0
- package/dist/src/cli/commands.js +480 -6
- package/dist/src/cli/format.d.ts +12 -1
- package/dist/src/cli/format.js +23 -3
- package/dist/src/cli/json-schemas.js +166 -1
- package/dist/src/cli/main.js +18 -4
- package/dist/src/core/advisor.d.ts +176 -0
- package/dist/src/core/advisor.js +472 -0
- package/dist/src/core/browser-profiles.d.ts +16 -0
- package/dist/src/core/browser-profiles.js +45 -0
- package/dist/src/core/cli-commands.js +25 -1
- package/dist/src/core/config.d.ts +29 -0
- package/dist/src/core/config.js +25 -0
- package/dist/src/core/handoff-select.d.ts +13 -2
- package/dist/src/core/handoff-select.js +6 -2
- package/dist/src/core/launch.d.ts +4 -0
- package/dist/src/core/launch.js +7 -0
- package/dist/src/core/limit-reset.d.ts +198 -0
- package/dist/src/core/limit-reset.js +299 -0
- package/dist/src/core/quota-fetch.d.ts +57 -2
- package/dist/src/core/quota-fetch.js +291 -13
- package/dist/src/core/quota-levels.d.ts +70 -0
- package/dist/src/core/quota-levels.js +80 -0
- package/dist/src/core/quota-store.d.ts +15 -1
- package/dist/src/core/quota-store.js +26 -1
- package/dist/src/core/same-login.d.ts +8 -0
- package/dist/src/core/same-login.js +39 -2
- package/dist/src/core/search-catalog.js +38 -0
- package/dist/src/families/claude/index.js +2 -0
- package/dist/src/families/codex/index.js +3 -1
- package/dist/src/families/codex/quota.d.ts +23 -1
- package/dist/src/families/codex/quota.js +122 -21
- package/dist/src/families/grok/quota-log.d.ts +1 -0
- package/dist/src/menubar/script.js +70 -18
- package/dist/src/menubar/snapshot.d.ts +33 -1
- package/dist/src/menubar/snapshot.js +79 -11
- package/dist/src/menubar/strings.d.ts +16 -0
- package/dist/src/menubar/strings.js +16 -0
- package/dist/src/panel/handler.d.ts +21 -0
- package/dist/src/panel/handler.js +111 -9
- package/dist/src/panel/i18n.d.ts +87 -0
- package/dist/src/panel/i18n.js +174 -0
- package/dist/src/panel/page-logic.d.ts +17 -0
- package/dist/src/panel/page-logic.js +23 -0
- package/dist/src/panel/page-script.js +440 -19
- package/dist/src/panel/page-styles.js +38 -2
- package/dist/src/plugins/loader.d.ts +2 -0
- package/dist/src/plugins/loader.js +27 -0
- package/dist/src/runtime.d.ts +63 -1
- package/dist/src/runtime.js +529 -9
- package/dist/src/types.d.ts +67 -0
- package/package.json +1 -1
- package/schemas/advisor.json +332 -0
- package/schemas/config.json +22 -0
- package/schemas/error.json +4 -0
- package/schemas/menubar-reset.json +93 -0
- package/schemas/menubar-snapshot.json +70 -2
- package/schemas/quota-reset.json +369 -0
- package/schemas/quota.json +30 -0
- package/schemas/update.json +4 -0
- package/skills/sideby/SKILL.md +6 -2
- package/skills/sideby/references/ai-tasks.md +1 -1
- package/skills/sideby/references/panel.md +14 -0
- package/skills/sideby/references/quota.md +27 -0
- package/skills/sideby/references/update.md +1 -1
|
@@ -75,16 +75,21 @@ function run(argv) {
|
|
|
75
75
|
}
|
|
76
76
|
var forceNext = false;
|
|
77
77
|
// While a manual refresh runs: when it started (ISO, for --refreshing-since) and the cache-only snapshot in flight.
|
|
78
|
-
var refreshSince = '', peekTask = null, peekHandle = null, peekOut = out + '.peek';
|
|
78
|
+
var refreshSince = '', peekTask = null, peekHandle = null, peekOut = out + '.peek', peekManual = false;
|
|
79
|
+
// The account whose "Use a reset…" was clicked, and whether the menu has opened since: the first snapshot after
|
|
80
|
+
// that asks it once. A manual refresh asks every account, so it settles this too.
|
|
81
|
+
var askNext = '', askDue = false;
|
|
79
82
|
function startSnapshot(force) {
|
|
80
83
|
if (task) { if (force) forceNext = true; return; }
|
|
81
84
|
force = force || forceNext;
|
|
82
85
|
forceNext = false;
|
|
86
|
+
var ask = !force && askDue ? askNext : '';
|
|
87
|
+
if (force || ask) { askNext = ''; askDue = false; }
|
|
83
88
|
if (force) refreshSince = new Date().toISOString();
|
|
84
89
|
$.NSFileManager.defaultManager.createFileAtPathContentsAttributes(out, $(), $());
|
|
85
90
|
hotkeyReported = hotkeyReport();
|
|
86
91
|
iconReported = iconStable;
|
|
87
|
-
var t = sideby(['menubar', 'snapshot', '--json', '--lang', lang].concat(force ? ['--refresh'] : [], hotkeyReported ? ['--hotkey', hotkeyStatus, '--hotkey-label', hotkeyWant.label] : [], iconReported ? ['--icon', iconReported] : []));
|
|
92
|
+
var t = sideby(['menubar', 'snapshot', '--json', '--lang', lang].concat(force ? ['--refresh'] : [], ask ? ['--ask', ask] : [], hotkeyReported ? ['--hotkey', hotkeyStatus, '--hotkey-label', hotkeyWant.label] : [], iconReported ? ['--icon', iconReported] : []));
|
|
88
93
|
handle = $.NSFileHandle.fileHandleForWritingAtPath(out);
|
|
89
94
|
t.standardOutput = handle;
|
|
90
95
|
lastStart = now();
|
|
@@ -123,20 +128,23 @@ function run(argv) {
|
|
|
123
128
|
});
|
|
124
129
|
build();
|
|
125
130
|
}
|
|
126
|
-
//
|
|
127
|
-
// numbers
|
|
131
|
+
// While a snapshot asks Hosts, a cache-only snapshot that never asks one: accounts already answered show their new
|
|
132
|
+
// numbers as they land. During a manual refresh the others say they are refreshing; during an automatic one they
|
|
133
|
+
// keep what was kept, and it starts only once the snapshot has run for a while (it is asking). At most one at a time.
|
|
128
134
|
function peek() {
|
|
129
135
|
if (task && !task.running) { finishSnapshot(); return; }
|
|
130
136
|
if (peekTask && !peekTask.running) {
|
|
131
137
|
var ok = peekTask.terminationStatus === 0;
|
|
132
138
|
peekTask = null;
|
|
133
139
|
closePeek();
|
|
134
|
-
var next = ok && task && manual ? readSnapshot(peekOut) : null;
|
|
140
|
+
var next = ok && task && manual === peekManual ? readSnapshot(peekOut) : null;
|
|
135
141
|
if (next) { snap = next; build(); }
|
|
136
142
|
}
|
|
137
|
-
if (peekTask || !task
|
|
143
|
+
if (peekTask || !task) return;
|
|
144
|
+
if (manual ? !refreshSince : now() - lastStart < PEEK) return;
|
|
145
|
+
peekManual = manual;
|
|
138
146
|
$.NSFileManager.defaultManager.createFileAtPathContentsAttributes(peekOut, $(), $());
|
|
139
|
-
var t = sideby(['menubar', 'snapshot', '--json', '--cached', '--
|
|
147
|
+
var t = sideby(['menubar', 'snapshot', '--json', '--cached', '--lang', lang].concat(manual ? ['--refreshing-since', refreshSince] : []));
|
|
140
148
|
peekHandle = $.NSFileHandle.fileHandleForWritingAtPath(peekOut);
|
|
141
149
|
t.standardOutput = peekHandle;
|
|
142
150
|
if (t.launchAndReturnError(null)) peekTask = t;
|
|
@@ -377,7 +385,7 @@ function run(argv) {
|
|
|
377
385
|
return (bars[key] = $.NSAttributedString.attributedStringWithAttachment(att));
|
|
378
386
|
}
|
|
379
387
|
|
|
380
|
-
var keptW = { name: 0, reset: 0, tag: 0 };
|
|
388
|
+
var keptW = { name: 0, reset: 0, tag: 0, aside: 0 };
|
|
381
389
|
// Columns: the name, then per window its bar and percent, then the reset time. One set of tab stops lines them up
|
|
382
390
|
// across every tool; the window names sit once in each tool's header, over their column. A tool with one window
|
|
383
391
|
// draws it in the second column, under the others' long window.
|
|
@@ -392,7 +400,7 @@ function run(argv) {
|
|
|
392
400
|
// The reset column names its window ("7d", then "tomorrow 4:59 PM"), so it is as wide as its longest entry. While the
|
|
393
401
|
// menu is open it never gets narrower, so rows changing during a refresh do not make the menu jump.
|
|
394
402
|
// The times start at one tab stop after the widest window tag, so 7d and 31d rows line their times up.
|
|
395
|
-
var nameW = 0, first = false, tagW = width('7d', L.font), timeW = width('Wed 12:59 PM', L.font), plainW = 0;
|
|
403
|
+
var nameW = 0, first = false, tagW = width('7d', L.font), timeW = width('Wed 12:59 PM', L.font), plainW = 0, asideW = 0;
|
|
396
404
|
function measure(r) {
|
|
397
405
|
var c = resetCell(r);
|
|
398
406
|
if (c[0]) { tagW = Math.max(tagW, width(c[0], L.font)); timeW = Math.max(timeW, width(c[1], L.font)); }
|
|
@@ -403,17 +411,18 @@ function run(argv) {
|
|
|
403
411
|
if (s.columns[0]) first = true;
|
|
404
412
|
s.rows.concat(s.more ? s.more.rows : []).forEach(function (r) {
|
|
405
413
|
nameW = Math.max(nameW, width(r.label, L.font));
|
|
414
|
+
asideW = Math.max(asideW, width(aside(r), L.small));
|
|
406
415
|
if (r.bars) measure(r);
|
|
407
416
|
(r.groups || []).forEach(function (g) {
|
|
408
417
|
nameW = Math.max(nameW, width(GROUP_INDENT + g.label, L.font));
|
|
409
|
-
measure({ reset: g.reset, resetLabel: g.resetLabel, resetTime: g.resetTime, refreshing: r.refreshing, refreshFailed: r.refreshFailed, stale: r
|
|
418
|
+
measure({ reset: g.reset, resetLabel: g.resetLabel, resetTime: g.resetTime, refreshing: r.refreshing, refreshFailed: r.refreshFailed, stale: groupStale(r, g), note: g.reset });
|
|
410
419
|
});
|
|
411
420
|
});
|
|
412
421
|
});
|
|
413
422
|
tagW = Math.ceil(tagW) + 8;
|
|
414
423
|
var resetW = Math.max(tagW + timeW, plainW);
|
|
415
|
-
if (menuOpen) { nameW = Math.max(nameW, keptW.name); resetW = Math.max(resetW, keptW.reset); tagW = Math.max(tagW, keptW.tag); }
|
|
416
|
-
keptW = { name: nameW, reset: resetW, tag: tagW };
|
|
424
|
+
if (menuOpen) { nameW = Math.max(nameW, keptW.name); resetW = Math.max(resetW, keptW.reset); tagW = Math.max(tagW, keptW.tag); asideW = Math.max(asideW, keptW.aside); }
|
|
425
|
+
keptW = { name: nameW, reset: resetW, tag: tagW, aside: asideW };
|
|
417
426
|
var pctW = width('100%', L.mono), x = Math.ceil(nameW) + 20, stops = [], at = [];
|
|
418
427
|
function tab(pos) { stops.push($.NSTextTab.alloc.initWithTextAlignmentLocationOptions($.NSTextAlignmentLeft, pos, $())); }
|
|
419
428
|
for (var c = 0; c < (first ? 2 : 1); c++) {
|
|
@@ -423,6 +432,8 @@ function run(argv) {
|
|
|
423
432
|
}
|
|
424
433
|
tab(x);
|
|
425
434
|
tab(x + tagW);
|
|
435
|
+
// A last column for quiet remarks (a Limit Reset the account holds, how old its numbers are), only when a row has one.
|
|
436
|
+
if (asideW) tab(x + resetW + 16);
|
|
426
437
|
L.reset = x;
|
|
427
438
|
L.first = first;
|
|
428
439
|
L.para = $.NSMutableParagraphStyle.alloc.init;
|
|
@@ -432,9 +443,18 @@ function run(argv) {
|
|
|
432
443
|
L.headPara.tabStops = $(at.concat([x]).map(function (pos) {
|
|
433
444
|
return $.NSTextTab.alloc.initWithTextAlignmentLocationOptions($.NSTextAlignmentLeft, pos, $());
|
|
434
445
|
}));
|
|
435
|
-
L.width = x + resetW + 70;
|
|
446
|
+
L.width = x + resetW + 70 + (asideW ? Math.ceil(asideW) + 16 : 0);
|
|
447
|
+
L.aside = asideW > 0;
|
|
448
|
+
L.tag = tagW;
|
|
436
449
|
return L;
|
|
437
450
|
}
|
|
451
|
+
// The quiet remarks after a row's reset time: the Limit Resets it holds, then how old its numbers are.
|
|
452
|
+
function aside(r) {
|
|
453
|
+
return [r.limitResets, r.age].filter(function (x) { return x; }).join(' · ');
|
|
454
|
+
}
|
|
455
|
+
// Whether a line's numbers are old: a model group may have been read at another time than the account's own bars.
|
|
456
|
+
function barsStale(r) { return r.barsStale === undefined ? r.stale : r.barsStale; }
|
|
457
|
+
function groupStale(r, g) { return g.stale === undefined ? r.stale : g.stale; }
|
|
438
458
|
// The reset cell: [window tag, time]. The tag is drawn grey and the time in the text colour; a cell that says
|
|
439
459
|
// something else (refreshing, failed, an old reading, every window past its reset) has only grey words.
|
|
440
460
|
function resetCell(r) {
|
|
@@ -464,13 +484,18 @@ function run(argv) {
|
|
|
464
484
|
if (cell[0]) {
|
|
465
485
|
line.appendAttributedString(str('\t' + cell[0], dim));
|
|
466
486
|
line.appendAttributedString(str('\t' + cell[1], stale() ? dim : plain));
|
|
467
|
-
} else
|
|
487
|
+
} else {
|
|
488
|
+
line.appendAttributedString(str('\t' + cell[1], dim));
|
|
489
|
+
// Words shorter than the window tag stop before the time's tab stop: one more tab reaches the remarks column.
|
|
490
|
+
if (L.aside && r.aside && width(cell[1], L.font) < L.tag) line.appendAttributedString(str('\t', dim));
|
|
491
|
+
}
|
|
492
|
+
if (L.aside && r.aside) line.appendAttributedString(str('\t' + r.aside, attrs($.NSColor.secondaryLabelColor, L.small, L.para)));
|
|
468
493
|
return line;
|
|
469
494
|
}
|
|
470
495
|
function accountItem(menu, r, L) {
|
|
471
496
|
refs.push(r.ref);
|
|
472
497
|
var mi = add(menu, r.label, 'start:', refs.length);
|
|
473
|
-
mi.attributedTitle = rowTitle(r, L);
|
|
498
|
+
mi.attributedTitle = rowTitle({ label: r.label, bars: r.bars, reset: r.reset, resetLabel: r.resetLabel, resetTime: r.resetTime, refreshing: r.refreshing, refreshFailed: r.refreshFailed, stale: barsStale(r), note: r.note, aside: aside(r) }, L);
|
|
474
499
|
// An empty image as wide as the tools' logos, so every row's text starts where the headers' text does and the
|
|
475
500
|
// window names sit over their bars.
|
|
476
501
|
mi.image = GUTTER;
|
|
@@ -488,10 +513,18 @@ function run(argv) {
|
|
|
488
513
|
(r.groups || []).forEach(function (g) {
|
|
489
514
|
refs.push(r.ref);
|
|
490
515
|
var gi = add(menu, g.label, 'start:', refs.length);
|
|
491
|
-
gi.attributedTitle = rowTitle({ label: GROUP_INDENT + g.label, bars: g.bars, reset: g.reset, resetLabel: g.resetLabel, resetTime: g.resetTime, refreshing: r.refreshing, refreshFailed: r.refreshFailed, stale: r
|
|
516
|
+
gi.attributedTitle = rowTitle({ label: GROUP_INDENT + g.label, bars: g.bars, reset: g.reset, resetLabel: g.resetLabel, resetTime: g.resetTime, refreshing: r.refreshing, refreshFailed: r.refreshFailed, stale: groupStale(r, g), note: g.reset }, L);
|
|
492
517
|
gi.image = GUTTER;
|
|
493
518
|
gi.toolTip = g.tip;
|
|
494
519
|
});
|
|
520
|
+
// The way to using a Limit Reset (ADR-0072), under the account: it opens a page and uses nothing by itself.
|
|
521
|
+
if (r.useReset) {
|
|
522
|
+
refs.push(r.ref);
|
|
523
|
+
var ui = add(menu, GROUP_INDENT + r.useReset.title, 'useReset:', refs.length);
|
|
524
|
+
ui.attributedTitle = str(GROUP_INDENT + r.useReset.title, attrs($.NSColor.secondaryLabelColor, L.font, L.para));
|
|
525
|
+
ui.image = GUTTER;
|
|
526
|
+
ui.toolTip = r.useReset.tip;
|
|
527
|
+
}
|
|
495
528
|
return mi;
|
|
496
529
|
}
|
|
497
530
|
// A tool's header: its mark, its name, and the window names over the bar columns. A view, not a title: macOS dims
|
|
@@ -643,7 +676,15 @@ function run(argv) {
|
|
|
643
676
|
name: 'SidebyMenuBar',
|
|
644
677
|
protocols: ['NSMenuDelegate'],
|
|
645
678
|
methods: {
|
|
646
|
-
'menuWillOpen:': {
|
|
679
|
+
'menuWillOpen:': {
|
|
680
|
+
types: ['void', ['id']],
|
|
681
|
+
implementation: function () {
|
|
682
|
+
menuOpen = true;
|
|
683
|
+
try { unregisterHotkey(); } catch (e) {}
|
|
684
|
+
// After "Use a reset…": ask that one account once, now that the menu is looked at again.
|
|
685
|
+
if (askNext) { askDue = true; try { startSnapshot(); } catch (e) {} }
|
|
686
|
+
},
|
|
687
|
+
},
|
|
647
688
|
'menuDidClose:': {
|
|
648
689
|
types: ['void', ['id']],
|
|
649
690
|
implementation: function () { menuOpen = false; closedAt = uptime(); lastUse = now(); try { registerHotkey(); } catch (e) {} },
|
|
@@ -660,7 +701,7 @@ function run(argv) {
|
|
|
660
701
|
if (task && !task.running) finishSnapshot();
|
|
661
702
|
lookAtIcon();
|
|
662
703
|
// A shortcut that just registered or failed, and an icon that just showed or went, are told at once.
|
|
663
|
-
if (!task && (forceNext || now() - lastStart >= SNAPSHOT || hotkeyReport() !== hotkeyReported || iconStable !== iconReported)) startSnapshot();
|
|
704
|
+
if (!task && (forceNext || askDue || now() - lastStart >= SNAPSHOT || hotkeyReport() !== hotkeyReported || iconStable !== iconReported)) startSnapshot();
|
|
664
705
|
// The bars are pictures in the colours of the moment; redraw them when light or dark mode changes.
|
|
665
706
|
if (ObjC.unwrap(app.effectiveAppearance.name) !== appearance) build();
|
|
666
707
|
else drawTitle();
|
|
@@ -714,6 +755,17 @@ function run(argv) {
|
|
|
714
755
|
if (ref) act(['menubar', 'start', ref]);
|
|
715
756
|
},
|
|
716
757
|
},
|
|
758
|
+
// "Use a reset…": the command opens the Panel on that account's confirmation, or the vendor's page where only
|
|
759
|
+
// that can use one. The numbers may change there, so the next time the menu opens that account is asked once.
|
|
760
|
+
'useReset:': {
|
|
761
|
+
types: ['void', ['id']],
|
|
762
|
+
implementation: function (sender) {
|
|
763
|
+
var ref = refs[sender.tag - 1];
|
|
764
|
+
if (!ref) return;
|
|
765
|
+
askNext = ref;
|
|
766
|
+
act(['menubar', 'reset', ref]);
|
|
767
|
+
},
|
|
768
|
+
},
|
|
717
769
|
},
|
|
718
770
|
});
|
|
719
771
|
var target = $.SidebyMenuBar.alloc.init;
|
|
@@ -22,8 +22,13 @@ export interface MenubarRow {
|
|
|
22
22
|
recommended: boolean;
|
|
23
23
|
/** When the quota was observed, independently of the menu's check time; null without quota. */
|
|
24
24
|
observedAt: string | null;
|
|
25
|
-
/** An old or undated reading, or a failed quota query. */
|
|
25
|
+
/** An old or undated reading, or a failed quota query; true when any of the row's windows is. */
|
|
26
26
|
stale: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the account's own bars are old, when that differs from `stale`: a model group under them was read at
|
|
29
|
+
* another time (ADR-0073). Left out, `stale` stands for them.
|
|
30
|
+
*/
|
|
31
|
+
barsStale?: boolean;
|
|
27
32
|
/** Hover text: when the numbers were read, each window's use and reset, and what a click does. */
|
|
28
33
|
tip: string;
|
|
29
34
|
/**
|
|
@@ -39,6 +44,8 @@ export interface MenubarRow {
|
|
|
39
44
|
label: string;
|
|
40
45
|
bars: MenubarRow['bars'];
|
|
41
46
|
tip: string;
|
|
47
|
+
/** Whether this group's numbers are old by their own read time (ADR-0073); left out, the row's `stale` stands. */
|
|
48
|
+
stale?: boolean;
|
|
42
49
|
} & Pick<MenubarRow, 'reset' | 'resetLabel' | 'resetTime'>)[] | null;
|
|
43
50
|
/**
|
|
44
51
|
* Which window resets and when, such as `7d · tomorrow 4:59 PM`: the window closest to its own red level (85% for 5
|
|
@@ -59,6 +66,23 @@ export interface MenubarRow {
|
|
|
59
66
|
refreshFailed?: true;
|
|
60
67
|
/** A no-quota explanation, or an old-reading warning beside the bars. */
|
|
61
68
|
note: string;
|
|
69
|
+
/** The Limit Resets the account holds, in words (`1 reset available`, ADR-0072); left out for none or unknown. */
|
|
70
|
+
limitResets?: string;
|
|
71
|
+
/**
|
|
72
|
+
* A line under the account that leads to using a Limit Reset (spec §3.40, ADR-0072): its words and hover text.
|
|
73
|
+
* `sideby menubar reset <account>` is what a click runs; it opens a page and never uses one itself. Present for an
|
|
74
|
+
* Account that holds one where the Host can use it (Codex), and for one with a window at its warning level where
|
|
75
|
+
* only the vendor's page can (Claude Code). Left out otherwise.
|
|
76
|
+
*/
|
|
77
|
+
useReset?: {
|
|
78
|
+
title: string;
|
|
79
|
+
tip: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* How old the numbers are, in words (`read 25m ago`), once they are older than the Family's check interval or old
|
|
83
|
+
* (ADR-0073); left out while they are current. The hover text always says when they were read.
|
|
84
|
+
*/
|
|
85
|
+
age?: string;
|
|
62
86
|
}
|
|
63
87
|
export interface MenubarSection {
|
|
64
88
|
family: string;
|
|
@@ -113,6 +137,14 @@ export interface MenubarFamilyInput {
|
|
|
113
137
|
* changes only when a session runs in the account; old readings then say so. Default true.
|
|
114
138
|
*/
|
|
115
139
|
refreshable?: boolean;
|
|
140
|
+
/** How often the Family asks its Host for Quota (`fetchQuota.everyMinutes`); the age shows once a reading is older. */
|
|
141
|
+
everyMinutes?: number;
|
|
142
|
+
/**
|
|
143
|
+
* How a Limit Reset is used in this Family (`FamilyDef.limitReset`): `use` when the Host's CLI can, `page` when only
|
|
144
|
+
* the vendor's page can, with that page's host name in `limitResetSite`. Left out when it offers neither.
|
|
145
|
+
*/
|
|
146
|
+
limitReset?: 'use' | 'page';
|
|
147
|
+
limitResetSite?: string;
|
|
116
148
|
/** Its Handoff ranking (`sideby next`); null when the Family has no Quota source. */
|
|
117
149
|
plan: HandoffPlan | null;
|
|
118
150
|
/** In Display Order. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bindingWindow, openWindows,
|
|
1
|
+
import { bindingWindow, limitResetOffer, openWindows, QUOTA_LONG_WARN_PERCENT, QUOTA_WARN_PERCENT, quotaAge, windowLevel, worseLevel, } from '../core/quota-levels.js';
|
|
2
2
|
import { resetDate, resetWhen } from '../panel/page-logic.js';
|
|
3
3
|
import { fill, MENUBAR_STRINGS } from './strings.js';
|
|
4
4
|
export const DEFAULT_MENUBAR_HOTKEY = 'opt+x';
|
|
@@ -194,8 +194,8 @@ function observedText(observedAt, now, s) {
|
|
|
194
194
|
return s.observedJustNow;
|
|
195
195
|
return fill(s.observedAgo, { time: durationText(minutes, s) });
|
|
196
196
|
}
|
|
197
|
-
function row(a, plan, now, s, refreshable, lang) {
|
|
198
|
-
const r = quotaRow(a, plan, now, s, refreshable, lang);
|
|
197
|
+
function row(a, plan, now, s, refreshable, lang, everyMinutes, limitReset) {
|
|
198
|
+
const r = quotaRow(a, plan, now, s, refreshable, lang, everyMinutes, limitReset);
|
|
199
199
|
if (!a.refresh)
|
|
200
200
|
return r;
|
|
201
201
|
// A manual refresh in progress (spec §3.31): the old bars stay, and the reset cell says where the refresh stands.
|
|
@@ -212,7 +212,7 @@ function row(a, plan, now, s, refreshable, lang) {
|
|
|
212
212
|
detail: [r.detail, says].filter(Boolean).join(s.sep),
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
function quotaRow(a, plan, now, s, refreshable, lang) {
|
|
215
|
+
function quotaRow(a, plan, now, s, refreshable, lang, everyMinutes, limitReset) {
|
|
216
216
|
const recommended = Boolean(plan?.hasQuota && plan.pick === a.ref);
|
|
217
217
|
const startTip = fill(s.startTip, { account: a.ref });
|
|
218
218
|
const base = {
|
|
@@ -238,9 +238,12 @@ function quotaRow(a, plan, now, s, refreshable, lang) {
|
|
|
238
238
|
const quota = a.quota;
|
|
239
239
|
if (quota.status !== 'ok')
|
|
240
240
|
return noted(s.noData);
|
|
241
|
-
|
|
241
|
+
// Each window by its own read time (ADR-0073): a model group kept under a newer plan reading may be older.
|
|
242
|
+
const ageOf = (windows) => quotaAge({ ...quota, windows }, now.getTime(), a.lastUseAt, everyMinutes);
|
|
243
|
+
const age = ageOf(quota.windows);
|
|
244
|
+
const stale = age.stale;
|
|
242
245
|
// Over an hour old but unused here since: the numbers stand, and the hover text says what it cannot see.
|
|
243
|
-
const quiet = !stale &&
|
|
246
|
+
const quiet = !stale && age.quiet;
|
|
244
247
|
// The head of the hover text: when the numbers were read, and why they may be old.
|
|
245
248
|
const head = [
|
|
246
249
|
observedText(quota.observedAt, now, s),
|
|
@@ -248,27 +251,80 @@ function quotaRow(a, plan, now, s, refreshable, lang) {
|
|
|
248
251
|
...(quiet ? [s.quietTip] : []),
|
|
249
252
|
...(quota.fetchError ? [fill(s.fetchFailed, { error: quota.fetchError })] : []),
|
|
250
253
|
];
|
|
254
|
+
// The Limit Resets the Host tells (ADR-0072): a quiet note on the row, with the next expiry in the hover text.
|
|
255
|
+
const stock = quota.limitResets && quota.limitResets.available > 0 ? quota.limitResets : null;
|
|
256
|
+
const resetsNote = stock
|
|
257
|
+
? stock.available === 1
|
|
258
|
+
? s.limitResetsOne
|
|
259
|
+
: fill(s.limitResetsMany, { n: stock.available })
|
|
260
|
+
: '';
|
|
261
|
+
const resetsTip = stock
|
|
262
|
+
? [
|
|
263
|
+
'',
|
|
264
|
+
fill(s.limitResetsTip, { n: stock.available }),
|
|
265
|
+
...(stock.nextExpiresAt
|
|
266
|
+
? [fill(s.limitResetsExpiry, { date: resetDate(stock.nextExpiresAt, now.getTime(), lang) })]
|
|
267
|
+
: []),
|
|
268
|
+
]
|
|
269
|
+
: [];
|
|
270
|
+
const minutesOld = Math.floor((now.getTime() - Date.parse(age.observedAt)) / 60000);
|
|
271
|
+
const ageNote = age.showAge && Number.isFinite(minutesOld) && minutesOld >= 1
|
|
272
|
+
? fill(s.readAgo, { time: durationText(minutesOld, s) })
|
|
273
|
+
: '';
|
|
274
|
+
// The line that leads to using one: where the Host can, whenever the Account holds one; where only the vendor's
|
|
275
|
+
// page can, once a window is at its warning level, as sideby cannot see the count.
|
|
276
|
+
const offered = limitReset?.kind === 'use'
|
|
277
|
+
? stock !== null
|
|
278
|
+
: limitReset?.kind === 'page' &&
|
|
279
|
+
limitResetOffer(quota, 'page', now.getTime(), {
|
|
280
|
+
short: QUOTA_WARN_PERCENT,
|
|
281
|
+
long: QUOTA_LONG_WARN_PERCENT,
|
|
282
|
+
}) !== null;
|
|
283
|
+
const extra = {
|
|
284
|
+
...(offered
|
|
285
|
+
? {
|
|
286
|
+
useReset: {
|
|
287
|
+
title: s.useReset,
|
|
288
|
+
tip: limitReset.kind === 'use'
|
|
289
|
+
? s.useResetTip
|
|
290
|
+
: fill(s.useResetPageTip, { site: limitReset.site ?? '' }),
|
|
291
|
+
},
|
|
292
|
+
}
|
|
293
|
+
: {}),
|
|
294
|
+
...(resetsNote ? { limitResets: resetsNote } : {}),
|
|
295
|
+
...(ageNote ? { age: ageNote } : {}),
|
|
296
|
+
};
|
|
251
297
|
// Every window is past its reset: Refresh asks now, where the Family can be asked.
|
|
252
298
|
const due = (d) => (d.allPassed && refreshable ? [s.resetDueTip] : []);
|
|
253
299
|
const groups = quotaGroups(quota);
|
|
254
300
|
if (groups) {
|
|
255
301
|
// One line per model group under the account, each with its own 5h and 7d bars (spec §3.31). Windows that cover
|
|
256
302
|
// every model (Cursor's plan total) keep their bars on the account's own line.
|
|
257
|
-
const drawnGroups = groups.map((g) => ({
|
|
303
|
+
const drawnGroups = groups.map((g) => ({
|
|
304
|
+
name: g.name,
|
|
305
|
+
d: drawn(g.quota, now, s, lang),
|
|
306
|
+
age: ageOf(g.quota.windows),
|
|
307
|
+
}));
|
|
258
308
|
const groupTip = (g) => [
|
|
259
309
|
g.name,
|
|
260
310
|
...g.d.lines.map((l) => ` ${l}`),
|
|
311
|
+
// A group read at another time than the rest says when.
|
|
312
|
+
...(g.age.observedAt !== quota.observedAt ? [` ${observedText(g.age.observedAt, now, s)}`] : []),
|
|
261
313
|
...due(g.d).map((l) => ` ${l}`),
|
|
262
314
|
];
|
|
263
315
|
const all = openWindows(quota, now) ? drawn(quota, now, s, lang) : null;
|
|
316
|
+
const ownStale = all ? ageOf(quota.windows.filter((w) => !w.name)).stale : stale;
|
|
264
317
|
return {
|
|
265
318
|
...base,
|
|
319
|
+
...extra,
|
|
266
320
|
observedAt: quota.observedAt,
|
|
267
321
|
stale,
|
|
322
|
+
...(ownStale !== stale ? { barsStale: ownStale } : {}),
|
|
268
323
|
detail: [
|
|
269
324
|
...(all ? [all.parts.join(' ')] : []),
|
|
270
325
|
...drawnGroups.map((g) => `${groupLabel(g.name)} ${g.d.parts.join(' ')}`),
|
|
271
326
|
...(stale ? [s.olderReading] : []),
|
|
327
|
+
...(resetsNote ? [resetsNote] : []),
|
|
272
328
|
].join(s.sep),
|
|
273
329
|
level: drawnGroups.reduce((l, g) => worseLevel(l, g.d.level), all?.level ?? 'ok'),
|
|
274
330
|
tip: [
|
|
@@ -276,6 +332,7 @@ function quotaRow(a, plan, now, s, refreshable, lang) {
|
|
|
276
332
|
'',
|
|
277
333
|
...(all ? [...all.lines, ...due(all), ''] : []),
|
|
278
334
|
...drawnGroups.flatMap(groupTip),
|
|
335
|
+
...resetsTip,
|
|
279
336
|
'',
|
|
280
337
|
startTip,
|
|
281
338
|
].join('\n'),
|
|
@@ -294,8 +351,9 @@ function quotaRow(a, plan, now, s, refreshable, lang) {
|
|
|
294
351
|
resetLabel: g.d.resetLabel,
|
|
295
352
|
resetTime: g.d.resetTime,
|
|
296
353
|
tip: [...head, '', ...groupTip(g), '', startTip].join('\n'),
|
|
354
|
+
...(g.age.stale !== stale ? { stale: g.age.stale } : {}),
|
|
297
355
|
})),
|
|
298
|
-
note:
|
|
356
|
+
note: ownStale ? s.olderReading : '',
|
|
299
357
|
};
|
|
300
358
|
}
|
|
301
359
|
if (openWindows(quota, now) === null)
|
|
@@ -308,13 +366,16 @@ function quotaRow(a, plan, now, s, refreshable, lang) {
|
|
|
308
366
|
parts.push(s.resetDue);
|
|
309
367
|
if (stale)
|
|
310
368
|
parts.push(s.olderReading);
|
|
369
|
+
if (resetsNote)
|
|
370
|
+
parts.push(resetsNote);
|
|
311
371
|
return {
|
|
312
372
|
...base,
|
|
373
|
+
...extra,
|
|
313
374
|
observedAt: quota.observedAt,
|
|
314
375
|
stale,
|
|
315
376
|
detail: parts.join(s.sep),
|
|
316
377
|
level: d.level,
|
|
317
|
-
tip: [...head, '', ...d.lines, ...due(d), '', startTip].join('\n'),
|
|
378
|
+
tip: [...head, '', ...d.lines, ...due(d), ...resetsTip, '', startTip].join('\n'),
|
|
318
379
|
bars: d.bars,
|
|
319
380
|
reset: d.reset,
|
|
320
381
|
resetLabel: d.resetLabel,
|
|
@@ -339,7 +400,12 @@ function section(f, now, s, lang) {
|
|
|
339
400
|
...(f.logo.gradients?.length ? { gradients: f.logo.gradients } : {}),
|
|
340
401
|
}
|
|
341
402
|
: null;
|
|
342
|
-
const all = f.accounts.map((a) => ({
|
|
403
|
+
const all = f.accounts.map((a) => ({
|
|
404
|
+
a,
|
|
405
|
+
r: row(a, f.plan, now, s, f.refreshable !== false, lang, f.everyMinutes, f.limitReset
|
|
406
|
+
? { kind: f.limitReset, ...(f.limitResetSite ? { site: f.limitResetSite } : {}) }
|
|
407
|
+
: undefined),
|
|
408
|
+
}));
|
|
343
409
|
const aside = (a) => a.kind === 'api' || a.login === 'logged-out';
|
|
344
410
|
// A Same Login is one quota, so one row, named like the Panel's: after the directory first in Display Order (the
|
|
345
411
|
// Panel's "Set as shown name" moves one there). It is recommended when any of its directories is. The other
|
|
@@ -370,10 +436,12 @@ function section(f, now, s, lang) {
|
|
|
370
436
|
: lead);
|
|
371
437
|
for (const y of others) {
|
|
372
438
|
const note = y.a.loginExpired ? s.loginExpired : fill(s.sameLoginNote, { name: lead.a.name });
|
|
439
|
+
// The shared Quota, its Limit Resets and its age are said once, on the row that leads the login.
|
|
440
|
+
const { limitResets: _resets, age: _age, useReset: _use, ...rest } = y.r;
|
|
373
441
|
same.push({
|
|
374
442
|
...y,
|
|
375
443
|
r: {
|
|
376
|
-
...
|
|
444
|
+
...rest,
|
|
377
445
|
bars: null,
|
|
378
446
|
reset: '',
|
|
379
447
|
resetLabel: '',
|
|
@@ -30,6 +30,14 @@ export declare const MENUBAR_STRINGS: {
|
|
|
30
30
|
readonly olderReadingSessionTip: 'These numbers may be old · they update when a session runs in this account';
|
|
31
31
|
readonly quietTip: 'Not used on this computer since · use on the web or other computers is not included';
|
|
32
32
|
readonly fetchFailed: 'The last check failed: {error}';
|
|
33
|
+
readonly readAgo: 'read {time} ago';
|
|
34
|
+
readonly limitResetsOne: '1 reset available';
|
|
35
|
+
readonly limitResetsMany: '{n} resets available';
|
|
36
|
+
readonly limitResetsTip: 'Limit resets: {n} available · using one restores quota before a window resets by itself';
|
|
37
|
+
readonly limitResetsExpiry: 'The next one expires {date}';
|
|
38
|
+
readonly useReset: 'Use a reset…';
|
|
39
|
+
readonly useResetTip: 'Opens the Panel, which shows what a reset would do and asks before using one';
|
|
40
|
+
readonly useResetPageTip: 'Opens {site}, where a reset is used · sideby cannot see whether this account holds one';
|
|
33
41
|
readonly windowTip: '{label}: {p}% used';
|
|
34
42
|
readonly windowResetsTip: '{label}: {p}% used · resets {date} (in {left})';
|
|
35
43
|
readonly windowPassedTip: '{label}: reset at {date} · new numbers come with the next check';
|
|
@@ -99,6 +107,14 @@ export declare const MENUBAR_STRINGS: {
|
|
|
99
107
|
readonly olderReadingSessionTip: '这些数字可能已经过时 · 在这个账号开一次会话就会更新';
|
|
100
108
|
readonly quietTip: '之后这台电脑没用过这个账号 · 网页或其他电脑上的用量不在内';
|
|
101
109
|
readonly fetchFailed: '上次检查没成功:{error}';
|
|
110
|
+
readonly readAgo: '{time}前读取';
|
|
111
|
+
readonly limitResetsOne: '可用重置 1 次';
|
|
112
|
+
readonly limitResetsMany: '可用重置 {n} 次';
|
|
113
|
+
readonly limitResetsTip: '重置次数:可用 {n} 次 · 用一次能在窗口自己重置之前恢复额度';
|
|
114
|
+
readonly limitResetsExpiry: '最近一次 {date} 到期';
|
|
115
|
+
readonly useReset: '使用重置…';
|
|
116
|
+
readonly useResetTip: '打开面板:先看这次重置会带来什么,确认后才使用';
|
|
117
|
+
readonly useResetPageTip: '打开 {site},在那里使用重置 · sideby 看不到这个账号有没有可用的重置';
|
|
102
118
|
readonly windowTip: '{label}:已用 {p}%';
|
|
103
119
|
readonly windowResetsTip: '{label}:已用 {p}% · {date} 重置({left}后)';
|
|
104
120
|
readonly windowPassedTip: '{label}:已于 {date} 重置 · 下次检查时更新';
|
|
@@ -30,6 +30,14 @@ export const MENUBAR_STRINGS = {
|
|
|
30
30
|
olderReadingSessionTip: 'These numbers may be old · they update when a session runs in this account',
|
|
31
31
|
quietTip: 'Not used on this computer since · use on the web or other computers is not included',
|
|
32
32
|
fetchFailed: 'The last check failed: {error}',
|
|
33
|
+
readAgo: 'read {time} ago',
|
|
34
|
+
limitResetsOne: '1 reset available',
|
|
35
|
+
limitResetsMany: '{n} resets available',
|
|
36
|
+
limitResetsTip: 'Limit resets: {n} available · using one restores quota before a window resets by itself',
|
|
37
|
+
limitResetsExpiry: 'The next one expires {date}',
|
|
38
|
+
useReset: 'Use a reset…',
|
|
39
|
+
useResetTip: 'Opens the Panel, which shows what a reset would do and asks before using one',
|
|
40
|
+
useResetPageTip: 'Opens {site}, where a reset is used · sideby cannot see whether this account holds one',
|
|
33
41
|
windowTip: '{label}: {p}% used',
|
|
34
42
|
windowResetsTip: '{label}: {p}% used · resets {date} (in {left})',
|
|
35
43
|
windowPassedTip: '{label}: reset at {date} · new numbers come with the next check',
|
|
@@ -99,6 +107,14 @@ export const MENUBAR_STRINGS = {
|
|
|
99
107
|
olderReadingSessionTip: '这些数字可能已经过时 · 在这个账号开一次会话就会更新',
|
|
100
108
|
quietTip: '之后这台电脑没用过这个账号 · 网页或其他电脑上的用量不在内',
|
|
101
109
|
fetchFailed: '上次检查没成功:{error}',
|
|
110
|
+
readAgo: '{time}前读取',
|
|
111
|
+
limitResetsOne: '可用重置 1 次',
|
|
112
|
+
limitResetsMany: '可用重置 {n} 次',
|
|
113
|
+
limitResetsTip: '重置次数:可用 {n} 次 · 用一次能在窗口自己重置之前恢复额度',
|
|
114
|
+
limitResetsExpiry: '最近一次 {date} 到期',
|
|
115
|
+
useReset: '使用重置…',
|
|
116
|
+
useResetTip: '打开面板:先看这次重置会带来什么,确认后才使用',
|
|
117
|
+
useResetPageTip: '打开 {site},在那里使用重置 · sideby 看不到这个账号有没有可用的重置',
|
|
102
118
|
windowTip: '{label}:已用 {p}%',
|
|
103
119
|
windowResetsTip: '{label}:已用 {p}% · {date} 重置({left}后)',
|
|
104
120
|
windowPassedTip: '{label}:已于 {date} 重置 · 下次检查时更新',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { type AdvisorStatus } from '../core/advisor.ts';
|
|
2
3
|
import { type AppProfileStatus } from '../core/app-profiles.ts';
|
|
3
4
|
import { type AutostartContext, type AutostartStatus } from '../core/autostart.ts';
|
|
4
5
|
import { type BrowserReport } from '../core/browser-profiles.ts';
|
|
@@ -168,6 +169,15 @@ export type PanelFamily = FamilyInfo & {
|
|
|
168
169
|
aiTaskSafe?: true;
|
|
169
170
|
/** "Refresh" can ask the Host for its Quota (`fetchQuota`); without it old numbers wait for a session (spec §3.31). */
|
|
170
171
|
quotaRefresh?: true;
|
|
172
|
+
/** How often sideby asks this Host for Quota, in minutes: a number older than this says its age (ADR-0073). */
|
|
173
|
+
quotaEvery?: number;
|
|
174
|
+
/**
|
|
175
|
+
* How a Limit Reset of its Subscription Accounts is spent (ADR-0072): `use` through the Host after a confirmation,
|
|
176
|
+
* `page` only on the vendor's page (`limitResetPage`). Absent when the Family offers neither.
|
|
177
|
+
*/
|
|
178
|
+
limitReset?: 'use' | 'page';
|
|
179
|
+
/** The vendor's page where a Limit Reset is spent, when the Family names one. */
|
|
180
|
+
limitResetPage?: string;
|
|
171
181
|
};
|
|
172
182
|
/** What the Panel shows about updates (spec §3.23); absent when the handler was created with `updates: false`. */
|
|
173
183
|
export interface PanelUpdate {
|
|
@@ -216,6 +226,11 @@ export interface PanelState {
|
|
|
216
226
|
/** Config `ask.permissions` when it is `account` (ADR-0070): AI Tasks start with the Account's own arguments. */
|
|
217
227
|
aiTaskPermissions?: 'account';
|
|
218
228
|
accounts: PanelAccount[];
|
|
229
|
+
/**
|
|
230
|
+
* The Accounts whose Host is being asked for Quota right now, behind the kept answer on show (spec §3.26); the page
|
|
231
|
+
* reads the state again soon, so each row takes its new numbers as they land. Left out when none is.
|
|
232
|
+
*/
|
|
233
|
+
quotaAsking?: string[];
|
|
219
234
|
pluginErrors: {
|
|
220
235
|
where: string;
|
|
221
236
|
message: string;
|
|
@@ -262,6 +277,11 @@ export interface PanelState {
|
|
|
262
277
|
};
|
|
263
278
|
/** Claude settings files grouped as `sideby remote-control` shows them (spec §3.22); absent without Claude Accounts. */
|
|
264
279
|
remoteControl?: RemoteControlView[];
|
|
280
|
+
/**
|
|
281
|
+
* Claude Code's advisor as `sideby advisor --json` shows it (spec §3.41): the settings files of Claude subscription
|
|
282
|
+
* Accounts and whether sideby unlocks it at launch; absent without such Accounts.
|
|
283
|
+
*/
|
|
284
|
+
advisor?: AdvisorView;
|
|
265
285
|
/** Grok Bot windows (ADR-0019), data folders shown as `~/…`; absent when there are none to show. */
|
|
266
286
|
appProfiles?: AppProfileStatus[];
|
|
267
287
|
/** Update Check result and Auto Update setting (spec §3.23); absent with `updates: false`. */
|
|
@@ -340,6 +360,7 @@ export declare function handoffByFamily(rt: Runtime, accounts: readonly PanelAcc
|
|
|
340
360
|
export type RemoteControlView = Omit<RemoteControlGroup, 'file'> & {
|
|
341
361
|
file: string;
|
|
342
362
|
};
|
|
363
|
+
export type AdvisorView = AdvisorStatus;
|
|
343
364
|
/**
|
|
344
365
|
* How long one state waits for an Account's reads. A slower Account (a plugin reader that hangs, a Host that answers
|
|
345
366
|
* late) is sent as pending, so it does not hold up every other row; its reads go on and the next state picks up the
|