feat(pi-turn-limit): add widget, /turn-limit command, and boundary confirmation

- Live widget showing Turns: {current}/{max}
- /turn-limit <N> command to change max turns mid-session
- Confirmation dialog at boundary turn (Yes resets counter, No aborts)
- Widget visible on session reload and fresh start
This commit is contained in:
Willem van den Ende 2026-04-21 12:34:09 +01:00
parent 14282370ec
commit a7f9822fa0

View File

@ -36,12 +36,19 @@ export default function (pi: ExtensionAPI) {
let turnCount = 0;
let maxTurns = getMaxTurns();
pi.on("session_start", async (event, ctx) => {
// On reload, show the widget immediately
if (event.reason === "reload" && ctx.hasUI) {
ctx.ui.setWidget("turn-limit", [`Turns: ${turnCount}/${maxTurns}`]);
}
});
pi.on("agent_start", async (_event, ctx) => {
// Reset counter for each new user prompt
turnCount = 0;
// Clear widget on new session
// Show initial widget state on fresh session
if (ctx.hasUI) {
ctx.ui.setWidget("turn-limit", undefined);
ctx.ui.setWidget("turn-limit", [`Turns: ${turnCount}/${maxTurns}`]);
}
});