pi-freeflow 1.1.5 → 1.1.7
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/extensions/index.ts +55 -3
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -1729,12 +1729,64 @@ export default async function (pi: ExtensionAPI) {
|
|
|
1729
1729
|
pi.registerCommand("freeflow", commandSpec);
|
|
1730
1730
|
pi.registerCommand("bansos", commandSpec);
|
|
1731
1731
|
|
|
1732
|
-
|
|
1732
|
+
function updateStatusBar(ui?: ExtensionContext["ui"], providerName?: string) {
|
|
1733
|
+
if (!ui) return;
|
|
1734
|
+
if (relayState.enabled && relayState.relays.length > 0) {
|
|
1735
|
+
const label = shortRelayLabel(relayState.url);
|
|
1736
|
+
const idx = Math.max(
|
|
1737
|
+
1,
|
|
1738
|
+
relayState.relays.findIndex((r) => r.url === relayState.url) + 1,
|
|
1739
|
+
);
|
|
1740
|
+
const total = relayState.relays.length;
|
|
1741
|
+
ui.setStatus?.("freeflow", `relay: ON | ${label} ${idx}/${total}`);
|
|
1742
|
+
} else {
|
|
1743
|
+
ui.setStatus?.("freeflow", undefined);
|
|
1744
|
+
}
|
|
1745
|
+
ui.setStatus?.("bansos", undefined);
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
// Reload persisted state on session start/resume and show status ONLY if active model is FreeFlow
|
|
1733
1749
|
pi.on?.("session_start", async (_event, ctx) => {
|
|
1734
1750
|
relayState = resolveRelayState();
|
|
1735
1751
|
statusUi = ctx.ui;
|
|
1736
|
-
|
|
1737
|
-
|
|
1752
|
+
|
|
1753
|
+
const activeModel =
|
|
1754
|
+
ctx && typeof ctx === "object" && "model" in ctx
|
|
1755
|
+
? (ctx as { model?: { provider?: string; id?: string } }).model
|
|
1756
|
+
: null;
|
|
1757
|
+
const provider = activeModel?.provider;
|
|
1758
|
+
const modelId = activeModel?.id;
|
|
1759
|
+
const isFreeFlow =
|
|
1760
|
+
provider === "freeflow" ||
|
|
1761
|
+
Boolean(modelId && aliveCatalog.some((m) => m.id === modelId));
|
|
1762
|
+
|
|
1763
|
+
if (isFreeFlow) {
|
|
1764
|
+
updateStatusBar(ctx.ui);
|
|
1765
|
+
} else {
|
|
1766
|
+
// Relay status OFF / cleared when non-freeflow model is active in session
|
|
1767
|
+
ctx.ui?.setStatus?.("freeflow", undefined);
|
|
1768
|
+
}
|
|
1769
|
+
});
|
|
1770
|
+
|
|
1771
|
+
// Update status bar immediately when user switches models
|
|
1772
|
+
pi.on?.("model_select", async (event, ctx) => {
|
|
1773
|
+
statusUi = ctx.ui;
|
|
1774
|
+
const model =
|
|
1775
|
+
event && typeof event === "object" && "model" in event
|
|
1776
|
+
? (event as { model?: { provider?: string; id?: string } }).model
|
|
1777
|
+
: null;
|
|
1778
|
+
const provider = model?.provider;
|
|
1779
|
+
const modelId = model?.id;
|
|
1780
|
+
const isFreeFlow =
|
|
1781
|
+
provider === "freeflow" ||
|
|
1782
|
+
Boolean(modelId && aliveCatalog.some((m) => m.id === modelId));
|
|
1783
|
+
|
|
1784
|
+
if (isFreeFlow) {
|
|
1785
|
+
updateStatusBar(ctx.ui);
|
|
1786
|
+
} else {
|
|
1787
|
+
// Matikan status relay seketika jika model yang dipilih bukan model FreeFlow
|
|
1788
|
+
ctx.ui?.setStatus?.("freeflow", undefined);
|
|
1789
|
+
}
|
|
1738
1790
|
});
|
|
1739
1791
|
|
|
1740
1792
|
// Pi normally pauses after threshold compaction. Queue a follow-up while the
|