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 <agent@continue.dev>
Co-authored-by: Continue <noreply@continue.dev>
This commit is contained in:
continue[bot] 2025-09-30 23:31:50 -07:00 • committed by GitHub
parent d9ab8ec7d5
commit a1d1fc599f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"),
);