@arhen/pi-senja 1.2.4 → 1.2.5

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/README.md CHANGED
@@ -13,7 +13,7 @@ Forked from [pi-haiku](https://github.com/nnocte/pi-haiku) **0.2.0** by **nocte*
13
13
  - **Quiet tool text** — tool titles and output both use the foreground beige (`fg0`) rather than loud accents, keeping panels calm against their tint.
14
14
  - **Editor-style code colors** — pink keywords, olive strings, aqua function names, amber types, warm beige identifiers and punctuation, readable muted comments. Applies to code in tool calls/results and Markdown code blocks through Pi's syntax roles.
15
15
  - **A live timer** while Pi works, plus elapsed-time completion message and notification. Preserves the active mode label and colour from `@arhen/pi-add-mode` (`review is working... 8s`).
16
- - **Fast / Ultrafast mode** — `/fast on|off` and `/ultrafast on|off` set a paid speed preference per OpenAI provider and model. For ChatGPT sign-in, Senja checks the account’s model catalog before enabling or restoring a tier. If it is unavailable or cannot be verified, Senja warns and does not apply it. API-key mode checks known model support, not account entitlement. The footer shows only `fast` or `ultrafast`. If a completed request reports a different tier (or none), Senja warns once for that response. The badge stays on, and the next request still asks for the selected tier. Failed or canceled requests do not change the preference. Off shows no chip and adds no tier. Preferences persist under `<agent-dir>/fast-mode/`; explicit `samplingParams.service_tier` still wins.
16
+ - **Fast / Ultrafast mode** — `/fast on|off` and `/ultrafast on|off` set a paid speed preference per OpenAI provider and model. For ChatGPT sign-in, Senja checks the account’s model catalog before enabling or restoring a tier. If it is unavailable or cannot be verified, Senja warns and does not apply it. API-key mode checks known model support, not account entitlement. The footer shows only `fast` or `ultrafast`. Only a different reported tier counts as a `miss`. A missing or unknown tier shows `tier not confirmed` instead. The badge stays on, and the next request still asks for the selected tier. Failed or canceled requests do not change the preference. Off shows no chip and adds no tier. Preferences persist under `<agent-dir>/fast-mode/`; explicit `samplingParams.service_tier` still wins.
17
17
  - **A fresh start** — clear the visible screen on initial terminal startup without clearing scrollback.
18
18
 
19
19
  Enabled by default in terminal UI mode. Print, JSON, SDK, and RPC modes do not install terminal components, switch themes, clear the screen, or start UI timers. `/senja` in RPC mode reports that terminal UI is required.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arhen/pi-senja",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Senja Gruvbox Material theme with Haiku's structured header, footer, and live timer for Pi.",
5
5
  "license": "MIT",
6
6
  "author": "arhen",
package/src/index.ts CHANGED
@@ -63,7 +63,7 @@ async function canRequestTier(ctx: ExtensionContext, model: NonNullable<Extensio
63
63
  const codex = model.provider === "openai-codex";
64
64
  const base = codex ? "https://chatgpt.com/backend-api" : "https://api.openai.com/v1";
65
65
  const failure = `Cannot verify ${tier} for ${model.provider}/${model.id}; not enabled.`;
66
- const unsupported = `${tier} is not available for ${model.provider}/${model.id}; not enabled.`;
66
+ const unsupported = `${tier}: not supported for ${model.provider}/${model.id}`;
67
67
  if (model.baseUrl?.replace(/\/$/, "") !== base) return failure;
68
68
  if (!ctx.modelRegistry.isUsingOAuth(model)) return SPEED_TIER_SUPPORT[tier].has(model.id) ? undefined : unsupported;
69
69
  try {
@@ -434,28 +434,34 @@ export default function (pi: ExtensionAPI) {
434
434
  return { ...payload, service_tier: wireTier(tier) };
435
435
  });
436
436
 
437
- function finishSpeedRequest(key: string, served: unknown, ctx: ExtensionContext) {
437
+ function finishSpeedRequest(provider: string, model: string, served: unknown, ctx: ExtensionContext) {
438
+ const key = `${provider}/${model}`;
438
439
  const tier = pendingReports.get(key);
439
440
  if (!tier) return;
440
441
  pendingReports.delete(key);
441
442
  if (!ctx.hasUI || served === wireTier(tier) || served === tier) return;
442
- const reason =
443
- typeof served === "string" && /^[a-z0-9_-]{1,32}$/i.test(served) ? `reported ${served}` : "did not report a tier";
444
- ctx.ui.notify(`Requested ${tier} for ${key}; OpenAI ${reason}. ${tier} stays on.`, "warning");
443
+ const message =
444
+ typeof served === "string" && ["default", "priority", "fast", "ultrafast", "flex", "scale"].includes(served)
445
+ ? `${tier} miss: served ${served} (${sanitizeStatus(model)})`
446
+ : `${tier}: tier not confirmed`;
447
+ if (ctx.mode === "tui") ctx.ui.notify(ctx.ui.theme.fg("warning", message), "info");
448
+ else ctx.ui.notify(message, "warning");
445
449
  }
446
450
 
447
451
  pi.on("provider_stream_event", (event, ctx) => {
448
452
  const data = event.data as { type?: string; response?: { service_tier?: unknown; status?: string } } | null;
449
453
  if (data?.type !== "response.completed" && data?.type !== "response.done") return;
450
454
  if (data.response?.status && data.response.status !== "completed") return;
451
- finishSpeedRequest(`${event.provider}/${event.model}`, data.response?.service_tier, ctx);
455
+ finishSpeedRequest(event.provider, event.model, data.response?.service_tier, ctx);
452
456
  });
453
457
 
454
458
  pi.on("message_end", ({ message }, ctx) => {
455
459
  if (message.role !== "assistant") return;
456
- const key = `${message.provider}/${message.model}`;
457
- if (message.stopReason === "stop" || message.stopReason === "toolUse") finishSpeedRequest(key, undefined, ctx);
458
- else pendingReports.delete(key);
460
+ if (message.stopReason === "stop" || message.stopReason === "toolUse") {
461
+ finishSpeedRequest(message.provider, message.model, undefined, ctx);
462
+ } else {
463
+ pendingReports.delete(`${message.provider}/${message.model}`);
464
+ }
459
465
  });
460
466
 
461
467
  // Track how long the current prompt has been running.