@cortexkit/opencode-openai-auth 1.0.5 → 1.2.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/bin.js +9 -8
- package/dist/{pool-lifecycle-C_6YRmsh.d.ts → codex-request-CjXETpTA.d.ts} +190 -27
- package/dist/index-03em8hv1.js +69 -0
- package/dist/index-6n4pnfkg.js +2 -0
- package/dist/{index-pg305s90.js → index-bc89akak.js} +1 -1
- package/dist/{index-y4gxyxqd.js → index-ehjj89rx.js} +2 -2
- package/dist/index-f21addzm.js +90 -0
- package/dist/{index-fsky1rsh.js → index-ffg0sgg5.js} +2 -2
- package/dist/{index-nx2qh047.js → index-ftkhhr6d.js} +1 -1
- package/dist/{index-826s1yxa.js → index-htvcmtcx.js} +2 -2
- package/dist/{index-fsxbncpw.js → index-qp5hdpw8.js} +1 -1
- package/dist/index-qxbchh2d.js +8 -0
- package/dist/{index-116q849r.js → index-r2s51ac1.js} +2 -2
- package/dist/index-rwbrhkse.js +65 -0
- package/dist/{index-66asrje2.js → index-xwvze96g.js} +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.js +1 -1
- package/dist/{protocol-DctqemRI.d.ts → model-CQcw10oW.d.ts} +67 -25
- package/dist/{port-file-ZPlxXB4G.d.ts → port-file-BDJnzgHH.d.ts} +1 -1
- package/dist/protocol-C-kagE6O.d.ts +29 -0
- package/dist/rpc/port-file.d.ts +1 -1
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.d.ts +3 -3
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/{sidebar-state-z_M7Trnd.d.ts → sidebar-state-BfQ4mpZO.d.ts} +109 -10
- package/dist/sidebar-state.d.ts +2 -2
- package/dist/sidebar-state.js +1 -1
- package/dist/token-util-cf0nyh7n.js +1 -0
- package/dist/{token-bzhkgc29.js → token-z6qq7a1d.js} +1 -1
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +20 -2
- package/dist/v2/server.d.ts +180 -1
- package/dist/v2/server.js +3 -3
- package/package.json +3 -3
- package/src/tui-compiled/raw/shared/0332701351b3eeec-format.js +148 -26
- package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +371 -0
- package/src/tui-compiled/raw/shared/134b008900698fe0-backoff.js +92 -0
- package/src/tui-compiled/raw/shared/169b2b4bf30909bc-consumer.js +430 -0
- package/src/tui-compiled/raw/shared/2577ec69f9973ae9-quota-normalize.js +154 -0
- package/src/tui-compiled/raw/shared/2dce6e9613993329-quota-manager.js +473 -0
- package/src/tui-compiled/raw/shared/30f5bc480f31f51c-roster.js +566 -0
- package/src/tui-compiled/raw/shared/43fc9e6b994519c7-refresh-lock.js +0 -1
- package/src/tui-compiled/raw/shared/4593a4d71edf69fd-tombstone.js +25 -0
- package/src/tui-compiled/raw/shared/4d05c2d7a531aece-oauth.js +500 -0
- package/src/tui-compiled/raw/shared/6371b24a0573d79e-any-signal.js +42 -0
- package/src/tui-compiled/raw/shared/7c140680fc81be92-interlock.js +29 -0
- package/src/tui-compiled/raw/shared/85512cc5263ba259-provider.js +87 -0
- package/src/tui-compiled/raw/shared/abd062d633e29fd2-pool-routing.js +192 -0
- package/src/tui-compiled/raw/shared/b9588ad4725c1d10-enrollment.js +806 -0
- package/src/tui-compiled/raw/shared/bfbdd0f9aae56b47-pool-quota.js +85 -0
- package/src/tui-compiled/raw/shared/c852a15cfe489d12-pool.js +0 -1
- package/src/tui-compiled/raw/shared/ca0fccaba1d87af4-errors.js +8 -0
- package/src/tui-compiled/raw/shared/d0f0b6be200311af-insula.js +152 -0
- package/src/tui-compiled/raw/shared/d5a8f1061ee2f114-index.js +1 -1
- package/src/tui-compiled/raw/shared/d9d2892a4c371301-host-slot.js +72 -0
- package/src/tui-compiled/raw/shared/dbc61cd405941828-accounts.js +1470 -0
- package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +26 -12
- package/src/tui-compiled/raw/shared/e8d3c8da776ef9cd-index.js +24 -0
- package/src/tui-compiled/raw/sidebar-state.js +103 -14
- package/src/tui-compiled/raw/tui/command-dialogs.tsx +3 -34
- package/src/tui-compiled/raw/tui/section-text.js +21 -0
- package/src/tui-compiled/raw/tui/v2-dialog.js +137 -0
- package/src/tui-compiled/raw/tui/v2.tsx +133 -0
- package/src/tui-compiled/raw/tui.tsx +228 -70
- package/src/tui-compiled/runtime/shared/0332701351b3eeec-format.js +148 -26
- package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +371 -0
- package/src/tui-compiled/runtime/shared/134b008900698fe0-backoff.js +92 -0
- package/src/tui-compiled/runtime/shared/169b2b4bf30909bc-consumer.js +430 -0
- package/src/tui-compiled/runtime/shared/2577ec69f9973ae9-quota-normalize.js +154 -0
- package/src/tui-compiled/runtime/shared/2dce6e9613993329-quota-manager.js +473 -0
- package/src/tui-compiled/runtime/shared/30f5bc480f31f51c-roster.js +566 -0
- package/src/tui-compiled/runtime/shared/43fc9e6b994519c7-refresh-lock.js +0 -1
- package/src/tui-compiled/runtime/shared/4593a4d71edf69fd-tombstone.js +25 -0
- package/src/tui-compiled/runtime/shared/4d05c2d7a531aece-oauth.js +500 -0
- package/src/tui-compiled/runtime/shared/6371b24a0573d79e-any-signal.js +42 -0
- package/src/tui-compiled/runtime/shared/7c140680fc81be92-interlock.js +29 -0
- package/src/tui-compiled/runtime/shared/85512cc5263ba259-provider.js +87 -0
- package/src/tui-compiled/runtime/shared/abd062d633e29fd2-pool-routing.js +192 -0
- package/src/tui-compiled/runtime/shared/b9588ad4725c1d10-enrollment.js +806 -0
- package/src/tui-compiled/runtime/shared/bfbdd0f9aae56b47-pool-quota.js +85 -0
- package/src/tui-compiled/runtime/shared/c852a15cfe489d12-pool.js +0 -1
- package/src/tui-compiled/runtime/shared/ca0fccaba1d87af4-errors.js +8 -0
- package/src/tui-compiled/runtime/shared/d0f0b6be200311af-insula.js +152 -0
- package/src/tui-compiled/runtime/shared/d5a8f1061ee2f114-index.js +1 -1
- package/src/tui-compiled/runtime/shared/d9d2892a4c371301-host-slot.js +72 -0
- package/src/tui-compiled/runtime/shared/dbc61cd405941828-accounts.js +1470 -0
- package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +26 -12
- package/src/tui-compiled/runtime/shared/e8d3c8da776ef9cd-index.js +24 -0
- package/src/tui-compiled/runtime/sidebar-state.js +103 -14
- package/src/tui-compiled/runtime/tui/command-dialogs.js +3 -15
- package/src/tui-compiled/runtime/tui/section-text.js +21 -0
- package/src/tui-compiled/runtime/tui/v2-dialog.js +137 -0
- package/src/tui-compiled/runtime/tui/v2.js +95 -0
- package/src/tui-compiled/runtime/tui.js +351 -222
- package/dist/index-4fnghj9e.js +0 -65
- package/dist/index-a69gr76b.js +0 -2
- package/dist/index-h263aftt.js +0 -157
- package/dist/index-ssj7m2rd.js +0 -8
- package/dist/index-ydz3hbhc.js +0 -2
- package/dist/map-m6f5a_IA.d.ts +0 -56
- package/dist/token-util-4a2xxnpg.js +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
1
|
import { createTextNode as _$createTextNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
2
|
+
import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
3
3
|
import { createComponent as _$createComponent } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
4
|
+
import { use as _$use } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
4
5
|
import { effect as _$effect } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
5
6
|
import { insertNode as _$insertNode } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
6
7
|
import { insert as _$insert } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
@@ -11,14 +12,15 @@ import { createElement as _$createElement } from "opentui:runtime-module:%40open
|
|
|
11
12
|
import { readFileSync } from "node:fs";
|
|
12
13
|
import { dirname, join } from "node:path";
|
|
13
14
|
import { fileURLToPath } from "node:url";
|
|
14
|
-
import { formatQuota, quotaTextParts } from "./shared/d5a8f1061ee2f114-index.js";
|
|
15
|
-
import { createEffect, createSignal, For, onCleanup, Show } from "opentui:runtime-module:solid-js";
|
|
15
|
+
import { formatQuota, quotaTextParts, quotaWindowParts } from "./shared/d5a8f1061ee2f114-index.js";
|
|
16
|
+
import { createEffect, createSignal, For, Index, onCleanup, Show } from "opentui:runtime-module:solid-js";
|
|
16
17
|
import { createLogger } from "./logger.js";
|
|
17
18
|
import { isNotifyPayload } from "./rpc/protocol.js";
|
|
18
19
|
import { createRpcClient } from "./rpc/rpc-client.js";
|
|
19
20
|
import { resolveRpcDir } from "./rpc/rpc-dir.js";
|
|
20
|
-
import { computeQuotaPacing, DEFAULT_SIDEBAR_STATE, getCollapsedQuotaSummary, getPresentQuotaWindows, getSidebarState, resolveActiveAccount, resolveSessionSidebarRouting, resolveSessionStickyAccount, sidebarQuotaProjection } from "./sidebar-state.js";
|
|
21
|
+
import { computeQuotaPacing, DEFAULT_SIDEBAR_STATE, displayWidth, fitCollapsedLabel, getCollapsedAccountLines, getCollapsedQuotaSummary, getPresentQuotaWindows, getSidebarState, resolveActiveAccount, resolveSessionSidebarRouting, resolveSessionStickyAccount, sidebarQuotaProjection } from "./sidebar-state.js";
|
|
21
22
|
import { openCommandDialog } from "./tui/command-dialogs.js";
|
|
23
|
+
import { setupTui } from "./tui/v2.js";
|
|
22
24
|
import { computeEffectiveOrder, DEFAULT_SLOT_ORDER, PLUGIN_KEY, queueTuiPreferenceUpdate, readTuiPreferencesFile, resolveOpenaiAuthPrefs, watchTuiPreferences } from "./tui-preferences.js";
|
|
23
25
|
const RPC_POLL_MS = 500;
|
|
24
26
|
let rpcPollStarted = false;
|
|
@@ -202,19 +204,82 @@ function StatRow(props) {
|
|
|
202
204
|
})();
|
|
203
205
|
}
|
|
204
206
|
|
|
205
|
-
//
|
|
206
|
-
// right.
|
|
207
|
-
|
|
207
|
+
// One account in the collapsed view: label left; narrow quota text and the
|
|
208
|
+
// status dot right (red ⊘ when killed). The session's account keeps the
|
|
209
|
+
// usage tone; other accounts, and any account whose reading is stale, are
|
|
210
|
+
// drawn muted. The row measures its own width so only the label is cut (with
|
|
211
|
+
// …) when the line does not fit; the quota text is never cut.
|
|
212
|
+
function CollapsedAccountRow(props) {
|
|
213
|
+
const [width, setWidth] = createSignal(0);
|
|
214
|
+
let row;
|
|
215
|
+
const dim = () => props.line.stale || !props.line.active;
|
|
216
|
+
const label = () => {
|
|
217
|
+
const columns = width();
|
|
218
|
+
if (columns <= 0) return props.line.name;
|
|
219
|
+
// The value side is the text plus ` ●`, or a lone `—`; one column
|
|
220
|
+
// separates it from the label.
|
|
221
|
+
const value = props.line.text === null ? 1 : displayWidth(props.line.text) + 2;
|
|
222
|
+
return fitCollapsedLabel(props.line.name, columns - value - 1);
|
|
223
|
+
};
|
|
208
224
|
return (() => {
|
|
209
225
|
var _el$8 = _$createElement("box"),
|
|
210
226
|
_el$9 = _$createElement("text");
|
|
211
227
|
_$insertNode(_el$8, _el$9);
|
|
228
|
+
_$use(element => {
|
|
229
|
+
row = element;
|
|
230
|
+
}, _el$8);
|
|
231
|
+
_$setProp(_el$8, "onSizeChange", () => setWidth(row?.width ?? 0));
|
|
212
232
|
_$setProp(_el$8, "width", '100%');
|
|
213
233
|
_$setProp(_el$8, "flexDirection", 'row');
|
|
214
234
|
_$setProp(_el$8, "justifyContent", 'space-between');
|
|
215
|
-
_$
|
|
216
|
-
_$
|
|
217
|
-
_$
|
|
235
|
+
_$setProp(_el$9, "wrapMode", 'none');
|
|
236
|
+
_$setProp(_el$9, "flexShrink", 1);
|
|
237
|
+
_$insert(_el$9, label);
|
|
238
|
+
_$insert(_el$8, _$createComponent(Show, {
|
|
239
|
+
get when() {
|
|
240
|
+
return props.line.text !== null;
|
|
241
|
+
},
|
|
242
|
+
get fallback() {
|
|
243
|
+
return (() => {
|
|
244
|
+
var _el$12 = _$createElement("text");
|
|
245
|
+
_$insertNode(_el$12, _$createTextNode(`—`));
|
|
246
|
+
_$effect(_$p => _$setProp(_el$12, "fg", props.theme.textMuted, _$p));
|
|
247
|
+
return _el$12;
|
|
248
|
+
})();
|
|
249
|
+
},
|
|
250
|
+
get children() {
|
|
251
|
+
var _el$0 = _$createElement("box"),
|
|
252
|
+
_el$11 = _$createElement("text");
|
|
253
|
+
_$insertNode(_el$0, _el$11);
|
|
254
|
+
_$setProp(_el$0, "flexDirection", 'row');
|
|
255
|
+
_$setProp(_el$0, "flexShrink", 0);
|
|
256
|
+
_$insert(_el$0, _$createComponent(Show, {
|
|
257
|
+
get when() {
|
|
258
|
+
return !dim();
|
|
259
|
+
},
|
|
260
|
+
get fallback() {
|
|
261
|
+
return (() => {
|
|
262
|
+
var _el$14 = _$createElement("text");
|
|
263
|
+
_$insert(_el$14, () => props.line.text);
|
|
264
|
+
_$effect(_$p => _$setProp(_el$14, "fg", toneColor(props.theme, 'muted'), _$p));
|
|
265
|
+
return _el$14;
|
|
266
|
+
})();
|
|
267
|
+
},
|
|
268
|
+
get children() {
|
|
269
|
+
var _el$1 = _$createElement("text"),
|
|
270
|
+
_el$10 = _$createElement("b");
|
|
271
|
+
_$insertNode(_el$1, _el$10);
|
|
272
|
+
_$insert(_el$10, () => props.line.text);
|
|
273
|
+
_$effect(_$p => _$setProp(_el$1, "fg", toneColor(props.theme, props.tone), _$p));
|
|
274
|
+
return _el$1;
|
|
275
|
+
}
|
|
276
|
+
}), _el$11);
|
|
277
|
+
_$insert(_el$11, () => props.line.killed ? ' \u2298' : ' \u25cf');
|
|
278
|
+
_$effect(_$p => _$setProp(_el$11, "fg", toneColor(props.theme, props.line.killed ? 'err' : dim() ? 'muted' : props.tone), _$p));
|
|
279
|
+
return _el$0;
|
|
280
|
+
}
|
|
281
|
+
}), null);
|
|
282
|
+
_$effect(_$p => _$setProp(_el$9, "fg", toneColor(props.theme, dim() ? 'muted' : 'text'), _$p));
|
|
218
283
|
return _el$8;
|
|
219
284
|
})();
|
|
220
285
|
}
|
|
@@ -244,7 +309,7 @@ function quotaRowLabels(quota) {
|
|
|
244
309
|
*/
|
|
245
310
|
export function renderedQuotas(state) {
|
|
246
311
|
// In vault mode only the vault accounts are rendered.
|
|
247
|
-
if (state.vaultAccounts !== undefined) return state.vaultAccounts.
|
|
312
|
+
if (state.vaultAccounts !== undefined) return state.vaultAccounts.map(account => account.quota);
|
|
248
313
|
return [state.main?.quota ?? null, ...(state.fallbacks ?? []).filter(fallback => fallback.enabled).map(fallback => fallback.quota)];
|
|
249
314
|
}
|
|
250
315
|
export function computeQuotaLabelWidth(quotas) {
|
|
@@ -263,34 +328,48 @@ export function computeQuotaLabelWidth(quotas) {
|
|
|
263
328
|
// that only inspect pacing may omit it and get this row set's own width.
|
|
264
329
|
export function buildQuotaRowsForDisplay(quota, now, pacingEnabled, labelWidth) {
|
|
265
330
|
const projection = sidebarQuotaProjection(quota, now);
|
|
266
|
-
const rows = getPresentQuotaWindows(quota).map(row =>
|
|
267
|
-
|
|
268
|
-
label: row.label,
|
|
269
|
-
window: row.window,
|
|
270
|
-
text: formatQuota(projection && {
|
|
331
|
+
const rows = getPresentQuotaWindows(quota).map(row => {
|
|
332
|
+
const rowProjection = projection && {
|
|
271
333
|
...projection,
|
|
272
334
|
budget: undefined,
|
|
273
335
|
limits: projection.limits.filter(limit => limit.label === row.key)
|
|
274
|
-
}
|
|
336
|
+
};
|
|
337
|
+
const reset = quotaWindowParts(rowProjection, {
|
|
275
338
|
now,
|
|
276
|
-
form: 'compact',
|
|
277
339
|
staleAfterMs: Number.POSITIVE_INFINITY
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
|
|
340
|
+
}).windows[0];
|
|
341
|
+
return {
|
|
342
|
+
key: row.key,
|
|
343
|
+
label: row.label,
|
|
344
|
+
window: row.window,
|
|
345
|
+
text: formatQuota(rowProjection, {
|
|
346
|
+
now,
|
|
347
|
+
form: 'compact',
|
|
348
|
+
staleAfterMs: Number.POSITIVE_INFINITY
|
|
349
|
+
}),
|
|
350
|
+
resetText: reset?.resetIn ?? (reset?.resetSinceReading ? 'reset' : undefined),
|
|
351
|
+
pacing: pacingEnabled && row.windowMs !== null ? computeQuotaPacing(row.window, row.windowMs, now) : null
|
|
352
|
+
};
|
|
353
|
+
});
|
|
281
354
|
const spendControl = quota?.spendControl;
|
|
282
355
|
if (spendControl) {
|
|
356
|
+
const rowProjection = projection && {
|
|
357
|
+
...projection,
|
|
358
|
+
limits: []
|
|
359
|
+
};
|
|
360
|
+
const reset = quotaWindowParts(rowProjection, {
|
|
361
|
+
now,
|
|
362
|
+
staleAfterMs: Number.POSITIVE_INFINITY
|
|
363
|
+
}).windows[0];
|
|
283
364
|
rows.push({
|
|
284
365
|
key: 'spendControl',
|
|
285
366
|
label: SPEND_CONTROL_LABEL,
|
|
286
|
-
text: formatQuota(
|
|
287
|
-
...projection,
|
|
288
|
-
limits: []
|
|
289
|
-
}, {
|
|
367
|
+
text: formatQuota(rowProjection, {
|
|
290
368
|
now,
|
|
291
369
|
form: 'compact',
|
|
292
370
|
staleAfterMs: Number.POSITIVE_INFINITY
|
|
293
371
|
}),
|
|
372
|
+
resetText: reset?.resetIn ?? (reset?.resetSinceReading ? 'reset' : undefined),
|
|
294
373
|
window: {
|
|
295
374
|
usedPercent: spendControl.usedPercent,
|
|
296
375
|
remainingPercent: spendControl.remainingPercent,
|
|
@@ -378,90 +457,101 @@ function QuotaRow(props) {
|
|
|
378
457
|
},
|
|
379
458
|
get fallback() {
|
|
380
459
|
return (() => {
|
|
381
|
-
var _el$
|
|
382
|
-
_el$
|
|
383
|
-
_el$
|
|
384
|
-
_$insertNode(_el$
|
|
385
|
-
_$insertNode(_el$
|
|
386
|
-
_$setProp(_el$
|
|
387
|
-
_$setProp(_el$
|
|
388
|
-
_$insert(_el$
|
|
389
|
-
_$insertNode(_el$
|
|
460
|
+
var _el$23 = _$createElement("box"),
|
|
461
|
+
_el$24 = _$createElement("text"),
|
|
462
|
+
_el$25 = _$createElement("text");
|
|
463
|
+
_$insertNode(_el$23, _el$24);
|
|
464
|
+
_$insertNode(_el$23, _el$25);
|
|
465
|
+
_$setProp(_el$23, "width", '100%');
|
|
466
|
+
_$setProp(_el$23, "flexDirection", 'row');
|
|
467
|
+
_$insert(_el$24, () => props.label.padEnd(props.labelWidth));
|
|
468
|
+
_$insertNode(_el$25, _$createTextNode(`—`));
|
|
390
469
|
_$effect(_p$ => {
|
|
391
470
|
var _v$9 = props.theme.textMuted,
|
|
392
471
|
_v$0 = props.theme.textMuted;
|
|
393
|
-
_v$9 !== _p$.e && (_p$.e = _$setProp(_el$
|
|
394
|
-
_v$0 !== _p$.t && (_p$.t = _$setProp(_el$
|
|
472
|
+
_v$9 !== _p$.e && (_p$.e = _$setProp(_el$24, "fg", _v$9, _p$.e));
|
|
473
|
+
_v$0 !== _p$.t && (_p$.t = _$setProp(_el$25, "fg", _v$0, _p$.t));
|
|
395
474
|
return _p$;
|
|
396
475
|
}, {
|
|
397
476
|
e: undefined,
|
|
398
477
|
t: undefined
|
|
399
478
|
});
|
|
400
|
-
return _el$
|
|
479
|
+
return _el$23;
|
|
401
480
|
})();
|
|
402
481
|
},
|
|
403
482
|
get children() {
|
|
404
483
|
return [(() => {
|
|
405
|
-
var _el$
|
|
406
|
-
_el$
|
|
407
|
-
_el$
|
|
408
|
-
_el$
|
|
409
|
-
_$insertNode(_el$
|
|
410
|
-
_$setProp(_el$
|
|
411
|
-
_$setProp(_el$
|
|
412
|
-
_$setProp(_el$
|
|
413
|
-
_$insertNode(_el$
|
|
414
|
-
_$insertNode(_el$
|
|
415
|
-
_$setProp(_el$
|
|
416
|
-
_$insert(_el$
|
|
417
|
-
_$insert(_el$
|
|
484
|
+
var _el$15 = _$createElement("box"),
|
|
485
|
+
_el$16 = _$createElement("box"),
|
|
486
|
+
_el$17 = _$createElement("text"),
|
|
487
|
+
_el$18 = _$createElement("text");
|
|
488
|
+
_$insertNode(_el$15, _el$16);
|
|
489
|
+
_$setProp(_el$15, "width", '100%');
|
|
490
|
+
_$setProp(_el$15, "flexDirection", 'row');
|
|
491
|
+
_$setProp(_el$15, "justifyContent", 'space-between');
|
|
492
|
+
_$insertNode(_el$16, _el$17);
|
|
493
|
+
_$insertNode(_el$16, _el$18);
|
|
494
|
+
_$setProp(_el$16, "flexDirection", 'row');
|
|
495
|
+
_$insert(_el$17, () => props.label.padEnd(props.labelWidth));
|
|
496
|
+
_$insert(_el$16, _$createComponent(For, {
|
|
418
497
|
get each() {
|
|
419
498
|
return quotaBarSegments(used(), props.appearance, props.pacing);
|
|
420
499
|
},
|
|
421
500
|
children: segment => (() => {
|
|
501
|
+
var _el$27 = _$createElement("text");
|
|
502
|
+
_$insert(_el$27, () => segment.text);
|
|
503
|
+
_$effect(_$p => _$setProp(_el$27, "fg", toneColor(props.theme, segment.tone), _$p));
|
|
504
|
+
return _el$27;
|
|
505
|
+
})()
|
|
506
|
+
}), _el$18);
|
|
507
|
+
_$insert(_el$18, () => ` ${props.text.slice(props.label.length + 1)}`);
|
|
508
|
+
_$insert(_el$15, _$createComponent(Show, {
|
|
509
|
+
get when() {
|
|
510
|
+
return props.resetText;
|
|
511
|
+
},
|
|
512
|
+
get children() {
|
|
422
513
|
var _el$19 = _$createElement("text");
|
|
423
|
-
_$insert(_el$19, () =>
|
|
424
|
-
_$effect(_$p => _$setProp(_el$19, "fg",
|
|
514
|
+
_$insert(_el$19, () => props.resetText);
|
|
515
|
+
_$effect(_$p => _$setProp(_el$19, "fg", props.theme.textMuted, _$p));
|
|
425
516
|
return _el$19;
|
|
426
|
-
}
|
|
427
|
-
}),
|
|
428
|
-
_$insert(_el$11, () => ` ${props.text.slice(props.label.length + 1)}`);
|
|
517
|
+
}
|
|
518
|
+
}), null);
|
|
429
519
|
_$effect(_p$ => {
|
|
430
520
|
var _v$5 = props.theme.textMuted,
|
|
431
521
|
_v$6 = toneColor(props.theme, usageTone(used(), props.appearance));
|
|
432
|
-
_v$5 !== _p$.e && (_p$.e = _$setProp(_el$
|
|
433
|
-
_v$6 !== _p$.t && (_p$.t = _$setProp(_el$
|
|
522
|
+
_v$5 !== _p$.e && (_p$.e = _$setProp(_el$17, "fg", _v$5, _p$.e));
|
|
523
|
+
_v$6 !== _p$.t && (_p$.t = _$setProp(_el$18, "fg", _v$6, _p$.t));
|
|
434
524
|
return _p$;
|
|
435
525
|
}, {
|
|
436
526
|
e: undefined,
|
|
437
527
|
t: undefined
|
|
438
528
|
});
|
|
439
|
-
return _el$
|
|
529
|
+
return _el$15;
|
|
440
530
|
})(), _$createComponent(Show, {
|
|
441
531
|
get when() {
|
|
442
532
|
return paceLine();
|
|
443
533
|
},
|
|
444
534
|
get children() {
|
|
445
|
-
var _el$
|
|
446
|
-
_el$
|
|
447
|
-
_el$
|
|
448
|
-
_$insertNode(_el$
|
|
449
|
-
_$insertNode(_el$
|
|
450
|
-
_$setProp(_el$
|
|
451
|
-
_$setProp(_el$
|
|
452
|
-
_$insert(_el$
|
|
453
|
-
_$insert(_el$
|
|
535
|
+
var _el$20 = _$createElement("box"),
|
|
536
|
+
_el$21 = _$createElement("text"),
|
|
537
|
+
_el$22 = _$createElement("text");
|
|
538
|
+
_$insertNode(_el$20, _el$21);
|
|
539
|
+
_$insertNode(_el$20, _el$22);
|
|
540
|
+
_$setProp(_el$20, "width", '100%');
|
|
541
|
+
_$setProp(_el$20, "flexDirection", 'row');
|
|
542
|
+
_$insert(_el$21, () => ''.padEnd(props.labelWidth));
|
|
543
|
+
_$insert(_el$22, paceLine);
|
|
454
544
|
_$effect(_p$ => {
|
|
455
545
|
var _v$7 = props.theme.textMuted,
|
|
456
546
|
_v$8 = toneColor(props.theme, props.pacing?.state === 'deficit' ? 'warn' : 'muted');
|
|
457
|
-
_v$7 !== _p$.e && (_p$.e = _$setProp(_el$
|
|
458
|
-
_v$8 !== _p$.t && (_p$.t = _$setProp(_el$
|
|
547
|
+
_v$7 !== _p$.e && (_p$.e = _$setProp(_el$21, "fg", _v$7, _p$.e));
|
|
548
|
+
_v$8 !== _p$.t && (_p$.t = _$setProp(_el$22, "fg", _v$8, _p$.t));
|
|
459
549
|
return _p$;
|
|
460
550
|
}, {
|
|
461
551
|
e: undefined,
|
|
462
552
|
t: undefined
|
|
463
553
|
});
|
|
464
|
-
return _el$
|
|
554
|
+
return _el$20;
|
|
465
555
|
}
|
|
466
556
|
})];
|
|
467
557
|
}
|
|
@@ -476,34 +566,56 @@ function AccountBlock(props) {
|
|
|
476
566
|
const statusTone = () => props.killed ? 'err' : props.active ? 'ok' : 'muted';
|
|
477
567
|
const rows = () => buildQuotaRowsForDisplay(props.quota, Date.now(), props.pacingEnabled, props.labelWidth);
|
|
478
568
|
return (() => {
|
|
479
|
-
var _el$
|
|
480
|
-
_el$
|
|
481
|
-
_el$
|
|
482
|
-
_el$
|
|
483
|
-
_el$
|
|
484
|
-
_el$
|
|
485
|
-
_$insertNode(_el$
|
|
486
|
-
_$setProp(_el$
|
|
487
|
-
_$setProp(_el$
|
|
488
|
-
_$insertNode(_el$
|
|
489
|
-
_$insertNode(_el$
|
|
490
|
-
_$setProp(_el$
|
|
491
|
-
_$setProp(_el$
|
|
492
|
-
_$setProp(_el$
|
|
493
|
-
_$insertNode(_el$
|
|
494
|
-
_$insert(_el$
|
|
495
|
-
_$insertNode(_el$
|
|
496
|
-
_$insert(_el$
|
|
497
|
-
_$insert(_el$
|
|
569
|
+
var _el$28 = _$createElement("box"),
|
|
570
|
+
_el$29 = _$createElement("box"),
|
|
571
|
+
_el$30 = _$createElement("text"),
|
|
572
|
+
_el$31 = _$createElement("b"),
|
|
573
|
+
_el$32 = _$createElement("text"),
|
|
574
|
+
_el$33 = _$createElement("b");
|
|
575
|
+
_$insertNode(_el$28, _el$29);
|
|
576
|
+
_$setProp(_el$28, "width", '100%');
|
|
577
|
+
_$setProp(_el$28, "flexDirection", 'column');
|
|
578
|
+
_$insertNode(_el$29, _el$30);
|
|
579
|
+
_$insertNode(_el$29, _el$32);
|
|
580
|
+
_$setProp(_el$29, "width", '100%');
|
|
581
|
+
_$setProp(_el$29, "flexDirection", 'row');
|
|
582
|
+
_$setProp(_el$29, "justifyContent", 'space-between');
|
|
583
|
+
_$insertNode(_el$30, _el$31);
|
|
584
|
+
_$insert(_el$31, () => props.name);
|
|
585
|
+
_$insertNode(_el$32, _el$33);
|
|
586
|
+
_$insert(_el$33, statusWord);
|
|
587
|
+
_$insert(_el$28, _$createComponent(Show, {
|
|
588
|
+
get when() {
|
|
589
|
+
return props.vaultState;
|
|
590
|
+
},
|
|
591
|
+
get children() {
|
|
592
|
+
var _el$34 = _$createElement("text");
|
|
593
|
+
_$insert(_el$34, () => props.vaultState);
|
|
594
|
+
_$effect(_$p => _$setProp(_el$34, "fg", props.theme.warning, _$p));
|
|
595
|
+
return _el$34;
|
|
596
|
+
}
|
|
597
|
+
}), null);
|
|
598
|
+
_$insert(_el$28, _$createComponent(Show, {
|
|
599
|
+
get when() {
|
|
600
|
+
return props.hostDisabled;
|
|
601
|
+
},
|
|
602
|
+
get children() {
|
|
603
|
+
var _el$35 = _$createElement("text");
|
|
604
|
+
_$insertNode(_el$35, _$createTextNode(`off in /openai`));
|
|
605
|
+
_$effect(_$p => _$setProp(_el$35, "fg", props.theme.textMuted, _$p));
|
|
606
|
+
return _el$35;
|
|
607
|
+
}
|
|
608
|
+
}), null);
|
|
609
|
+
_$insert(_el$28, _$createComponent(Show, {
|
|
498
610
|
get when() {
|
|
499
611
|
return isQuotaLoaded(props.quota);
|
|
500
612
|
},
|
|
501
613
|
get fallback() {
|
|
502
614
|
return (() => {
|
|
503
|
-
var _el$
|
|
504
|
-
_$insertNode(_el$
|
|
505
|
-
_$effect(_$p => _$setProp(_el$
|
|
506
|
-
return _el$
|
|
615
|
+
var _el$37 = _$createElement("text");
|
|
616
|
+
_$insertNode(_el$37, _$createTextNode(`checking…`));
|
|
617
|
+
_$effect(_$p => _$setProp(_el$37, "fg", props.theme.textMuted, _$p));
|
|
618
|
+
return _el$37;
|
|
507
619
|
})();
|
|
508
620
|
},
|
|
509
621
|
get children() {
|
|
@@ -513,10 +625,10 @@ function AccountBlock(props) {
|
|
|
513
625
|
},
|
|
514
626
|
get fallback() {
|
|
515
627
|
return (() => {
|
|
516
|
-
var _el$
|
|
517
|
-
_$insertNode(_el$
|
|
518
|
-
_$effect(_$p => _$setProp(_el$
|
|
519
|
-
return _el$
|
|
628
|
+
var _el$39 = _$createElement("text");
|
|
629
|
+
_$insertNode(_el$39, _$createTextNode(`—`));
|
|
630
|
+
_$effect(_$p => _$setProp(_el$39, "fg", props.theme.textMuted, _$p));
|
|
631
|
+
return _el$39;
|
|
520
632
|
})();
|
|
521
633
|
},
|
|
522
634
|
get children() {
|
|
@@ -540,6 +652,9 @@ function AccountBlock(props) {
|
|
|
540
652
|
get text() {
|
|
541
653
|
return row.text;
|
|
542
654
|
},
|
|
655
|
+
get resetText() {
|
|
656
|
+
return row.resetText;
|
|
657
|
+
},
|
|
543
658
|
get window() {
|
|
544
659
|
return row.window;
|
|
545
660
|
},
|
|
@@ -552,7 +667,7 @@ function AccountBlock(props) {
|
|
|
552
667
|
});
|
|
553
668
|
}
|
|
554
669
|
}), null);
|
|
555
|
-
_$insert(_el$
|
|
670
|
+
_$insert(_el$28, _$createComponent(For, {
|
|
556
671
|
get each() {
|
|
557
672
|
return quotaTextParts(sidebarQuotaProjection(props.quota, Date.now()), {
|
|
558
673
|
now: Date.now(),
|
|
@@ -560,13 +675,13 @@ function AccountBlock(props) {
|
|
|
560
675
|
}).filter(part => part.startsWith('checked '));
|
|
561
676
|
},
|
|
562
677
|
children: age => (() => {
|
|
563
|
-
var _el$
|
|
564
|
-
_$insert(_el$
|
|
565
|
-
_$effect(_$p => _$setProp(_el$
|
|
566
|
-
return _el$
|
|
678
|
+
var _el$41 = _$createElement("text");
|
|
679
|
+
_$insert(_el$41, age);
|
|
680
|
+
_$effect(_$p => _$setProp(_el$41, "fg", props.theme.textMuted, _$p));
|
|
681
|
+
return _el$41;
|
|
567
682
|
})()
|
|
568
683
|
}), null);
|
|
569
|
-
_$insert(_el$
|
|
684
|
+
_$insert(_el$28, _$createComponent(For, {
|
|
570
685
|
get each() {
|
|
571
686
|
return getAccountMetadataRows(props.resetCredits, props.quota?.spendControl);
|
|
572
687
|
},
|
|
@@ -587,16 +702,16 @@ function AccountBlock(props) {
|
|
|
587
702
|
var _v$1 = props.marginTop ?? 0,
|
|
588
703
|
_v$10 = props.theme.text,
|
|
589
704
|
_v$11 = toneColor(props.theme, statusTone());
|
|
590
|
-
_v$1 !== _p$.e && (_p$.e = _$setProp(_el$
|
|
591
|
-
_v$10 !== _p$.t && (_p$.t = _$setProp(_el$
|
|
592
|
-
_v$11 !== _p$.a && (_p$.a = _$setProp(_el$
|
|
705
|
+
_v$1 !== _p$.e && (_p$.e = _$setProp(_el$28, "marginTop", _v$1, _p$.e));
|
|
706
|
+
_v$10 !== _p$.t && (_p$.t = _$setProp(_el$30, "fg", _v$10, _p$.t));
|
|
707
|
+
_v$11 !== _p$.a && (_p$.a = _$setProp(_el$32, "fg", _v$11, _p$.a));
|
|
593
708
|
return _p$;
|
|
594
709
|
}, {
|
|
595
710
|
e: undefined,
|
|
596
711
|
t: undefined,
|
|
597
712
|
a: undefined
|
|
598
713
|
});
|
|
599
|
-
return _el$
|
|
714
|
+
return _el$28;
|
|
600
715
|
})();
|
|
601
716
|
}
|
|
602
717
|
|
|
@@ -643,15 +758,13 @@ function createSidebarController(initialPrefs) {
|
|
|
643
758
|
const [collapsed, setCollapsed] = createSignal(seedCollapsed);
|
|
644
759
|
let lastPersistedCollapsed = initialPrefs.collapsed;
|
|
645
760
|
let lastApplied = JSON.stringify(initialPrefs);
|
|
646
|
-
|
|
647
|
-
//
|
|
648
|
-
//
|
|
649
|
-
|
|
650
|
-
// watcher echoes of the previous persisted value are rejected by the
|
|
651
|
-
// `!==` check and cannot revert a user click.
|
|
652
|
-
watchTuiPreferences(() => {
|
|
761
|
+
let disposed = false;
|
|
762
|
+
// Remember the last value written to disk, not an unpersisted click. A watcher
|
|
763
|
+
// echo of the previous disk value must not undo a click whose write is pending.
|
|
764
|
+
const unwatch = watchTuiPreferences(() => {
|
|
653
765
|
void (async () => {
|
|
654
766
|
const next = resolveOpenaiAuthPrefs(await readTuiPreferencesFile());
|
|
767
|
+
if (disposed) return;
|
|
655
768
|
const serialized = JSON.stringify(next);
|
|
656
769
|
if (serialized === lastApplied) return;
|
|
657
770
|
lastApplied = serialized;
|
|
@@ -674,7 +787,11 @@ function createSidebarController(initialPrefs) {
|
|
|
674
787
|
return {
|
|
675
788
|
prefs,
|
|
676
789
|
collapsed,
|
|
677
|
-
toggleCollapsed
|
|
790
|
+
toggleCollapsed,
|
|
791
|
+
dispose() {
|
|
792
|
+
disposed = true;
|
|
793
|
+
unwatch();
|
|
794
|
+
}
|
|
678
795
|
};
|
|
679
796
|
}
|
|
680
797
|
function QuotaSidebar(props) {
|
|
@@ -683,9 +800,11 @@ function QuotaSidebar(props) {
|
|
|
683
800
|
const [state, setState] = createSignal(DEFAULT_SIDEBAR_STATE);
|
|
684
801
|
let lastUpdated = 0;
|
|
685
802
|
let debounce = null;
|
|
803
|
+
let disposed = false;
|
|
686
804
|
async function refresh() {
|
|
805
|
+
if (disposed) return;
|
|
687
806
|
const next = await readStateFromFile();
|
|
688
|
-
if (next.lastUpdated !== lastUpdated) {
|
|
807
|
+
if (!disposed && next.lastUpdated !== lastUpdated) {
|
|
689
808
|
lastUpdated = next.lastUpdated;
|
|
690
809
|
setState(next);
|
|
691
810
|
}
|
|
@@ -706,8 +825,10 @@ function QuotaSidebar(props) {
|
|
|
706
825
|
onCleanup(() => clearInterval(timer));
|
|
707
826
|
});
|
|
708
827
|
const unsubs = [props.api.event.on('session.updated', scheduleRefresh), props.api.event.on('message.updated', scheduleRefresh)];
|
|
709
|
-
setTimeout(refresh, 300);
|
|
828
|
+
const initialRefresh = setTimeout(refresh, 300);
|
|
710
829
|
onCleanup(() => {
|
|
830
|
+
disposed = true;
|
|
831
|
+
clearTimeout(initialRefresh);
|
|
711
832
|
if (debounce) clearTimeout(debounce);
|
|
712
833
|
for (const u of unsubs) u();
|
|
713
834
|
});
|
|
@@ -716,8 +837,8 @@ function QuotaSidebar(props) {
|
|
|
716
837
|
// Vault mode: the host uses only the vault's accounts, which the file lists
|
|
717
838
|
// in `vaultAccounts`; main and the local fallbacks are not shown.
|
|
718
839
|
const vaultMode = () => state().vaultAccounts !== undefined;
|
|
719
|
-
const
|
|
720
|
-
const hasData = () => vaultMode() ?
|
|
840
|
+
const vaultAccounts = () => state().vaultAccounts ?? [];
|
|
841
|
+
const hasData = () => vaultMode() ? vaultAccounts().length > 0 : state().main?.quota != null || enabledFallbacks().length > 0;
|
|
721
842
|
const headerLabel = () => {
|
|
722
843
|
const name = prefs().header.label;
|
|
723
844
|
return !hasData() ? name : collapsed() ? `\u25b6 ${name}` : `\u25bc ${name}`;
|
|
@@ -729,6 +850,9 @@ function QuotaSidebar(props) {
|
|
|
729
850
|
route: sessionRouting().route
|
|
730
851
|
});
|
|
731
852
|
const activeAccount = () => resolveActiveAccount(sessionState());
|
|
853
|
+
const collapsedLines = () => getCollapsedAccountLines(sessionState(), {
|
|
854
|
+
showFallbacks: prefs().sections.fallbackAccounts
|
|
855
|
+
});
|
|
732
856
|
const quotaLabelWidth = () => computeQuotaLabelWidth(renderedQuotas(state()));
|
|
733
857
|
const activeQuotaSummary = () => getCollapsedQuotaSummary(activeAccount().quota);
|
|
734
858
|
const activePacingDeficit = () => {
|
|
@@ -745,38 +869,38 @@ function QuotaSidebar(props) {
|
|
|
745
869
|
if (!activePacingDeficit()) return base;
|
|
746
870
|
return base === 'ok' || base === 'muted' ? 'warn' : base;
|
|
747
871
|
};
|
|
748
|
-
const killedNames = () => [state().main?.killed ? 'main' : '', ...enabledFallbacks().filter(f => f.killed).map(f => f.label ?? f.id)].filter(Boolean);
|
|
872
|
+
const killedNames = () => [!vaultMode() && state().main?.killed ? 'main' : '', ...(vaultMode() ? vaultAccounts() : enabledFallbacks()).filter(f => f.killed).map(f => f.label ?? f.id)].filter(Boolean);
|
|
749
873
|
const quotaBackedOff = () => state().main?.quotaBackedOff === true;
|
|
750
874
|
const refreshBackedOff = () => state().main?.refreshBackedOff === true;
|
|
751
875
|
const degraded = () => killedNames().length > 0 || quotaBackedOff() || refreshBackedOff();
|
|
752
876
|
return (() => {
|
|
753
|
-
var _el$
|
|
754
|
-
_el$
|
|
755
|
-
_el$
|
|
756
|
-
_el$
|
|
757
|
-
_el$
|
|
758
|
-
_$insertNode(_el$
|
|
759
|
-
_$setProp(_el$
|
|
760
|
-
_$setProp(_el$
|
|
761
|
-
_$setProp(_el$
|
|
762
|
-
_$setProp(_el$
|
|
763
|
-
_$setProp(_el$
|
|
764
|
-
_$setProp(_el$
|
|
765
|
-
_$setProp(_el$
|
|
766
|
-
_$insertNode(_el$
|
|
767
|
-
_$setProp(_el$
|
|
768
|
-
_$setProp(_el$
|
|
769
|
-
_$setProp(_el$
|
|
770
|
-
_$setProp(_el$
|
|
771
|
-
_$setProp(_el$
|
|
877
|
+
var _el$42 = _$createElement("box"),
|
|
878
|
+
_el$43 = _$createElement("box"),
|
|
879
|
+
_el$44 = _$createElement("box"),
|
|
880
|
+
_el$45 = _$createElement("text"),
|
|
881
|
+
_el$46 = _$createElement("b");
|
|
882
|
+
_$insertNode(_el$42, _el$43);
|
|
883
|
+
_$setProp(_el$42, "width", '100%');
|
|
884
|
+
_$setProp(_el$42, "flexDirection", 'column');
|
|
885
|
+
_$setProp(_el$42, "border", SINGLE_BORDER);
|
|
886
|
+
_$setProp(_el$42, "paddingTop", 1);
|
|
887
|
+
_$setProp(_el$42, "paddingBottom", 1);
|
|
888
|
+
_$setProp(_el$42, "paddingLeft", 1);
|
|
889
|
+
_$setProp(_el$42, "paddingRight", 1);
|
|
890
|
+
_$insertNode(_el$43, _el$44);
|
|
891
|
+
_$setProp(_el$43, "width", '100%');
|
|
892
|
+
_$setProp(_el$43, "flexDirection", 'row');
|
|
893
|
+
_$setProp(_el$43, "justifyContent", 'space-between');
|
|
894
|
+
_$setProp(_el$43, "alignItems", 'center');
|
|
895
|
+
_$setProp(_el$43, "onMouseDown", () => {
|
|
772
896
|
if (hasData()) props.controller.toggleCollapsed();
|
|
773
897
|
});
|
|
774
|
-
_$insertNode(_el$
|
|
775
|
-
_$setProp(_el$
|
|
776
|
-
_$setProp(_el$
|
|
777
|
-
_$insertNode(_el$
|
|
778
|
-
_$insert(_el$
|
|
779
|
-
_$insert(_el$
|
|
898
|
+
_$insertNode(_el$44, _el$45);
|
|
899
|
+
_$setProp(_el$44, "paddingLeft", 1);
|
|
900
|
+
_$setProp(_el$44, "paddingRight", 1);
|
|
901
|
+
_$insertNode(_el$45, _el$46);
|
|
902
|
+
_$insert(_el$46, headerLabel);
|
|
903
|
+
_$insert(_el$43, _$createComponent(Show, {
|
|
780
904
|
get when() {
|
|
781
905
|
return degraded();
|
|
782
906
|
},
|
|
@@ -786,89 +910,59 @@ function QuotaSidebar(props) {
|
|
|
786
910
|
return prefs().header.showVersion && PLUGIN_VERSION !== '';
|
|
787
911
|
},
|
|
788
912
|
get children() {
|
|
789
|
-
var _el$
|
|
790
|
-
_$insert(_el$
|
|
791
|
-
_$effect(_$p => _$setProp(_el$
|
|
792
|
-
return _el$
|
|
913
|
+
var _el$51 = _$createElement("text");
|
|
914
|
+
_$insert(_el$51, `v${PLUGIN_VERSION}`);
|
|
915
|
+
_$effect(_$p => _$setProp(_el$51, "fg", theme().textMuted, _$p));
|
|
916
|
+
return _el$51;
|
|
793
917
|
}
|
|
794
918
|
});
|
|
795
919
|
},
|
|
796
920
|
get children() {
|
|
797
|
-
var _el$
|
|
798
|
-
_el$
|
|
799
|
-
_el$
|
|
800
|
-
_$insertNode(_el$
|
|
801
|
-
_$setProp(_el$
|
|
802
|
-
_$setProp(_el$
|
|
803
|
-
_$insertNode(_el$
|
|
804
|
-
_$insertNode(_el$
|
|
921
|
+
var _el$47 = _$createElement("box"),
|
|
922
|
+
_el$48 = _$createElement("text"),
|
|
923
|
+
_el$49 = _$createElement("b");
|
|
924
|
+
_$insertNode(_el$47, _el$48);
|
|
925
|
+
_$setProp(_el$47, "paddingLeft", 1);
|
|
926
|
+
_$setProp(_el$47, "paddingRight", 1);
|
|
927
|
+
_$insertNode(_el$48, _el$49);
|
|
928
|
+
_$insertNode(_el$49, _$createTextNode(`LIMITED`));
|
|
805
929
|
_$effect(_p$ => {
|
|
806
930
|
var _v$12 = theme().warning,
|
|
807
931
|
_v$13 = theme().background;
|
|
808
|
-
_v$12 !== _p$.e && (_p$.e = _$setProp(_el$
|
|
809
|
-
_v$13 !== _p$.t && (_p$.t = _$setProp(_el$
|
|
932
|
+
_v$12 !== _p$.e && (_p$.e = _$setProp(_el$47, "backgroundColor", _v$12, _p$.e));
|
|
933
|
+
_v$13 !== _p$.t && (_p$.t = _$setProp(_el$48, "fg", _v$13, _p$.t));
|
|
810
934
|
return _p$;
|
|
811
935
|
}, {
|
|
812
936
|
e: undefined,
|
|
813
937
|
t: undefined
|
|
814
938
|
});
|
|
815
|
-
return _el$
|
|
939
|
+
return _el$47;
|
|
816
940
|
}
|
|
817
941
|
}), null);
|
|
818
|
-
_$insert(_el$
|
|
942
|
+
_$insert(_el$42, _$createComponent(Show, {
|
|
819
943
|
get when() {
|
|
820
944
|
return _$memo(() => !!collapsed())() && hasData();
|
|
821
945
|
},
|
|
822
946
|
get children() {
|
|
823
|
-
return _$createComponent(
|
|
824
|
-
get
|
|
825
|
-
return
|
|
826
|
-
},
|
|
827
|
-
get label() {
|
|
828
|
-
return activeAccount().name;
|
|
947
|
+
return _$createComponent(Index, {
|
|
948
|
+
get each() {
|
|
949
|
+
return collapsedLines();
|
|
829
950
|
},
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
})();
|
|
842
|
-
},
|
|
843
|
-
get children() {
|
|
844
|
-
var _el$40 = _$createElement("box"),
|
|
845
|
-
_el$41 = _$createElement("text"),
|
|
846
|
-
_el$42 = _$createElement("b"),
|
|
847
|
-
_el$43 = _$createElement("text");
|
|
848
|
-
_$insertNode(_el$40, _el$41);
|
|
849
|
-
_$insertNode(_el$40, _el$43);
|
|
850
|
-
_$setProp(_el$40, "flexDirection", 'row');
|
|
851
|
-
_$insertNode(_el$41, _el$42);
|
|
852
|
-
_$insert(_el$42, () => activeQuotaSummary().text);
|
|
853
|
-
_$insert(_el$43, () => activeAccount().killed ? ' \u2298' : ' \u25cf');
|
|
854
|
-
_$effect(_p$ => {
|
|
855
|
-
var _v$14 = toneColor(theme(), activeQuotaTone()),
|
|
856
|
-
_v$15 = toneColor(theme(), activeAccount().killed ? 'err' : activeQuotaTone());
|
|
857
|
-
_v$14 !== _p$.e && (_p$.e = _$setProp(_el$41, "fg", _v$14, _p$.e));
|
|
858
|
-
_v$15 !== _p$.t && (_p$.t = _$setProp(_el$43, "fg", _v$15, _p$.t));
|
|
859
|
-
return _p$;
|
|
860
|
-
}, {
|
|
861
|
-
e: undefined,
|
|
862
|
-
t: undefined
|
|
863
|
-
});
|
|
864
|
-
return _el$40;
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
}
|
|
951
|
+
children: line => _$createComponent(CollapsedAccountRow, {
|
|
952
|
+
get theme() {
|
|
953
|
+
return theme();
|
|
954
|
+
},
|
|
955
|
+
get line() {
|
|
956
|
+
return line();
|
|
957
|
+
},
|
|
958
|
+
get tone() {
|
|
959
|
+
return activeQuotaTone();
|
|
960
|
+
}
|
|
961
|
+
})
|
|
868
962
|
});
|
|
869
963
|
}
|
|
870
964
|
}), null);
|
|
871
|
-
_$insert(_el$
|
|
965
|
+
_$insert(_el$42, _$createComponent(Show, {
|
|
872
966
|
get when() {
|
|
873
967
|
return !collapsed() || !hasData();
|
|
874
968
|
},
|
|
@@ -879,14 +973,14 @@ function QuotaSidebar(props) {
|
|
|
879
973
|
},
|
|
880
974
|
get fallback() {
|
|
881
975
|
return (() => {
|
|
882
|
-
var _el$
|
|
883
|
-
_el$
|
|
884
|
-
_$insertNode(_el$
|
|
885
|
-
_$setProp(_el$
|
|
886
|
-
_$setProp(_el$
|
|
887
|
-
_$insertNode(_el$
|
|
888
|
-
_$effect(_$p => _$setProp(_el$
|
|
889
|
-
return _el$
|
|
976
|
+
var _el$52 = _$createElement("box"),
|
|
977
|
+
_el$53 = _$createElement("text");
|
|
978
|
+
_$insertNode(_el$52, _el$53);
|
|
979
|
+
_$setProp(_el$52, "marginTop", 1);
|
|
980
|
+
_$setProp(_el$52, "width", '100%');
|
|
981
|
+
_$insertNode(_el$53, _$createTextNode(`Waiting for quota…`));
|
|
982
|
+
_$effect(_$p => _$setProp(_el$53, "fg", theme().textMuted, _$p));
|
|
983
|
+
return _el$52;
|
|
890
984
|
})();
|
|
891
985
|
},
|
|
892
986
|
get children() {
|
|
@@ -907,7 +1001,7 @@ function QuotaSidebar(props) {
|
|
|
907
1001
|
get fallback() {
|
|
908
1002
|
return _$createComponent(For, {
|
|
909
1003
|
get each() {
|
|
910
|
-
return
|
|
1004
|
+
return vaultAccounts();
|
|
911
1005
|
},
|
|
912
1006
|
children: (account, index) => _$createComponent(AccountBlock, {
|
|
913
1007
|
get theme() {
|
|
@@ -925,6 +1019,12 @@ function QuotaSidebar(props) {
|
|
|
925
1019
|
get killed() {
|
|
926
1020
|
return account.killed;
|
|
927
1021
|
},
|
|
1022
|
+
get vaultState() {
|
|
1023
|
+
return account.vaultState;
|
|
1024
|
+
},
|
|
1025
|
+
get hostDisabled() {
|
|
1026
|
+
return !account.enabled;
|
|
1027
|
+
},
|
|
928
1028
|
get active() {
|
|
929
1029
|
return sessionRouting().activeId === account.id;
|
|
930
1030
|
},
|
|
@@ -1127,19 +1227,19 @@ function QuotaSidebar(props) {
|
|
|
1127
1227
|
}
|
|
1128
1228
|
}), null);
|
|
1129
1229
|
_$effect(_p$ => {
|
|
1130
|
-
var _v$
|
|
1131
|
-
_v$
|
|
1132
|
-
_v$
|
|
1133
|
-
_v$
|
|
1134
|
-
_v$
|
|
1135
|
-
_v$
|
|
1230
|
+
var _v$14 = theme().borderActive,
|
|
1231
|
+
_v$15 = theme().accent,
|
|
1232
|
+
_v$16 = theme().background;
|
|
1233
|
+
_v$14 !== _p$.e && (_p$.e = _$setProp(_el$42, "borderColor", _v$14, _p$.e));
|
|
1234
|
+
_v$15 !== _p$.t && (_p$.t = _$setProp(_el$44, "backgroundColor", _v$15, _p$.t));
|
|
1235
|
+
_v$16 !== _p$.a && (_p$.a = _$setProp(_el$45, "fg", _v$16, _p$.a));
|
|
1136
1236
|
return _p$;
|
|
1137
1237
|
}, {
|
|
1138
1238
|
e: undefined,
|
|
1139
1239
|
t: undefined,
|
|
1140
1240
|
a: undefined
|
|
1141
1241
|
});
|
|
1142
|
-
return _el$
|
|
1242
|
+
return _el$42;
|
|
1143
1243
|
})();
|
|
1144
1244
|
}
|
|
1145
1245
|
const tui = async api => {
|
|
@@ -1196,8 +1296,37 @@ const tui = async api => {
|
|
|
1196
1296
|
}, RPC_POLL_MS);
|
|
1197
1297
|
}
|
|
1198
1298
|
};
|
|
1299
|
+
async function setup(context, options = {}) {
|
|
1300
|
+
if (options.sidebarText !== undefined || options.sidebar) return setupTui(context, options);
|
|
1301
|
+
const root = await readTuiPreferencesFile();
|
|
1302
|
+
const controller = createSidebarController(resolveOpenaiAuthPrefs(root));
|
|
1303
|
+
const api = {
|
|
1304
|
+
theme: {
|
|
1305
|
+
get current() {
|
|
1306
|
+
return context.theme;
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
event: {
|
|
1310
|
+
on: (type, listener) => context.data.on(type === 'session.updated' ? 'session.metadata.updated' : 'session.usage.updated', listener)
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
return setupTui(context, {
|
|
1314
|
+
...options,
|
|
1315
|
+
sidebar: {
|
|
1316
|
+
render: input => _$createComponent(QuotaSidebar, {
|
|
1317
|
+
api: api,
|
|
1318
|
+
controller: controller,
|
|
1319
|
+
get sessionId() {
|
|
1320
|
+
return input.sessionID;
|
|
1321
|
+
}
|
|
1322
|
+
}),
|
|
1323
|
+
dispose: controller.dispose
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1199
1327
|
const plugin = {
|
|
1200
1328
|
id: ID,
|
|
1329
|
+
setup,
|
|
1201
1330
|
tui
|
|
1202
1331
|
};
|
|
1203
1332
|
export default plugin;
|