@victor-software-house/pi-multicodex 1.0.10 → 1.0.11

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 (2) hide show
  1. package/package.json +1 -1
  2. package/status.ts +44 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@victor-software-house/pi-multicodex",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Codex account rotation extension for pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/status.ts CHANGED
@@ -24,6 +24,7 @@ const REFRESH_INTERVAL_MS = 60_000;
24
24
  const MODEL_SELECT_REFRESH_DEBOUNCE_MS = 250;
25
25
  const UNKNOWN_PERCENT = "--";
26
26
  const BRAND_LABEL = "Codex";
27
+ const SEGMENT_SEPARATOR = "·";
27
28
  const FIVE_HOUR_LABEL = "5h:";
28
29
  const SEVEN_DAY_LABEL = "7d:";
29
30
 
@@ -148,25 +149,40 @@ function formatLoading(ctx: ExtensionContext): string {
148
149
  return ctx.ui.theme.fg("muted", "loading...");
149
150
  }
150
151
 
151
- function formatPercent(
152
- ctx: ExtensionContext,
152
+ function formatSeparator(ctx: ExtensionContext): string {
153
+ return ctx.ui.theme.fg("muted", SEGMENT_SEPARATOR);
154
+ }
155
+
156
+ function getUsageSeverityToken(
153
157
  displayPercent: number | undefined,
154
158
  mode: PercentDisplayMode,
155
- ): string {
159
+ ): "success" | "thinkingMedium" | "warning" | "error" | "dim" {
156
160
  if (typeof displayPercent !== "number" || Number.isNaN(displayPercent)) {
157
- return ctx.ui.theme.fg("dim", UNKNOWN_PERCENT);
161
+ return "dim";
158
162
  }
159
163
 
160
- const text = `${Math.round(clampPercent(displayPercent))}% ${mode}`;
161
164
  if (mode === "left") {
162
- if (displayPercent <= 10) return ctx.ui.theme.fg("error", text);
163
- if (displayPercent <= 25) return ctx.ui.theme.fg("warning", text);
164
- return ctx.ui.theme.fg("success", text);
165
+ if (displayPercent <= 10) return "error";
166
+ if (displayPercent <= 25) return "warning";
167
+ if (displayPercent <= 50) return "thinkingMedium";
168
+ return "success";
165
169
  }
166
170
 
167
- if (displayPercent >= 90) return ctx.ui.theme.fg("error", text);
168
- if (displayPercent >= 75) return ctx.ui.theme.fg("warning", text);
169
- return ctx.ui.theme.fg("success", text);
171
+ if (displayPercent >= 90) return "error";
172
+ if (displayPercent >= 75) return "warning";
173
+ if (displayPercent >= 50) return "thinkingMedium";
174
+ return "success";
175
+ }
176
+
177
+ function formatPercent(
178
+ displayPercent: number | undefined,
179
+ mode: PercentDisplayMode,
180
+ ): string {
181
+ if (typeof displayPercent !== "number" || Number.isNaN(displayPercent)) {
182
+ return UNKNOWN_PERCENT;
183
+ }
184
+
185
+ return `${Math.round(clampPercent(displayPercent))}% ${mode}`;
170
186
  }
171
187
 
172
188
  function formatResetCountdown(resetAt: number | undefined): string | undefined {
@@ -200,20 +216,23 @@ function formatUsageSegment(
200
216
  showReset: boolean,
201
217
  preferences: FooterPreferences,
202
218
  ): string {
219
+ const displayPercent = usedToDisplayPercent(
220
+ usedPercent,
221
+ preferences.usageMode,
222
+ );
203
223
  const parts = [
204
- `${ctx.ui.theme.fg("dim", label)}${formatPercent(
205
- ctx,
206
- usedToDisplayPercent(usedPercent, preferences.usageMode),
207
- preferences.usageMode,
208
- )}`,
224
+ `${label}${formatPercent(displayPercent, preferences.usageMode)}`,
209
225
  ];
210
226
  if (showReset) {
211
227
  const countdown = formatResetCountdown(resetAt);
212
228
  if (countdown) {
213
- parts.push(ctx.ui.theme.fg("muted", `(↺${countdown})`));
229
+ parts.push(`(↺${countdown})`);
214
230
  }
215
231
  }
216
- return parts.join(" ");
232
+ return ctx.ui.theme.fg(
233
+ getUsageSeverityToken(displayPercent, preferences.usageMode),
234
+ parts.join(" "),
235
+ );
217
236
  }
218
237
 
219
238
  export function isManagedModel(model: MaybeModel): boolean {
@@ -227,7 +246,7 @@ export function formatActiveAccountStatus(
227
246
  preferences: FooterPreferences,
228
247
  ): string {
229
248
  const accountText = preferences.showAccount
230
- ? ctx.ui.theme.fg("muted", accountEmail)
249
+ ? ctx.ui.theme.fg("text", accountEmail)
231
250
  : undefined;
232
251
  if (!usage) {
233
252
  return [formatBrand(ctx), accountText, formatLoading(ctx)]
@@ -252,16 +271,18 @@ export function formatActiveAccountStatus(
252
271
  preferences,
253
272
  );
254
273
 
274
+ const usageSegments = [fiveHour, sevenDay].filter(Boolean);
275
+ const usageText = usageSegments.join(` ${formatSeparator(ctx)} `);
255
276
  const leading =
256
277
  preferences.order === "account-first"
257
- ? [formatBrand(ctx), accountText]
258
- : [formatBrand(ctx)];
278
+ ? [formatBrand(ctx), accountText, usageText]
279
+ : [formatBrand(ctx), usageText];
259
280
  const trailing =
260
281
  preferences.order === "account-first" ? [] : [accountText].filter(Boolean);
261
282
 
262
- return [...leading, fiveHour, sevenDay, ...trailing]
283
+ return [...leading, ...trailing]
263
284
  .filter(Boolean)
264
- .join(" ");
285
+ .join(` ${formatSeparator(ctx)} `);
265
286
  }
266
287
 
267
288
  function getBooleanLabel(value: boolean): string {