sideby 0.32.2 → 0.34.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/assets/brand/sai-painted-1024.png +0 -0
- package/assets/brand/sai-painted-128.png +0 -0
- package/assets/brand/sai-painted-256.png +0 -0
- package/assets/brand/sai-painted-64.png +0 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +76 -18
- package/dist/src/cli/format.js +3 -1
- package/dist/src/cli/json-schemas.js +34 -6
- package/dist/src/cli/main.js +12 -5
- package/dist/src/core/brand-mark.d.ts +18 -115
- package/dist/src/core/brand-mark.js +43 -174
- package/dist/src/core/live-sessions.d.ts +4 -0
- package/dist/src/core/live-sessions.js +17 -3
- package/dist/src/core/messages.d.ts +26 -5
- package/dist/src/core/messages.js +73 -16
- package/dist/src/core/quota-fetch.js +9 -2
- package/dist/src/core/session-status.d.ts +55 -0
- package/dist/src/core/session-status.js +59 -0
- package/dist/src/core/unattended-retry.d.ts +39 -0
- package/dist/src/core/unattended-retry.js +107 -0
- package/dist/src/core/unattended.d.ts +2 -2
- package/dist/src/core/unattended.js +10 -2
- package/dist/src/desktop/icon.d.ts +13 -1
- package/dist/src/desktop/icon.js +153 -285
- package/dist/src/families/claude/deliver.js +14 -2
- package/dist/src/families/claude/messaging.d.ts +14 -1
- package/dist/src/families/claude/messaging.js +24 -4
- package/dist/src/families/codex/deliver.d.ts +10 -1
- package/dist/src/families/codex/deliver.js +24 -2
- package/dist/src/families/messaging.d.ts +12 -1
- package/dist/src/handoff/messages.js +1 -1
- package/dist/src/menubar/script.d.ts +5 -0
- package/dist/src/menubar/script.js +111 -25
- package/dist/src/menubar/snapshot.d.ts +25 -5
- package/dist/src/menubar/snapshot.js +114 -26
- package/dist/src/menubar/strings.d.ts +22 -6
- package/dist/src/menubar/strings.js +22 -6
- package/dist/src/panel/handler.d.ts +2 -2
- package/dist/src/panel/handler.js +8 -2
- package/dist/src/panel/i18n.d.ts +11 -0
- package/dist/src/panel/i18n.js +35 -13
- package/dist/src/panel/page-logic.d.ts +41 -4
- package/dist/src/panel/page-logic.js +145 -10
- package/dist/src/panel/page-script.js +50 -11
- package/dist/src/panel/page-styles.js +5 -5
- package/dist/src/panel/page.js +2 -2
- package/dist/src/panel/theme.d.ts +4 -1
- package/dist/src/runtime.d.ts +3 -1
- package/dist/src/runtime.js +1 -1
- package/dist/src/unattended/hook.d.ts +4 -0
- package/dist/src/unattended/hook.js +86 -2
- package/package.json +2 -1
- package/schemas/menubar-snapshot.json +102 -2
- package/schemas/messages.json +6 -2
- package/schemas/send.json +6 -2
- package/schemas/sessions.json +22 -1
- package/skills/sideby/SKILL.md +1 -1
- package/skills/sideby/references/panel.md +1 -1
- package/skills/sideby/references/sessions.md +7 -4
- package/skills/sideby/references/unattended.md +4 -2
|
@@ -8,10 +8,23 @@ import { accountEnv } from '../../core/launch.js';
|
|
|
8
8
|
export const QUEUE_TIMEOUT_MS = 20_000;
|
|
9
9
|
/** How long the queue process gets to end after SIGTERM before it is sent SIGKILL. */
|
|
10
10
|
const KILL_GRACE_MS = 2_000;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* `codex queue` started but did not finish in time: it may already have queued the line, so the outcome is unknown
|
|
13
|
+
* (ADR-0065), unlike a start failure or a non-zero exit, which mean it did not.
|
|
14
|
+
*/
|
|
15
|
+
export class CodexQueueTimeout extends Error {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Runs `codex <args>` and resolves to its exit code; its output is ignored, as it may hold account details. Rejects
|
|
19
|
+
* with `CodexQueueTimeout` when the process started and did not end within `timeoutMs`, else with a plain Error.
|
|
20
|
+
*/
|
|
12
21
|
export function runCodex(args, env, timeoutMs) {
|
|
13
22
|
return new Promise((resolve, reject) => {
|
|
14
23
|
const child = spawn('codex', args, { cwd: tmpdir(), env, stdio: 'ignore' });
|
|
24
|
+
let started = false;
|
|
25
|
+
child.once('spawn', () => {
|
|
26
|
+
started = true;
|
|
27
|
+
});
|
|
15
28
|
const timer = setTimeout(() => {
|
|
16
29
|
// Only this short-lived queue process is ended (by its own pid), never a Codex session.
|
|
17
30
|
child.kill('SIGTERM');
|
|
@@ -23,7 +36,8 @@ export function runCodex(args, env, timeoutMs) {
|
|
|
23
36
|
}
|
|
24
37
|
catch { }
|
|
25
38
|
}, KILL_GRACE_MS).unref();
|
|
26
|
-
|
|
39
|
+
const why = 'Codex did not answer in time';
|
|
40
|
+
reject(started ? new CodexQueueTimeout(why) : new Error(why));
|
|
27
41
|
}, timeoutMs);
|
|
28
42
|
child.once('error', (err) => {
|
|
29
43
|
clearTimeout(timer);
|
|
@@ -59,6 +73,14 @@ export async function deliverCodex(req) {
|
|
|
59
73
|
code = await (deps.runCodex ?? runCodex)(args, accountEnv(family, acct, rt.env), deps.timeoutMs ?? QUEUE_TIMEOUT_MS);
|
|
60
74
|
}
|
|
61
75
|
catch (err) {
|
|
76
|
+
if (err instanceof CodexQueueTimeout) {
|
|
77
|
+
// It may have queued the line already; a paste on top of it could reach the session twice.
|
|
78
|
+
const ended = await req.ended();
|
|
79
|
+
return {
|
|
80
|
+
status: 'unknown',
|
|
81
|
+
note: `sideby could not confirm that ${to.label} got it: \`codex queue\` did not finish within ${(deps.timeoutMs ?? QUEUE_TIMEOUT_MS) / 1000} s.${ended ? ' The session has ended since.' : ''} It may still show up; check the session before you send it again`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
62
84
|
return {
|
|
63
85
|
status: 'paste-needed',
|
|
64
86
|
note: `sideby could not send it to ${to.label} (${err.message}); paste the line into its terminal tab`,
|
|
@@ -15,13 +15,24 @@ export interface DeliveryRequest {
|
|
|
15
15
|
pasteText: string;
|
|
16
16
|
/** A fresh look at the processes. */
|
|
17
17
|
procs: ProcessView;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the target's process is gone by now, from another fresh look (for after a delivery that could not be
|
|
20
|
+
* confirmed); a failed look counts as still running.
|
|
21
|
+
*/
|
|
22
|
+
ended: () => Promise<boolean>;
|
|
18
23
|
deps: MessageDeps;
|
|
19
24
|
}
|
|
20
25
|
export interface Delivery {
|
|
21
26
|
status: MessageStatus;
|
|
22
|
-
/** Plain-language note: why paste is needed,
|
|
27
|
+
/** Plain-language note: why paste is needed, what the target must still do, or why it could not be confirmed. */
|
|
23
28
|
note?: string;
|
|
24
29
|
/** The Host took it but shows it only after the user approves it in the target's terminal (ADR-0045). */
|
|
25
30
|
needsApproval?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A `paste-needed` whose channel took nothing and failed in a way that may pass (a refused connection, no answer
|
|
33
|
+
* before writing): sending again cannot deliver it twice, so `core/messages.ts` tries again after a wait. Never
|
|
34
|
+
* kept in a receipt.
|
|
35
|
+
*/
|
|
36
|
+
retry?: boolean;
|
|
26
37
|
}
|
|
27
38
|
export declare const DELIVERERS: Readonly<Record<string, (req: DeliveryRequest) => Promise<Delivery>>>;
|
|
@@ -52,7 +52,7 @@ const WHY = {
|
|
|
52
52
|
};
|
|
53
53
|
/** The next session's first prompt: the Brief's path only, never its text (it would show in a process list). */
|
|
54
54
|
export function firstPrompt(fromRef, brief, trigger) {
|
|
55
|
-
return `This task was handed over from ${fromRef} by sideby because ${WHY[trigger]}. Read ${brief} first, then continue the task it describes. If the user asks to move the task to another account (back to ${fromRef}, say), run \`sideby handoff ready --to <account>\` and end your turn.`;
|
|
55
|
+
return `This task was handed over from ${fromRef} by sideby because ${WHY[trigger]}. Read ${brief} first, then continue the task it describes. The previous session may have stopped mid-step: check the working tree, git history and any remote state before you repeat an outside action such as a push, a message or a pull request, and do not repeat one that already happened. If the user asks to move the task to another account (back to ${fromRef}, say), run \`sideby handoff ready --to <account>\` and end your turn.`;
|
|
56
56
|
}
|
|
57
57
|
const clock = (iso) => new Date(iso).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
|
|
58
58
|
/** For the user, not the model (ADR-0018): this session will wait for the reset, and how to move on now instead. */
|
|
@@ -5,6 +5,11 @@ export declare const TICK_SECONDS = 5;
|
|
|
5
5
|
export declare const STALE_SECONDS: number;
|
|
6
6
|
/** A snapshot still running after this is ended, so a stuck one cannot stop the refreshes. */
|
|
7
7
|
export declare const SNAPSHOT_TIMEOUT_SECONDS = 60;
|
|
8
|
+
/**
|
|
9
|
+
* While a manual refresh runs, a cache-only snapshot (`--cached`) every this many seconds, so each account's new
|
|
10
|
+
* numbers show as soon as its answer is kept instead of all at once at the end (spec §3.31).
|
|
11
|
+
*/
|
|
12
|
+
export declare const PEEK_SECONDS = 2;
|
|
8
13
|
/**
|
|
9
14
|
* Hours after which an idle item starts itself again. Over many hours the menu took longer and longer to open (1.6 to
|
|
10
15
|
* 2 s after 18 hours on macOS 27, 2026-10-30, against about 0.1 s fresh), with no cause found in the script.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The Menu Bar Item's process (spec §3.31, ADR-0034): JXA run by the system's `osascript`, with no compiled code. It
|
|
2
2
|
// draws what `sideby menubar snapshot --json` says and turns clicks into sideby commands; it reads no other file and
|
|
3
3
|
// decides nothing itself. Arguments: the Node binary and the sideby entry the LaunchAgent recorded.
|
|
4
|
-
import {
|
|
4
|
+
import { MENUBAR_ICON_PNG } from '../core/brand-mark.js';
|
|
5
5
|
import { MENUBAR_STRINGS } from './strings.js';
|
|
6
6
|
/** Seconds between two snapshots, and between two looks at a running one. */
|
|
7
7
|
export const SNAPSHOT_SECONDS = 120;
|
|
@@ -10,6 +10,11 @@ export const TICK_SECONDS = 5;
|
|
|
10
10
|
export const STALE_SECONDS = 15 * 60;
|
|
11
11
|
/** A snapshot still running after this is ended, so a stuck one cannot stop the refreshes. */
|
|
12
12
|
export const SNAPSHOT_TIMEOUT_SECONDS = 60;
|
|
13
|
+
/**
|
|
14
|
+
* While a manual refresh runs, a cache-only snapshot (`--cached`) every this many seconds, so each account's new
|
|
15
|
+
* numbers show as soon as its answer is kept instead of all at once at the end (spec §3.31).
|
|
16
|
+
*/
|
|
17
|
+
export const PEEK_SECONDS = 2;
|
|
13
18
|
/**
|
|
14
19
|
* Hours after which an idle item starts itself again. Over many hours the menu took longer and longer to open (1.6 to
|
|
15
20
|
* 2 s after 18 hours on macOS 27, 2026-10-30, against about 0.1 s fresh), with no cause found in the script.
|
|
@@ -23,7 +28,7 @@ ObjC.import('Carbon');
|
|
|
23
28
|
ObjC.import('stdlib');
|
|
24
29
|
function run(argv) {
|
|
25
30
|
var node = argv[0], entry = argv[1];
|
|
26
|
-
var SNAPSHOT = ${SNAPSHOT_SECONDS}, TICK = ${TICK_SECONDS}, STALE = ${STALE_SECONDS}, TIMEOUT = ${SNAPSHOT_TIMEOUT_SECONDS};
|
|
31
|
+
var SNAPSHOT = ${SNAPSHOT_SECONDS}, TICK = ${TICK_SECONDS}, STALE = ${STALE_SECONDS}, TIMEOUT = ${SNAPSHOT_TIMEOUT_SECONDS}, PEEK = ${PEEK_SECONDS};
|
|
27
32
|
var lang = 'en';
|
|
28
33
|
try { lang = ObjC.unwrap($.NSLocale.preferredLanguages.firstObject) || 'en'; } catch (e) {}
|
|
29
34
|
var app = $.NSApplication.sharedApplication;
|
|
@@ -31,9 +36,10 @@ function run(argv) {
|
|
|
31
36
|
var item = $.NSStatusBar.systemStatusBar.statusItemWithLength($.NSVariableStatusItemLength);
|
|
32
37
|
// Keeps the place a user drags it to with Command held, such as out from under the notch.
|
|
33
38
|
item.autosaveName = 'dev.sideby.menubar';
|
|
34
|
-
// Sai, the sideby buddy, in colour (core/brand-mark.ts); a system gauge, drawn as a template,
|
|
35
|
-
var
|
|
36
|
-
|
|
39
|
+
// Sai, the painted sideby buddy, in colour (core/brand-mark.ts); a system gauge, drawn as a template, if it cannot load.
|
|
40
|
+
var MARK_PNG = ${JSON.stringify(MENUBAR_ICON_PNG)};
|
|
41
|
+
var icon = pngImage(MARK_PNG, 18);
|
|
42
|
+
if (!icon) {
|
|
37
43
|
icon = $.NSImage.imageWithSystemSymbolNameAccessibilityDescription('gauge.with.needle', 'sideby');
|
|
38
44
|
if (icon && !icon.isNil()) icon.template = true;
|
|
39
45
|
}
|
|
@@ -48,7 +54,6 @@ function run(argv) {
|
|
|
48
54
|
var refs = [], actions = [], footer = null, appearance = '', manual = false;
|
|
49
55
|
// The first words, before any snapshot has said which language to use.
|
|
50
56
|
var zh = /^zh/i.test(lang);
|
|
51
|
-
var CARD_ICON = ${JSON.stringify(FAVICON_SVG)};
|
|
52
57
|
var LOADING = zh ? ${JSON.stringify(MENUBAR_STRINGS.zh.loading)} : ${JSON.stringify(MENUBAR_STRINGS.en.loading)};
|
|
53
58
|
var OPEN_PANEL = zh ? ${JSON.stringify(MENUBAR_STRINGS.zh.openPanel)} : ${JSON.stringify(MENUBAR_STRINGS.en.openPanel)};
|
|
54
59
|
var now = function () { return Date.now() / 1000; };
|
|
@@ -69,10 +74,13 @@ function run(argv) {
|
|
|
69
74
|
if (t.launchAndReturnError(null)) actions.push(t);
|
|
70
75
|
}
|
|
71
76
|
var forceNext = false;
|
|
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';
|
|
72
79
|
function startSnapshot(force) {
|
|
73
80
|
if (task) { if (force) forceNext = true; return; }
|
|
74
81
|
force = force || forceNext;
|
|
75
82
|
forceNext = false;
|
|
83
|
+
if (force) refreshSince = new Date().toISOString();
|
|
76
84
|
$.NSFileManager.defaultManager.createFileAtPathContentsAttributes(out, $(), $());
|
|
77
85
|
hotkeyReported = hotkeyReport();
|
|
78
86
|
iconReported = iconStable;
|
|
@@ -86,21 +94,62 @@ function run(argv) {
|
|
|
86
94
|
function closeHandle() {
|
|
87
95
|
if (handle) { handle.closeFile; handle = null; }
|
|
88
96
|
}
|
|
97
|
+
// The snapshot a finished task wrote, or null.
|
|
98
|
+
function readSnapshot(path) {
|
|
99
|
+
try {
|
|
100
|
+
var next = JSON.parse(ObjC.unwrap($.NSString.stringWithContentsOfFileEncodingError(path, $.NSUTF8StringEncoding, null)));
|
|
101
|
+
return next && next.schemaVersion === 1 ? next : null;
|
|
102
|
+
} catch (e) { return null; }
|
|
103
|
+
}
|
|
89
104
|
function finishSnapshot() {
|
|
90
105
|
var ok = task.terminationStatus === 0;
|
|
91
106
|
task = null;
|
|
92
|
-
|
|
107
|
+
// A refresh asked for while an automatic read ran starts next; it stays a manual one.
|
|
108
|
+
if (!forceNext) manual = false;
|
|
93
109
|
closeHandle();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (next && next.schemaVersion === 1) { snap = next; lastOk = now(); failed = false; hotkey(snap.hotkey); build(); return; }
|
|
99
|
-
} catch (e) {}
|
|
100
|
-
}
|
|
110
|
+
// The refresh's own result wins: a cache-only snapshot still running started before it and is dropped.
|
|
111
|
+
stopPeek();
|
|
112
|
+
var next = ok ? readSnapshot(out) : null;
|
|
113
|
+
if (next) { snap = next; lastOk = now(); failed = false; hotkey(snap.hotkey); build(); return; }
|
|
101
114
|
failed = true;
|
|
115
|
+
// A cache-only snapshot may have marked rows as refreshing; nothing is refreshing any more.
|
|
116
|
+
if (snap) (snap.sections || []).forEach(function (s) {
|
|
117
|
+
s.rows.concat(s.more ? s.more.rows : []).forEach(function (r) {
|
|
118
|
+
if (!r.refreshing) return;
|
|
119
|
+
var says = snap.lang === 'zh' ? ${JSON.stringify(MENUBAR_STRINGS.zh.rowRefreshFailed)} : ${JSON.stringify(MENUBAR_STRINGS.en.rowRefreshFailed)};
|
|
120
|
+
r.refreshing = false; r.refreshFailed = true; r.reset = r.resetTime = says;
|
|
121
|
+
(r.groups || []).forEach(function (g) { g.reset = g.resetTime = says; });
|
|
122
|
+
});
|
|
123
|
+
});
|
|
102
124
|
build();
|
|
103
125
|
}
|
|
126
|
+
// During a manual refresh, a cache-only snapshot that never asks a Host: accounts already answered show their new
|
|
127
|
+
// numbers, the others say they are refreshing. At most one runs at a time.
|
|
128
|
+
function peek() {
|
|
129
|
+
if (task && !task.running) { finishSnapshot(); return; }
|
|
130
|
+
if (peekTask && !peekTask.running) {
|
|
131
|
+
var ok = peekTask.terminationStatus === 0;
|
|
132
|
+
peekTask = null;
|
|
133
|
+
closePeek();
|
|
134
|
+
var next = ok && task && manual ? readSnapshot(peekOut) : null;
|
|
135
|
+
if (next) { snap = next; build(); }
|
|
136
|
+
}
|
|
137
|
+
if (peekTask || !task || !manual || !refreshSince) return;
|
|
138
|
+
$.NSFileManager.defaultManager.createFileAtPathContentsAttributes(peekOut, $(), $());
|
|
139
|
+
var t = sideby(['menubar', 'snapshot', '--json', '--cached', '--refreshing-since', refreshSince, '--lang', lang]);
|
|
140
|
+
peekHandle = $.NSFileHandle.fileHandleForWritingAtPath(peekOut);
|
|
141
|
+
t.standardOutput = peekHandle;
|
|
142
|
+
if (t.launchAndReturnError(null)) peekTask = t;
|
|
143
|
+
else closePeek();
|
|
144
|
+
}
|
|
145
|
+
function closePeek() {
|
|
146
|
+
if (peekHandle) { peekHandle.closeFile; peekHandle = null; }
|
|
147
|
+
}
|
|
148
|
+
function stopPeek() {
|
|
149
|
+
if (peekTask && peekTask.running) peekTask.terminate;
|
|
150
|
+
peekTask = null;
|
|
151
|
+
closePeek();
|
|
152
|
+
}
|
|
104
153
|
|
|
105
154
|
// The shortcut that toggles the menu from anywhere (config menubar.hotkey), registered with Carbon's
|
|
106
155
|
// RegisterEventHotKey: it needs no permission, unlike watching every key press. macOS hands a press to this app as a
|
|
@@ -267,6 +316,15 @@ function run(argv) {
|
|
|
267
316
|
img.template = template;
|
|
268
317
|
return img;
|
|
269
318
|
}
|
|
319
|
+
// A base64 PNG at size×size points; null when macOS cannot read it.
|
|
320
|
+
function pngImage(b64, size) {
|
|
321
|
+
var data = $.NSData.alloc.initWithBase64EncodedStringOptions($(b64), 0);
|
|
322
|
+
if (!data || data.isNil()) return null;
|
|
323
|
+
var img = $.NSImage.alloc.initWithData(data);
|
|
324
|
+
if (!img || img.isNil() || !img.isValid) return null;
|
|
325
|
+
img.size = $.NSMakeSize(size, size);
|
|
326
|
+
return img;
|
|
327
|
+
}
|
|
270
328
|
function symbol(name) {
|
|
271
329
|
var img = $.NSImage.imageWithSystemSymbolNameAccessibilityDescription(name, name);
|
|
272
330
|
return img && !img.isNil() ? img : null;
|
|
@@ -319,6 +377,7 @@ function run(argv) {
|
|
|
319
377
|
return (bars[key] = $.NSAttributedString.attributedStringWithAttachment(att));
|
|
320
378
|
}
|
|
321
379
|
|
|
380
|
+
var keptW = { name: 0, reset: 0, tag: 0 };
|
|
322
381
|
// Columns: the name, then per window its bar and percent, then the reset time. One set of tab stops lines them up
|
|
323
382
|
// across every tool; the window names sit once in each tool's header, over their column. A tool with one window
|
|
324
383
|
// draws it in the second column, under the others' long window.
|
|
@@ -330,20 +389,31 @@ function run(argv) {
|
|
|
330
389
|
head: $.NSFont.systemFontOfSizeWeight(size - 2, $.NSFontWeightSemibold),
|
|
331
390
|
small: $.NSFont.systemFontOfSize(size - 2),
|
|
332
391
|
};
|
|
333
|
-
// The reset column names its window ("7d
|
|
334
|
-
|
|
392
|
+
// The reset column names its window ("7d", then "tomorrow 4:59 PM"), so it is as wide as its longest entry. While the
|
|
393
|
+
// menu is open it never gets narrower, so rows changing during a refresh do not make the menu jump.
|
|
394
|
+
// 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;
|
|
396
|
+
function measure(r) {
|
|
397
|
+
var c = resetCell(r);
|
|
398
|
+
if (c[0]) { tagW = Math.max(tagW, width(c[0], L.font)); timeW = Math.max(timeW, width(c[1], L.font)); }
|
|
399
|
+
else plainW = Math.max(plainW, width(c[1], L.font));
|
|
400
|
+
}
|
|
335
401
|
sections.forEach(function (s) {
|
|
336
402
|
nameW = Math.max(nameW, width(s.title, L.head));
|
|
337
403
|
if (s.columns[0]) first = true;
|
|
338
404
|
s.rows.concat(s.more ? s.more.rows : []).forEach(function (r) {
|
|
339
405
|
nameW = Math.max(nameW, width(r.label, L.font));
|
|
340
|
-
if (r.
|
|
406
|
+
if (r.bars) measure(r);
|
|
341
407
|
(r.groups || []).forEach(function (g) {
|
|
342
408
|
nameW = Math.max(nameW, width(GROUP_INDENT + g.label, L.font));
|
|
343
|
-
|
|
409
|
+
measure({ reset: g.reset, resetLabel: g.resetLabel, resetTime: g.resetTime, refreshing: r.refreshing, refreshFailed: r.refreshFailed, stale: r.stale, note: g.reset });
|
|
344
410
|
});
|
|
345
411
|
});
|
|
346
412
|
});
|
|
413
|
+
tagW = Math.ceil(tagW) + 8;
|
|
414
|
+
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 };
|
|
347
417
|
var pctW = width('100%', L.mono), x = Math.ceil(nameW) + 20, stops = [], at = [];
|
|
348
418
|
function tab(pos) { stops.push($.NSTextTab.alloc.initWithTextAlignmentLocationOptions($.NSTextAlignmentLeft, pos, $())); }
|
|
349
419
|
for (var c = 0; c < (first ? 2 : 1); c++) {
|
|
@@ -352,6 +422,7 @@ function run(argv) {
|
|
|
352
422
|
tab(x); x += pctW + 20;
|
|
353
423
|
}
|
|
354
424
|
tab(x);
|
|
425
|
+
tab(x + tagW);
|
|
355
426
|
L.reset = x;
|
|
356
427
|
L.first = first;
|
|
357
428
|
L.para = $.NSMutableParagraphStyle.alloc.init;
|
|
@@ -364,6 +435,14 @@ function run(argv) {
|
|
|
364
435
|
L.width = x + resetW + 70;
|
|
365
436
|
return L;
|
|
366
437
|
}
|
|
438
|
+
// The reset cell: [window tag, time]. The tag is drawn grey and the time in the text colour; a cell that says
|
|
439
|
+
// something else (refreshing, failed, an old reading, every window past its reset) has only grey words.
|
|
440
|
+
function resetCell(r) {
|
|
441
|
+
if (r.refreshing || r.refreshFailed) return ['', r.resetTime || r.reset || ''];
|
|
442
|
+
if (r.stale) return ['', r.note || ''];
|
|
443
|
+
if (r.resetLabel) return [r.resetLabel, r.resetTime];
|
|
444
|
+
return ['', r.reset || ''];
|
|
445
|
+
}
|
|
367
446
|
function rowTitle(r, L) {
|
|
368
447
|
var line = $.NSMutableAttributedString.alloc.init;
|
|
369
448
|
var plain = attrs(null, L.font, L.para), dim = attrs($.NSColor.secondaryLabelColor, L.font, L.para);
|
|
@@ -376,11 +455,16 @@ function run(argv) {
|
|
|
376
455
|
if (!i && !L.first) return;
|
|
377
456
|
if (!b) { line.appendAttributedString(str('\t\t', plain)); return; }
|
|
378
457
|
line.appendAttributedString(str('\t', plain));
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
458
|
+
// A window past its reset keeps its old bar in grey, with no percent: the reading no longer says how much is used.
|
|
459
|
+
line.appendAttributedString(bar(b, r.stale || b.passed));
|
|
460
|
+
var c = stale() || r.stale || b.passed ? color('stale') : b.level === 'ok' ? null : color(b.level);
|
|
461
|
+
line.appendAttributedString(str('\t' + (b.passed ? '–' : b.percent + '%'), attrs(c, L.mono, L.para)));
|
|
382
462
|
});
|
|
383
|
-
|
|
463
|
+
var cell = resetCell(r);
|
|
464
|
+
if (cell[0]) {
|
|
465
|
+
line.appendAttributedString(str('\t' + cell[0], dim));
|
|
466
|
+
line.appendAttributedString(str('\t' + cell[1], stale() ? dim : plain));
|
|
467
|
+
} else if (cell[1]) line.appendAttributedString(str('\t' + cell[1], dim));
|
|
384
468
|
return line;
|
|
385
469
|
}
|
|
386
470
|
function accountItem(menu, r, L) {
|
|
@@ -404,7 +488,7 @@ function run(argv) {
|
|
|
404
488
|
(r.groups || []).forEach(function (g) {
|
|
405
489
|
refs.push(r.ref);
|
|
406
490
|
var gi = add(menu, g.label, 'start:', refs.length);
|
|
407
|
-
gi.attributedTitle = rowTitle({ label: GROUP_INDENT + g.label, bars: g.bars, reset: g.reset, stale: r.stale, note: g.reset }, L);
|
|
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.stale, note: g.reset }, L);
|
|
408
492
|
gi.image = GUTTER;
|
|
409
493
|
gi.toolTip = g.tip;
|
|
410
494
|
});
|
|
@@ -418,7 +502,7 @@ function run(argv) {
|
|
|
418
502
|
line.appendAttributedString(str(s.title, attrs($.NSColor.labelColor, L.head, L.headPara)));
|
|
419
503
|
var cols = L.first ? s.columns : [s.columns[1]];
|
|
420
504
|
cols.forEach(function (c) { line.appendAttributedString(str('\t' + (c || ''), attrs($.NSColor.secondaryLabelColor, L.small, L.headPara))); });
|
|
421
|
-
if (s.rows.some(function (r) { return r.reset || (r.groups || []).some(function (g) { return g.reset; }); }))
|
|
505
|
+
if (s.rows.some(function (r) { return r.reset || r.refreshing || r.refreshFailed || (r.groups || []).some(function (g) { return g.reset; }); }))
|
|
422
506
|
line.appendAttributedString(str('\t' + snap.labels.resetsHeader, attrs($.NSColor.secondaryLabelColor, L.small, L.headPara)));
|
|
423
507
|
var W = Math.max(280, L.width), H = 24;
|
|
424
508
|
var v = $.NSView.alloc.initWithFrame($.NSMakeRect(0, 0, W, H));
|
|
@@ -441,7 +525,7 @@ function run(argv) {
|
|
|
441
525
|
var W = Math.max(280, L.width), H = 50;
|
|
442
526
|
var v = $.NSView.alloc.initWithFrame($.NSMakeRect(0, 0, W, H));
|
|
443
527
|
v.autoresizingMask = $.NSViewWidthSizable;
|
|
444
|
-
var icon =
|
|
528
|
+
var icon = pngImage(MARK_PNG, 30);
|
|
445
529
|
if (icon) {
|
|
446
530
|
var iv = $.NSImageView.imageViewWithImage(icon);
|
|
447
531
|
iv.frame = $.NSMakeRect(14, 10, 30, 30);
|
|
@@ -583,6 +667,7 @@ function run(argv) {
|
|
|
583
667
|
if (footer) footer.stringValue = footerText();
|
|
584
668
|
},
|
|
585
669
|
},
|
|
670
|
+
'peek:': { types: ['void', ['id']], implementation: function () { try { peek(); } catch (e) {} } },
|
|
586
671
|
'refresh:': {
|
|
587
672
|
types: ['void', ['id']],
|
|
588
673
|
implementation: function () {
|
|
@@ -638,6 +723,7 @@ function run(argv) {
|
|
|
638
723
|
startSnapshot();
|
|
639
724
|
// Common modes: the tick also runs while the menu is open, so a refresh started there lands in place.
|
|
640
725
|
$.NSRunLoop.mainRunLoop.addTimerForMode($.NSTimer.timerWithTimeIntervalTargetSelectorUserInfoRepeats(TICK, target, 'tick:', $(), true), $.NSRunLoopCommonModes);
|
|
726
|
+
$.NSRunLoop.mainRunLoop.addTimerForMode($.NSTimer.timerWithTimeIntervalTargetSelectorUserInfoRepeats(PEEK, target, 'peek:', $(), true), $.NSRunLoopCommonModes);
|
|
641
727
|
app.run;
|
|
642
728
|
}
|
|
643
729
|
`;
|
|
@@ -5,8 +5,12 @@ export type MenubarLevel = 'ok' | 'warn' | 'fail' | 'none';
|
|
|
5
5
|
/** One quota window drawn as a small bar. */
|
|
6
6
|
export interface MenubarBar {
|
|
7
7
|
label: string;
|
|
8
|
+
/** For a window past its reset: what it had used, drawn grey with `–` for the percent. */
|
|
8
9
|
percent: number;
|
|
10
|
+
/** `none` for a window past its reset. */
|
|
9
11
|
level: MenubarLevel;
|
|
12
|
+
/** The window's reset time has passed and no newer reading has come yet; it counts toward no level. */
|
|
13
|
+
passed?: true;
|
|
10
14
|
}
|
|
11
15
|
export interface MenubarRow {
|
|
12
16
|
ref: string;
|
|
@@ -31,17 +35,28 @@ export interface MenubarRow {
|
|
|
31
35
|
* A Host whose every limit covers one model group (Antigravity CLI): a line per group under the account, each with
|
|
32
36
|
* its own two bars, reset and hover text, while the account's own `bars` stay null. Null otherwise.
|
|
33
37
|
*/
|
|
34
|
-
groups: {
|
|
38
|
+
groups: ({
|
|
35
39
|
label: string;
|
|
36
40
|
bars: MenubarRow['bars'];
|
|
37
|
-
reset: string;
|
|
38
41
|
tip: string;
|
|
39
|
-
}[] | null;
|
|
42
|
+
} & Pick<MenubarRow, 'reset' | 'resetLabel' | 'resetTime'>)[] | null;
|
|
40
43
|
/**
|
|
41
|
-
* Which window resets and
|
|
42
|
-
*
|
|
44
|
+
* Which window resets and when, such as `7d · tomorrow 4:59 PM`: the window closest to its own red level (85% for 5
|
|
45
|
+
* hours, 95% for a week), so the one that runs out first. `resetLabel` and `resetTime` joined, for readers that do
|
|
46
|
+
* not draw. Empty when nothing is used.
|
|
43
47
|
*/
|
|
44
48
|
reset: string;
|
|
49
|
+
/** The window of `reset` as the column headers name it (`5h`, `7d`); empty when the cell names no window. */
|
|
50
|
+
resetLabel: string;
|
|
51
|
+
/**
|
|
52
|
+
* When it resets (`in 4h 20m`, `tomorrow 4:59 PM`, spec §3.31), or what the cell says instead: every window is past
|
|
53
|
+
* its reset, the row is refreshing, or its refresh failed.
|
|
54
|
+
*/
|
|
55
|
+
resetTime: string;
|
|
56
|
+
/** A manual refresh is asking the Host for this account and has no answer yet; the old bars stay. */
|
|
57
|
+
refreshing?: true;
|
|
58
|
+
/** This refresh asked the Host for this account and it failed; the old bars stay. */
|
|
59
|
+
refreshFailed?: true;
|
|
45
60
|
/** A no-quota explanation, or an old-reading warning beside the bars. */
|
|
46
61
|
note: string;
|
|
47
62
|
}
|
|
@@ -109,6 +124,11 @@ export interface MenubarFamilyInput {
|
|
|
109
124
|
quota: QuotaResult;
|
|
110
125
|
/** The other refs of its Same Login: the same subscription, so one quota. */
|
|
111
126
|
sameLogin?: readonly string[];
|
|
127
|
+
/**
|
|
128
|
+
* Where a manual refresh stands for this account (spec §3.31): `waiting` while it is asked and has not answered,
|
|
129
|
+
* `failed` when this refresh's answer failed. Left out for accounts the refresh does not ask.
|
|
130
|
+
*/
|
|
131
|
+
refresh?: 'waiting' | 'failed';
|
|
112
132
|
/**
|
|
113
133
|
* The newest use of its login on this computer (its own and its Same Login's sessions), when known. A reading
|
|
114
134
|
* older than an hour with no use since is not marked old (`quotaIsStale`).
|