From a1d1fc599f8e04bae2522cde62d628bba439bdf5 Mon Sep 17 00:00:00 2001 From: "continue[bot]" <230936708+continue[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 23:31:50 -0700 Subject: [PATCH] Add /pause endpoint to cn serve command (#8025) This endpoint allows pausing the agent run in the same way that pressing escape does in the normal cn TUI. It aborts the current processing and sets isProcessing to false. Generated with [Continue](https://continue.dev) Co-authored-by: Continue Agent Co-authored-by: Continue --- extensions/cli/src/commands/serve.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/extensions/cli/src/commands/serve.ts b/extensions/cli/src/commands/serve.ts index 2aee9e23a..8256ca6f1 100644 --- a/extensions/cli/src/commands/serve.ts +++ b/extensions/cli/src/commands/serve.ts @@ -259,6 +259,32 @@ export async function serve(prompt?: string, options: ServeOptions = {}) { }); }); + // POST /pause - Pause the current agent run (like pressing escape in TUI) + app.post("/pause", async (_req: Request, res: Response) => { + state.lastActivity = Date.now(); + + // Check if there's anything to pause + if (!state.isProcessing) { + return res.json({ + success: false, + message: "No active processing to pause", + }); + } + + // Abort the current processing + if (state.currentAbortController) { + state.currentAbortController.abort(); + } + + // Set isProcessing to false + state.isProcessing = false; + + res.json({ + success: true, + message: "Agent run paused", + }); + }); + // GET /diff - Return git diff against main branch app.get("/diff", async (_req: Request, res: Response) => { state.lastActivity = Date.now(); @@ -343,6 +369,7 @@ export async function serve(prompt?: string, options: ServeOptions = {}) { " POST /permission - Approve/reject tool (body: { requestId, approved })", ), ); + console.log(chalk.dim(" POST /pause - Pause the current agent run")); console.log( chalk.dim(" GET /diff - Get git diff against main branch"), );