@cortexkit/opencode-antigravity-auth 3.0.21 → 3.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/cli.js +279 -246
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +38 -13
  4. package/dist/index.js +766 -360
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +95 -20
  7. package/dist/server.js +785 -379
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  11. package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
  12. package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
  13. package/dist/src/common-auth-embedded/quota/format.js +45 -26
  14. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  15. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  16. package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
  17. package/dist/src/common-auth-embedded/source-output.json +42 -22
  18. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  19. package/dist/src/plugin/index.d.ts.map +1 -1
  20. package/dist/src/plugin/index.js +2 -0
  21. package/dist/src/plugin/index.js.map +1 -1
  22. package/dist/src/plugin/request.d.ts.map +1 -1
  23. package/dist/src/plugin/request.js +1 -0
  24. package/dist/src/plugin/request.js.map +1 -1
  25. package/dist/src/plugin/shared/request-services.d.ts +6 -0
  26. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  27. package/dist/src/plugin/shared/request-services.js +89 -2
  28. package/dist/src/plugin/shared/request-services.js.map +1 -1
  29. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  30. package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
  31. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  32. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  33. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  34. package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
  35. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
  36. package/dist/src/plugin/shared/vault-routing.d.ts +36 -0
  37. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
  38. package/dist/src/plugin/shared/vault-routing.js +213 -0
  39. package/dist/src/plugin/shared/vault-routing.js.map +1 -0
  40. package/dist/src/plugin/types.d.ts +1 -0
  41. package/dist/src/plugin/types.d.ts.map +1 -1
  42. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  43. package/dist/src/tui/sidebar-frame.js +18 -16
  44. package/dist/src/tui/sidebar-frame.js.map +1 -1
  45. package/dist/tui-build-map.json +13 -13
  46. package/dist/tui-ga-build-map.json +13 -13
  47. package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
  48. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  49. package/dist/types/src/plugin/index.d.ts.map +1 -1
  50. package/dist/types/src/plugin/request.d.ts.map +1 -1
  51. package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
  52. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  53. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  54. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  55. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  56. package/dist/types/src/plugin/shared/vault-routing.d.ts +36 -0
  57. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
  58. package/dist/types/src/plugin/types.d.ts +1 -0
  59. package/dist/types/src/plugin/types.d.ts.map +1 -1
  60. package/package.json +2 -2
  61. package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  62. package/src/common-auth-embedded/fs/with-lock.js +37 -10
  63. package/src/common-auth-embedded/quota/format.d.ts +9 -4
  64. package/src/common-auth-embedded/quota/format.js +45 -26
  65. package/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  66. package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  67. package/src/common-auth-embedded/routing-accessor/index.js +128 -0
  68. package/src/common-auth-embedded/source-output.json +42 -22
  69. package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
  70. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +165 -148
  71. package/src/tui-compiled/tui/sidebar-frame.js +17 -16
  72. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
  73. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +17 -16
  74. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +165 -148
  75. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
  76. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +21 -19
  77. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +56 -32
  78. package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
  79. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  80. package/src/tui-raw/tui/sidebar-frame.tsx +21 -19
@@ -10,6 +10,7 @@ import {
10
10
  NO_QUOTA_READING,
11
11
  type ProjectedLimit,
12
12
  type ProjectedQuota,
13
+ type QuotaWindowPart,
13
14
  } from "./bf17cbee28e58197-index.js"
14
15
  import {
15
16
  type AccountView,
@@ -171,13 +172,7 @@ function accountView(
171
172
  ? 'textMuted'
172
173
  : quotaTone(100 - remaining, appearance)
173
174
  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,
180
- )
175
+ const windows = accountWindows(account, now)
181
176
  return {
182
177
  id: account.id,
183
178
  label: account.label,
@@ -193,18 +188,25 @@ function accountView(
193
188
  groups: QUOTA_ORDER.flatMap((key) => {
194
189
  const rows = windows
195
190
  .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
- }))
191
+ .map(({ reading, text }) => {
192
+ const name =
193
+ text.name ||
194
+ (reading.window === 'weekly' ? '7d' : (reading.window ?? ''))
195
+ return {
196
+ part: {
197
+ kind: 'window',
198
+ reading: text.remaining === null ? 'unknown' : 'known',
199
+ name,
200
+ short: name,
201
+ figure: text.remaining === null ? 'no reading' : text.figure,
202
+ remainingPercent: text.remaining ?? undefined,
203
+ resetIn: text.reset || undefined,
204
+ checkedAt:
205
+ text.remaining === null ? undefined : reading.checkedAt,
206
+ resetSinceReading: text.resetSinceReading,
207
+ } satisfies QuotaWindowPart,
208
+ }
209
+ })
208
210
  return rows.length ? [{ title: GROUP_NAMES[key], rows }] : []
209
211
  }),
210
212
  }
@@ -238,17 +238,20 @@ function QuotaRow(props: {
238
238
  ' '.repeat(Math.max(0, props.labelWidth - displayWidth(props.part.name)))
239
239
  const figure = () =>
240
240
  ` ${props.part.kind === 'budget' && props.part.figure.startsWith(`${props.part.name} `) ? props.part.figure.slice(props.part.name.length + 1) : props.part.figure}`
241
+ const hasReading = () => props.part.reading === 'known'
241
242
  const used = () => 100 - (props.part.remainingPercent ?? 100)
242
243
  // Size notifications can recompute an unchanged fit after text has been flushed
243
244
  // for the frame. Keep equal segments, and update fixed slots in place when the
244
245
  // bar changes, rather than replacing text nodes during layout.
245
246
  const segments = createMemo(
246
247
  () =>
247
- barSegments(
248
- used(),
249
- { ...context.appearance, barWidth: props.barCells },
250
- props.pace,
251
- ),
248
+ hasReading()
249
+ ? barSegments(
250
+ used(),
251
+ { ...context.appearance, barWidth: props.barCells },
252
+ props.pace,
253
+ )
254
+ : [],
252
255
  undefined,
253
256
  {
254
257
  equals: (previous, next) =>
@@ -286,36 +289,49 @@ function QuotaRow(props: {
286
289
  </text>
287
290
  </Show>
288
291
  <Show
289
- when={!props.part.resetSinceReading}
292
+ when={hasReading()}
290
293
  fallback={
291
294
  <text fg={context.theme.textMuted} wrapMode='none'>
292
- reset since last check
295
+ no reading
293
296
  </text>
294
297
  }
295
298
  >
296
- <Show when={props.barCells > 0}>
297
- {/* Text nodes clear omitted theme colours; empty slots must not reserve a cell. */}
298
- <Index each={segments()}>
299
- {(segment) => (
300
- <text
301
- fg={context.theme[segment().tone]}
302
- wrapMode='none'
303
- width={segment().text ? undefined : 0}
304
- >
305
- {segment().text}
306
- </text>
307
- )}
308
- </Index>
309
- </Show>
310
- <text
311
- fg={context.theme[usageTone(used(), context.appearance)]}
312
- wrapMode='none'
299
+ <Show
300
+ when={!props.part.resetSinceReading}
301
+ fallback={
302
+ <text fg={context.theme.textMuted} wrapMode='none'>
303
+ reset since last check
304
+ </text>
305
+ }
313
306
  >
314
- {figure()}
315
- </text>
307
+ <Show when={props.barCells > 0}>
308
+ {/* Text nodes clear omitted theme colours; empty slots must not reserve a cell. */}
309
+ <Index each={segments()}>
310
+ {(segment) => (
311
+ <text
312
+ fg={context.theme[segment().tone]}
313
+ wrapMode='none'
314
+ width={segment().text ? undefined : 0}
315
+ >
316
+ {segment().text}
317
+ </text>
318
+ )}
319
+ </Index>
320
+ </Show>
321
+ <text
322
+ fg={context.theme[usageTone(used(), context.appearance)]}
323
+ wrapMode='none'
324
+ >
325
+ {figure()}
326
+ </text>
327
+ </Show>
316
328
  </Show>
317
329
  </box>
318
- <Show when={props.showReset && !props.part.resetSinceReading}>
330
+ <Show
331
+ when={
332
+ hasReading() && props.showReset && !props.part.resetSinceReading
333
+ }
334
+ >
319
335
  <box
320
336
  width={props.resetWidth}
321
337
  flexShrink={0}
@@ -331,7 +347,10 @@ function QuotaRow(props: {
331
347
  </Show>
332
348
  </box>
333
349
  {/* A changed fitted line needs a fresh text node to draw at its new width. */}
334
- <Show when={!props.part.resetSinceReading && paceLine()} keyed>
350
+ <Show
351
+ when={hasReading() && !props.part.resetSinceReading && paceLine()}
352
+ keyed
353
+ >
335
354
  {(line: string) => (
336
355
  <box width='100%' flexDirection='row'>
337
356
  <Show when={props.labelWidth > 0}>
@@ -357,8 +376,9 @@ function CollapsedAccountRow(props: { account: AccountView }) {
357
376
  const [width, setWidth] = createSignal(0)
358
377
  let row: { width: number } | undefined
359
378
  const hasQuota = () =>
360
- quotaWindowParts(props.account.quota, { now: context.now }).windows.length >
361
- 0
379
+ quotaWindowParts(props.account.quota, { now: context.now }).windows.some(
380
+ (part) => part.reading === 'known',
381
+ )
362
382
  const text = () =>
363
383
  hasQuota()
364
384
  ? formatQuota(props.account.quota, { now: context.now, form: 'narrow' })
@@ -431,14 +451,18 @@ function AccountBlock(props: { account: AccountView; marginTop: number }) {
431
451
  Math.max(
432
452
  0,
433
453
  ...rows().map(({ part }) =>
434
- part.resetSinceReading ? 0 : displayWidth(part.resetIn ?? ''),
454
+ part.reading === 'unknown' || part.resetSinceReading
455
+ ? 0
456
+ : displayWidth(part.resetIn ?? ''),
435
457
  ),
436
458
  )
437
459
  const figureWidth = createMemo(() =>
438
460
  Math.max(
439
461
  10,
440
462
  ...rows()
441
- .filter(({ part }) => !part.resetSinceReading)
463
+ .filter(
464
+ ({ part }) => part.reading === 'known' && !part.resetSinceReading,
465
+ )
442
466
  .map(({ part }) =>
443
467
  displayWidth(
444
468
  ` ${part.kind === 'budget' && part.figure.startsWith(`${part.name} `) ? part.figure.slice(part.name.length + 1) : part.figure}`,
@@ -5,10 +5,10 @@
5
5
  //
6
6
  // The rules: a window is named by its length (`5h`, `7d`), or, for a window
7
7
  // that binds only one model family, by the label the plugin stored it under.
8
- // Every figure is "% left". A window the provider did not report (an absence
9
- // record or a retirement tombstone) is left out rather than written as "not
10
- // reported". A reset is a short time from now (`resets 2h`). A reading older
11
- // than fifteen minutes says how old it is (`checked 3h ago`).
8
+ // Every reported window figure is "% left". A window the provider did not
9
+ // report (an absence record or a retirement tombstone) is left out rather than
10
+ // written as "not reported". A reset is a short time from now (`resets 2h`).
11
+ // A reading older than fifteen minutes says how old it is (`checked 3h ago`).
12
12
  //
13
13
  // Like the rest of this module it reads no clock: `now` is a parameter.
14
14
  import { ALL_SCOPE } from "./map.js";
@@ -97,12 +97,14 @@ function displayOrder(left, right) {
97
97
  return left.label < right.label ? -1 : left.label > right.label ? 1 : 0;
98
98
  }
99
99
  /**
100
- * Structured quota wording for layouts that need one row per window. The
101
- * windows use the same filtering and order as `quotaTextParts`; future resets
102
- * and the optional age keep the shared formatter's wording.
100
+ * Structured quota wording for layouts that need one row per window.
101
+ * Windows without a dated percentage remain as explicit unknown parts. Limits
102
+ * marked absent (not reported) or retired (no longer tracked) remain omitted.
103
+ * Reported windows, future resets and the optional age keep the shared
104
+ * formatter's wording and order.
103
105
  */
104
106
  export function quotaWindowParts(quota, options) {
105
- const { windows, age } = scopedWindowParts(quota, options);
107
+ const { windows, age } = scopedWindowParts(quota, options, true);
106
108
  const parts = windows.map(({ part }) => part);
107
109
  return age === undefined ? { windows: parts } : { windows: parts, age };
108
110
  }
@@ -125,34 +127,47 @@ function withShortNames(windows) {
125
127
  }
126
128
  return windows;
127
129
  }
130
+ function hasWindowReading(limit) {
131
+ return (Number.isFinite(limit.remainingPercent) && Number.isFinite(limit.checkedAt));
132
+ }
128
133
  /**
129
134
  * `quotaWindowParts` with each window's scope kept beside it. The narrow form
130
135
  * needs the scope to name and pick model-scoped windows; the public parts do
131
- * not carry it, so their shape stays as it was.
136
+ * not carry the scope.
132
137
  */
133
- function scopedWindowParts(quota, options) {
138
+ function scopedWindowParts(quota, options, includeUnknown = false) {
134
139
  if (!quota)
135
140
  return { windows: [] };
136
141
  const { now } = options;
137
142
  const readings = quota.limits
138
- .filter((limit) => limit.kind === 'reading' && limit.remainingPercent !== undefined)
143
+ .filter((limit) => limit.kind === 'reading' && (includeUnknown || hasWindowReading(limit)))
139
144
  .sort(displayOrder);
140
145
  const windows = readings.map((limit) => {
141
- const remainingPercent = clampPercent(limit.remainingPercent ?? 0);
142
- return {
143
- scope: limit.scope,
144
- ...(limit.windowMinutes === undefined
145
- ? {}
146
- : { windowMinutes: limit.windowMinutes }),
147
- part: {
146
+ const part = hasWindowReading(limit)
147
+ ? {
148
148
  kind: 'window',
149
+ reading: 'known',
149
150
  name: quotaWindowName(limit),
150
151
  short: '',
151
- figure: percentLeft(limit.remainingPercent ?? 0),
152
- remainingPercent,
152
+ figure: percentLeft(limit.remainingPercent),
153
+ remainingPercent: clampPercent(limit.remainingPercent),
153
154
  checkedAt: limit.checkedAt,
154
155
  ...resetDetails(limit.resetsAt, limit.checkedAt, now),
155
- },
156
+ }
157
+ : {
158
+ kind: 'window',
159
+ reading: 'unknown',
160
+ name: quotaWindowName(limit),
161
+ short: '',
162
+ figure: 'no reading',
163
+ resetSinceReading: false,
164
+ };
165
+ return {
166
+ scope: limit.scope,
167
+ ...(limit.windowMinutes === undefined
168
+ ? {}
169
+ : { windowMinutes: limit.windowMinutes }),
170
+ part,
156
171
  };
157
172
  });
158
173
  const budget = quota.budget;
@@ -168,6 +183,7 @@ function scopedWindowParts(quota, options) {
168
183
  spent: budget.reached,
169
184
  part: {
170
185
  kind: 'budget',
186
+ reading: 'known',
171
187
  name: 'credits',
172
188
  short: '',
173
189
  figure,
@@ -180,8 +196,11 @@ function scopedWindowParts(quota, options) {
180
196
  });
181
197
  }
182
198
  withShortNames(windows);
183
- if (windows.length > 0) {
184
- const age = now - Math.min(...windows.map(({ part }) => part.checkedAt));
199
+ const readingTimes = windows.flatMap(({ part }) => part.reading === 'known' && part.checkedAt !== undefined
200
+ ? [part.checkedAt]
201
+ : []);
202
+ if (readingTimes.length > 0) {
203
+ const age = now - Math.min(...readingTimes);
185
204
  if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
186
205
  return { windows, age: `checked ${shortSpan(age)} ago` };
187
206
  }
@@ -357,13 +376,13 @@ function narrowTextParts(quota, options) {
357
376
  export function quotaTextParts(quota, options) {
358
377
  if (options.form === 'narrow')
359
378
  return narrowTextParts(quota, options);
360
- const parts = quotaWindowParts(quota, options);
379
+ const { windows, age } = scopedWindowParts(quota, options);
361
380
  const full = (options.form ?? 'full') === 'full';
362
- const text = parts.windows.map((part) => {
381
+ const text = windows.map(({ part }) => {
363
382
  const reset = full && part.resetIn ? `, resets ${part.resetIn}` : '';
364
383
  return `${part.kind === 'budget' ? '' : `${part.name} `}${part.figure}${reset}`;
365
384
  });
366
- return parts.age === undefined ? text : [...text, parts.age];
385
+ return age === undefined ? text : [...text, age];
367
386
  }
368
387
  /**
369
388
  * A row's quota as one line: `5h 58% left · 7d 90% left` in the compact
@@ -238,17 +238,20 @@ function QuotaRow(props: {
238
238
  ' '.repeat(Math.max(0, props.labelWidth - displayWidth(props.part.name)))
239
239
  const figure = () =>
240
240
  ` ${props.part.kind === 'budget' && props.part.figure.startsWith(`${props.part.name} `) ? props.part.figure.slice(props.part.name.length + 1) : props.part.figure}`
241
+ const hasReading = () => props.part.reading === 'known'
241
242
  const used = () => 100 - (props.part.remainingPercent ?? 100)
242
243
  // Size notifications can recompute an unchanged fit after text has been flushed
243
244
  // for the frame. Keep equal segments, and update fixed slots in place when the
244
245
  // bar changes, rather than replacing text nodes during layout.
245
246
  const segments = createMemo(
246
247
  () =>
247
- barSegments(
248
- used(),
249
- { ...context.appearance, barWidth: props.barCells },
250
- props.pace,
251
- ),
248
+ hasReading()
249
+ ? barSegments(
250
+ used(),
251
+ { ...context.appearance, barWidth: props.barCells },
252
+ props.pace,
253
+ )
254
+ : [],
252
255
  undefined,
253
256
  {
254
257
  equals: (previous, next) =>
@@ -286,36 +289,49 @@ function QuotaRow(props: {
286
289
  </text>
287
290
  </Show>
288
291
  <Show
289
- when={!props.part.resetSinceReading}
292
+ when={hasReading()}
290
293
  fallback={
291
294
  <text fg={context.theme.textMuted} wrapMode='none'>
292
- reset since last check
295
+ no reading
293
296
  </text>
294
297
  }
295
298
  >
296
- <Show when={props.barCells > 0}>
297
- {/* Text nodes clear omitted theme colours; empty slots must not reserve a cell. */}
298
- <Index each={segments()}>
299
- {(segment) => (
300
- <text
301
- fg={context.theme[segment().tone]}
302
- wrapMode='none'
303
- width={segment().text ? undefined : 0}
304
- >
305
- {segment().text}
306
- </text>
307
- )}
308
- </Index>
309
- </Show>
310
- <text
311
- fg={context.theme[usageTone(used(), context.appearance)]}
312
- wrapMode='none'
299
+ <Show
300
+ when={!props.part.resetSinceReading}
301
+ fallback={
302
+ <text fg={context.theme.textMuted} wrapMode='none'>
303
+ reset since last check
304
+ </text>
305
+ }
313
306
  >
314
- {figure()}
315
- </text>
307
+ <Show when={props.barCells > 0}>
308
+ {/* Text nodes clear omitted theme colours; empty slots must not reserve a cell. */}
309
+ <Index each={segments()}>
310
+ {(segment) => (
311
+ <text
312
+ fg={context.theme[segment().tone]}
313
+ wrapMode='none'
314
+ width={segment().text ? undefined : 0}
315
+ >
316
+ {segment().text}
317
+ </text>
318
+ )}
319
+ </Index>
320
+ </Show>
321
+ <text
322
+ fg={context.theme[usageTone(used(), context.appearance)]}
323
+ wrapMode='none'
324
+ >
325
+ {figure()}
326
+ </text>
327
+ </Show>
316
328
  </Show>
317
329
  </box>
318
- <Show when={props.showReset && !props.part.resetSinceReading}>
330
+ <Show
331
+ when={
332
+ hasReading() && props.showReset && !props.part.resetSinceReading
333
+ }
334
+ >
319
335
  <box
320
336
  width={props.resetWidth}
321
337
  flexShrink={0}
@@ -331,7 +347,10 @@ function QuotaRow(props: {
331
347
  </Show>
332
348
  </box>
333
349
  {/* A changed fitted line needs a fresh text node to draw at its new width. */}
334
- <Show when={!props.part.resetSinceReading && paceLine()} keyed>
350
+ <Show
351
+ when={hasReading() && !props.part.resetSinceReading && paceLine()}
352
+ keyed
353
+ >
335
354
  {(line: string) => (
336
355
  <box width='100%' flexDirection='row'>
337
356
  <Show when={props.labelWidth > 0}>
@@ -357,8 +376,9 @@ function CollapsedAccountRow(props: { account: AccountView }) {
357
376
  const [width, setWidth] = createSignal(0)
358
377
  let row: { width: number } | undefined
359
378
  const hasQuota = () =>
360
- quotaWindowParts(props.account.quota, { now: context.now }).windows.length >
361
- 0
379
+ quotaWindowParts(props.account.quota, { now: context.now }).windows.some(
380
+ (part) => part.reading === 'known',
381
+ )
362
382
  const text = () =>
363
383
  hasQuota()
364
384
  ? formatQuota(props.account.quota, { now: context.now, form: 'narrow' })
@@ -431,14 +451,18 @@ function AccountBlock(props: { account: AccountView; marginTop: number }) {
431
451
  Math.max(
432
452
  0,
433
453
  ...rows().map(({ part }) =>
434
- part.resetSinceReading ? 0 : displayWidth(part.resetIn ?? ''),
454
+ part.reading === 'unknown' || part.resetSinceReading
455
+ ? 0
456
+ : displayWidth(part.resetIn ?? ''),
435
457
  ),
436
458
  )
437
459
  const figureWidth = createMemo(() =>
438
460
  Math.max(
439
461
  10,
440
462
  ...rows()
441
- .filter(({ part }) => !part.resetSinceReading)
463
+ .filter(
464
+ ({ part }) => part.reading === 'known' && !part.resetSinceReading,
465
+ )
442
466
  .map(({ part }) =>
443
467
  displayWidth(
444
468
  ` ${part.kind === 'budget' && part.figure.startsWith(`${part.name} `) ? part.figure.slice(part.name.length + 1) : part.figure}`,
@@ -10,6 +10,7 @@ import {
10
10
  NO_QUOTA_READING,
11
11
  type ProjectedLimit,
12
12
  type ProjectedQuota,
13
+ type QuotaWindowPart,
13
14
  } from "../common-auth-embedded/quota/index.js"
14
15
  import {
15
16
  type AccountView,
@@ -171,13 +172,7 @@ function accountView(
171
172
  ? 'textMuted'
172
173
  : quotaTone(100 - remaining, appearance)
173
174
  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,
180
- )
175
+ const windows = accountWindows(account, now)
181
176
  return {
182
177
  id: account.id,
183
178
  label: account.label,
@@ -193,18 +188,25 @@ function accountView(
193
188
  groups: QUOTA_ORDER.flatMap((key) => {
194
189
  const rows = windows
195
190
  .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
- }))
191
+ .map(({ reading, text }) => {
192
+ const name =
193
+ text.name ||
194
+ (reading.window === 'weekly' ? '7d' : (reading.window ?? ''))
195
+ return {
196
+ part: {
197
+ kind: 'window',
198
+ reading: text.remaining === null ? 'unknown' : 'known',
199
+ name,
200
+ short: name,
201
+ figure: text.remaining === null ? 'no reading' : text.figure,
202
+ remainingPercent: text.remaining ?? undefined,
203
+ resetIn: text.reset || undefined,
204
+ checkedAt:
205
+ text.remaining === null ? undefined : reading.checkedAt,
206
+ resetSinceReading: text.resetSinceReading,
207
+ } satisfies QuotaWindowPart,
208
+ }
209
+ })
208
210
  return rows.length ? [{ title: GROUP_NAMES[key], rows }] : []
209
211
  }),
210
212
  }