Skip to content

Commit 947f2ff

Browse files
authored
feat(pi-extension): add status bar indicator for ponytail mode (closes #84) (#275)
Add a syncStatus function to Pi extension to display the current Ponytail mode in the status bar. The indicator updates upon mode changes and hooks into the agent_start and agent_end events to display a visual active/inactive state. This provides the user with clear feedback on the currently active Ponytail intensity level (lite, full, ultra) without running commands.
1 parent 08f0daf commit 947f2ff

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎pi-extension/index.js‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,33 @@ export { writeDefaultMode };
5656
export default function ponytailExtension(pi) {
5757
let currentMode = DEFAULT_MODE;
5858
let configuredDefaultMode = getDefaultMode();
59+
let isActive = false;
60+
let lastCtx = null;
61+
62+
// -- Status bar --
63+
function syncStatus(ctx) {
64+
if (ctx) lastCtx = ctx;
65+
const c = ctx || lastCtx;
66+
if (!c?.ui?.setStatus) return;
67+
const theme = c.ui.theme;
68+
if (currentMode === "off") {
69+
c.ui.setStatus("ponytail", "");
70+
return;
71+
}
72+
const levelIcons = { lite: "🌿", full: "⚡", ultra: "🔥" };
73+
const icon = levelIcons[currentMode] || "";
74+
const label = currentMode.toUpperCase();
75+
const indicator = isActive ? theme.fg("accent", "●") : theme.fg("dim", "○");
76+
c.ui.setStatus("ponytail", indicator + " 🐴 " + theme.fg("muted", "ponytail: ") + theme.fg("text", icon + " " + label));
77+
}
5978

6079
const setMode = (mode, ctx) => {
6180
const normalized = normalizePersistedMode(mode);
6281
if (!normalized) return;
6382

6483
currentMode = normalized;
6584
pi.appendEntry("ponytail-mode", { mode: normalized });
85+
syncStatus(ctx);
6686
ctx?.ui?.notify?.(`Ponytail mode set to ${normalized}.`, "info");
6787
};
6888

@@ -148,6 +168,18 @@ export default function ponytailExtension(pi) {
148168
const entries = ctx?.sessionManager?.getBranch?.() || ctx?.sessionManager?.getEntries?.() || [];
149169
configuredDefaultMode = getDefaultMode();
150170
currentMode = resolveSessionMode(entries, configuredDefaultMode);
171+
syncStatus(ctx);
172+
ctx?.ui?.notify?.(`Ponytail loaded: ${currentMode}`, "info");
173+
});
174+
175+
pi.on("agent_start", async (_event, ctx) => {
176+
isActive = true;
177+
syncStatus(ctx);
178+
});
179+
180+
pi.on("agent_end", async (_event, ctx) => {
181+
isActive = false;
182+
syncStatus(ctx);
151183
});
152184

153185
pi.on("before_agent_start", async (event) => {

0 commit comments

Comments
 (0)