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