@cortexkit/opencode-anthropic-auth 2.1.2 → 2.2.0

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/src/tui/entry.mjs CHANGED
@@ -37,6 +37,17 @@ async function loadLegacyTui() {
37
37
  return mod.default
38
38
  }
39
39
 
40
+ // The quota sidebar renderer shared with OpenCode 1, loaded the same way.
41
+ async function loadSidebar() {
42
+ try {
43
+ await import(runtimeProbe)
44
+ } catch (error) {
45
+ if (!isMissingRuntimeRegistry(error)) throw error
46
+ return import('./claude-sidebar.tsx')
47
+ }
48
+ return import('../tui-compiled/tui/claude-sidebar.tsx')
49
+ }
50
+
40
51
  let legacyModule
41
52
 
42
53
  // OpenCode 1 reads id and tui from the default definition; OpenCode 2 reads
@@ -57,7 +68,10 @@ export const setup = async (context) => {
57
68
  // TUI must not load the OpenCode 1 renderer or start that renderer's separate
58
69
  // loopback notification poller.
59
70
  const { setupAnthropicTui } = await import('../../dist/v2/tui.js')
60
- return setupAnthropicTui(context)
71
+ return setupAnthropicTui(context, {
72
+ mountSidebar: async (ctx, read) =>
73
+ (await loadSidebar()).mountClaudeSidebar(ctx, read),
74
+ })
61
75
  }
62
76
 
63
77
  export default { id, tui, setup }
@@ -888,7 +888,10 @@ export function formatPrimeCost(value: number): string {
888
888
  return value.toFixed(Math.min(6, Math.max(0, 4)))
889
889
  }
890
890
 
891
- export function formatPrimeAccountValue(account: PrimeSidebarAccountState): {
891
+ export function formatPrimeAccountValue(
892
+ account: PrimeSidebarAccountState,
893
+ now = Date.now(),
894
+ ): {
892
895
  text: string
893
896
  hasError: boolean
894
897
  } {
@@ -898,7 +901,7 @@ export function formatPrimeAccountValue(account: PrimeSidebarAccountState): {
898
901
  if (account.lastResult === 'skipped') {
899
902
  return { text: 'skip', hasError: false }
900
903
  }
901
- if (account.nextDueAt && account.nextDueAt > Date.now()) {
904
+ if (account.nextDueAt && account.nextDueAt > now) {
902
905
  return { text: formatPrimeTime(account.nextDueAt), hasError: false }
903
906
  }
904
907
  if (account.lastPrimedAt) {
@@ -994,7 +997,9 @@ export function getCollapsedAccounts(
994
997
  state: SidebarState,
995
998
  showFallbacks = true,
996
999
  ) {
997
- const activeId = resolveActiveAccount(state).id
1000
+ // Before any request no account is active; do not mark main as serving.
1001
+ const activeId =
1002
+ state.activeId === undefined ? undefined : resolveActiveAccount(state).id
998
1003
  return [
999
1004
  {
1000
1005
  id: 'main',