@cortexkit/common-auth 0.32.0 → 0.32.1

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.
@@ -1,4 +1,4 @@
1
- import { createContext, createMemo, createSignal, For, mergeProps, Show, useContext, } from 'solid-js';
1
+ import { createContext, createMemo, createSignal, For, Index, mergeProps, Show, useContext, } from 'solid-js';
2
2
  import { formatQuota, quotaWindowParts } from '../quota/format.js';
3
3
  const FrameContext = createContext();
4
4
  function frameContext() {
@@ -76,18 +76,20 @@ function barSegments(used, appearance, pace) {
76
76
  const cells = (pct) => Math.max(0, Math.min(Math.round((pct / 100) * width), width));
77
77
  const usedCells = cells(used);
78
78
  const tone = usageTone(used, appearance);
79
+ // Keep the overlay's slot even when empty so live pacing changes reuse nodes.
79
80
  const plain = [
80
81
  { text: appearance.barFilledChar.repeat(usedCells), tone },
82
+ { text: '', tone },
81
83
  { text: appearance.barEmptyChar.repeat(width - usedCells), tone },
82
84
  ];
83
85
  const overlay = pace?.overlay;
84
86
  if (!overlay)
85
- return plain.filter((segment) => segment.text.length > 0);
87
+ return plain;
86
88
  const paceCells = cells(overlay.percent);
87
89
  const lo = Math.min(usedCells, paceCells);
88
90
  const hi = Math.max(usedCells, paceCells);
89
91
  if (lo === hi)
90
- return plain.filter((segment) => segment.text.length > 0);
92
+ return plain;
91
93
  return [
92
94
  { text: appearance.barFilledChar.repeat(lo), tone },
93
95
  {
@@ -95,7 +97,7 @@ function barSegments(used, appearance, pace) {
95
97
  tone: overlay.kind === 'deficit' ? 'error' : 'success',
96
98
  },
97
99
  { text: appearance.barEmptyChar.repeat(width - hi), tone },
98
- ].filter((segment) => segment.text.length > 0);
100
+ ];
99
101
  }
100
102
  function QuotaRow(props) {
101
103
  const context = frameContext();
@@ -105,6 +107,14 @@ function QuotaRow(props) {
105
107
  ' '.repeat(Math.max(0, props.labelWidth - displayWidth(props.part.name)));
106
108
  const figure = () => ` ${props.part.kind === 'budget' && props.part.figure.startsWith(`${props.part.name} `) ? props.part.figure.slice(props.part.name.length + 1) : props.part.figure}`;
107
109
  const used = () => 100 - (props.part.remainingPercent ?? 100);
110
+ // Size notifications can recompute an unchanged fit after text has been flushed
111
+ // for the frame. Keep equal segments, and update fixed slots in place when the
112
+ // bar changes, rather than replacing text nodes during layout.
113
+ const segments = createMemo(() => barSegments(used(), { ...context.appearance, barWidth: props.barCells }, props.pace), undefined, {
114
+ equals: (previous, next) => previous.length === next.length &&
115
+ previous.every((segment, index) => segment.text === next[index]?.text &&
116
+ segment.tone === next[index]?.tone),
117
+ });
108
118
  const paceLine = () => {
109
119
  const text = props.pace?.text;
110
120
  if (!text || columns() <= 0)
@@ -124,11 +134,14 @@ function QuotaRow(props) {
124
134
  <Show when={!props.part.resetSinceReading} fallback={<text fg={context.theme.textMuted} wrapMode='none'>
125
135
  reset since last check
126
136
  </text>}>
127
- <For each={barSegments(used(), { ...context.appearance, barWidth: props.barCells }, props.pace)}>
128
- {(segment) => (<text fg={context.theme[segment.tone]} wrapMode='none'>
129
- {segment.text}
130
- </text>)}
131
- </For>
137
+ <Show when={props.barCells > 0}>
138
+ {/* Text nodes clear omitted theme colours; empty slots must not reserve a cell. */}
139
+ <Index each={segments()}>
140
+ {(segment) => (<text fg={context.theme[segment().tone]} wrapMode='none' width={segment().text ? undefined : 0}>
141
+ {segment().text}
142
+ </text>)}
143
+ </Index>
144
+ </Show>
132
145
  <text fg={context.theme[usageTone(used(), context.appearance)]} wrapMode='none'>
133
146
  {figure()}
134
147
  </text>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/common-auth",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
4
4
  "description": "Shared code for the CortexKit auth plugins: account pool, quota and routing, commands and auth menu, OpenCode 2 hooks, Claustrum custody, and plumbing (loopback RPC, file locks, logger, sidebar state, TUI preferences and build).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -5,6 +5,7 @@ import {
5
5
  createMemo,
6
6
  createSignal,
7
7
  For,
8
+ Index,
8
9
  mergeProps,
9
10
  Show,
10
11
  useContext,
@@ -198,16 +199,18 @@ function barSegments(
198
199
  Math.max(0, Math.min(Math.round((pct / 100) * width), width))
199
200
  const usedCells = cells(used)
200
201
  const tone = usageTone(used, appearance)
202
+ // Keep the overlay's slot even when empty so live pacing changes reuse nodes.
201
203
  const plain = [
202
204
  { text: appearance.barFilledChar.repeat(usedCells), tone },
205
+ { text: '', tone },
203
206
  { text: appearance.barEmptyChar.repeat(width - usedCells), tone },
204
207
  ]
205
208
  const overlay = pace?.overlay
206
- if (!overlay) return plain.filter((segment) => segment.text.length > 0)
209
+ if (!overlay) return plain
207
210
  const paceCells = cells(overlay.percent)
208
211
  const lo = Math.min(usedCells, paceCells)
209
212
  const hi = Math.max(usedCells, paceCells)
210
- if (lo === hi) return plain.filter((segment) => segment.text.length > 0)
213
+ if (lo === hi) return plain
211
214
  return [
212
215
  { text: appearance.barFilledChar.repeat(lo), tone },
213
216
  {
@@ -216,7 +219,7 @@ function barSegments(
216
219
  overlay.kind === 'deficit' ? ('error' as const) : ('success' as const),
217
220
  },
218
221
  { text: appearance.barEmptyChar.repeat(width - hi), tone },
219
- ].filter((segment) => segment.text.length > 0)
222
+ ]
220
223
  }
221
224
 
222
225
  function QuotaRow(props: {
@@ -236,6 +239,27 @@ function QuotaRow(props: {
236
239
  const figure = () =>
237
240
  ` ${props.part.kind === 'budget' && props.part.figure.startsWith(`${props.part.name} `) ? props.part.figure.slice(props.part.name.length + 1) : props.part.figure}`
238
241
  const used = () => 100 - (props.part.remainingPercent ?? 100)
242
+ // Size notifications can recompute an unchanged fit after text has been flushed
243
+ // for the frame. Keep equal segments, and update fixed slots in place when the
244
+ // bar changes, rather than replacing text nodes during layout.
245
+ const segments = createMemo(
246
+ () =>
247
+ barSegments(
248
+ used(),
249
+ { ...context.appearance, barWidth: props.barCells },
250
+ props.pace,
251
+ ),
252
+ undefined,
253
+ {
254
+ equals: (previous, next) =>
255
+ previous.length === next.length &&
256
+ previous.every(
257
+ (segment, index) =>
258
+ segment.text === next[index]?.text &&
259
+ segment.tone === next[index]?.tone,
260
+ ),
261
+ },
262
+ )
239
263
  const paceLine = () => {
240
264
  const text = props.pace?.text
241
265
  if (!text || columns() <= 0) return text
@@ -269,19 +293,20 @@ function QuotaRow(props: {
269
293
  </text>
270
294
  }
271
295
  >
272
- <For
273
- each={barSegments(
274
- used(),
275
- { ...context.appearance, barWidth: props.barCells },
276
- props.pace,
277
- )}
278
- >
279
- {(segment) => (
280
- <text fg={context.theme[segment.tone]} wrapMode='none'>
281
- {segment.text}
282
- </text>
283
- )}
284
- </For>
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>
285
310
  <text
286
311
  fg={context.theme[usageTone(used(), context.appearance)]}
287
312
  wrapMode='none'