@arhen/pi-senja 1.2.3 → 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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/index.ts +16 -17
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 Senja request reports a different tier or none, Senja warns once and turns the mode off for that model. 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.3",
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,35 +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
- if (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
- let warning = `OpenAI ${reason}. Turned off ${tier} for ${key}.`;
445
- try {
446
- setSpeedTier(key, null);
447
- } catch {
448
- warning += " Could not save this change.";
449
- }
450
- requestFooterRender();
451
- if (ctx.hasUI) ctx.ui.notify(warning, "warning");
442
+ if (!ctx.hasUI || served === wireTier(tier) || served === tier) return;
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");
452
449
  }
453
450
 
454
451
  pi.on("provider_stream_event", (event, ctx) => {
455
452
  const data = event.data as { type?: string; response?: { service_tier?: unknown; status?: string } } | null;
456
453
  if (data?.type !== "response.completed" && data?.type !== "response.done") return;
457
454
  if (data.response?.status && data.response.status !== "completed") return;
458
- finishSpeedRequest(`${event.provider}/${event.model}`, data.response?.service_tier, ctx);
455
+ finishSpeedRequest(event.provider, event.model, data.response?.service_tier, ctx);
459
456
  });
460
457
 
461
458
  pi.on("message_end", ({ message }, ctx) => {
462
459
  if (message.role !== "assistant") return;
463
- const key = `${message.provider}/${message.model}`;
464
- if (message.stopReason === "stop" || message.stopReason === "toolUse") finishSpeedRequest(key, undefined, ctx);
465
- 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
+ }
466
465
  });
467
466
 
468
467
  // Track how long the current prompt has been running.