pi-better-openai 0.1.10 → 0.1.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.
- package/index.ts +22 -7
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -107,6 +107,7 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
107
107
|
let shuttingDown = false;
|
|
108
108
|
let usageAbortController: AbortController | undefined;
|
|
109
109
|
let footerInstalled = false;
|
|
110
|
+
let statusInstalled = false;
|
|
110
111
|
let requestFooterRender: (() => void) | undefined;
|
|
111
112
|
let lastInjectedAt: number | undefined;
|
|
112
113
|
let lastInjectedModel: string | undefined;
|
|
@@ -336,7 +337,7 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
336
337
|
currentValue: cfg.footer.mode,
|
|
337
338
|
values: [...FOOTER_MODES],
|
|
338
339
|
description:
|
|
339
|
-
"replace = custom footer, status = pi footer plus status line, off = no Better OpenAI footer/status.",
|
|
340
|
+
"replace = custom footer, status = pi footer plus status line, off = no Better OpenAI footer/status and leaves other footers untouched.",
|
|
340
341
|
},
|
|
341
342
|
{
|
|
342
343
|
id: "usage.enabled",
|
|
@@ -676,20 +677,34 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
676
677
|
});
|
|
677
678
|
}
|
|
678
679
|
|
|
680
|
+
function clearFooter(ctx: ExtensionContext): void {
|
|
681
|
+
if (!footerInstalled) return;
|
|
682
|
+
ctx.ui.setFooter(undefined);
|
|
683
|
+
footerInstalled = false;
|
|
684
|
+
requestFooterRender = undefined;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function setStatus(ctx: ExtensionContext, text: string | undefined): void {
|
|
688
|
+
if (!text && !statusInstalled) return;
|
|
689
|
+
ctx.ui.setStatus(STATUS_KEY, text);
|
|
690
|
+
statusInstalled = text !== undefined;
|
|
691
|
+
}
|
|
692
|
+
|
|
679
693
|
function updateFooter(ctx: ExtensionContext): void {
|
|
680
694
|
const cfg = config(ctx);
|
|
681
695
|
if (cfg.footer.mode === "replace") {
|
|
682
|
-
|
|
696
|
+
setStatus(ctx, undefined);
|
|
683
697
|
installFooter(ctx);
|
|
684
698
|
return;
|
|
685
699
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
700
|
+
|
|
701
|
+
clearFooter(ctx);
|
|
702
|
+
|
|
689
703
|
if (cfg.footer.mode === "off") {
|
|
690
|
-
|
|
704
|
+
setStatus(ctx, undefined);
|
|
691
705
|
return;
|
|
692
706
|
}
|
|
707
|
+
|
|
693
708
|
const fast =
|
|
694
709
|
active && supportsFast(ctx, cfg.supportedModels)
|
|
695
710
|
? `${ctx.model?.id ?? "model"} fast`
|
|
@@ -698,7 +713,7 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
698
713
|
usageSnapshot && cfg.usage.enabled && isOpenAISubscriptionModel(ctx, cfg)
|
|
699
714
|
? formatUsageSnapshot(usageSnapshot, cfg.usage)
|
|
700
715
|
: undefined;
|
|
701
|
-
|
|
716
|
+
setStatus(ctx, [fast, usage].filter(Boolean).join(" | ") || undefined);
|
|
702
717
|
}
|
|
703
718
|
|
|
704
719
|
pi.on("session_start", (_event, ctx) => {
|