@cortexkit/opencode-antigravity-auth 3.0.19 → 3.0.21
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/README.md +3 -1
- package/dist/cli.js +277 -150
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +43 -23
- package/dist/index.js +331 -204
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +43 -23
- package/dist/server.js +344 -217
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/src/common-auth-embedded/claustrum/custody.js +45 -6
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/src/common-auth-embedded/claustrum/hub.js +75 -6
- package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/dist/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/dist/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/src/common-auth-embedded/opencode2/install.js +144 -17
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/dist/src/common-auth-embedded/source-output.json +73 -53
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +2 -3
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/server.d.ts +4 -4
- package/dist/src/server.js +4 -4
- package/dist/src/tui/quota-layout.d.ts +4 -58
- package/dist/src/tui/quota-layout.d.ts.map +1 -1
- package/dist/src/tui/quota-layout.js +4 -90
- package/dist/src/tui/quota-layout.js.map +1 -1
- package/dist/src/tui/sidebar-frame.d.ts +4 -35
- package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
- package/dist/src/tui/sidebar-frame.js +91 -171
- package/dist/src/tui/sidebar-frame.js.map +1 -1
- package/dist/src/tui.js +3 -3
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +27 -13
- package/dist/tui-ga-build-map.json +28 -13
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/dist/types/src/server.d.ts +4 -4
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
- package/src/common-auth-embedded/claustrum/consumer.js +25 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
- package/src/common-auth-embedded/claustrum/custody.js +45 -6
- package/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
- package/src/common-auth-embedded/claustrum/hub.js +75 -6
- package/src/common-auth-embedded/claustrum/insula.js +6 -0
- package/src/common-auth-embedded/claustrum/roster.js +1 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
- package/src/common-auth-embedded/fs/with-lock.js +1 -1
- package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/src/common-auth-embedded/opencode2/install.d.ts +4 -3
- package/src/common-auth-embedded/opencode2/install.js +144 -17
- package/src/common-auth-embedded/opencode2/types.d.ts +52 -1
- package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
- package/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/src/common-auth-embedded/source-output.json +73 -53
- package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +666 -0
- package/src/tui-compiled/tui/quota-layout.js +5 -330
- package/src/tui-compiled/tui/sidebar-frame.js +241 -503
- package/src/tui-compiled/tui.js +3 -3
- package/src/tui-ga-compiled/host-ga.js +2 -3
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +241 -503
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
- package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +666 -0
- package/src/tui-ga-raw/host-ga.tsx +2 -3
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +209 -419
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
- package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +630 -0
- package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +630 -0
- package/src/tui-raw/tui/quota-layout.tsx +10 -301
- package/src/tui-raw/tui/sidebar-frame.tsx +209 -419
- package/src/tui-raw/tui.tsx +3 -3
- package/src/tui.tsx +3 -3
|
@@ -1,38 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* Quota layout shared by the OpenCode 1 sidebar (`tui.tsx`) and the OpenCode 2
|
|
4
|
-
* sidebar (`ga/tui/host-ga.tsx`): one account block with its header line, the
|
|
5
|
-
* reading age once per account, plain-word group headers and one width-fitted
|
|
6
|
-
* row per quota window.
|
|
7
|
-
*
|
|
8
|
-
* Each renderer supplies its own data source and colors. This module imports
|
|
9
|
-
* only the pure quota presentation helpers, so it stays inside both TUI
|
|
10
|
-
* import graphs: no sidebar file, preferences file, RPC, account store,
|
|
11
|
-
* OAuth, token or host SDK module, and nothing that writes to the terminal.
|
|
12
|
-
*/
|
|
13
|
-
import type { RGBA } from '@opentui/core';
|
|
14
|
-
import { type JSX } from 'solid-js';
|
|
1
|
+
/** Pure account-window inputs shared by the two sidebar hosts. */
|
|
2
|
+
import type { SidebarAppearance, Tone } from '../common-auth-embedded/quota-sidebar/index.js';
|
|
15
3
|
import { type QuotaReading, type QuotaWindowText } from '../quota-presentation.js';
|
|
16
|
-
export type
|
|
17
|
-
/** A text color; `undefined` leaves the host's default color in place. */
|
|
18
|
-
export type QuotaColor = string | RGBA | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* How a renderer colors the quota layout. OpenCode 1 maps these onto its live
|
|
21
|
-
* host theme; a renderer without a theme returns `undefined` everywhere.
|
|
22
|
-
*/
|
|
23
|
-
export interface QuotaPalette {
|
|
24
|
-
readonly text: () => QuotaColor;
|
|
25
|
-
readonly muted: () => QuotaColor;
|
|
26
|
-
readonly tone: (tone: QuotaTone) => QuotaColor;
|
|
27
|
-
}
|
|
28
|
-
/** The bar and threshold settings the layout reads. */
|
|
29
|
-
export interface QuotaAppearance {
|
|
30
|
-
readonly barWidth: number;
|
|
31
|
-
readonly barFilledChar: string;
|
|
32
|
-
readonly barEmptyChar: string;
|
|
33
|
-
readonly warnThreshold: number;
|
|
34
|
-
readonly errorThreshold: number;
|
|
35
|
-
}
|
|
4
|
+
export type QuotaAppearance = SidebarAppearance;
|
|
36
5
|
/**
|
|
37
6
|
* The OpenCode 1 preference defaults for the quota bar, for a renderer that
|
|
38
7
|
* has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
|
|
@@ -63,34 +32,11 @@ export interface QuotaLayoutAccount {
|
|
|
63
32
|
}
|
|
64
33
|
export declare const GROUP_NAMES: Record<QuotaGroupKey, string>;
|
|
65
34
|
export declare const QUOTA_ORDER: readonly QuotaGroupKey[];
|
|
66
|
-
export declare
|
|
67
|
-
export declare const ASSUMED_CONTENT_WIDTH = 28;
|
|
68
|
-
export declare function quotaTone(usedPct: number, appearance: QuotaAppearance): QuotaTone;
|
|
35
|
+
export declare function quotaTone(usedPct: number, appearance: QuotaAppearance): Tone;
|
|
69
36
|
export interface AccountWindow {
|
|
70
37
|
key: QuotaGroupKey;
|
|
71
38
|
reading: QuotaReading;
|
|
72
39
|
text: QuotaWindowText;
|
|
73
40
|
}
|
|
74
41
|
export declare function accountWindows(account: QuotaLayoutAccount, now: number): AccountWindow[];
|
|
75
|
-
export declare function showsFigure(window: AccountWindow): boolean;
|
|
76
|
-
export declare function fitLabel(label: string, max: number): string;
|
|
77
|
-
/**
|
|
78
|
-
* One account's quota block. The header line is the account label, the
|
|
79
|
-
* reading age when the oldest reading is stale, and the caller's status word
|
|
80
|
-
* right-aligned; the age moves to its own dim line when the three do not
|
|
81
|
-
* fit. Below it each quota group present gets a plain-word header and one
|
|
82
|
-
* row per window, or a single dim line when there is no reading at all.
|
|
83
|
-
* `children`, when given, render after the quota rows.
|
|
84
|
-
*/
|
|
85
|
-
export declare function QuotaAccountBlock(props: {
|
|
86
|
-
palette: QuotaPalette;
|
|
87
|
-
appearance: QuotaAppearance;
|
|
88
|
-
account: QuotaLayoutAccount;
|
|
89
|
-
status: string;
|
|
90
|
-
statusTone: QuotaTone;
|
|
91
|
-
now: () => number;
|
|
92
|
-
width: () => number;
|
|
93
|
-
marginTop?: number;
|
|
94
|
-
children?: JSX.Element;
|
|
95
|
-
}): JSX.Element;
|
|
96
42
|
//# sourceMappingURL=quota-layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-layout.d.ts","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"quota-layout.d.ts","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,IAAI,EACL,MAAM,6CAA6C,CAAA;AACpD,OAAO,EACL,KAAK,YAAY,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IAC5B,GAAG,EAAE,aAAa,CAAA;IAClB,OAAO,EAAE,YAAY,CAAA;IACrB,IAAI,EAAE,eAAe,CAAA;CACtB;AAID,wBAAgB,cAAc,CAC5B,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,MAAM,GACV,aAAa,EAAE,CAwBjB"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { For, Show } from 'solid-js';
|
|
3
|
-
import { NO_QUOTA_READING, quotaReadingAge, quotaWindowText, } from '../quota-presentation';
|
|
1
|
+
import { quotaWindowText, } from '../quota-presentation';
|
|
4
2
|
/**
|
|
5
3
|
* The OpenCode 1 preference defaults for the quota bar, for a renderer that
|
|
6
4
|
* has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
|
|
@@ -23,33 +21,12 @@ export const QUOTA_ORDER = [
|
|
|
23
21
|
'non-gemini',
|
|
24
22
|
'gemini-argon',
|
|
25
23
|
];
|
|
26
|
-
// Shown instead of a stored figure once the window has reset since it was
|
|
27
|
-
// read: the stored figure describes the window before the reset.
|
|
28
|
-
export const RESET_SINCE_READING = 'reset since last check';
|
|
29
|
-
// Content width used until the first layout pass reports the real one. It
|
|
30
|
-
// fits the narrowest OpenCode sidebar.
|
|
31
|
-
export const ASSUMED_CONTENT_WIDTH = 28;
|
|
32
|
-
// A window row is `<name> <bar> <figure> <reset>`. The bar shrinks to this
|
|
33
|
-
// before the reset column is dropped; below it the bar is dropped too.
|
|
34
|
-
const MIN_BAR_WIDTH = 4;
|
|
35
|
-
// The widest figure the formatter writes: `100% left`.
|
|
36
|
-
const FIGURE_WIDTH = 9;
|
|
37
|
-
// A window name (`5h`, `7d`) and the space after it.
|
|
38
|
-
const NAME_WIDTH = 3;
|
|
39
24
|
export function quotaTone(usedPct, appearance) {
|
|
40
25
|
if (usedPct < appearance.warnThreshold)
|
|
41
|
-
return '
|
|
26
|
+
return 'success';
|
|
42
27
|
if (usedPct < appearance.errorThreshold)
|
|
43
|
-
return '
|
|
44
|
-
return '
|
|
45
|
-
}
|
|
46
|
-
function quotaBarSegments(remainingPct, width, appearance) {
|
|
47
|
-
const usedCells = Math.max(0, Math.min(Math.round((remainingPct / 100) * width), width));
|
|
48
|
-
const tone = quotaTone(100 - remainingPct, appearance);
|
|
49
|
-
return [
|
|
50
|
-
{ text: appearance.barFilledChar.repeat(usedCells), tone },
|
|
51
|
-
{ text: appearance.barEmptyChar.repeat(width - usedCells), tone },
|
|
52
|
-
].filter((segment) => segment.text.length > 0);
|
|
28
|
+
return 'warning';
|
|
29
|
+
return 'error';
|
|
53
30
|
}
|
|
54
31
|
// One entry per stored window, in group order. A pool stored before
|
|
55
32
|
// per-window readings existed contributes one window without a name.
|
|
@@ -78,67 +55,4 @@ export function accountWindows(account, now) {
|
|
|
78
55
|
}
|
|
79
56
|
return result;
|
|
80
57
|
}
|
|
81
|
-
// A window shows its figure only while no reset has happened since it was
|
|
82
|
-
// read and it has a read time at all.
|
|
83
|
-
export function showsFigure(window) {
|
|
84
|
-
return window.text.remaining != null && !window.text.resetSinceReading;
|
|
85
|
-
}
|
|
86
|
-
// Column widths for one `<name> <bar> <figure> <reset>` row within `width`
|
|
87
|
-
// cells. The bar shrinks first, down to MIN_BAR_WIDTH; then the reset column
|
|
88
|
-
// is dropped; when even that leaves less than MIN_BAR_WIDTH cells for the
|
|
89
|
-
// bar, the bar is left out and the row is just the name and figure.
|
|
90
|
-
function windowRowLayout(width, named, resetWidth, maxBar) {
|
|
91
|
-
const room = width - (named ? NAME_WIDTH : 0) - FIGURE_WIDTH;
|
|
92
|
-
if (resetWidth > 0) {
|
|
93
|
-
const bar = Math.min(maxBar, room - resetWidth - 2);
|
|
94
|
-
if (bar >= MIN_BAR_WIDTH)
|
|
95
|
-
return { bar, reset: true };
|
|
96
|
-
}
|
|
97
|
-
const bar = Math.min(maxBar, room - 1);
|
|
98
|
-
return { bar: bar >= MIN_BAR_WIDTH ? bar : 0, reset: false };
|
|
99
|
-
}
|
|
100
|
-
// Shorten a label to `max` cells, marking the cut with an ellipsis.
|
|
101
|
-
export function fitLabel(label, max) {
|
|
102
|
-
if (label.length <= max)
|
|
103
|
-
return label;
|
|
104
|
-
if (max <= 0)
|
|
105
|
-
return '';
|
|
106
|
-
if (max === 1)
|
|
107
|
-
return '…';
|
|
108
|
-
return `${label.slice(0, max - 1)}…`;
|
|
109
|
-
}
|
|
110
|
-
// One quota window on one line. The bar fills with remaining quota; the
|
|
111
|
-
// figure and reset come from the shared formatter. A window that reset since
|
|
112
|
-
// its reading shows that fact, dim, in place of the stale figure.
|
|
113
|
-
function WindowRow(props) {
|
|
114
|
-
const text = () => props.window.text;
|
|
115
|
-
const tone = () => quotaTone(100 - (text().remaining ?? 0), props.appearance);
|
|
116
|
-
return (_jsxs("box", { width: '100%', flexDirection: 'row', children: [_jsx(Show, { when: text().name !== '', children: _jsx("text", { width: NAME_WIDTH, flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: text().name }) }), _jsxs(Show, { when: showsFigure(props.window), fallback: _jsx("text", { flexShrink: 1, wrapMode: 'none', fg: props.palette.muted(), children: text().resetSinceReading ? RESET_SINCE_READING : text().figure }), children: [_jsx(Show, { when: props.layout.bar > 0, children: _jsx("box", { width: props.layout.bar + 1, flexShrink: 0, flexDirection: 'row', children: _jsx(For, { each: quotaBarSegments(text().remaining ?? 0, props.layout.bar, props.appearance), children: (segment) => (_jsx("text", { wrapMode: 'none', fg: props.palette.tone(segment.tone), children: segment.text })) }) }) }), _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.tone(tone()), children: text().figure }), _jsx("box", { flexGrow: 1 }), _jsx(Show, { when: props.layout.reset && text().reset !== '', children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: text().reset }) })] })] }));
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* One account's quota block. The header line is the account label, the
|
|
120
|
-
* reading age when the oldest reading is stale, and the caller's status word
|
|
121
|
-
* right-aligned; the age moves to its own dim line when the three do not
|
|
122
|
-
* fit. Below it each quota group present gets a plain-word header and one
|
|
123
|
-
* row per window, or a single dim line when there is no reading at all.
|
|
124
|
-
* `children`, when given, render after the quota rows.
|
|
125
|
-
*/
|
|
126
|
-
export function QuotaAccountBlock(props) {
|
|
127
|
-
const windows = () => accountWindows(props.account, props.now());
|
|
128
|
-
const age = () => quotaReadingAge(windows().map((window) => window.reading), props.now());
|
|
129
|
-
const ageInline = () => age() !== '' &&
|
|
130
|
-
props.account.label.length + 3 + age().length + 1 + props.status.length <=
|
|
131
|
-
props.width();
|
|
132
|
-
const label = () => fitLabel(props.account.label, props.width() - 1 - props.status.length);
|
|
133
|
-
// One reset column width per account, so bars line up across its rows.
|
|
134
|
-
const resetWidth = () => Math.max(0, ...windows()
|
|
135
|
-
.filter(showsFigure)
|
|
136
|
-
.map((window) => window.text.reset.length));
|
|
137
|
-
const layoutFor = (window) => windowRowLayout(props.width(), window.text.name !== '', resetWidth(), props.appearance.barWidth);
|
|
138
|
-
const groups = () => QUOTA_ORDER.map((key) => ({
|
|
139
|
-
key,
|
|
140
|
-
windows: windows().filter((window) => window.key === key),
|
|
141
|
-
})).filter((group) => group.windows.length > 0);
|
|
142
|
-
return (_jsxs("box", { width: '100%', flexDirection: 'column', marginTop: props.marginTop ?? 0, children: [_jsxs("box", { width: '100%', flexDirection: 'row', children: [_jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.text(), children: _jsx("b", { children: label() }) }), _jsx(Show, { when: ageInline(), children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: ` · ${age()}` }) }), _jsx("box", { flexGrow: 1 }), _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.tone(props.statusTone), children: _jsx("b", { children: props.status }) })] }), _jsx(Show, { when: age() !== '' && !ageInline(), children: _jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: age() }) }), _jsx(Show, { when: groups().length > 0, fallback: _jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: NO_QUOTA_READING }), children: _jsx(For, { each: groups(), children: (group) => (_jsxs(_Fragment, { children: [_jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: GROUP_NAMES[group.key] }), _jsx(For, { each: group.windows, children: (window) => (_jsx(WindowRow, { palette: props.palette, appearance: props.appearance, window: window, layout: layoutFor(window) })) })] })) }) }), props.children] }));
|
|
143
|
-
}
|
|
144
58
|
//# sourceMappingURL=quota-layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-layout.js","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-layout.js","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,eAAe,GAChB,MAAM,uBAAuB,CAAA;AAI9B;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,GAAG;IACjB,aAAa,EAAE,EAAE;IACjB,cAAc,EAAE,EAAE;CACnB,CAAA;AA6BD,qDAAqD;AACrD,MAAM,CAAC,MAAM,WAAW,GAAkC;IACxD,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,cAAc;IAC5B,cAAc,EAAE,OAAO;CACxB,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAA6B;IACnD,QAAQ;IACR,YAAY;IACZ,cAAc;CACf,CAAA;AAED,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,UAA2B;IACpE,IAAI,OAAO,GAAG,UAAU,CAAC,aAAa;QAAE,OAAO,SAAS,CAAA;IACxD,IAAI,OAAO,GAAG,UAAU,CAAC,cAAc;QAAE,OAAO,SAAS,CAAA;IACzD,OAAO,OAAO,CAAA;AAChB,CAAC;AAQD,oEAAoE;AACpE,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAC5B,OAA2B,EAC3B,GAAW;IAEX,MAAM,MAAM,GAAoB,EAAE,CAAA;IAClC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,CAAC,KAAK;YAAE,SAAQ;QACpB,MAAM,QAAQ,GACZ,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YACvC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;YACL,CAAC,CAAC;gBACE;oBACE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;oBACxC,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B;aACF,CAAA;QACP,KAAK,MAAM,OAAO,IAAI,QAAQ;YAC5B,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
|
-
/**
|
|
3
|
-
* The Antigravity sidebar frame, shared by the OpenCode 1 sidebar (`tui.tsx`)
|
|
4
|
-
* and the OpenCode 2 sidebar (`ga/tui/host-ga.tsx`): the bordered, padded
|
|
5
|
-
* panel, the clickable `▼`/`▶` header badge with the plugin version (or a
|
|
6
|
-
* `LIMITED` badge) at the right, one line per account when collapsed, and the
|
|
7
|
-
* `Quota`, `Routing` and `Health` sections when expanded.
|
|
8
|
-
*
|
|
9
|
-
* Each renderer reads its own data source (the sidebar file, or the
|
|
10
|
-
* location's `state` answer), maps its own host theme onto `FrameTheme` and
|
|
11
|
-
* owns its own collapse state; everything drawn is decided here, so a change
|
|
12
|
-
* of shape is made once for both hosts.
|
|
13
|
-
*
|
|
14
|
-
* This module stays inside both TUI import graphs: besides Solid and
|
|
15
|
-
* OpenTUI it imports only the pure quota and sidebar-projection helpers and
|
|
16
|
-
* the shared layouts. No sidebar file, preferences file, RPC, account
|
|
17
|
-
* store, OAuth, token or host SDK module, no Node built-in, and nothing
|
|
18
|
-
* that writes to the terminal.
|
|
19
|
-
*/
|
|
2
|
+
/** Plugin-owned projection and Routing/Health sections for the shared quota frame. */
|
|
20
3
|
import type { RGBA } from '@opentui/core';
|
|
21
4
|
import { type JSX } from 'solid-js';
|
|
22
5
|
import { type ProjectedQuota } from '../common-auth-embedded/quota/index.js';
|
|
23
|
-
import { type QuotaAppearance, type QuotaLayoutAccount
|
|
24
|
-
type Tone = QuotaTone;
|
|
6
|
+
import { type QuotaAppearance, type QuotaLayoutAccount } from './quota-layout.js';
|
|
25
7
|
/** A theme color; `undefined` leaves the host's default color in place. */
|
|
26
8
|
export type FrameColor = string | RGBA | undefined;
|
|
27
9
|
/**
|
|
@@ -35,15 +17,13 @@ export interface FrameTheme {
|
|
|
35
17
|
readonly textMuted: FrameColor;
|
|
36
18
|
readonly accent: FrameColor;
|
|
37
19
|
readonly background: FrameColor;
|
|
38
|
-
readonly borderActive: FrameColor;
|
|
39
20
|
readonly success: FrameColor;
|
|
40
21
|
readonly warning: FrameColor;
|
|
41
22
|
readonly error: FrameColor;
|
|
42
23
|
}
|
|
43
|
-
export declare function toneColor(theme: FrameTheme, tone: Tone): FrameColor;
|
|
44
|
-
export declare function themePalette(theme: () => FrameTheme): QuotaPalette;
|
|
45
24
|
/** The account fields the frame reads: the quota layout's plus the state. */
|
|
46
25
|
export interface FrameAccount extends QuotaLayoutAccount {
|
|
26
|
+
readonly id: string;
|
|
47
27
|
readonly enabled: boolean;
|
|
48
28
|
readonly current: boolean;
|
|
49
29
|
readonly cooldownUntil?: number;
|
|
@@ -77,16 +57,6 @@ export interface FrameSettings {
|
|
|
77
57
|
* `DEFAULT_PREFS`.
|
|
78
58
|
*/
|
|
79
59
|
export declare const DEFAULT_FRAME_SETTINGS: FrameSettings;
|
|
80
|
-
export declare function SectionHeader(props: {
|
|
81
|
-
theme: () => FrameTheme;
|
|
82
|
-
title: string;
|
|
83
|
-
}): JSX.Element;
|
|
84
|
-
export declare function StatRow(props: {
|
|
85
|
-
theme: () => FrameTheme;
|
|
86
|
-
label: string;
|
|
87
|
-
value: string;
|
|
88
|
-
tone?: Tone;
|
|
89
|
-
}): JSX.Element;
|
|
90
60
|
export declare function sidebarQuotaProjection(account: QuotaLayoutAccount, now: number): ProjectedQuota | undefined;
|
|
91
61
|
export interface SidebarFrameProps {
|
|
92
62
|
readonly theme: () => FrameTheme;
|
|
@@ -104,6 +74,5 @@ export interface SidebarFrameProps {
|
|
|
104
74
|
readonly lastError: () => string | null | undefined;
|
|
105
75
|
readonly now: () => number;
|
|
106
76
|
}
|
|
107
|
-
export declare function
|
|
108
|
-
export {};
|
|
77
|
+
export declare function AntigravitySidebar(props: SidebarFrameProps): JSX.Element;
|
|
109
78
|
//# sourceMappingURL=sidebar-frame.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-frame.d.ts","sourceRoot":"","sources":["../../../src/tui/sidebar-frame.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC
|
|
1
|
+
{"version":3,"file":"sidebar-frame.d.ts","sourceRoot":"","sources":["../../../src/tui/sidebar-frame.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,sFAAsF;AAEtF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAiC,KAAK,GAAG,EAAQ,MAAM,UAAU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-js';
|
|
3
|
-
import {
|
|
3
|
+
import { isQuotaStale, NO_QUOTA_READING, } from '../common-auth-embedded/quota/index.js';
|
|
4
|
+
import { SidebarFrame, SidebarSection, SidebarTextRow, } from '../common-auth-embedded/quota-sidebar/index';
|
|
4
5
|
import { formatResetIn, formatWait } from '../sidebar-projection';
|
|
5
|
-
import {
|
|
6
|
+
import { accountWindows, DEFAULT_QUOTA_APPEARANCE, GROUP_NAMES, QUOTA_ORDER, quotaTone, } from './quota-layout';
|
|
6
7
|
import { routeLineFits } from './route-layout';
|
|
7
|
-
// Every tone falls through to a sibling token, so a sparse custom theme still
|
|
8
|
-
// renders readably.
|
|
9
|
-
export function toneColor(theme, tone) {
|
|
10
|
-
switch (tone) {
|
|
11
|
-
case 'ok':
|
|
12
|
-
return theme.success ?? theme.accent;
|
|
13
|
-
case 'warn':
|
|
14
|
-
return theme.warning ?? theme.accent;
|
|
15
|
-
case 'err':
|
|
16
|
-
return theme.error ?? theme.accent;
|
|
17
|
-
case 'muted':
|
|
18
|
-
return theme.textMuted ?? theme.text;
|
|
19
|
-
case 'accent':
|
|
20
|
-
return theme.accent ?? theme.text;
|
|
21
|
-
default:
|
|
22
|
-
return theme.text;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// The shared quota layout reads its colors through this palette. Muted text
|
|
26
|
-
// and the account label read `textMuted` and `text` straight from the theme,
|
|
27
|
-
// without the `toneColor` fallback chain.
|
|
28
|
-
export function themePalette(theme) {
|
|
29
|
-
return {
|
|
30
|
-
text: () => theme().text,
|
|
31
|
-
muted: () => theme().textMuted,
|
|
32
|
-
tone: (tone) => toneColor(theme(), tone),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
8
|
/**
|
|
36
9
|
* The OpenCode 1 preference defaults for the frame, for a renderer that has
|
|
37
10
|
* no preferences file. A test keeps it equal to the matching part of
|
|
@@ -47,53 +20,6 @@ export const DEFAULT_FRAME_SETTINGS = {
|
|
|
47
20
|
},
|
|
48
21
|
appearance: DEFAULT_QUOTA_APPEARANCE,
|
|
49
22
|
};
|
|
50
|
-
// --- Rows ------------------------------------------------------------------
|
|
51
|
-
// Section header: bold title, themed text color, top margin for vertical
|
|
52
|
-
// breathing room between sections.
|
|
53
|
-
export function SectionHeader(props) {
|
|
54
|
-
return (_jsx("box", { width: '100%', marginTop: 1, children: _jsx("text", { fg: toneColor(props.theme(), 'text'), children: _jsx("b", { children: props.title }) }) }));
|
|
55
|
-
}
|
|
56
|
-
// Muted label left, value (optionally tone-tinted, bold) right, for the
|
|
57
|
-
// routing and health rows.
|
|
58
|
-
export function StatRow(props) {
|
|
59
|
-
return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().textMuted, children: props.label }), _jsx("text", { fg: toneColor(props.theme(), props.tone ?? 'text'), children: _jsx("b", { children: props.value }) })] }));
|
|
60
|
-
}
|
|
61
|
-
// Muted label left, caller-supplied value right. The collapsed view renders
|
|
62
|
-
// one row for every visible account. The caller sizes both sides to the
|
|
63
|
-
// measured width, so neither side may wrap.
|
|
64
|
-
function CollapsedRow(props) {
|
|
65
|
-
return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.theme().textMuted, children: props.label }), props.children] }));
|
|
66
|
-
}
|
|
67
|
-
// One account in the Quota section: the shared quota block, with the status
|
|
68
|
-
// word computed from the account state. Status word priorities (first match
|
|
69
|
-
// wins):
|
|
70
|
-
// - `off` when the account is disabled
|
|
71
|
-
// - `cooling <wait>` when cooldownUntil is still in the future
|
|
72
|
-
// - `active` when current === true
|
|
73
|
-
// - `idle` for the fallback (current === false) case
|
|
74
|
-
function AccountBlock(props) {
|
|
75
|
-
const cooldownMs = () => {
|
|
76
|
-
const cd = props.account.cooldownUntil;
|
|
77
|
-
if (typeof cd !== 'number')
|
|
78
|
-
return 0;
|
|
79
|
-
return Math.max(0, cd - props.now());
|
|
80
|
-
};
|
|
81
|
-
const statusWord = () => {
|
|
82
|
-
if (!props.account.enabled)
|
|
83
|
-
return 'off';
|
|
84
|
-
if (cooldownMs() > 0)
|
|
85
|
-
return `cooling ${formatWait(cooldownMs())}`;
|
|
86
|
-
return props.account.current ? 'active' : 'idle';
|
|
87
|
-
};
|
|
88
|
-
const statusTone = () => {
|
|
89
|
-
if (!props.account.enabled)
|
|
90
|
-
return 'muted';
|
|
91
|
-
if (cooldownMs() > 0)
|
|
92
|
-
return 'warn';
|
|
93
|
-
return props.account.current ? 'ok' : 'muted';
|
|
94
|
-
};
|
|
95
|
-
return (_jsx(QuotaAccountBlock, { palette: themePalette(props.theme), appearance: props.appearance, account: props.account, status: statusWord(), statusTone: statusTone(), now: props.now, width: props.width, marginTop: props.marginTop }));
|
|
96
|
-
}
|
|
97
23
|
// Stored quota values are percentages and epoch-millisecond reset times.
|
|
98
24
|
// Adapt them to the shared projection so common-auth, not the renderer,
|
|
99
25
|
// decides how the narrow line reads.
|
|
@@ -135,110 +61,104 @@ export function sidebarQuotaProjection(account, now) {
|
|
|
135
61
|
})),
|
|
136
62
|
};
|
|
137
63
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
64
|
+
/** Preserve provider status and projection policy; the library owns all quota layout. */
|
|
65
|
+
function accountView(account, now, appearance) {
|
|
66
|
+
const cooldown = Math.max(0, (account.cooldownUntil ?? 0) - now);
|
|
67
|
+
const status = !account.enabled
|
|
68
|
+
? { text: 'off', tone: 'textMuted' }
|
|
69
|
+
: cooldown > 0
|
|
70
|
+
? { text: `cooling ${formatWait(cooldown)}`, tone: 'warning' }
|
|
71
|
+
: account.current
|
|
72
|
+
? { text: 'active', tone: 'success' }
|
|
73
|
+
: { text: 'idle', tone: 'textMuted' };
|
|
74
|
+
const quota = sidebarQuotaProjection(account, now);
|
|
75
|
+
const stale = isQuotaStale(quota, { now });
|
|
76
|
+
const remaining = quota?.limits.length
|
|
77
|
+
? Math.min(...quota.limits.map((limit) => limit.remainingPercent ?? 100))
|
|
78
|
+
: undefined;
|
|
79
|
+
const quotaColor = remaining === undefined
|
|
80
|
+
? 'textMuted'
|
|
81
|
+
: quotaTone(100 - remaining, appearance);
|
|
82
|
+
const blocked = !account.enabled || cooldown > 0;
|
|
83
|
+
const windows = accountWindows(account, now).filter(({ reading, text }) => typeof reading.checkedAt === 'number' &&
|
|
84
|
+
Number.isFinite(reading.checkedAt) &&
|
|
85
|
+
reading.checkedAt >= 0 &&
|
|
86
|
+
text.remaining !== null);
|
|
87
|
+
return {
|
|
88
|
+
id: account.id,
|
|
89
|
+
label: account.label,
|
|
90
|
+
status,
|
|
91
|
+
blocked,
|
|
92
|
+
indicatorTone: stale ? 'textMuted' : blocked ? 'error' : quotaColor,
|
|
93
|
+
quota,
|
|
94
|
+
collapsed: {
|
|
95
|
+
quotaTone: quotaColor,
|
|
96
|
+
muted: stale || status.text !== 'active',
|
|
97
|
+
},
|
|
98
|
+
emptyQuotaText: { expanded: NO_QUOTA_READING, collapsed: NO_QUOTA_READING },
|
|
99
|
+
groups: QUOTA_ORDER.flatMap((key) => {
|
|
100
|
+
const rows = windows
|
|
101
|
+
.filter((window) => window.key === key)
|
|
102
|
+
.map(({ reading, text }) => ({
|
|
103
|
+
part: {
|
|
104
|
+
kind: 'window',
|
|
105
|
+
name: text.name,
|
|
106
|
+
short: text.name,
|
|
107
|
+
figure: text.figure,
|
|
108
|
+
remainingPercent: text.remaining ?? undefined,
|
|
109
|
+
resetIn: text.reset || undefined,
|
|
110
|
+
checkedAt: reading.checkedAt ?? now,
|
|
111
|
+
resetSinceReading: text.resetSinceReading,
|
|
112
|
+
},
|
|
113
|
+
}));
|
|
114
|
+
return rows.length ? [{ title: GROUP_NAMES[key], rows }] : [];
|
|
115
|
+
}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function StatRow(props) {
|
|
119
|
+
return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().textMuted, children: props.label }), _jsx("text", { fg: props.theme()[props.tone ?? 'text'], children: _jsx("b", { children: props.value }) })] }));
|
|
185
120
|
}
|
|
186
|
-
|
|
187
|
-
// The opentui border prop is not typed in the plugin TUI surface.
|
|
188
|
-
const SINGLE_BORDER = { type: 'single' };
|
|
189
|
-
export function SidebarFrame(props) {
|
|
190
|
-
const theme = props.theme;
|
|
121
|
+
export function AntigravitySidebar(props) {
|
|
191
122
|
const prefs = props.settings;
|
|
192
|
-
const collapsed = props.collapsed;
|
|
193
123
|
const now = props.now;
|
|
194
124
|
const hasData = () => props.accounts().length > 0;
|
|
195
125
|
const backoffActive = () => {
|
|
196
126
|
const until = props.quotaBackoffUntil();
|
|
197
127
|
return typeof until === 'number' && until > now();
|
|
198
128
|
};
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
129
|
+
const visibleAccounts = createMemo(() => props
|
|
130
|
+
.accounts()
|
|
131
|
+
.filter((account) => prefs().sections.fallbackAccounts || account.current)
|
|
132
|
+
.map((account) => accountView(account, now(), prefs().appearance)));
|
|
133
|
+
const theme = () => {
|
|
134
|
+
const source = props.theme();
|
|
135
|
+
return {
|
|
136
|
+
...source,
|
|
137
|
+
textMuted: source.textMuted ?? source.text,
|
|
138
|
+
accent: source.accent ?? source.text,
|
|
139
|
+
success: source.success ?? source.accent ?? source.text,
|
|
140
|
+
warning: source.warning ?? source.accent ?? source.text,
|
|
141
|
+
error: source.error ?? source.accent ?? source.text,
|
|
142
|
+
};
|
|
209
143
|
};
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const routeLines = (route) => [`${route.family}: ${route.style}`, route.strategy ?? ''].filter((line) => line !== '');
|
|
214
|
-
// The width available to content: the header row spans the panel inside
|
|
215
|
-
// its border and padding. Layout reports it during a render pass, so the
|
|
216
|
-
// signal is updated afterwards rather than rebuilding rows mid-pass.
|
|
217
|
-
const [contentWidth, setContentWidth] = createSignal(ASSUMED_CONTENT_WIDTH);
|
|
218
|
-
let headerRow;
|
|
144
|
+
// Routing keeps whole parts on separate lines when the single stat row is too wide.
|
|
145
|
+
const [contentWidth, setContentWidth] = createSignal(28);
|
|
146
|
+
let sections;
|
|
219
147
|
const measureContentWidth = () => {
|
|
220
|
-
const width =
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
queueMicrotask(() => {
|
|
224
|
-
if (width !== contentWidth())
|
|
225
|
-
setContentWidth(width);
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
// Header badge: ▼/▶ {label}, with the version at the right when nothing is
|
|
229
|
-
// degraded and a `LIMITED` badge in its place when something is.
|
|
230
|
-
const headerLabel = () => {
|
|
231
|
-
const name = prefs().header.label;
|
|
232
|
-
return !hasData() ? name : collapsed() ? `\u25b6 ${name}` : `\u25bc ${name}`;
|
|
148
|
+
const width = sections?.width;
|
|
149
|
+
if (width && width !== contentWidth())
|
|
150
|
+
queueMicrotask(() => setContentWidth(width));
|
|
233
151
|
};
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
152
|
+
const routeValue = (route) => `${route.strategy ? `${route.strategy} · ` : ''}${route.family}: ${route.style}`;
|
|
153
|
+
const routeLines = (route) => [`${route.family}: ${route.style}`, route.strategy ?? ''].filter(Boolean);
|
|
154
|
+
return (_jsx(SidebarFrame, { header: {
|
|
155
|
+
badge: prefs().header.label,
|
|
156
|
+
version: prefs().header.showVersion && props.version
|
|
157
|
+
? `v${props.version}`
|
|
158
|
+
: undefined,
|
|
159
|
+
}, theme: theme(), appearance: prefs().appearance, accounts: visibleAccounts(), showQuota: prefs().sections.quota, now: now(), collapsed: props.collapsed(), onToggle: props.onToggleCollapsed, sections: () => (_jsx(Show, { when: !props.collapsed() || !hasData(), children: _jsx("box", { width: '100%', flexDirection: 'column', ref: (element) => {
|
|
160
|
+
sections = element;
|
|
161
|
+
}, onSizeChange: measureContentWidth, children: _jsxs(Show, { when: hasData(), fallback: _jsx("box", { marginTop: 1, width: '100%', children: _jsx(SidebarTextRow, { text: 'Waiting for quota\u2026', wrapMode: 'none' }) }), children: [_jsx(Show, { when: prefs().sections.quota && visibleAccounts().length === 0, children: _jsx(SidebarSection, { title: 'Quota' }) }), _jsx(Show, { when: prefs().sections.routing, children: _jsx(SidebarSection, { title: 'Routing', children: _jsx(Show, { when: props.route(), fallback: _jsx(SidebarTextRow, { text: 'No request yet', wrapMode: 'none' }), children: (route) => (_jsx(Show, { when: routeLineFits('Route', routeValue(route()), contentWidth()), fallback: _jsx(For, { each: routeLines(route()), children: (line) => (_jsx("text", { fg: theme().accent, wrapMode: 'none', children: _jsx("b", { children: line }) })) }), children: _jsx(StatRow, { theme: theme, label: 'Route', value: routeValue(route()), tone: 'accent' }) })) }) }) }), _jsx(Show, { when: (backoffActive() || !!props.lastError()) &&
|
|
162
|
+
prefs().sections.health, children: _jsxs(SidebarSection, { title: 'Health', children: [_jsx(Show, { when: backoffActive(), children: _jsx(StatRow, { theme: theme, label: 'Quota API', value: `backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`, tone: 'warning' }) }), _jsx(Show, { when: props.lastError(), children: _jsx(StatRow, { theme: theme, label: 'Last error', value: props.lastError() ?? '', tone: 'error' }) })] }) })] }) }) })) }));
|
|
243
163
|
}
|
|
244
164
|
//# sourceMappingURL=sidebar-frame.js.map
|