Stop background tasks separately from chat turns

Keep Esc and /stop scoped to the foreground turn while exposing an explicit stop-tasks operation for supported chat backends. Add the protocol, server routing, app command, and coverage for task stopping and unsupported harnesses.
This commit is contained in:
2026-11-13 16:47:41 +00:00
parent c3c2c1bbc9
commit 2a182d7f17
19 changed files with 331 additions and 2 deletions
+20
View File
@@ -322,6 +322,26 @@ func (c *Chat) Interrupt(ctx context.Context, id string) error {
return nil
}
// StopTasks terminates background shell operations, without interrupting the
// session's foreground turn.
func (c *Chat) StopTasks(ctx context.Context, id string) (int, error) {
shells, err := c.Shells(ctx, id)
if err != nil {
return 0, err
}
stopped := 0
for _, shell := range shells {
if shell.Status != protocol.ChatShellRunning {
continue
}
if _, err := c.call(ctx, "delete", "/api/shell/"+url.PathEscape(shell.ID), nil); err != nil {
return stopped, fmt.Errorf("stop shell %s: %w", shell.ID, err)
}
stopped++
}
return stopped, nil
}
// ReleaseSession stops active and background work for an explicit operator
// close or /new without deleting the persisted native conversation. OpenCode
// interrupt only stops the foreground drain; running shells are separate native