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:
parent
d9ab8ec7d5
commit
a1d1fc599f
1 changed files with 27 additions and 0 deletions
|
|
@ -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"),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue