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:
parent
14282370ec
commit
a7f9822fa0
@ -36,12 +36,19 @@ export default function (pi: ExtensionAPI) {
|
|||||||
let turnCount = 0;
|
let turnCount = 0;
|
||||||
let maxTurns = getMaxTurns();
|
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) => {
|
pi.on("agent_start", async (_event, ctx) => {
|
||||||
// Reset counter for each new user prompt
|
// Reset counter for each new user prompt
|
||||||
turnCount = 0;
|
turnCount = 0;
|
||||||
// Clear widget on new session
|
// Show initial widget state on fresh session
|
||||||
if (ctx.hasUI) {
|
if (ctx.hasUI) {
|
||||||
ctx.ui.setWidget("turn-limit", undefined);
|
ctx.ui.setWidget("turn-limit", [`Turns: ${turnCount}/${maxTurns}`]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user