From 1217e032257ea9b8c6c201cda344072e5914836d Mon Sep 17 00:00:00 2001 From: SparkLabScout Date: Fri, 13 Mar 2026 12:29:15 +0800 Subject: [PATCH] fix: make /exit use graceful shutdown, add /kill for immediate exit - /exit now calls stopAuto() before exiting to save activity log and clear locks - Added new /kill command for immediate exit without cleanup - Fixes issue #132: /exit terminates too abruptly and leaves terminal state dirty --- src/resources/extensions/gsd/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/resources/extensions/gsd/index.ts b/src/resources/extensions/gsd/index.ts index 37c255fd0..5b21d4cb6 100644 --- a/src/resources/extensions/gsd/index.ts +++ b/src/resources/extensions/gsd/index.ts @@ -63,9 +63,20 @@ export default function (pi: ExtensionAPI) { registerGSDCommand(pi); registerWorktreeCommand(pi); - // ── /exit — kill the process immediately ────────────────────────────── + // ── /exit — graceful exit (cleanup auto-mode, save state) ────────────── pi.registerCommand("exit", { - description: "Exit GSD immediately", + description: "Exit GSD gracefully (saves auto-mode state)", + handler: async (_ctx) => { + // Gracefully stop auto-mode if running (saves activity log, clears locks) + const { stopAuto } = await import("./auto.js"); + await stopAuto(_ctx, pi); + process.exit(0); + }, + }); + + // ── /kill — immediate exit (bypass cleanup) ───────────────────────────── + pi.registerCommand("kill", { + description: "Exit GSD immediately (no cleanup)", handler: async (_ctx) => { process.exit(0); },