@cortexkit/opencode-antigravity-auth 3.0.20 → 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/dist/cli.js +75 -32
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +31 -11
- package/dist/index.js +75 -32
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +31 -11
- package/dist/server.js +75 -32
- package/dist/server.js.map +3 -3
- 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/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 +37 -17
- 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/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 +91 -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 +27 -13
- package/dist/tui-ga-build-map.json +28 -13
- 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/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 +37 -17
- 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 -466
- package/src/tui-compiled/tui.js +2 -2
- package/src/tui-ga-compiled/host-ga.js +2 -2
- package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +241 -466
- 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 -2
- package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +211 -399
- 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 +211 -399
- package/src/tui-raw/tui.tsx +2 -2
- package/src/tui.tsx +2 -2
|
@@ -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 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,
|
|
30
13
|
} from "./bf17cbee28e58197-index.js"
|
|
14
|
+
import {
|
|
15
|
+
type AccountView,
|
|
16
|
+
SidebarFrame,
|
|
17
|
+
SidebarSection,
|
|
18
|
+
SidebarTextRow,
|
|
19
|
+
type SidebarTheme,
|
|
20
|
+
type Tone,
|
|
21
|
+
} from "./e4ec36f367492969-index.tsx"
|
|
31
22
|
import { formatResetIn, formatWait } from "./8ae1927e5910ea81-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 "./dd4c9e1a907f8ef0-quota-layout.tsx"
|
|
46
32
|
import { routeLineFits } from "./6ca47cd4ec33fe72-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. */
|
|
@@ -68,40 +52,11 @@ export interface FrameTheme {
|
|
|
68
52
|
readonly error: FrameColor
|
|
69
53
|
}
|
|
70
54
|
|
|
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
55
|
// --- Frame inputs ----------------------------------------------------------
|
|
102
56
|
|
|
103
57
|
/** The account fields the frame reads: the quota layout's plus the state. */
|
|
104
58
|
export interface FrameAccount extends QuotaLayoutAccount {
|
|
59
|
+
readonly id: string
|
|
105
60
|
readonly enabled: boolean
|
|
106
61
|
readonly current: boolean
|
|
107
62
|
readonly cooldownUntil?: number
|
|
@@ -145,103 +100,6 @@ export const DEFAULT_FRAME_SETTINGS: FrameSettings = {
|
|
|
145
100
|
appearance: DEFAULT_QUOTA_APPEARANCE,
|
|
146
101
|
}
|
|
147
102
|
|
|
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
103
|
// Stored quota values are percentages and epoch-millisecond reset times.
|
|
246
104
|
// Adapt them to the shared projection so common-auth, not the renderer,
|
|
247
105
|
// decides how the narrow line reads.
|
|
@@ -289,82 +147,67 @@ export function sidebarQuotaProjection(
|
|
|
289
147
|
}
|
|
290
148
|
}
|
|
291
149
|
|
|
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
|
-
remaining === undefined
|
|
323
|
-
? 'muted'
|
|
324
|
-
: quotaTone(100 - remaining, props.appearance())
|
|
325
|
-
const stale = isQuotaStale(projection, { now: currentTime })
|
|
326
|
-
const dot = unavailable() ? ' ⊘' : ' ●'
|
|
327
|
-
const width = props.width()
|
|
328
|
-
// Keep a complete shared line or omit it; a partial quota can make an
|
|
329
|
-
// account look as if it has less remaining.
|
|
330
|
-
const showQuota = text.length <= width
|
|
331
|
-
const showDot =
|
|
332
|
-
dot.length <= width && (!showQuota || text.length + dot.length <= width)
|
|
333
|
-
const rightWidth =
|
|
334
|
-
(showQuota ? text.length : 0) + (showDot ? dot.length : 0)
|
|
335
|
-
const labelWidth = Math.max(0, width - rightWidth - 1)
|
|
336
|
-
return {
|
|
337
|
-
dot,
|
|
338
|
-
label: fitLabel(account.label, labelWidth),
|
|
339
|
-
showDot,
|
|
340
|
-
showQuota,
|
|
341
|
-
stale,
|
|
342
|
-
text,
|
|
343
|
-
tone,
|
|
344
|
-
}
|
|
345
|
-
})
|
|
346
|
-
const quotaColor = () =>
|
|
347
|
-
line().stale ? theme().textMuted : toneColor(theme(), line().tone)
|
|
348
|
-
const dotColor = () =>
|
|
349
|
-
line().stale
|
|
350
|
-
? theme().textMuted
|
|
351
|
-
: toneColor(theme(), unavailable() ? 'err' : line().tone)
|
|
352
|
-
return (
|
|
353
|
-
<CollapsedRow theme={theme} label={line().label}>
|
|
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>
|
|
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,
|
|
367
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
|
+
}
|
|
368
211
|
}
|
|
369
212
|
|
|
370
213
|
// --- Frame -----------------------------------------------------------------
|
|
@@ -386,196 +229,165 @@ export interface SidebarFrameProps {
|
|
|
386
229
|
readonly now: () => number
|
|
387
230
|
}
|
|
388
231
|
|
|
389
|
-
|
|
390
|
-
|
|
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 {
|
|
391
249
|
const prefs = props.settings
|
|
392
|
-
const collapsed = props.collapsed
|
|
393
250
|
const now = props.now
|
|
394
|
-
|
|
395
251
|
const hasData = () => props.accounts().length > 0
|
|
396
252
|
const backoffActive = () => {
|
|
397
253
|
const until = props.quotaBackoffUntil()
|
|
398
254
|
return typeof until === 'number' && until > now()
|
|
399
255
|
}
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
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
|
+
}
|
|
409
272
|
}
|
|
410
273
|
|
|
411
|
-
//
|
|
412
|
-
|
|
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
|
+
}
|
|
413
282
|
const routeValue = (route: FrameRoute): string =>
|
|
414
283
|
`${route.strategy ? `${route.strategy} · ` : ''}${route.family}: ${route.style}`
|
|
415
284
|
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
|
-
}
|
|
285
|
+
[`${route.family}: ${route.style}`, route.strategy ?? ''].filter(Boolean)
|
|
438
286
|
|
|
439
287
|
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' />
|
|
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()}>
|
|
305
|
+
<box
|
|
306
|
+
width='100%'
|
|
307
|
+
flexDirection='column'
|
|
308
|
+
ref={(element) => {
|
|
309
|
+
sections = element
|
|
310
|
+
}}
|
|
311
|
+
onSizeChange={measureContentWidth}
|
|
312
|
+
>
|
|
521
313
|
<Show
|
|
522
|
-
when={
|
|
314
|
+
when={hasData()}
|
|
523
315
|
fallback={
|
|
524
|
-
<
|
|
525
|
-
|
|
526
|
-
</
|
|
316
|
+
<box marginTop={1} width='100%'>
|
|
317
|
+
<SidebarTextRow text='Waiting for quota…' wrapMode='none' />
|
|
318
|
+
</box>
|
|
527
319
|
}
|
|
528
320
|
>
|
|
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
|
-
|
|
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>
|
|
554
387
|
</Show>
|
|
555
|
-
</
|
|
556
|
-
|
|
557
|
-
{/* Health — only when something is wrong AND sections.health is true */}
|
|
558
|
-
<Show when={degraded() && prefs().sections.health}>
|
|
559
|
-
<SectionHeader theme={theme} title='Health' />
|
|
560
|
-
<Show when={backoffActive()}>
|
|
561
|
-
<StatRow
|
|
562
|
-
theme={theme}
|
|
563
|
-
label='Quota API'
|
|
564
|
-
value={`backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`}
|
|
565
|
-
tone='warn'
|
|
566
|
-
/>
|
|
567
|
-
</Show>
|
|
568
|
-
<Show when={lastError()}>
|
|
569
|
-
<StatRow
|
|
570
|
-
theme={theme}
|
|
571
|
-
label='Last error'
|
|
572
|
-
value={lastError() ?? ''}
|
|
573
|
-
tone='err'
|
|
574
|
-
/>
|
|
575
|
-
</Show>
|
|
576
|
-
</Show>
|
|
388
|
+
</box>
|
|
577
389
|
</Show>
|
|
578
|
-
|
|
579
|
-
|
|
390
|
+
)}
|
|
391
|
+
/>
|
|
580
392
|
)
|
|
581
393
|
}
|