peon is done
This commit is contained in:
@@ -6,14 +6,14 @@
|
||||
*/
|
||||
|
||||
import type { ExtensionAPI, SessionBeforeSwitchEvent, SessionMessageEntry } from "@mariozechner/pi-coding-agent";
|
||||
import { sendNotification } from "./notify.js";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
pi.on("session_before_switch", async (event: SessionBeforeSwitchEvent, ctx) => {
|
||||
if (!ctx.hasUI) return;
|
||||
|
||||
if (event.reason === "new") {
|
||||
sendNotification("Clear session confirmation");
|
||||
// Emit event for sound extensions (before hasUI check)
|
||||
pi.events.emit("peon:input_required", { source: "confirm-destructive", action: "clear-session" });
|
||||
if (!ctx.hasUI) return;
|
||||
|
||||
const confirmed = await ctx.ui.confirm(
|
||||
"Clear session?",
|
||||
"This will delete all messages in the current session.",
|
||||
@@ -33,7 +33,10 @@ export default function (pi: ExtensionAPI) {
|
||||
);
|
||||
|
||||
if (hasUnsavedWork) {
|
||||
sendNotification("Switch session confirmation");
|
||||
// Emit event for sound extensions (before hasUI check)
|
||||
pi.events.emit("peon:input_required", { source: "confirm-destructive", action: "switch-session" });
|
||||
if (!ctx.hasUI) return;
|
||||
|
||||
const confirmed = await ctx.ui.confirm(
|
||||
"Switch session?",
|
||||
"You have messages in the current session. Switch anyway?",
|
||||
@@ -47,9 +50,10 @@ export default function (pi: ExtensionAPI) {
|
||||
});
|
||||
|
||||
pi.on("session_before_fork", async (event, ctx) => {
|
||||
// Emit event for sound extensions (before hasUI check)
|
||||
pi.events.emit("peon:input_required", { source: "confirm-destructive", action: "fork-session" });
|
||||
if (!ctx.hasUI) return;
|
||||
|
||||
sendNotification("Fork session confirmation");
|
||||
const choice = await ctx.ui.select(`Fork from entry ${event.entryId.slice(0, 8)}?`, [
|
||||
"Yes, create fork",
|
||||
"No, stay in current session",
|
||||
|
||||
Reference in New Issue
Block a user