@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,52 +1,36 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* The Antigravity sidebar frame, shared by the OpenCode 1 sidebar (`tui.tsx`)
|
|
5
|
-
* and the OpenCode 2 sidebar (`ga/tui/host-ga.tsx`): the bordered, padded
|
|
6
|
-
* panel, the clickable `▼`/`▶` header badge with the plugin version (or a
|
|
7
|
-
* `LIMITED` badge) at the right, one line per account when collapsed, and the
|
|
8
|
-
* `Quota`, `Routing` and `Health` sections when expanded.
|
|
9
|
-
*
|
|
10
|
-
* Each renderer reads its own data source (the sidebar file, or the
|
|
11
|
-
* location's `state` answer), maps its own host theme onto `FrameTheme` and
|
|
12
|
-
* owns its own collapse state; everything drawn is decided here, so a change
|
|
13
|
-
* of shape is made once for both hosts.
|
|
14
|
-
*
|
|
15
|
-
* This module stays inside both TUI import graphs: besides Solid and
|
|
16
|
-
* OpenTUI it imports only the pure quota and sidebar-projection helpers and
|
|
17
|
-
* the shared layouts. No sidebar file, preferences file, RPC, account
|
|
18
|
-
* store, OAuth, token or host SDK module, no Node built-in, and nothing
|
|
19
|
-
* that writes to the terminal.
|
|
20
|
-
*/
|
|
3
|
+
/** Plugin-owned projection and Routing/Health sections for the shared quota frame. */
|
|
21
4
|
|
|
22
5
|
import type { RGBA } from "@opentui/core"
|
|
23
6
|
import { createMemo, createSignal, For, type JSX, Show } from "solid-js"
|
|
24
7
|
|
|
25
8
|
import {
|
|
26
|
-
formatQuota,
|
|
27
9
|
isQuotaStale,
|
|
10
|
+
NO_QUOTA_READING,
|
|
28
11
|
type ProjectedLimit,
|
|
29
12
|
type ProjectedQuota,
|
|
30
13
|
} from "../common-auth-embedded/quota/index.js"
|
|
14
|
+
import {
|
|
15
|
+
type AccountView,
|
|
16
|
+
SidebarFrame,
|
|
17
|
+
SidebarSection,
|
|
18
|
+
SidebarTextRow,
|
|
19
|
+
type SidebarTheme,
|
|
20
|
+
type Tone,
|
|
21
|
+
} from "../common-auth-embedded/quota-sidebar/index.tsx"
|
|
31
22
|
import { formatResetIn, formatWait } from "../sidebar-projection.js"
|
|
32
23
|
import {
|
|
33
|
-
ASSUMED_CONTENT_WIDTH,
|
|
34
24
|
accountWindows,
|
|
35
25
|
DEFAULT_QUOTA_APPEARANCE,
|
|
36
|
-
fitLabel,
|
|
37
26
|
GROUP_NAMES,
|
|
38
27
|
QUOTA_ORDER,
|
|
39
|
-
QuotaAccountBlock,
|
|
40
28
|
type QuotaAppearance,
|
|
41
29
|
type QuotaLayoutAccount,
|
|
42
|
-
type QuotaPalette,
|
|
43
|
-
type QuotaTone,
|
|
44
30
|
quotaTone,
|
|
45
31
|
} from "./quota-layout.tsx"
|
|
46
32
|
import { routeLineFits } from "./route-layout.js"
|
|
47
33
|
|
|
48
|
-
type Tone = QuotaTone
|
|
49
|
-
|
|
50
34
|
// --- Theme -----------------------------------------------------------------
|
|
51
35
|
|
|
52
36
|
/** A theme color; `undefined` leaves the host's default color in place. */
|
|
@@ -63,46 +47,16 @@ export interface FrameTheme {
|
|
|
63
47
|
readonly textMuted: FrameColor
|
|
64
48
|
readonly accent: FrameColor
|
|
65
49
|
readonly background: FrameColor
|
|
66
|
-
readonly borderActive: FrameColor
|
|
67
50
|
readonly success: FrameColor
|
|
68
51
|
readonly warning: FrameColor
|
|
69
52
|
readonly error: FrameColor
|
|
70
53
|
}
|
|
71
54
|
|
|
72
|
-
// Every tone falls through to a sibling token, so a sparse custom theme still
|
|
73
|
-
// renders readably.
|
|
74
|
-
export function toneColor(theme: FrameTheme, tone: Tone): FrameColor {
|
|
75
|
-
switch (tone) {
|
|
76
|
-
case 'ok':
|
|
77
|
-
return theme.success ?? theme.accent
|
|
78
|
-
case 'warn':
|
|
79
|
-
return theme.warning ?? theme.accent
|
|
80
|
-
case 'err':
|
|
81
|
-
return theme.error ?? theme.accent
|
|
82
|
-
case 'muted':
|
|
83
|
-
return theme.textMuted ?? theme.text
|
|
84
|
-
case 'accent':
|
|
85
|
-
return theme.accent ?? theme.text
|
|
86
|
-
default:
|
|
87
|
-
return theme.text
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// The shared quota layout reads its colors through this palette. Muted text
|
|
92
|
-
// and the account label read `textMuted` and `text` straight from the theme,
|
|
93
|
-
// without the `toneColor` fallback chain.
|
|
94
|
-
export function themePalette(theme: () => FrameTheme): QuotaPalette {
|
|
95
|
-
return {
|
|
96
|
-
text: () => theme().text,
|
|
97
|
-
muted: () => theme().textMuted,
|
|
98
|
-
tone: (tone) => toneColor(theme(), tone),
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
55
|
// --- Frame inputs ----------------------------------------------------------
|
|
103
56
|
|
|
104
57
|
/** The account fields the frame reads: the quota layout's plus the state. */
|
|
105
58
|
export interface FrameAccount extends QuotaLayoutAccount {
|
|
59
|
+
readonly id: string
|
|
106
60
|
readonly enabled: boolean
|
|
107
61
|
readonly current: boolean
|
|
108
62
|
readonly cooldownUntil?: number
|
|
@@ -146,103 +100,6 @@ export const DEFAULT_FRAME_SETTINGS: FrameSettings = {
|
|
|
146
100
|
appearance: DEFAULT_QUOTA_APPEARANCE,
|
|
147
101
|
}
|
|
148
102
|
|
|
149
|
-
// --- Rows ------------------------------------------------------------------
|
|
150
|
-
|
|
151
|
-
// Section header: bold title, themed text color, top margin for vertical
|
|
152
|
-
// breathing room between sections.
|
|
153
|
-
export function SectionHeader(props: {
|
|
154
|
-
theme: () => FrameTheme
|
|
155
|
-
title: string
|
|
156
|
-
}): JSX.Element {
|
|
157
|
-
return (
|
|
158
|
-
<box width='100%' marginTop={1}>
|
|
159
|
-
<text fg={toneColor(props.theme(), 'text')}>
|
|
160
|
-
<b>{props.title}</b>
|
|
161
|
-
</text>
|
|
162
|
-
</box>
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Muted label left, value (optionally tone-tinted, bold) right, for the
|
|
167
|
-
// routing and health rows.
|
|
168
|
-
export function StatRow(props: {
|
|
169
|
-
theme: () => FrameTheme
|
|
170
|
-
label: string
|
|
171
|
-
value: string
|
|
172
|
-
tone?: Tone
|
|
173
|
-
}): JSX.Element {
|
|
174
|
-
return (
|
|
175
|
-
<box width='100%' flexDirection='row' justifyContent='space-between'>
|
|
176
|
-
<text fg={props.theme().textMuted}>{props.label}</text>
|
|
177
|
-
<text fg={toneColor(props.theme(), props.tone ?? 'text')}>
|
|
178
|
-
<b>{props.value}</b>
|
|
179
|
-
</text>
|
|
180
|
-
</box>
|
|
181
|
-
)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Muted label left, caller-supplied value right. The collapsed view renders
|
|
185
|
-
// one row for every visible account. The caller sizes both sides to the
|
|
186
|
-
// measured width, so neither side may wrap.
|
|
187
|
-
function CollapsedRow(props: {
|
|
188
|
-
theme: () => FrameTheme
|
|
189
|
-
label: string
|
|
190
|
-
children: JSX.Element
|
|
191
|
-
}): JSX.Element {
|
|
192
|
-
return (
|
|
193
|
-
<box width='100%' flexDirection='row' justifyContent='space-between'>
|
|
194
|
-
<text flexShrink={0} wrapMode='none' fg={props.theme().textMuted}>
|
|
195
|
-
{props.label}
|
|
196
|
-
</text>
|
|
197
|
-
{props.children}
|
|
198
|
-
</box>
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// One account in the Quota section: the shared quota block, with the status
|
|
203
|
-
// word computed from the account state. Status word priorities (first match
|
|
204
|
-
// wins):
|
|
205
|
-
// - `off` when the account is disabled
|
|
206
|
-
// - `cooling <wait>` when cooldownUntil is still in the future
|
|
207
|
-
// - `active` when current === true
|
|
208
|
-
// - `idle` for the fallback (current === false) case
|
|
209
|
-
function AccountBlock(props: {
|
|
210
|
-
theme: () => FrameTheme
|
|
211
|
-
appearance: QuotaAppearance
|
|
212
|
-
account: FrameAccount
|
|
213
|
-
now: () => number
|
|
214
|
-
width: () => number
|
|
215
|
-
marginTop?: number
|
|
216
|
-
}): JSX.Element {
|
|
217
|
-
const cooldownMs = (): number => {
|
|
218
|
-
const cd = props.account.cooldownUntil
|
|
219
|
-
if (typeof cd !== 'number') return 0
|
|
220
|
-
return Math.max(0, cd - props.now())
|
|
221
|
-
}
|
|
222
|
-
const statusWord = (): string => {
|
|
223
|
-
if (!props.account.enabled) return 'off'
|
|
224
|
-
if (cooldownMs() > 0) return `cooling ${formatWait(cooldownMs())}`
|
|
225
|
-
return props.account.current ? 'active' : 'idle'
|
|
226
|
-
}
|
|
227
|
-
const statusTone = (): Tone => {
|
|
228
|
-
if (!props.account.enabled) return 'muted'
|
|
229
|
-
if (cooldownMs() > 0) return 'warn'
|
|
230
|
-
return props.account.current ? 'ok' : 'muted'
|
|
231
|
-
}
|
|
232
|
-
return (
|
|
233
|
-
<QuotaAccountBlock
|
|
234
|
-
palette={themePalette(props.theme)}
|
|
235
|
-
appearance={props.appearance}
|
|
236
|
-
account={props.account}
|
|
237
|
-
status={statusWord()}
|
|
238
|
-
statusTone={statusTone()}
|
|
239
|
-
now={props.now}
|
|
240
|
-
width={props.width}
|
|
241
|
-
marginTop={props.marginTop}
|
|
242
|
-
/>
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
|
|
246
103
|
// Stored quota values are percentages and epoch-millisecond reset times.
|
|
247
104
|
// Adapt them to the shared projection so common-auth, not the renderer,
|
|
248
105
|
// decides how the narrow line reads.
|
|
@@ -290,89 +147,71 @@ export function sidebarQuotaProjection(
|
|
|
290
147
|
}
|
|
291
148
|
}
|
|
292
149
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
remaining === undefined
|
|
324
|
-
? 'muted'
|
|
325
|
-
: quotaTone(100 - remaining, props.appearance())
|
|
326
|
-
const stale = isQuotaStale(projection, { now: currentTime })
|
|
327
|
-
const dot = unavailable() ? ' ⊘' : ' ●'
|
|
328
|
-
const width = props.width()
|
|
329
|
-
// Keep a complete shared line or omit it; a partial quota can make an
|
|
330
|
-
// account look as if it has less remaining.
|
|
331
|
-
const showQuota = text.length <= width
|
|
332
|
-
const showDot =
|
|
333
|
-
dot.length <= width && (!showQuota || text.length + dot.length <= width)
|
|
334
|
-
const rightWidth =
|
|
335
|
-
(showQuota ? text.length : 0) + (showDot ? dot.length : 0)
|
|
336
|
-
const labelWidth = Math.max(0, width - rightWidth - 1)
|
|
337
|
-
return {
|
|
338
|
-
dot,
|
|
339
|
-
label: fitLabel(account.label, labelWidth),
|
|
340
|
-
showDot,
|
|
341
|
-
showQuota,
|
|
342
|
-
stale,
|
|
343
|
-
text,
|
|
344
|
-
tone,
|
|
345
|
-
}
|
|
346
|
-
})
|
|
347
|
-
const quotaColor = () =>
|
|
348
|
-
line().stale ? theme().textMuted : toneColor(theme(), line().tone)
|
|
349
|
-
const dotColor = () =>
|
|
350
|
-
line().stale
|
|
351
|
-
? theme().textMuted
|
|
352
|
-
: toneColor(theme(), unavailable() ? 'err' : line().tone)
|
|
353
|
-
return (
|
|
354
|
-
<CollapsedRow theme={theme} label={line().label}>
|
|
355
|
-
<box flexDirection='row' flexShrink={0}>
|
|
356
|
-
<Show when={line().showQuota}>
|
|
357
|
-
<text flexShrink={0} wrapMode='none' fg={quotaColor()}>
|
|
358
|
-
<b>{line().text}</b>
|
|
359
|
-
</text>
|
|
360
|
-
</Show>
|
|
361
|
-
<Show when={line().showDot}>
|
|
362
|
-
<text flexShrink={0} wrapMode='none' fg={dotColor()}>
|
|
363
|
-
{line().dot}
|
|
364
|
-
</text>
|
|
365
|
-
</Show>
|
|
366
|
-
</box>
|
|
367
|
-
</CollapsedRow>
|
|
150
|
+
/** Preserve provider status and projection policy; the library owns all quota layout. */
|
|
151
|
+
function accountView(
|
|
152
|
+
account: FrameAccount,
|
|
153
|
+
now: number,
|
|
154
|
+
appearance: QuotaAppearance,
|
|
155
|
+
): AccountView {
|
|
156
|
+
const cooldown = Math.max(0, (account.cooldownUntil ?? 0) - now)
|
|
157
|
+
const status: AccountView['status'] = !account.enabled
|
|
158
|
+
? { text: 'off', tone: 'textMuted' }
|
|
159
|
+
: cooldown > 0
|
|
160
|
+
? { text: `cooling ${formatWait(cooldown)}`, tone: 'warning' }
|
|
161
|
+
: account.current
|
|
162
|
+
? { text: 'active', tone: 'success' }
|
|
163
|
+
: { text: 'idle', tone: 'textMuted' }
|
|
164
|
+
const quota = sidebarQuotaProjection(account, now)
|
|
165
|
+
const stale = isQuotaStale(quota, { now })
|
|
166
|
+
const remaining = quota?.limits.length
|
|
167
|
+
? Math.min(...quota.limits.map((limit) => limit.remainingPercent ?? 100))
|
|
168
|
+
: undefined
|
|
169
|
+
const quotaColor =
|
|
170
|
+
remaining === undefined
|
|
171
|
+
? 'textMuted'
|
|
172
|
+
: quotaTone(100 - remaining, appearance)
|
|
173
|
+
const blocked = !account.enabled || cooldown > 0
|
|
174
|
+
const windows = accountWindows(account, now).filter(
|
|
175
|
+
({ reading, text }) =>
|
|
176
|
+
typeof reading.checkedAt === 'number' &&
|
|
177
|
+
Number.isFinite(reading.checkedAt) &&
|
|
178
|
+
reading.checkedAt >= 0 &&
|
|
179
|
+
text.remaining !== null,
|
|
368
180
|
)
|
|
181
|
+
return {
|
|
182
|
+
id: account.id,
|
|
183
|
+
label: account.label,
|
|
184
|
+
status,
|
|
185
|
+
blocked,
|
|
186
|
+
indicatorTone: stale ? 'textMuted' : blocked ? 'error' : quotaColor,
|
|
187
|
+
quota,
|
|
188
|
+
collapsed: {
|
|
189
|
+
quotaTone: quotaColor,
|
|
190
|
+
muted: stale || status.text !== 'active',
|
|
191
|
+
},
|
|
192
|
+
emptyQuotaText: { expanded: NO_QUOTA_READING, collapsed: NO_QUOTA_READING },
|
|
193
|
+
groups: QUOTA_ORDER.flatMap((key) => {
|
|
194
|
+
const rows = windows
|
|
195
|
+
.filter((window) => window.key === key)
|
|
196
|
+
.map(({ reading, text }) => ({
|
|
197
|
+
part: {
|
|
198
|
+
kind: 'window' as const,
|
|
199
|
+
name: text.name,
|
|
200
|
+
short: text.name,
|
|
201
|
+
figure: text.figure,
|
|
202
|
+
remainingPercent: text.remaining ?? undefined,
|
|
203
|
+
resetIn: text.reset || undefined,
|
|
204
|
+
checkedAt: reading.checkedAt ?? now,
|
|
205
|
+
resetSinceReading: text.resetSinceReading,
|
|
206
|
+
},
|
|
207
|
+
}))
|
|
208
|
+
return rows.length ? [{ title: GROUP_NAMES[key], rows }] : []
|
|
209
|
+
}),
|
|
210
|
+
}
|
|
369
211
|
}
|
|
370
212
|
|
|
371
213
|
// --- Frame -----------------------------------------------------------------
|
|
372
214
|
|
|
373
|
-
// The opentui border prop is not typed in the plugin TUI surface.
|
|
374
|
-
const SINGLE_BORDER = { type: 'single' } as any
|
|
375
|
-
|
|
376
215
|
export interface SidebarFrameProps {
|
|
377
216
|
readonly theme: () => FrameTheme
|
|
378
217
|
readonly settings: () => FrameSettings
|
|
@@ -390,214 +229,165 @@ export interface SidebarFrameProps {
|
|
|
390
229
|
readonly now: () => number
|
|
391
230
|
}
|
|
392
231
|
|
|
393
|
-
|
|
394
|
-
|
|
232
|
+
function StatRow(props: {
|
|
233
|
+
theme: () => SidebarTheme
|
|
234
|
+
label: string
|
|
235
|
+
value: string
|
|
236
|
+
tone?: Tone
|
|
237
|
+
}): JSX.Element {
|
|
238
|
+
return (
|
|
239
|
+
<box width='100%' flexDirection='row' justifyContent='space-between'>
|
|
240
|
+
<text fg={props.theme().textMuted}>{props.label}</text>
|
|
241
|
+
<text fg={props.theme()[props.tone ?? 'text']}>
|
|
242
|
+
<b>{props.value}</b>
|
|
243
|
+
</text>
|
|
244
|
+
</box>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function AntigravitySidebar(props: SidebarFrameProps): JSX.Element {
|
|
395
249
|
const prefs = props.settings
|
|
396
|
-
const collapsed = props.collapsed
|
|
397
250
|
const now = props.now
|
|
398
|
-
|
|
399
251
|
const hasData = () => props.accounts().length > 0
|
|
400
252
|
const backoffActive = () => {
|
|
401
253
|
const until = props.quotaBackoffUntil()
|
|
402
254
|
return typeof until === 'number' && until > now()
|
|
403
255
|
}
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return
|
|
256
|
+
const visibleAccounts = createMemo(() =>
|
|
257
|
+
props
|
|
258
|
+
.accounts()
|
|
259
|
+
.filter((account) => prefs().sections.fallbackAccounts || account.current)
|
|
260
|
+
.map((account) => accountView(account, now(), prefs().appearance)),
|
|
261
|
+
)
|
|
262
|
+
const theme = (): SidebarTheme => {
|
|
263
|
+
const source = props.theme()
|
|
264
|
+
return {
|
|
265
|
+
...source,
|
|
266
|
+
textMuted: source.textMuted ?? source.text,
|
|
267
|
+
accent: source.accent ?? source.text,
|
|
268
|
+
success: source.success ?? source.accent ?? source.text,
|
|
269
|
+
warning: source.warning ?? source.accent ?? source.text,
|
|
270
|
+
error: source.error ?? source.accent ?? source.text,
|
|
271
|
+
}
|
|
413
272
|
}
|
|
414
273
|
|
|
415
|
-
//
|
|
416
|
-
|
|
274
|
+
// Routing keeps whole parts on separate lines when the single stat row is too wide.
|
|
275
|
+
const [contentWidth, setContentWidth] = createSignal(28)
|
|
276
|
+
let sections: { width: number } | undefined
|
|
277
|
+
const measureContentWidth = () => {
|
|
278
|
+
const width = sections?.width
|
|
279
|
+
if (width && width !== contentWidth())
|
|
280
|
+
queueMicrotask(() => setContentWidth(width))
|
|
281
|
+
}
|
|
417
282
|
const routeValue = (route: FrameRoute): string =>
|
|
418
283
|
`${route.strategy ? `${route.strategy} · ` : ''}${route.family}: ${route.style}`
|
|
419
284
|
const routeLines = (route: FrameRoute): string[] =>
|
|
420
|
-
[`${route.family}: ${route.style}`, route.strategy ?? ''].filter(
|
|
421
|
-
(line) => line !== '',
|
|
422
|
-
)
|
|
423
|
-
|
|
424
|
-
// The width available to content: the header row spans the panel inside
|
|
425
|
-
// its border and padding. Layout reports it during a render pass, so the
|
|
426
|
-
// signal is updated afterwards rather than rebuilding rows mid-pass.
|
|
427
|
-
const [contentWidth, setContentWidth] = createSignal(ASSUMED_CONTENT_WIDTH)
|
|
428
|
-
let headerRow: { width: number } | undefined
|
|
429
|
-
const measureContentWidth = (): void => {
|
|
430
|
-
const width = headerRow?.width
|
|
431
|
-
if (typeof width !== 'number' || width <= 0) return
|
|
432
|
-
queueMicrotask(() => {
|
|
433
|
-
if (width !== contentWidth()) setContentWidth(width)
|
|
434
|
-
})
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// Header badge: ▼/▶ {label}, with the version at the right when nothing is
|
|
438
|
-
// degraded and a `LIMITED` badge in its place when something is.
|
|
439
|
-
const headerLabel = () => {
|
|
440
|
-
const name = prefs().header.label
|
|
441
|
-
return !hasData() ? name : collapsed() ? `\u25b6 ${name}` : `\u25bc ${name}`
|
|
442
|
-
}
|
|
285
|
+
[`${route.family}: ${route.style}`, route.strategy ?? ''].filter(Boolean)
|
|
443
286
|
|
|
444
287
|
return (
|
|
445
|
-
<
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
{
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
flexDirection='row'
|
|
463
|
-
justifyContent='space-between'
|
|
464
|
-
alignItems='center'
|
|
465
|
-
onMouseDown={() => {
|
|
466
|
-
// Only toggle when there is data to expand into. Without this a
|
|
467
|
-
// click on the empty-awaiting header would just toggle the
|
|
468
|
-
// affordance for nothing.
|
|
469
|
-
if (hasData()) props.onToggleCollapsed()
|
|
470
|
-
}}
|
|
471
|
-
>
|
|
472
|
-
<box paddingLeft={1} paddingRight={1} backgroundColor={theme().accent}>
|
|
473
|
-
<text fg={theme().background}>
|
|
474
|
-
<b>{headerLabel()}</b>
|
|
475
|
-
</text>
|
|
476
|
-
</box>
|
|
477
|
-
<Show
|
|
478
|
-
when={degraded()}
|
|
479
|
-
fallback={
|
|
480
|
-
<Show when={prefs().header.showVersion && props.version !== ''}>
|
|
481
|
-
<text fg={theme().textMuted}>{`v${props.version}`}</text>
|
|
482
|
-
</Show>
|
|
483
|
-
}
|
|
484
|
-
>
|
|
288
|
+
<SidebarFrame
|
|
289
|
+
header={{
|
|
290
|
+
badge: prefs().header.label,
|
|
291
|
+
version:
|
|
292
|
+
prefs().header.showVersion && props.version
|
|
293
|
+
? `v${props.version}`
|
|
294
|
+
: undefined,
|
|
295
|
+
}}
|
|
296
|
+
theme={theme()}
|
|
297
|
+
appearance={prefs().appearance}
|
|
298
|
+
accounts={visibleAccounts()}
|
|
299
|
+
showQuota={prefs().sections.quota}
|
|
300
|
+
now={now()}
|
|
301
|
+
collapsed={props.collapsed()}
|
|
302
|
+
onToggle={props.onToggleCollapsed}
|
|
303
|
+
sections={() => (
|
|
304
|
+
<Show when={!props.collapsed() || !hasData()}>
|
|
485
305
|
<box
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
306
|
+
width='100%'
|
|
307
|
+
flexDirection='column'
|
|
308
|
+
ref={(element) => {
|
|
309
|
+
sections = element
|
|
310
|
+
}}
|
|
311
|
+
onSizeChange={measureContentWidth}
|
|
489
312
|
>
|
|
490
|
-
<text fg={theme().background}>
|
|
491
|
-
<b>{'LIMITED'}</b>
|
|
492
|
-
</text>
|
|
493
|
-
</box>
|
|
494
|
-
</Show>
|
|
495
|
-
</box>
|
|
496
|
-
|
|
497
|
-
{/* Collapsed: one measured, non-wrapping row for each visible account. */}
|
|
498
|
-
<Show when={collapsed() && hasData()}>
|
|
499
|
-
<For each={visibleAccounts()}>
|
|
500
|
-
{(account) => (
|
|
501
|
-
<CollapsedAccount
|
|
502
|
-
theme={theme}
|
|
503
|
-
appearance={() => prefs().appearance}
|
|
504
|
-
account={account}
|
|
505
|
-
now={now}
|
|
506
|
-
width={contentWidth}
|
|
507
|
-
/>
|
|
508
|
-
)}
|
|
509
|
-
</For>
|
|
510
|
-
</Show>
|
|
511
|
-
|
|
512
|
-
{/* Expanded: full sections. Also render when there's no data so the
|
|
513
|
-
sidebar can never go blank if data clears while collapsed. */}
|
|
514
|
-
<Show when={!collapsed() || !hasData()}>
|
|
515
|
-
<Show
|
|
516
|
-
when={hasData()}
|
|
517
|
-
fallback={
|
|
518
|
-
<box marginTop={1} width='100%'>
|
|
519
|
-
<text fg={theme().textMuted}>{'Waiting for quota\u2026'}</text>
|
|
520
|
-
</box>
|
|
521
|
-
}
|
|
522
|
-
>
|
|
523
|
-
{/* Quota */}
|
|
524
|
-
<Show when={prefs().sections.quota}>
|
|
525
|
-
<SectionHeader theme={theme} title='Quota' />
|
|
526
|
-
<For each={visibleAccounts()}>
|
|
527
|
-
{(account, index) => (
|
|
528
|
-
<AccountBlock
|
|
529
|
-
theme={theme}
|
|
530
|
-
appearance={prefs().appearance}
|
|
531
|
-
account={account}
|
|
532
|
-
now={now}
|
|
533
|
-
width={contentWidth}
|
|
534
|
-
marginTop={index() === 0 ? 0 : 1}
|
|
535
|
-
/>
|
|
536
|
-
)}
|
|
537
|
-
</For>
|
|
538
|
-
</Show>
|
|
539
|
-
|
|
540
|
-
{/* Routing: the session's route, or one dim line before its first request. */}
|
|
541
|
-
<Show when={prefs().sections.routing}>
|
|
542
|
-
<SectionHeader theme={theme} title='Routing' />
|
|
543
313
|
<Show
|
|
544
|
-
when={
|
|
314
|
+
when={hasData()}
|
|
545
315
|
fallback={
|
|
546
|
-
<
|
|
547
|
-
|
|
548
|
-
</
|
|
316
|
+
<box marginTop={1} width='100%'>
|
|
317
|
+
<SidebarTextRow text='Waiting for quota…' wrapMode='none' />
|
|
318
|
+
</box>
|
|
549
319
|
}
|
|
550
320
|
>
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
321
|
+
<Show
|
|
322
|
+
when={prefs().sections.quota && visibleAccounts().length === 0}
|
|
323
|
+
>
|
|
324
|
+
<SidebarSection title='Quota' />
|
|
325
|
+
</Show>
|
|
326
|
+
<Show when={prefs().sections.routing}>
|
|
327
|
+
<SidebarSection title='Routing'>
|
|
328
|
+
<Show
|
|
329
|
+
when={props.route()}
|
|
330
|
+
fallback={
|
|
331
|
+
<SidebarTextRow text='No request yet' wrapMode='none' />
|
|
332
|
+
}
|
|
333
|
+
>
|
|
334
|
+
{(route) => (
|
|
335
|
+
<Show
|
|
336
|
+
when={routeLineFits(
|
|
337
|
+
'Route',
|
|
338
|
+
routeValue(route()),
|
|
339
|
+
contentWidth(),
|
|
340
|
+
)}
|
|
341
|
+
fallback={
|
|
342
|
+
<For each={routeLines(route())}>
|
|
343
|
+
{(line) => (
|
|
344
|
+
<text fg={theme().accent} wrapMode='none'>
|
|
345
|
+
<b>{line}</b>
|
|
346
|
+
</text>
|
|
347
|
+
)}
|
|
348
|
+
</For>
|
|
349
|
+
}
|
|
350
|
+
>
|
|
351
|
+
<StatRow
|
|
352
|
+
theme={theme}
|
|
353
|
+
label='Route'
|
|
354
|
+
value={routeValue(route())}
|
|
355
|
+
tone='accent'
|
|
356
|
+
/>
|
|
357
|
+
</Show>
|
|
358
|
+
)}
|
|
359
|
+
</Show>
|
|
360
|
+
</SidebarSection>
|
|
361
|
+
</Show>
|
|
362
|
+
<Show
|
|
363
|
+
when={
|
|
364
|
+
(backoffActive() || !!props.lastError()) &&
|
|
365
|
+
prefs().sections.health
|
|
366
|
+
}
|
|
367
|
+
>
|
|
368
|
+
<SidebarSection title='Health'>
|
|
369
|
+
<Show when={backoffActive()}>
|
|
370
|
+
<StatRow
|
|
371
|
+
theme={theme}
|
|
372
|
+
label='Quota API'
|
|
373
|
+
value={`backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`}
|
|
374
|
+
tone='warning'
|
|
375
|
+
/>
|
|
376
|
+
</Show>
|
|
377
|
+
<Show when={props.lastError()}>
|
|
378
|
+
<StatRow
|
|
379
|
+
theme={theme}
|
|
380
|
+
label='Last error'
|
|
381
|
+
value={props.lastError() ?? ''}
|
|
382
|
+
tone='error'
|
|
383
|
+
/>
|
|
384
|
+
</Show>
|
|
385
|
+
</SidebarSection>
|
|
386
|
+
</Show>
|
|
576
387
|
</Show>
|
|
577
|
-
</
|
|
578
|
-
|
|
579
|
-
{/* Health — only when something is wrong AND sections.health is true */}
|
|
580
|
-
<Show when={degraded() && prefs().sections.health}>
|
|
581
|
-
<SectionHeader theme={theme} title='Health' />
|
|
582
|
-
<Show when={backoffActive()}>
|
|
583
|
-
<StatRow
|
|
584
|
-
theme={theme}
|
|
585
|
-
label='Quota API'
|
|
586
|
-
value={`backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`}
|
|
587
|
-
tone='warn'
|
|
588
|
-
/>
|
|
589
|
-
</Show>
|
|
590
|
-
<Show when={lastError()}>
|
|
591
|
-
<StatRow
|
|
592
|
-
theme={theme}
|
|
593
|
-
label='Last error'
|
|
594
|
-
value={lastError() ?? ''}
|
|
595
|
-
tone='err'
|
|
596
|
-
/>
|
|
597
|
-
</Show>
|
|
598
|
-
</Show>
|
|
388
|
+
</box>
|
|
599
389
|
</Show>
|
|
600
|
-
|
|
601
|
-
|
|
390
|
+
)}
|
|
391
|
+
/>
|
|
602
392
|
)
|
|
603
393
|
}
|