pantheon-opencode 1.6.2-beta.1 → 1.6.2-beta.2
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/CHANGELOG.md +13 -0
- package/README.md +23 -14
- package/README.pt-BR.md +12 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/src/pantheon/cost-command.ts +30 -133
- package/src/pantheon/model-pricing.ts +1 -536
- package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +749 -0
- package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +1 -0
- package/src/plugins/tui/dist/quota-adapters.d.ts.map +1 -1
- package/src/plugins/tui/dist/quota-adapters.js +1 -1
- package/src/plugins/tui/dist/{quota-rpc-UL2HuFRJ.js → quota-rpc-DMmXBhBe.js} +295 -1
- package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +1 -0
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/server-v2.js +135 -12
- package/src/plugins/tui/dist/server-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui-v2.d.ts +132 -5
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +3720 -337
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +118 -0
- package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +1 -0
- package/src/plugins/tui/dist/usage-history-worker.js +25 -0
- package/src/plugins/tui/dist/usage-history-worker.js.map +1 -0
- package/src/plugins/tui/package-lock.json +17 -2
- package/src/plugins/tui/package.json +4 -2
- package/src/plugins/tui/src/cost-data.ts +607 -0
- package/src/plugins/tui/src/index-v2.tsx +32 -0
- package/src/plugins/tui/src/model-pricing.ts +536 -0
- package/src/plugins/tui/src/quota-rpc.ts +164 -0
- package/src/plugins/tui/src/quota-v2-model.ts +2 -2
- package/src/plugins/tui/src/quota-v2.tsx +338 -86
- package/src/plugins/tui/src/server-v2.ts +159 -15
- package/src/plugins/tui/src/usage-history-contract.ts +217 -0
- package/src/plugins/tui/src/usage-history-validation.ts +104 -0
- package/src/plugins/tui/src/usage-history-view.tsx +236 -0
- package/src/plugins/tui/src/usage-history-worker.ts +25 -0
- package/src/plugins/tui/src/usage-view-model.ts +272 -0
- package/src/plugins/tui/tsconfig.typecheck.json +6 -1
- package/src/plugins/tui/tsdown.config.ts +36 -4
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js.map +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
// biome-ignore-all lint/a11y/noStaticElementInteractions: OpenTUI has no DOM roles; mouse controls have keyboard equivalents.
|
|
2
3
|
|
|
3
4
|
import type { Context, KeymapCommand, KeymapLayer, PanelInput } from '@opencode/plugin/tui/context'
|
|
5
|
+
import { icon } from '@profullstack/hqtui'
|
|
4
6
|
import { createMemo, createSignal, For, type JSX, onCleanup, onMount, Show } from 'solid-js'
|
|
5
7
|
import {
|
|
6
8
|
contextBar,
|
|
7
9
|
contextUsageTone,
|
|
8
10
|
formatContextWindow,
|
|
9
|
-
formatSpent,
|
|
10
11
|
formatTokenCount,
|
|
11
12
|
} from './context-gauge'
|
|
12
13
|
import { quotaGoCheckCommand } from './go-key-diagnostic-ui'
|
|
@@ -28,10 +29,33 @@ import {
|
|
|
28
29
|
resolveActiveModelRef,
|
|
29
30
|
} from './quota-v2-model'
|
|
30
31
|
import { cellWidth, SIDEBAR_CONTENT_WIDTH } from './sidebar-width'
|
|
32
|
+
import { ActiveContextEstimate, UsageHistorySection } from './usage-history-view'
|
|
33
|
+
import { activeModelIdentity, sessionSpendLabel } from './usage-view-model'
|
|
31
34
|
|
|
32
35
|
export const QUOTA_PANEL_NAME = 'pantheon.quota'
|
|
33
36
|
export const QUOTA_OPEN_COMMAND_ID = 'pantheon.quota.open'
|
|
34
|
-
export
|
|
37
|
+
export type QuotaIconMode = 'nerd' | 'unicode' | 'ascii'
|
|
38
|
+
export type QuotaIconName =
|
|
39
|
+
| 'check'
|
|
40
|
+
| 'close'
|
|
41
|
+
| 'clock'
|
|
42
|
+
| 'gauge'
|
|
43
|
+
| 'plug'
|
|
44
|
+
| 'refresh'
|
|
45
|
+
| 'settings'
|
|
46
|
+
| 'sliders'
|
|
47
|
+
| 'warning'
|
|
48
|
+
|
|
49
|
+
export function quotaIcon(name: QuotaIconName, mode?: QuotaIconMode): string {
|
|
50
|
+
return icon(name, mode ? { mode } : undefined)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function iconInSlot(name: QuotaIconName, width: number, mode?: QuotaIconMode): string {
|
|
54
|
+
const glyph = quotaIcon(name, mode)
|
|
55
|
+
return `${glyph}${' '.repeat(Math.max(0, width - cellWidth(glyph)))}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const QUOTA_ICON = quotaIcon('refresh')
|
|
35
59
|
const QUOTA_PANEL_TOAST = 'Abra uma sessão para ver os detalhes da quota.'
|
|
36
60
|
|
|
37
61
|
type QuotaSurfaceProps = { context: Context; runtime: QuotaRuntime }
|
|
@@ -79,9 +103,9 @@ export function snapshotSummary(snapshot: QuotaSnapshot, display: 'used' | 'rema
|
|
|
79
103
|
const metric = metrics.find((item) => item.kind !== 'provider_status') ?? metrics[0]
|
|
80
104
|
if (metric) {
|
|
81
105
|
const value = compactQuotaMetric(metric, display) ?? 'quota indisponível'
|
|
82
|
-
return snapshot.status === 'partial' ? `
|
|
106
|
+
return snapshot.status === 'partial' ? `quota parcialmente disponível · ${value}` : value
|
|
83
107
|
}
|
|
84
|
-
if (snapshot.status === 'partial') return '
|
|
108
|
+
if (snapshot.status === 'partial') return 'quota parcialmente disponível'
|
|
85
109
|
if (snapshot.providers[0]?.message) return snapshot.providers[0].message
|
|
86
110
|
return 'quota indisponível'
|
|
87
111
|
}
|
|
@@ -299,11 +323,6 @@ export function quotaWindowLines(
|
|
|
299
323
|
const compact = ` ${title} ${value}`
|
|
300
324
|
const prefix = cellWidth(padded) <= width ? padded : compact
|
|
301
325
|
const suffix = reset ? ` ${reset}` : ''
|
|
302
|
-
const rawBar =
|
|
303
|
-
progress && (sidebarPercent || metric.unit.trim() === '%')
|
|
304
|
-
? contextBar(progress.usedPercent, 4)
|
|
305
|
-
: undefined
|
|
306
|
-
const bar = rawBar ? { ...rawBar, empty: '░'.repeat(cellWidth(rawBar.empty)) } : undefined
|
|
307
326
|
const secondaryAmount = sidebarPercent
|
|
308
327
|
? undefined
|
|
309
328
|
: quotaAmount(display === 'remaining' ? metric.used : metric.remaining, metric.unit)
|
|
@@ -317,9 +336,6 @@ export function quotaWindowLines(
|
|
|
317
336
|
if (!sidebarPercent && progress) {
|
|
318
337
|
secondary.push(...quotaTextLines(`${progress.remainingPercent}% restante`, width, 4))
|
|
319
338
|
}
|
|
320
|
-
if (bar && cellWidth(prefix + suffix) + 5 <= width) {
|
|
321
|
-
return [`${prefix} ${bar.filled}${bar.empty}${suffix}`, ...resetDateLines, ...secondary]
|
|
322
|
-
}
|
|
323
339
|
if (cellWidth(prefix + suffix) <= width)
|
|
324
340
|
return [`${prefix}${suffix}`, ...resetDateLines, ...secondary]
|
|
325
341
|
if (cellWidth(prefix) <= width)
|
|
@@ -429,13 +445,23 @@ function QuotaMetricLine(props: {
|
|
|
429
445
|
)
|
|
430
446
|
}
|
|
431
447
|
|
|
432
|
-
function providerState(
|
|
448
|
+
export function providerState(
|
|
449
|
+
provider: QuotaProviderDetail,
|
|
450
|
+
mode?: QuotaIconMode,
|
|
451
|
+
): { label: string; tone: QuotaTone } {
|
|
433
452
|
if (provider.authentication === 'not_connected')
|
|
434
|
-
return { label: '
|
|
435
|
-
if (provider.authentication === 'unavailable')
|
|
453
|
+
return { label: `${iconInSlot('settings', 2, mode)} Precisa configurar`, tone: 'warning' }
|
|
454
|
+
if (provider.authentication === 'unavailable')
|
|
455
|
+
return { label: `${iconInSlot('close', 2, mode)} Indisponível`, tone: 'error' }
|
|
436
456
|
return provider.state === 'available'
|
|
437
|
-
? {
|
|
438
|
-
|
|
457
|
+
? {
|
|
458
|
+
label: `${iconInSlot('check', 2, mode)} Credencial local · há dados`,
|
|
459
|
+
tone: 'success',
|
|
460
|
+
}
|
|
461
|
+
: {
|
|
462
|
+
label: `${iconInSlot('warning', 2, mode)} Credencial local · sem dados`,
|
|
463
|
+
tone: 'warning',
|
|
464
|
+
}
|
|
439
465
|
}
|
|
440
466
|
|
|
441
467
|
function recentModelUsage(context: Context, sessionID: string): RecentModelUsageRow[] {
|
|
@@ -544,18 +570,29 @@ function recentModelUsage(context: Context, sessionID: string): RecentModelUsage
|
|
|
544
570
|
})
|
|
545
571
|
}
|
|
546
572
|
|
|
547
|
-
function
|
|
573
|
+
export function activeQuotaModelLabel(row: RecentModelUsageRow | undefined): string {
|
|
574
|
+
return row ? `Modelo ativo · ${activeModelIdentity(row)}` : 'Modelo ativo indisponível'
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export function quotaPanelStatusMessage(
|
|
578
|
+
snapshot: Pick<QuotaSnapshot, 'status' | 'error'>,
|
|
579
|
+
): string | undefined {
|
|
580
|
+
if (snapshot.status === 'partial') return 'Dados parciais'
|
|
581
|
+
if (snapshot.status === 'ready') return undefined
|
|
582
|
+
return quotaSnapshotStatusLabel(snapshot.status, snapshot.error)
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function useRecentModelUsage(context: Context, sessionID: string): () => RecentModelUsageRow[] {
|
|
548
586
|
const [revision, setRevision] = createSignal(0)
|
|
549
587
|
const rows = createMemo(() => {
|
|
550
588
|
revision()
|
|
551
|
-
return recentModelUsage(
|
|
589
|
+
return recentModelUsage(context, sessionID)
|
|
552
590
|
})
|
|
553
|
-
|
|
554
591
|
onMount(() => {
|
|
555
592
|
const unsubscribe: Array<() => void> = []
|
|
556
593
|
for (const event of MODEL_USAGE_REFRESH_EVENTS) {
|
|
557
594
|
try {
|
|
558
|
-
unsubscribe.push(
|
|
595
|
+
unsubscribe.push(context.data.on(event, () => setRevision((value) => value + 1)))
|
|
559
596
|
} catch {
|
|
560
597
|
/* Cached values stay renderable if a host event is unavailable. */
|
|
561
598
|
}
|
|
@@ -564,6 +601,48 @@ function ModelUsageDetails(props: { context: Context; sessionID: string; width:
|
|
|
564
601
|
for (const dispose of unsubscribe) dispose()
|
|
565
602
|
})
|
|
566
603
|
})
|
|
604
|
+
return rows
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function ActiveModelHeader(props: {
|
|
608
|
+
context: Context
|
|
609
|
+
sessionID: string
|
|
610
|
+
width: number
|
|
611
|
+
snapshot: QuotaSnapshot
|
|
612
|
+
}): JSX.Element {
|
|
613
|
+
const rows = useRecentModelUsage(props.context, props.sessionID)
|
|
614
|
+
const activeModel = createMemo(() => rows().find((row) => row.active))
|
|
615
|
+
const status = () => props.snapshot.status
|
|
616
|
+
const message = () => quotaPanelStatusMessage(props.snapshot)
|
|
617
|
+
const modelLine = () => activeQuotaModelLabel(activeModel())
|
|
618
|
+
return (
|
|
619
|
+
<box flexDirection="column">
|
|
620
|
+
<For each={quotaTextLines(modelLine(), props.width, 0)}>
|
|
621
|
+
{(line) => <text fg={base(props.context)}>{line}</text>}
|
|
622
|
+
</For>
|
|
623
|
+
<Show when={message()}>
|
|
624
|
+
{(label) => (
|
|
625
|
+
<For each={quotaTextLines(label(), props.width, 0)}>
|
|
626
|
+
{(line) => (
|
|
627
|
+
<text
|
|
628
|
+
fg={
|
|
629
|
+
status() === 'partial'
|
|
630
|
+
? tone(props.context, 'warning')
|
|
631
|
+
: tone(props.context, status() === 'unavailable' ? 'error' : 'info')
|
|
632
|
+
}
|
|
633
|
+
>
|
|
634
|
+
{line}
|
|
635
|
+
</text>
|
|
636
|
+
)}
|
|
637
|
+
</For>
|
|
638
|
+
)}
|
|
639
|
+
</Show>
|
|
640
|
+
</box>
|
|
641
|
+
)
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function ModelUsageDetails(props: { context: Context; sessionID: string; width: number }) {
|
|
645
|
+
const rows = useRecentModelUsage(props.context, props.sessionID)
|
|
567
646
|
|
|
568
647
|
const contextTone = (percent: number) => tone(props.context, contextUsageTone(percent))
|
|
569
648
|
const contextCells = () => Math.max(4, Math.min(12, Math.floor((props.width - 30) / 2)))
|
|
@@ -580,9 +659,15 @@ function ModelUsageDetails(props: { context: Context; sessionID: string; width:
|
|
|
580
659
|
{(row, index) => (
|
|
581
660
|
<>
|
|
582
661
|
<Show when={row.active}>
|
|
583
|
-
<
|
|
584
|
-
MODELO ATUAL
|
|
585
|
-
|
|
662
|
+
<For
|
|
663
|
+
each={quotaTextLines(`MODELO ATUAL · ${activeModelIdentity(row)}`, props.width, 0)}
|
|
664
|
+
>
|
|
665
|
+
{(line) => (
|
|
666
|
+
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
667
|
+
{line}
|
|
668
|
+
</text>
|
|
669
|
+
)}
|
|
670
|
+
</For>
|
|
586
671
|
</Show>
|
|
587
672
|
<Show when={!row.active && index() === 1}>
|
|
588
673
|
<text fg={muted(props.context)} attributes={1}>
|
|
@@ -630,20 +715,25 @@ function ModelUsageDetails(props: { context: Context; sessionID: string; width:
|
|
|
630
715
|
)
|
|
631
716
|
}}
|
|
632
717
|
</Show>
|
|
633
|
-
<Show when={row.cost !== null}>
|
|
634
|
-
<For
|
|
635
|
-
each={quotaTextLines(
|
|
636
|
-
`Custo reportado · mensagens recentes · ${formatSpent(row.cost) ?? '—'}`,
|
|
637
|
-
props.width - 2,
|
|
638
|
-
0,
|
|
639
|
-
)}
|
|
640
|
-
>
|
|
641
|
-
{(line) => <text fg={muted(props.context)}>{line}</text>}
|
|
642
|
-
</For>
|
|
643
|
-
</Show>
|
|
644
718
|
<Show when={row.tokens !== null && row.context === null}>
|
|
645
719
|
<text fg={muted(props.context)}>Contexto indisponível</text>
|
|
646
720
|
</Show>
|
|
721
|
+
<Show when={row.active}>
|
|
722
|
+
<ActiveContextEstimate
|
|
723
|
+
context={props.context}
|
|
724
|
+
providerID={row.providerID}
|
|
725
|
+
modelID={row.modelID}
|
|
726
|
+
contextTokens={row.context?.tokens ?? null}
|
|
727
|
+
width={props.width - 2}
|
|
728
|
+
/>
|
|
729
|
+
</Show>
|
|
730
|
+
<Show when={row.cost === null ? null : sessionSpendLabel(row.cost)}>
|
|
731
|
+
{(label) => (
|
|
732
|
+
<For each={quotaTextLines(label(), props.width - 2, 0)}>
|
|
733
|
+
{(line) => <text fg={muted(props.context)}>{line}</text>}
|
|
734
|
+
</For>
|
|
735
|
+
)}
|
|
736
|
+
</Show>
|
|
647
737
|
</box>
|
|
648
738
|
</>
|
|
649
739
|
)}
|
|
@@ -741,6 +831,16 @@ function QuotaProviderDetails(props: {
|
|
|
741
831
|
|
|
742
832
|
export type QuotaPanelAction = 'toggle-enabled' | 'toggle-display' | 'refresh' | 'close'
|
|
743
833
|
|
|
834
|
+
export const QUOTA_TABS = ['usage', 'limits', 'plugin', 'settings'] as const
|
|
835
|
+
export type QuotaTab = (typeof QUOTA_TABS)[number]
|
|
836
|
+
export const DEFAULT_QUOTA_TAB: QuotaTab = 'limits'
|
|
837
|
+
|
|
838
|
+
export function moveQuotaTab(current: QuotaTab, direction: -1 | 1): QuotaTab {
|
|
839
|
+
const currentIndex = QUOTA_TABS.indexOf(current)
|
|
840
|
+
const nextIndex = (currentIndex + direction + QUOTA_TABS.length) % QUOTA_TABS.length
|
|
841
|
+
return QUOTA_TABS[nextIndex] ?? DEFAULT_QUOTA_TAB
|
|
842
|
+
}
|
|
843
|
+
|
|
744
844
|
export const QUOTA_PANEL_COMMANDS: readonly {
|
|
745
845
|
action: QuotaPanelAction
|
|
746
846
|
id: string
|
|
@@ -785,17 +885,40 @@ export function runQuotaPanelCommand(
|
|
|
785
885
|
export function quotaPanelKeymapLayer(
|
|
786
886
|
panel: Pick<PanelInput, 'focused' | 'close'>,
|
|
787
887
|
runtime: QuotaRuntime,
|
|
888
|
+
onTabChange?: (direction: -1 | 1) => void,
|
|
788
889
|
): KeymapLayer {
|
|
789
890
|
const focused = () => panel.focused === true
|
|
790
891
|
return {
|
|
791
892
|
mode: 'global',
|
|
792
893
|
enabled: focused,
|
|
793
|
-
commands:
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
894
|
+
commands: [
|
|
895
|
+
...QUOTA_PANEL_COMMANDS.map((command) => ({
|
|
896
|
+
id: command.id,
|
|
897
|
+
title: command.title,
|
|
898
|
+
bind: command.bind,
|
|
899
|
+
run: () => (focused() ? runQuotaPanelCommand(command.action, panel, runtime) : false),
|
|
900
|
+
})),
|
|
901
|
+
{
|
|
902
|
+
id: 'pantheon.quota.next-tab',
|
|
903
|
+
title: 'Quota: próxima aba',
|
|
904
|
+
bind: 'tab',
|
|
905
|
+
run: () => {
|
|
906
|
+
if (!focused()) return false
|
|
907
|
+
onTabChange?.(1)
|
|
908
|
+
return undefined
|
|
909
|
+
},
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
id: 'pantheon.quota.previous-tab',
|
|
913
|
+
title: 'Quota: aba anterior',
|
|
914
|
+
bind: 'shift+tab',
|
|
915
|
+
run: () => {
|
|
916
|
+
if (!focused()) return false
|
|
917
|
+
onTabChange?.(-1)
|
|
918
|
+
return undefined
|
|
919
|
+
},
|
|
920
|
+
},
|
|
921
|
+
],
|
|
799
922
|
}
|
|
800
923
|
}
|
|
801
924
|
|
|
@@ -829,39 +952,136 @@ export function openQuotaPanel(context: Pick<Context, 'ui'>): boolean {
|
|
|
829
952
|
return false
|
|
830
953
|
}
|
|
831
954
|
|
|
832
|
-
|
|
833
|
-
|
|
955
|
+
const QUOTA_TAB_LABELS: Record<QuotaTab, string> = {
|
|
956
|
+
usage: 'Usage',
|
|
957
|
+
limits: 'Limits',
|
|
958
|
+
plugin: 'Plugin',
|
|
959
|
+
settings: 'Settings',
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
const QUOTA_TAB_ICONS: Record<QuotaTab, QuotaIconName> = {
|
|
963
|
+
usage: 'clock',
|
|
964
|
+
limits: 'gauge',
|
|
965
|
+
plugin: 'plug',
|
|
966
|
+
settings: 'settings',
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
export function quotaTabLabel(tab: QuotaTab, mode?: QuotaIconMode): string {
|
|
970
|
+
return `${iconInSlot(QUOTA_TAB_ICONS[tab], 3, mode)} ${QUOTA_TAB_LABELS[tab]}`
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
function QuotaTabNavigation(props: {
|
|
974
|
+
context: Context
|
|
975
|
+
selected: QuotaTab
|
|
976
|
+
width: number
|
|
977
|
+
onSelect: (tab: QuotaTab) => void
|
|
978
|
+
}): JSX.Element {
|
|
979
|
+
return (
|
|
980
|
+
<box flexDirection={props.width < 54 ? 'column' : 'row'} gap={1}>
|
|
981
|
+
<For each={QUOTA_TABS}>
|
|
982
|
+
{(tab) => (
|
|
983
|
+
<box onMouseDown={() => props.onSelect(tab)}>
|
|
984
|
+
<text
|
|
985
|
+
fg={props.selected === tab ? tone(props.context, 'info') : muted(props.context)}
|
|
986
|
+
attributes={props.selected === tab ? 1 : 0}
|
|
987
|
+
>
|
|
988
|
+
{`${props.selected === tab ? '› ' : ' '}${quotaTabLabel(tab)}`}
|
|
989
|
+
</text>
|
|
990
|
+
</box>
|
|
991
|
+
)}
|
|
992
|
+
</For>
|
|
993
|
+
</box>
|
|
994
|
+
)
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
function QuotaCloseButton(props: { context: Context; close: () => void }): JSX.Element {
|
|
998
|
+
return (
|
|
999
|
+
<box onMouseDown={props.close}>
|
|
1000
|
+
<text fg={tone(props.context, 'info')}>{`${quotaIcon('close')} Fechar`}</text>
|
|
1001
|
+
</box>
|
|
1002
|
+
)
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
function QuotaPluginDetails(props: { context: Context; snapshot: QuotaSnapshot }): JSX.Element {
|
|
1006
|
+
return (
|
|
1007
|
+
<box flexDirection="column" paddingTop={1}>
|
|
1008
|
+
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
1009
|
+
Plugin
|
|
1010
|
+
</text>
|
|
1011
|
+
<text fg={base(props.context)}>{`Pantheon TUI v${__PANTHEON_VERSION__}`}</text>
|
|
1012
|
+
<text fg={muted(props.context)}>
|
|
1013
|
+
Status de conexão consultado pelo OpenCode; segredos não são exibidos.
|
|
1014
|
+
</text>
|
|
1015
|
+
<text fg={muted(props.context)}>
|
|
1016
|
+
{`Status da quota: ${quotaSnapshotStatusLabel(props.snapshot.status, props.snapshot.error)}`}
|
|
1017
|
+
</text>
|
|
1018
|
+
<Show when={props.snapshot.details.length > 0}>
|
|
1019
|
+
<text fg={muted(props.context)}>PROVEDORES DETECTADOS</text>
|
|
1020
|
+
<For each={props.snapshot.details}>
|
|
1021
|
+
{(provider) => {
|
|
1022
|
+
const state = providerState(provider)
|
|
1023
|
+
return (
|
|
1024
|
+
<text fg={tone(props.context, state.tone)}>
|
|
1025
|
+
{`${provider.label} · ${state.label}`}
|
|
1026
|
+
</text>
|
|
1027
|
+
)
|
|
1028
|
+
}}
|
|
1029
|
+
</For>
|
|
1030
|
+
</Show>
|
|
1031
|
+
<Show when={props.snapshot.details.length === 0}>
|
|
1032
|
+
<text fg={muted(props.context)}>Nenhum provedor elegível foi confirmado nesta sessão.</text>
|
|
1033
|
+
</Show>
|
|
1034
|
+
<text fg={muted(props.context)}>
|
|
1035
|
+
Configure a conexão e credenciais pelo fluxo oficial do OpenCode; o painel não altera
|
|
1036
|
+
configurações.
|
|
1037
|
+
</text>
|
|
1038
|
+
</box>
|
|
1039
|
+
)
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function QuotaSettings(props: { context: Context; runtime: QuotaRuntime }): JSX.Element {
|
|
1043
|
+
const preferences = () => props.runtime.preferences()
|
|
1044
|
+
return (
|
|
1045
|
+
<box flexDirection="column" paddingTop={1}>
|
|
1046
|
+
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
1047
|
+
Settings
|
|
1048
|
+
</text>
|
|
1049
|
+
<box onMouseDown={() => void props.runtime.toggleEnabled()}>
|
|
1050
|
+
<text fg={base(props.context)}>
|
|
1051
|
+
{`${quotaIcon(preferences().enabled ? 'check' : 'close')} [E] Quota ${preferences().enabled ? 'ativada' : 'desativada'} · clique para alternar`}
|
|
1052
|
+
</text>
|
|
1053
|
+
</box>
|
|
1054
|
+
<box onMouseDown={() => void props.runtime.toggleDisplay()}>
|
|
1055
|
+
<text fg={base(props.context)}>
|
|
1056
|
+
{`${quotaIcon('sliders')} [M] Exibir ${preferences().display === 'remaining' ? 'restante' : 'usado'} · clique para alternar`}
|
|
1057
|
+
</text>
|
|
1058
|
+
</box>
|
|
1059
|
+
<text fg={muted(props.context)}>Tab/Shift+Tab navega pelas abas; Esc fecha o painel.</text>
|
|
1060
|
+
</box>
|
|
1061
|
+
)
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
export function QuotaPanel(props: QuotaSurfaceProps & { panel: PanelInput }): JSX.Element {
|
|
1065
|
+
const [selectedTab, setSelectedTab] = createSignal<QuotaTab>(DEFAULT_QUOTA_TAB)
|
|
1066
|
+
props.context.keymap.layer(() =>
|
|
1067
|
+
quotaPanelKeymapLayer(props.panel, props.runtime, (direction) =>
|
|
1068
|
+
setSelectedTab((tab) => moveQuotaTab(tab, direction)),
|
|
1069
|
+
),
|
|
1070
|
+
)
|
|
834
1071
|
const preferences = () => props.runtime.preferences()
|
|
835
1072
|
const snapshot = () => props.runtime.snapshot()
|
|
836
|
-
const snapshotTone = (): QuotaTone => {
|
|
837
|
-
switch (snapshot().status) {
|
|
838
|
-
case 'ready':
|
|
839
|
-
return 'success'
|
|
840
|
-
case 'partial':
|
|
841
|
-
case 'connected_unavailable':
|
|
842
|
-
case 'needs_setup':
|
|
843
|
-
case 'stale':
|
|
844
|
-
return 'warning'
|
|
845
|
-
case 'unavailable':
|
|
846
|
-
return 'error'
|
|
847
|
-
case 'loading':
|
|
848
|
-
case 'disabled':
|
|
849
|
-
return 'info'
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
1073
|
|
|
853
1074
|
return (
|
|
854
1075
|
<box flexDirection="column" width="100%" height="100%" padding={1}>
|
|
855
1076
|
<Show
|
|
856
1077
|
when={props.panel.width >= 54}
|
|
857
1078
|
fallback={
|
|
858
|
-
<box flexDirection="
|
|
859
|
-
<text
|
|
860
|
-
{
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
</text>
|
|
1079
|
+
<box flexDirection="row" justifyContent="space-between" gap={1}>
|
|
1080
|
+
<text
|
|
1081
|
+
fg={tone(props.context, 'info')}
|
|
1082
|
+
attributes={1}
|
|
1083
|
+
>{`${QUOTA_ICON} Pantheon / Quota`}</text>
|
|
1084
|
+
<QuotaCloseButton context={props.context} close={props.panel.close} />
|
|
865
1085
|
</box>
|
|
866
1086
|
}
|
|
867
1087
|
>
|
|
@@ -869,11 +1089,21 @@ function QuotaPanel(props: QuotaSurfaceProps & { panel: PanelInput }) {
|
|
|
869
1089
|
<text fg={tone(props.context, 'info')} attributes={1}>
|
|
870
1090
|
{`${QUOTA_ICON} Pantheon / Quota`}
|
|
871
1091
|
</text>
|
|
872
|
-
<
|
|
873
|
-
{quotaSnapshotStatusLabel(snapshot().status, snapshot().error)}
|
|
874
|
-
</text>
|
|
1092
|
+
<QuotaCloseButton context={props.context} close={props.panel.close} />
|
|
875
1093
|
</box>
|
|
876
1094
|
</Show>
|
|
1095
|
+
<ActiveModelHeader
|
|
1096
|
+
context={props.context}
|
|
1097
|
+
sessionID={props.panel.sessionID}
|
|
1098
|
+
width={props.panel.width - 4}
|
|
1099
|
+
snapshot={snapshot()}
|
|
1100
|
+
/>
|
|
1101
|
+
<QuotaTabNavigation
|
|
1102
|
+
context={props.context}
|
|
1103
|
+
selected={selectedTab()}
|
|
1104
|
+
width={props.panel.width}
|
|
1105
|
+
onSelect={setSelectedTab}
|
|
1106
|
+
/>
|
|
877
1107
|
<Show when={snapshot().error !== undefined && snapshot().status !== 'ready'}>
|
|
878
1108
|
<text fg={muted(props.context)}>{`Último erro: ${snapshot().error}`}</text>
|
|
879
1109
|
</Show>
|
|
@@ -904,21 +1134,43 @@ function QuotaPanel(props: QuotaSurfaceProps & { panel: PanelInput }) {
|
|
|
904
1134
|
focusedBorderColor={tone(props.context, 'info')}
|
|
905
1135
|
>
|
|
906
1136
|
<box flexDirection="column" paddingX={1} paddingY={1}>
|
|
907
|
-
<
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1137
|
+
<Show when={selectedTab() === 'usage'}>
|
|
1138
|
+
<UsageHistorySection
|
|
1139
|
+
context={props.context}
|
|
1140
|
+
panel={props.panel}
|
|
1141
|
+
width={props.panel.width - 6}
|
|
1142
|
+
/>
|
|
1143
|
+
<ModelUsageDetails
|
|
1144
|
+
context={props.context}
|
|
1145
|
+
sessionID={props.panel.sessionID}
|
|
1146
|
+
width={props.panel.width - 6}
|
|
1147
|
+
/>
|
|
1148
|
+
</Show>
|
|
1149
|
+
<Show when={selectedTab() === 'limits'}>
|
|
1150
|
+
<Show when={snapshot().details.length > 0}>
|
|
1151
|
+
<For each={snapshot().details}>
|
|
1152
|
+
{(provider) => (
|
|
1153
|
+
<QuotaProviderDetails
|
|
1154
|
+
provider={provider}
|
|
1155
|
+
display={preferences().display}
|
|
1156
|
+
width={props.panel.width - 4}
|
|
1157
|
+
context={props.context}
|
|
1158
|
+
/>
|
|
1159
|
+
)}
|
|
1160
|
+
</For>
|
|
1161
|
+
</Show>
|
|
1162
|
+
<Show when={snapshot().details.length === 0}>
|
|
1163
|
+
<text fg={muted(props.context)}>
|
|
1164
|
+
{quotaSnapshotStatusLabel(snapshot().status, snapshot().error)}
|
|
1165
|
+
</text>
|
|
1166
|
+
</Show>
|
|
1167
|
+
</Show>
|
|
1168
|
+
<Show when={selectedTab() === 'plugin'}>
|
|
1169
|
+
<QuotaPluginDetails context={props.context} snapshot={snapshot()} />
|
|
1170
|
+
</Show>
|
|
1171
|
+
<Show when={selectedTab() === 'settings'}>
|
|
1172
|
+
<QuotaSettings context={props.context} runtime={props.runtime} />
|
|
1173
|
+
</Show>
|
|
922
1174
|
</box>
|
|
923
1175
|
</scrollbox>
|
|
924
1176
|
<box flexDirection="column" flexShrink={0}>
|
|
@@ -928,8 +1180,8 @@ function QuotaPanel(props: QuotaSurfaceProps & { panel: PanelInput }) {
|
|
|
928
1180
|
<text
|
|
929
1181
|
fg={muted(props.context)}
|
|
930
1182
|
>{`E ${preferences().enabled ? 'desativar' : 'ativar'} · M alternar usado/restante`}</text>
|
|
931
|
-
<text fg={muted(props.context)}
|
|
932
|
-
<text fg={muted(props.context)}>Esc/Q fechar</text>
|
|
1183
|
+
<text fg={muted(props.context)}>{`↑/↓ rolar · ${quotaIcon('refresh')} R atualizar`}</text>
|
|
1184
|
+
<text fg={muted(props.context)}>Tab/Shift+Tab abas · Esc/Q fechar</text>
|
|
933
1185
|
</box>
|
|
934
1186
|
</box>
|
|
935
1187
|
)
|