@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.
Files changed (90) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +277 -150
  3. package/dist/cli.js.map +3 -3
  4. package/dist/cli.meta.json +43 -23
  5. package/dist/index.js +331 -204
  6. package/dist/index.js.map +3 -3
  7. package/dist/index.meta.json +43 -23
  8. package/dist/server.js +344 -217
  9. package/dist/server.js.map +3 -3
  10. package/dist/server.meta.json +1 -1
  11. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  12. package/dist/src/common-auth-embedded/claustrum/consumer.js +25 -0
  13. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  14. package/dist/src/common-auth-embedded/claustrum/custody.js +45 -6
  15. package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  16. package/dist/src/common-auth-embedded/claustrum/hub.js +75 -6
  17. package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
  18. package/dist/src/common-auth-embedded/claustrum/roster.js +1 -1
  19. package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  20. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
  21. package/dist/src/common-auth-embedded/fs/with-lock.js +1 -1
  22. package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  23. package/dist/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  24. package/dist/src/common-auth-embedded/opencode2/install.js +144 -17
  25. package/dist/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  26. package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  27. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
  28. package/dist/src/common-auth-embedded/source-output.json +73 -53
  29. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  30. package/dist/src/ga/tui/host-ga.js +2 -3
  31. package/dist/src/ga/tui/host-ga.js.map +1 -1
  32. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  33. package/dist/src/server.d.ts +4 -4
  34. package/dist/src/server.js +4 -4
  35. package/dist/src/tui/quota-layout.d.ts +4 -58
  36. package/dist/src/tui/quota-layout.d.ts.map +1 -1
  37. package/dist/src/tui/quota-layout.js +4 -90
  38. package/dist/src/tui/quota-layout.js.map +1 -1
  39. package/dist/src/tui/sidebar-frame.d.ts +4 -35
  40. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  41. package/dist/src/tui/sidebar-frame.js +91 -171
  42. package/dist/src/tui/sidebar-frame.js.map +1 -1
  43. package/dist/src/tui.js +3 -3
  44. package/dist/src/tui.js.map +1 -1
  45. package/dist/tui-build-map.json +27 -13
  46. package/dist/tui-ga-build-map.json +28 -13
  47. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  48. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  49. package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  50. package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  51. package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  52. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  53. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  54. package/dist/types/src/server.d.ts +4 -4
  55. package/package.json +3 -3
  56. package/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  57. package/src/common-auth-embedded/claustrum/consumer.js +25 -0
  58. package/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  59. package/src/common-auth-embedded/claustrum/custody.js +45 -6
  60. package/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  61. package/src/common-auth-embedded/claustrum/hub.js +75 -6
  62. package/src/common-auth-embedded/claustrum/insula.js +6 -0
  63. package/src/common-auth-embedded/claustrum/roster.js +1 -1
  64. package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  65. package/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
  66. package/src/common-auth-embedded/fs/with-lock.js +1 -1
  67. package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  68. package/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  69. package/src/common-auth-embedded/opencode2/install.js +144 -17
  70. package/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  71. package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  72. package/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
  73. package/src/common-auth-embedded/source-output.json +73 -53
  74. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +666 -0
  75. package/src/tui-compiled/tui/quota-layout.js +5 -330
  76. package/src/tui-compiled/tui/sidebar-frame.js +241 -503
  77. package/src/tui-compiled/tui.js +3 -3
  78. package/src/tui-ga-compiled/host-ga.js +2 -3
  79. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +241 -503
  80. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
  81. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +666 -0
  82. package/src/tui-ga-raw/host-ga.tsx +2 -3
  83. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +209 -419
  84. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
  85. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +630 -0
  86. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +630 -0
  87. package/src/tui-raw/tui/quota-layout.tsx +10 -301
  88. package/src/tui-raw/tui/sidebar-frame.tsx +209 -419
  89. package/src/tui-raw/tui.tsx +3 -3
  90. package/src/tui.tsx +3 -3
@@ -1,38 +1,7 @@
1
- /** @jsxImportSource @opentui/solid */
2
- /**
3
- * Quota layout shared by the OpenCode 1 sidebar (`tui.tsx`) and the OpenCode 2
4
- * sidebar (`ga/tui/host-ga.tsx`): one account block with its header line, the
5
- * reading age once per account, plain-word group headers and one width-fitted
6
- * row per quota window.
7
- *
8
- * Each renderer supplies its own data source and colors. This module imports
9
- * only the pure quota presentation helpers, so it stays inside both TUI
10
- * import graphs: no sidebar file, preferences file, RPC, account store,
11
- * OAuth, token or host SDK module, and nothing that writes to the terminal.
12
- */
13
- import type { RGBA } from '@opentui/core';
14
- import { type JSX } from 'solid-js';
1
+ /** Pure account-window inputs shared by the two sidebar hosts. */
2
+ import type { SidebarAppearance, Tone } from '../common-auth-embedded/quota-sidebar/index.js';
15
3
  import { type QuotaReading, type QuotaWindowText } from '../quota-presentation.js';
16
- export type QuotaTone = 'ok' | 'warn' | 'err' | 'muted' | 'accent' | 'text';
17
- /** A text color; `undefined` leaves the host's default color in place. */
18
- export type QuotaColor = string | RGBA | undefined;
19
- /**
20
- * How a renderer colors the quota layout. OpenCode 1 maps these onto its live
21
- * host theme; a renderer without a theme returns `undefined` everywhere.
22
- */
23
- export interface QuotaPalette {
24
- readonly text: () => QuotaColor;
25
- readonly muted: () => QuotaColor;
26
- readonly tone: (tone: QuotaTone) => QuotaColor;
27
- }
28
- /** The bar and threshold settings the layout reads. */
29
- export interface QuotaAppearance {
30
- readonly barWidth: number;
31
- readonly barFilledChar: string;
32
- readonly barEmptyChar: string;
33
- readonly warnThreshold: number;
34
- readonly errorThreshold: number;
35
- }
4
+ export type QuotaAppearance = SidebarAppearance;
36
5
  /**
37
6
  * The OpenCode 1 preference defaults for the quota bar, for a renderer that
38
7
  * has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
@@ -63,34 +32,11 @@ export interface QuotaLayoutAccount {
63
32
  }
64
33
  export declare const GROUP_NAMES: Record<QuotaGroupKey, string>;
65
34
  export declare const QUOTA_ORDER: readonly QuotaGroupKey[];
66
- export declare const RESET_SINCE_READING = "reset since last check";
67
- export declare const ASSUMED_CONTENT_WIDTH = 28;
68
- export declare function quotaTone(usedPct: number, appearance: QuotaAppearance): QuotaTone;
35
+ export declare function quotaTone(usedPct: number, appearance: QuotaAppearance): Tone;
69
36
  export interface AccountWindow {
70
37
  key: QuotaGroupKey;
71
38
  reading: QuotaReading;
72
39
  text: QuotaWindowText;
73
40
  }
74
41
  export declare function accountWindows(account: QuotaLayoutAccount, now: number): AccountWindow[];
75
- export declare function showsFigure(window: AccountWindow): boolean;
76
- export declare function fitLabel(label: string, max: number): string;
77
- /**
78
- * One account's quota block. The header line is the account label, the
79
- * reading age when the oldest reading is stale, and the caller's status word
80
- * right-aligned; the age moves to its own dim line when the three do not
81
- * fit. Below it each quota group present gets a plain-word header and one
82
- * row per window, or a single dim line when there is no reading at all.
83
- * `children`, when given, render after the quota rows.
84
- */
85
- export declare function QuotaAccountBlock(props: {
86
- palette: QuotaPalette;
87
- appearance: QuotaAppearance;
88
- account: QuotaLayoutAccount;
89
- status: string;
90
- statusTone: QuotaTone;
91
- now: () => number;
92
- width: () => number;
93
- marginTop?: number;
94
- children?: JSX.Element;
95
- }): JSX.Element;
96
42
  //# sourceMappingURL=quota-layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quota-layout.d.ts","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAO,KAAK,GAAG,EAAQ,MAAM,UAAU,CAAA;AAC9C,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,eAAe,EAGrB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE3E,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAElD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,UAAU,CAAA;IAC/B,QAAQ,C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,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAI5E;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,aAAa,CAAA;IAClB,OAAO,EAAE,YAAY,CAAA;IACrB,IAAI,EAAE,eAAe,CAAA;CACtB;AAID,wBAAgB,cAAc,CAC5B,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,MAAM,GACV,aAAa,EAAE,CAwBjB"}
@@ -1,6 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@opentui/solid/jsx-runtime";
2
- import { For, Show } from 'solid-js';
3
- import { NO_QUOTA_READING, quotaReadingAge, quotaWindowText, } from '../quota-presentation';
1
+ import { quotaWindowText, } from '../quota-presentation';
4
2
  /**
5
3
  * The OpenCode 1 preference defaults for the quota bar, for a renderer that
6
4
  * has no preferences file. A test keeps it equal to `DEFAULT_PREFS.appearance`.
@@ -23,33 +21,12 @@ export const QUOTA_ORDER = [
23
21
  'non-gemini',
24
22
  'gemini-argon',
25
23
  ];
26
- // Shown instead of a stored figure once the window has reset since it was
27
- // read: the stored figure describes the window before the reset.
28
- export const RESET_SINCE_READING = 'reset since last check';
29
- // Content width used until the first layout pass reports the real one. It
30
- // fits the narrowest OpenCode sidebar.
31
- export const ASSUMED_CONTENT_WIDTH = 28;
32
- // A window row is `<name> <bar> <figure> <reset>`. The bar shrinks to this
33
- // before the reset column is dropped; below it the bar is dropped too.
34
- const MIN_BAR_WIDTH = 4;
35
- // The widest figure the formatter writes: `100% left`.
36
- const FIGURE_WIDTH = 9;
37
- // A window name (`5h`, `7d`) and the space after it.
38
- const NAME_WIDTH = 3;
39
24
  export function quotaTone(usedPct, appearance) {
40
25
  if (usedPct < appearance.warnThreshold)
41
- return 'ok';
26
+ return 'success';
42
27
  if (usedPct < appearance.errorThreshold)
43
- return 'warn';
44
- return 'err';
45
- }
46
- function quotaBarSegments(remainingPct, width, appearance) {
47
- const usedCells = Math.max(0, Math.min(Math.round((remainingPct / 100) * width), width));
48
- const tone = quotaTone(100 - remainingPct, appearance);
49
- return [
50
- { text: appearance.barFilledChar.repeat(usedCells), tone },
51
- { text: appearance.barEmptyChar.repeat(width - usedCells), tone },
52
- ].filter((segment) => segment.text.length > 0);
28
+ return 'warning';
29
+ return 'error';
53
30
  }
54
31
  // One entry per stored window, in group order. A pool stored before
55
32
  // per-window readings existed contributes one window without a name.
@@ -78,67 +55,4 @@ export function accountWindows(account, now) {
78
55
  }
79
56
  return result;
80
57
  }
81
- // A window shows its figure only while no reset has happened since it was
82
- // read and it has a read time at all.
83
- export function showsFigure(window) {
84
- return window.text.remaining != null && !window.text.resetSinceReading;
85
- }
86
- // Column widths for one `<name> <bar> <figure> <reset>` row within `width`
87
- // cells. The bar shrinks first, down to MIN_BAR_WIDTH; then the reset column
88
- // is dropped; when even that leaves less than MIN_BAR_WIDTH cells for the
89
- // bar, the bar is left out and the row is just the name and figure.
90
- function windowRowLayout(width, named, resetWidth, maxBar) {
91
- const room = width - (named ? NAME_WIDTH : 0) - FIGURE_WIDTH;
92
- if (resetWidth > 0) {
93
- const bar = Math.min(maxBar, room - resetWidth - 2);
94
- if (bar >= MIN_BAR_WIDTH)
95
- return { bar, reset: true };
96
- }
97
- const bar = Math.min(maxBar, room - 1);
98
- return { bar: bar >= MIN_BAR_WIDTH ? bar : 0, reset: false };
99
- }
100
- // Shorten a label to `max` cells, marking the cut with an ellipsis.
101
- export function fitLabel(label, max) {
102
- if (label.length <= max)
103
- return label;
104
- if (max <= 0)
105
- return '';
106
- if (max === 1)
107
- return '…';
108
- return `${label.slice(0, max - 1)}…`;
109
- }
110
- // One quota window on one line. The bar fills with remaining quota; the
111
- // figure and reset come from the shared formatter. A window that reset since
112
- // its reading shows that fact, dim, in place of the stale figure.
113
- function WindowRow(props) {
114
- const text = () => props.window.text;
115
- const tone = () => quotaTone(100 - (text().remaining ?? 0), props.appearance);
116
- return (_jsxs("box", { width: '100%', flexDirection: 'row', children: [_jsx(Show, { when: text().name !== '', children: _jsx("text", { width: NAME_WIDTH, flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: text().name }) }), _jsxs(Show, { when: showsFigure(props.window), fallback: _jsx("text", { flexShrink: 1, wrapMode: 'none', fg: props.palette.muted(), children: text().resetSinceReading ? RESET_SINCE_READING : text().figure }), children: [_jsx(Show, { when: props.layout.bar > 0, children: _jsx("box", { width: props.layout.bar + 1, flexShrink: 0, flexDirection: 'row', children: _jsx(For, { each: quotaBarSegments(text().remaining ?? 0, props.layout.bar, props.appearance), children: (segment) => (_jsx("text", { wrapMode: 'none', fg: props.palette.tone(segment.tone), children: segment.text })) }) }) }), _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.tone(tone()), children: text().figure }), _jsx("box", { flexGrow: 1 }), _jsx(Show, { when: props.layout.reset && text().reset !== '', children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: text().reset }) })] })] }));
117
- }
118
- /**
119
- * One account's quota block. The header line is the account label, the
120
- * reading age when the oldest reading is stale, and the caller's status word
121
- * right-aligned; the age moves to its own dim line when the three do not
122
- * fit. Below it each quota group present gets a plain-word header and one
123
- * row per window, or a single dim line when there is no reading at all.
124
- * `children`, when given, render after the quota rows.
125
- */
126
- export function QuotaAccountBlock(props) {
127
- const windows = () => accountWindows(props.account, props.now());
128
- const age = () => quotaReadingAge(windows().map((window) => window.reading), props.now());
129
- const ageInline = () => age() !== '' &&
130
- props.account.label.length + 3 + age().length + 1 + props.status.length <=
131
- props.width();
132
- const label = () => fitLabel(props.account.label, props.width() - 1 - props.status.length);
133
- // One reset column width per account, so bars line up across its rows.
134
- const resetWidth = () => Math.max(0, ...windows()
135
- .filter(showsFigure)
136
- .map((window) => window.text.reset.length));
137
- const layoutFor = (window) => windowRowLayout(props.width(), window.text.name !== '', resetWidth(), props.appearance.barWidth);
138
- const groups = () => QUOTA_ORDER.map((key) => ({
139
- key,
140
- windows: windows().filter((window) => window.key === key),
141
- })).filter((group) => group.windows.length > 0);
142
- return (_jsxs("box", { width: '100%', flexDirection: 'column', marginTop: props.marginTop ?? 0, children: [_jsxs("box", { width: '100%', flexDirection: 'row', children: [_jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.text(), children: _jsx("b", { children: label() }) }), _jsx(Show, { when: ageInline(), children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.muted(), children: ` · ${age()}` }) }), _jsx("box", { flexGrow: 1 }), _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.palette.tone(props.statusTone), children: _jsx("b", { children: props.status }) })] }), _jsx(Show, { when: age() !== '' && !ageInline(), children: _jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: age() }) }), _jsx(Show, { when: groups().length > 0, fallback: _jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: NO_QUOTA_READING }), children: _jsx(For, { each: groups(), children: (group) => (_jsxs(_Fragment, { children: [_jsx("text", { wrapMode: 'none', fg: props.palette.muted(), children: GROUP_NAMES[group.key] }), _jsx(For, { each: group.windows, children: (window) => (_jsx(WindowRow, { palette: props.palette, appearance: props.appearance, window: window, layout: layoutFor(window) })) })] })) }) }), props.children] }));
143
- }
144
58
  //# sourceMappingURL=quota-layout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"quota-layout.js","sourceRoot":"","sources":["../../../src/tui/quota-layout.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,GAAG,EAAY,IAAI,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EACL,gBAAgB,EAGhB,eAAe,EACf,eAAe,GAChB,MAAM,uBAAuB,CAAA;AA0B9B;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,GAAG;IACjB,aAAa,EAAE,EAAE;IACjB,cAAc,EAAE,EAAE;CACnB,CAAA;AA6BD,qDAAqD;AACrD,MAAM,CAAC,M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AK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YACvC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;YACL,CAAC,CAAC;gBACE;oBACE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;oBACxC,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B;aACF,CAAA;QACP,KAAK,MAAM,OAAO,IAAI,QAAQ;YAC5B,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,27 +1,9 @@
1
1
  /** @jsxImportSource @opentui/solid */
2
- /**
3
- * The Antigravity sidebar frame, shared by the OpenCode 1 sidebar (`tui.tsx`)
4
- * and the OpenCode 2 sidebar (`ga/tui/host-ga.tsx`): the bordered, padded
5
- * panel, the clickable `▼`/`▶` header badge with the plugin version (or a
6
- * `LIMITED` badge) at the right, one line per account when collapsed, and the
7
- * `Quota`, `Routing` and `Health` sections when expanded.
8
- *
9
- * Each renderer reads its own data source (the sidebar file, or the
10
- * location's `state` answer), maps its own host theme onto `FrameTheme` and
11
- * owns its own collapse state; everything drawn is decided here, so a change
12
- * of shape is made once for both hosts.
13
- *
14
- * This module stays inside both TUI import graphs: besides Solid and
15
- * OpenTUI it imports only the pure quota and sidebar-projection helpers and
16
- * the shared layouts. No sidebar file, preferences file, RPC, account
17
- * store, OAuth, token or host SDK module, no Node built-in, and nothing
18
- * that writes to the terminal.
19
- */
2
+ /** Plugin-owned projection and Routing/Health sections for the shared quota frame. */
20
3
  import type { RGBA } from '@opentui/core';
21
4
  import { type JSX } from 'solid-js';
22
5
  import { type ProjectedQuota } from '../common-auth-embedded/quota/index.js';
23
- import { type QuotaAppearance, type QuotaLayoutAccount, type QuotaPalette, type QuotaTone } from './quota-layout.js';
24
- type Tone = QuotaTone;
6
+ import { type QuotaAppearance, type QuotaLayoutAccount } from './quota-layout.js';
25
7
  /** A theme color; `undefined` leaves the host's default color in place. */
26
8
  export type FrameColor = string | RGBA | undefined;
27
9
  /**
@@ -35,15 +17,13 @@ export interface FrameTheme {
35
17
  readonly textMuted: FrameColor;
36
18
  readonly accent: FrameColor;
37
19
  readonly background: FrameColor;
38
- readonly borderActive: FrameColor;
39
20
  readonly success: FrameColor;
40
21
  readonly warning: FrameColor;
41
22
  readonly error: FrameColor;
42
23
  }
43
- export declare function toneColor(theme: FrameTheme, tone: Tone): FrameColor;
44
- export declare function themePalette(theme: () => FrameTheme): QuotaPalette;
45
24
  /** The account fields the frame reads: the quota layout's plus the state. */
46
25
  export interface FrameAccount extends QuotaLayoutAccount {
26
+ readonly id: string;
47
27
  readonly enabled: boolean;
48
28
  readonly current: boolean;
49
29
  readonly cooldownUntil?: number;
@@ -77,16 +57,6 @@ export interface FrameSettings {
77
57
  * `DEFAULT_PREFS`.
78
58
  */
79
59
  export declare const DEFAULT_FRAME_SETTINGS: FrameSettings;
80
- export declare function SectionHeader(props: {
81
- theme: () => FrameTheme;
82
- title: string;
83
- }): JSX.Element;
84
- export declare function StatRow(props: {
85
- theme: () => FrameTheme;
86
- label: string;
87
- value: string;
88
- tone?: Tone;
89
- }): JSX.Element;
90
60
  export declare function sidebarQuotaProjection(account: QuotaLayoutAccount, now: number): ProjectedQuota | undefined;
91
61
  export interface SidebarFrameProps {
92
62
  readonly theme: () => FrameTheme;
@@ -104,6 +74,5 @@ export interface SidebarFrameProps {
104
74
  readonly lastError: () => string | null | undefined;
105
75
  readonly now: () => number;
106
76
  }
107
- export declare function SidebarFrame(props: SidebarFrameProps): JSX.Element;
108
- export {};
77
+ export declare function AntigravitySidebar(props: SidebarFrameProps): JSX.Element;
109
78
  //# sourceMappingURL=sidebar-frame.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-frame.d.ts","sourceRoot":"","sources":["../../../src/tui/sidebar-frame.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAiC,KAAK,GAAG,EAAQ,MAAM,UAAU,CAAA;AAExE,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,wCAAwC,CAAA;AAE/C,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAA;AAGvB,KAAK,IAAI,GAAG,SAAS,CAAA;AAIrB,2EAA2E;AAC3E,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAElD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IAC/B,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAA;IACjC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAC3B;AAID,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,UAAU,CAenE;AAKD,wBAAgB,YAAY,C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AAA;KACzB,CAAA;IACD,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAA;CACrC;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aASpC,CAAA;AAKD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,MAAM,GACV,cAAc,GAAG,SAAS,CAuC5B;AAmED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,UAAU,CAAA;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,aAAa,CAAA;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,OAAO,CAAA;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,EAAE,MAAM,IAAI,CAAA;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,SAAS,YAAY,EAAE,CAAA;IAChD,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,UAAU,GAAG,IAAI,CAAA;IACvC,mEAAmE;IACnE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAA;CAC3B;AAkBD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAiJxE"}
@@ -1,37 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@opentui/solid/jsx-runtime";
2
2
  import { createMemo, createSignal, For, Show } from 'solid-js';
3
- import { formatQuota, isQuotaStale, } from '../common-auth-embedded/quota/index.js';
3
+ import { isQuotaStale, NO_QUOTA_READING, } from '../common-auth-embedded/quota/index.js';
4
+ import { SidebarFrame, SidebarSection, SidebarTextRow, } from '../common-auth-embedded/quota-sidebar/index';
4
5
  import { formatResetIn, formatWait } from '../sidebar-projection';
5
- import { ASSUMED_CONTENT_WIDTH, accountWindows, DEFAULT_QUOTA_APPEARANCE, fitLabel, GROUP_NAMES, QUOTA_ORDER, QuotaAccountBlock, quotaTone, } from './quota-layout';
6
+ import { accountWindows, DEFAULT_QUOTA_APPEARANCE, GROUP_NAMES, QUOTA_ORDER, quotaTone, } from './quota-layout';
6
7
  import { routeLineFits } from './route-layout';
7
- // Every tone falls through to a sibling token, so a sparse custom theme still
8
- // renders readably.
9
- export function toneColor(theme, tone) {
10
- switch (tone) {
11
- case 'ok':
12
- return theme.success ?? theme.accent;
13
- case 'warn':
14
- return theme.warning ?? theme.accent;
15
- case 'err':
16
- return theme.error ?? theme.accent;
17
- case 'muted':
18
- return theme.textMuted ?? theme.text;
19
- case 'accent':
20
- return theme.accent ?? theme.text;
21
- default:
22
- return theme.text;
23
- }
24
- }
25
- // The shared quota layout reads its colors through this palette. Muted text
26
- // and the account label read `textMuted` and `text` straight from the theme,
27
- // without the `toneColor` fallback chain.
28
- export function themePalette(theme) {
29
- return {
30
- text: () => theme().text,
31
- muted: () => theme().textMuted,
32
- tone: (tone) => toneColor(theme(), tone),
33
- };
34
- }
35
8
  /**
36
9
  * The OpenCode 1 preference defaults for the frame, for a renderer that has
37
10
  * no preferences file. A test keeps it equal to the matching part of
@@ -47,53 +20,6 @@ export const DEFAULT_FRAME_SETTINGS = {
47
20
  },
48
21
  appearance: DEFAULT_QUOTA_APPEARANCE,
49
22
  };
50
- // --- Rows ------------------------------------------------------------------
51
- // Section header: bold title, themed text color, top margin for vertical
52
- // breathing room between sections.
53
- export function SectionHeader(props) {
54
- return (_jsx("box", { width: '100%', marginTop: 1, children: _jsx("text", { fg: toneColor(props.theme(), 'text'), children: _jsx("b", { children: props.title }) }) }));
55
- }
56
- // Muted label left, value (optionally tone-tinted, bold) right, for the
57
- // routing and health rows.
58
- export function StatRow(props) {
59
- return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().textMuted, children: props.label }), _jsx("text", { fg: toneColor(props.theme(), props.tone ?? 'text'), children: _jsx("b", { children: props.value }) })] }));
60
- }
61
- // Muted label left, caller-supplied value right. The collapsed view renders
62
- // one row for every visible account. The caller sizes both sides to the
63
- // measured width, so neither side may wrap.
64
- function CollapsedRow(props) {
65
- return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { flexShrink: 0, wrapMode: 'none', fg: props.theme().textMuted, children: props.label }), props.children] }));
66
- }
67
- // One account in the Quota section: the shared quota block, with the status
68
- // word computed from the account state. Status word priorities (first match
69
- // wins):
70
- // - `off` when the account is disabled
71
- // - `cooling <wait>` when cooldownUntil is still in the future
72
- // - `active` when current === true
73
- // - `idle` for the fallback (current === false) case
74
- function AccountBlock(props) {
75
- const cooldownMs = () => {
76
- const cd = props.account.cooldownUntil;
77
- if (typeof cd !== 'number')
78
- return 0;
79
- return Math.max(0, cd - props.now());
80
- };
81
- const statusWord = () => {
82
- if (!props.account.enabled)
83
- return 'off';
84
- if (cooldownMs() > 0)
85
- return `cooling ${formatWait(cooldownMs())}`;
86
- return props.account.current ? 'active' : 'idle';
87
- };
88
- const statusTone = () => {
89
- if (!props.account.enabled)
90
- return 'muted';
91
- if (cooldownMs() > 0)
92
- return 'warn';
93
- return props.account.current ? 'ok' : 'muted';
94
- };
95
- return (_jsx(QuotaAccountBlock, { palette: themePalette(props.theme), appearance: props.appearance, account: props.account, status: statusWord(), statusTone: statusTone(), now: props.now, width: props.width, marginTop: props.marginTop }));
96
- }
97
23
  // Stored quota values are percentages and epoch-millisecond reset times.
98
24
  // Adapt them to the shared projection so common-auth, not the renderer,
99
25
  // decides how the narrow line reads.
@@ -135,110 +61,104 @@ export function sidebarQuotaProjection(account, now) {
135
61
  })),
136
62
  };
137
63
  }
138
- // One account on one measured, non-wrapping line: the label, the shared
139
- // narrow quota text and a status dot (`⊘` while the account is off or
140
- // cooling). The quota text is shown whole or not at all; the label is cut
141
- // with `…` to make room.
142
- function CollapsedAccount(props) {
143
- const account = props.account;
144
- const now = props.now;
145
- const theme = props.theme;
146
- const unavailable = () => !account.enabled ||
147
- (account.cooldownUntil != null && account.cooldownUntil > now());
148
- const line = createMemo(() => {
149
- const currentTime = now();
150
- const projection = sidebarQuotaProjection(account, currentTime);
151
- const text = formatQuota(projection, {
152
- now: currentTime,
153
- form: 'narrow',
154
- });
155
- const remaining = projection?.limits.length
156
- ? Math.min(...projection.limits.map((limit) => limit.remainingPercent ?? 100))
157
- : undefined;
158
- const tone = remaining === undefined
159
- ? 'muted'
160
- : quotaTone(100 - remaining, props.appearance());
161
- const stale = isQuotaStale(projection, { now: currentTime });
162
- const dot = unavailable() ? ' ⊘' : ' ●';
163
- const width = props.width();
164
- // Keep a complete shared line or omit it; a partial quota can make an
165
- // account look as if it has less remaining.
166
- const showQuota = text.length <= width;
167
- const showDot = dot.length <= width && (!showQuota || text.length + dot.length <= width);
168
- const rightWidth = (showQuota ? text.length : 0) + (showDot ? dot.length : 0);
169
- const labelWidth = Math.max(0, width - rightWidth - 1);
170
- return {
171
- dot,
172
- label: fitLabel(account.label, labelWidth),
173
- showDot,
174
- showQuota,
175
- stale,
176
- text,
177
- tone,
178
- };
179
- });
180
- const quotaColor = () => line().stale ? theme().textMuted : toneColor(theme(), line().tone);
181
- const dotColor = () => line().stale
182
- ? theme().textMuted
183
- : toneColor(theme(), unavailable() ? 'err' : line().tone);
184
- return (_jsx(CollapsedRow, { theme: theme, label: line().label, children: _jsxs("box", { flexDirection: 'row', flexShrink: 0, children: [_jsx(Show, { when: line().showQuota, children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: quotaColor(), children: _jsx("b", { children: line().text }) }) }), _jsx(Show, { when: line().showDot, children: _jsx("text", { flexShrink: 0, wrapMode: 'none', fg: dotColor(), children: line().dot }) })] }) }));
64
+ /** Preserve provider status and projection policy; the library owns all quota layout. */
65
+ function accountView(account, now, appearance) {
66
+ const cooldown = Math.max(0, (account.cooldownUntil ?? 0) - now);
67
+ const status = !account.enabled
68
+ ? { text: 'off', tone: 'textMuted' }
69
+ : cooldown > 0
70
+ ? { text: `cooling ${formatWait(cooldown)}`, tone: 'warning' }
71
+ : account.current
72
+ ? { text: 'active', tone: 'success' }
73
+ : { text: 'idle', tone: 'textMuted' };
74
+ const quota = sidebarQuotaProjection(account, now);
75
+ const stale = isQuotaStale(quota, { now });
76
+ const remaining = quota?.limits.length
77
+ ? Math.min(...quota.limits.map((limit) => limit.remainingPercent ?? 100))
78
+ : undefined;
79
+ const quotaColor = remaining === undefined
80
+ ? 'textMuted'
81
+ : quotaTone(100 - remaining, appearance);
82
+ const blocked = !account.enabled || cooldown > 0;
83
+ const windows = accountWindows(account, now).filter(({ reading, text }) => typeof reading.checkedAt === 'number' &&
84
+ Number.isFinite(reading.checkedAt) &&
85
+ reading.checkedAt >= 0 &&
86
+ text.remaining !== null);
87
+ return {
88
+ id: account.id,
89
+ label: account.label,
90
+ status,
91
+ blocked,
92
+ indicatorTone: stale ? 'textMuted' : blocked ? 'error' : quotaColor,
93
+ quota,
94
+ collapsed: {
95
+ quotaTone: quotaColor,
96
+ muted: stale || status.text !== 'active',
97
+ },
98
+ emptyQuotaText: { expanded: NO_QUOTA_READING, collapsed: NO_QUOTA_READING },
99
+ groups: QUOTA_ORDER.flatMap((key) => {
100
+ const rows = windows
101
+ .filter((window) => window.key === key)
102
+ .map(({ reading, text }) => ({
103
+ part: {
104
+ kind: 'window',
105
+ name: text.name,
106
+ short: text.name,
107
+ figure: text.figure,
108
+ remainingPercent: text.remaining ?? undefined,
109
+ resetIn: text.reset || undefined,
110
+ checkedAt: reading.checkedAt ?? now,
111
+ resetSinceReading: text.resetSinceReading,
112
+ },
113
+ }));
114
+ return rows.length ? [{ title: GROUP_NAMES[key], rows }] : [];
115
+ }),
116
+ };
117
+ }
118
+ function StatRow(props) {
119
+ return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().textMuted, children: props.label }), _jsx("text", { fg: props.theme()[props.tone ?? 'text'], children: _jsx("b", { children: props.value }) })] }));
185
120
  }
186
- // --- Frame -----------------------------------------------------------------
187
- // The opentui border prop is not typed in the plugin TUI surface.
188
- const SINGLE_BORDER = { type: 'single' };
189
- export function SidebarFrame(props) {
190
- const theme = props.theme;
121
+ export function AntigravitySidebar(props) {
191
122
  const prefs = props.settings;
192
- const collapsed = props.collapsed;
193
123
  const now = props.now;
194
124
  const hasData = () => props.accounts().length > 0;
195
125
  const backoffActive = () => {
196
126
  const until = props.quotaBackoffUntil();
197
127
  return typeof until === 'number' && until > now();
198
128
  };
199
- const lastError = () => props.lastError();
200
- const degraded = () => backoffActive() || !!lastError();
201
- // Honors sections.fallbackAccounts. Both the expanded (AccountBlock list)
202
- // and the collapsed (CollapsedAccount list) paths use the same filter so
203
- // the user sees the same account set in either mode.
204
- const visibleAccounts = () => {
205
- const showFallback = prefs().sections.fallbackAccounts;
206
- if (showFallback)
207
- return props.accounts();
208
- return props.accounts().filter((account) => account.current);
129
+ const visibleAccounts = createMemo(() => props
130
+ .accounts()
131
+ .filter((account) => prefs().sections.fallbackAccounts || account.current)
132
+ .map((account) => accountView(account, now(), prefs().appearance)));
133
+ const theme = () => {
134
+ const source = props.theme();
135
+ return {
136
+ ...source,
137
+ textMuted: source.textMuted ?? source.text,
138
+ accent: source.accent ?? source.text,
139
+ success: source.success ?? source.accent ?? source.text,
140
+ warning: source.warning ?? source.accent ?? source.text,
141
+ error: source.error ?? source.accent ?? source.text,
142
+ };
209
143
  };
210
- // The route on one `Route <value>` line when it fits, else one line per
211
- // part with the strategy last.
212
- const routeValue = (route) => `${route.strategy ? `${route.strategy} · ` : ''}${route.family}: ${route.style}`;
213
- const routeLines = (route) => [`${route.family}: ${route.style}`, route.strategy ?? ''].filter((line) => line !== '');
214
- // The width available to content: the header row spans the panel inside
215
- // its border and padding. Layout reports it during a render pass, so the
216
- // signal is updated afterwards rather than rebuilding rows mid-pass.
217
- const [contentWidth, setContentWidth] = createSignal(ASSUMED_CONTENT_WIDTH);
218
- let headerRow;
144
+ // Routing keeps whole parts on separate lines when the single stat row is too wide.
145
+ const [contentWidth, setContentWidth] = createSignal(28);
146
+ let sections;
219
147
  const measureContentWidth = () => {
220
- const width = headerRow?.width;
221
- if (typeof width !== 'number' || width <= 0)
222
- return;
223
- queueMicrotask(() => {
224
- if (width !== contentWidth())
225
- setContentWidth(width);
226
- });
227
- };
228
- // Header badge: ▼/▶ {label}, with the version at the right when nothing is
229
- // degraded and a `LIMITED` badge in its place when something is.
230
- const headerLabel = () => {
231
- const name = prefs().header.label;
232
- return !hasData() ? name : collapsed() ? `\u25b6 ${name}` : `\u25bc ${name}`;
148
+ const width = sections?.width;
149
+ if (width && width !== contentWidth())
150
+ queueMicrotask(() => setContentWidth(width));
233
151
  };
234
- return (_jsxs("box", { width: '100%', flexDirection: 'column', border: SINGLE_BORDER, borderColor: theme().borderActive, paddingTop: 1, paddingBottom: 1, paddingLeft: 1, paddingRight: 1, children: [_jsxs("box", { ref: (element) => {
235
- headerRow = element;
236
- }, onSizeChange: measureContentWidth, width: '100%', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', onMouseDown: () => {
237
- // Only toggle when there is data to expand into. Without this a
238
- // click on the empty-awaiting header would just toggle the
239
- // affordance for nothing.
240
- if (hasData())
241
- props.onToggleCollapsed();
242
- }, children: [_jsx("box", { paddingLeft: 1, paddingRight: 1, backgroundColor: theme().accent, children: _jsx("text", { fg: theme().background, children: _jsx("b", { children: headerLabel() }) }) }), _jsx(Show, { when: degraded(), fallback: _jsx(Show, { when: prefs().header.showVersion && props.version !== '', children: _jsx("text", { fg: theme().textMuted, children: `v${props.version}` }) }), children: _jsx("box", { paddingLeft: 1, paddingRight: 1, backgroundColor: theme().warning, children: _jsx("text", { fg: theme().background, children: _jsx("b", { children: 'LIMITED' }) }) }) })] }), _jsx(Show, { when: collapsed() && hasData(), children: _jsx(For, { each: visibleAccounts(), children: (account) => (_jsx(CollapsedAccount, { theme: theme, appearance: () => prefs().appearance, account: account, now: now, width: contentWidth })) }) }), _jsx(Show, { when: !collapsed() || !hasData(), children: _jsxs(Show, { when: hasData(), fallback: _jsx("box", { marginTop: 1, width: '100%', children: _jsx("text", { fg: theme().textMuted, children: 'Waiting for quota\u2026' }) }), children: [_jsxs(Show, { when: prefs().sections.quota, children: [_jsx(SectionHeader, { theme: theme, title: 'Quota' }), _jsx(For, { each: visibleAccounts(), children: (account, index) => (_jsx(AccountBlock, { theme: theme, appearance: prefs().appearance, account: account, now: now, width: contentWidth, marginTop: index() === 0 ? 0 : 1 })) })] }), _jsxs(Show, { when: prefs().sections.routing, children: [_jsx(SectionHeader, { theme: theme, title: 'Routing' }), _jsx(Show, { when: props.route(), fallback: _jsx("text", { wrapMode: 'none', fg: theme().textMuted, children: 'No request yet' }), children: (route) => (_jsx(Show, { when: routeLineFits('Route', routeValue(route()), contentWidth()), fallback: _jsx(For, { each: routeLines(route()), children: (line) => (_jsx("text", { wrapMode: 'none', fg: toneColor(theme(), 'accent'), children: _jsx("b", { children: line }) })) }), children: _jsx(StatRow, { theme: theme, label: 'Route', value: routeValue(route()), tone: 'accent' }) })) })] }), _jsxs(Show, { when: degraded() && prefs().sections.health, children: [_jsx(SectionHeader, { theme: theme, title: 'Health' }), _jsx(Show, { when: backoffActive(), children: _jsx(StatRow, { theme: theme, label: 'Quota API', value: `backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`, tone: 'warn' }) }), _jsx(Show, { when: lastError(), children: _jsx(StatRow, { theme: theme, label: 'Last error', value: lastError() ?? '', tone: 'err' }) })] })] }) })] }));
152
+ const routeValue = (route) => `${route.strategy ? `${route.strategy} · ` : ''}${route.family}: ${route.style}`;
153
+ const routeLines = (route) => [`${route.family}: ${route.style}`, route.strategy ?? ''].filter(Boolean);
154
+ return (_jsx(SidebarFrame, { header: {
155
+ badge: prefs().header.label,
156
+ version: prefs().header.showVersion && props.version
157
+ ? `v${props.version}`
158
+ : undefined,
159
+ }, theme: theme(), appearance: prefs().appearance, accounts: visibleAccounts(), showQuota: prefs().sections.quota, now: now(), collapsed: props.collapsed(), onToggle: props.onToggleCollapsed, sections: () => (_jsx(Show, { when: !props.collapsed() || !hasData(), children: _jsx("box", { width: '100%', flexDirection: 'column', ref: (element) => {
160
+ sections = element;
161
+ }, onSizeChange: measureContentWidth, children: _jsxs(Show, { when: hasData(), fallback: _jsx("box", { marginTop: 1, width: '100%', children: _jsx(SidebarTextRow, { text: 'Waiting for quota\u2026', wrapMode: 'none' }) }), children: [_jsx(Show, { when: prefs().sections.quota && visibleAccounts().length === 0, children: _jsx(SidebarSection, { title: 'Quota' }) }), _jsx(Show, { when: prefs().sections.routing, children: _jsx(SidebarSection, { title: 'Routing', children: _jsx(Show, { when: props.route(), fallback: _jsx(SidebarTextRow, { text: 'No request yet', wrapMode: 'none' }), children: (route) => (_jsx(Show, { when: routeLineFits('Route', routeValue(route()), contentWidth()), fallback: _jsx(For, { each: routeLines(route()), children: (line) => (_jsx("text", { fg: theme().accent, wrapMode: 'none', children: _jsx("b", { children: line }) })) }), children: _jsx(StatRow, { theme: theme, label: 'Route', value: routeValue(route()), tone: 'accent' }) })) }) }) }), _jsx(Show, { when: (backoffActive() || !!props.lastError()) &&
162
+ prefs().sections.health, children: _jsxs(SidebarSection, { title: 'Health', children: [_jsx(Show, { when: backoffActive(), children: _jsx(StatRow, { theme: theme, label: 'Quota API', value: `backoff ${formatResetIn(props.quotaBackoffUntil(), now())}`, tone: 'warning' }) }), _jsx(Show, { when: props.lastError(), children: _jsx(StatRow, { theme: theme, label: 'Last error', value: props.lastError() ?? '', tone: 'error' }) })] }) })] }) }) })) }));
243
163
  }
244
164
  //# sourceMappingURL=sidebar-frame.js.map