Skip to content

Comments

feat: add CancelCommand IPC message type for canceling running terminal commands#11632

Open
roomote[bot] wants to merge 3 commits intomainfrom
feat/clo-1004-cancel-command-ipc
Open

feat: add CancelCommand IPC message type for canceling running terminal commands#11632
roomote[bot] wants to merge 3 commits intomainfrom
feat/clo-1004-cancel-command-ipc

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 20, 2026

Related GitHub Issue

Closes: CLO-1004

Description

Adds a new CancelCommand IPC message type that allows the cloud sandbox to cancel a running terminal command without aborting the entire Roo task.

Key changes:

  • packages/types/src/ipc.ts: Added CancelCommand to the TaskCommandName enum and taskCommandSchema Zod discriminated union
  • src/extension/api.ts: Added handler in the IPC TaskCommand switch that calls sidebarProvider.getCurrentTask()?.handleTerminalOperation("abort") -- this reuses the existing abort flow that the webview UI already uses locally
  • packages/ipc/src/ipc-client.ts: Added cancelCommand() convenience method following the existing sendTaskMessage() / deleteQueuedMessage() pattern

How it works: When the cloud sends a CancelCommand via IPC, the extension calls handleTerminalOperation("abort") on the current task, which calls abort() on the terminal process. For execa terminals (used in cloud), this sends SIGKILL to the subprocess and all its children via ps-tree.

Merge order note: The Roo-Code-Cloud PR will reference TaskCommandName.CancelCommand from @roo-code/types. This PR must merge first so the updated package can be published before the cloud PR can resolve its type references.

Test Procedure

  • Added schema validation tests in packages/types/src/__tests__/ipc.test.ts (validates CancelCommand parses correctly, included in expected commands list)
  • Added API handler tests in src/extension/__tests__/api-cancel-command.spec.ts (verifies abort is called on current task, handles missing task gracefully, handles task with no terminal process)
  • All 16 new tests pass, all 9 existing related API tests still pass
  • All lint and type checks pass across the full monorepo

Pre-Submission Checklist

  • Issue Linked: This PR is linked to CLO-1004.
  • Scope: Changes are focused on adding the CancelCommand IPC message type (one feature).
  • Self-Review: Self-reviewed all changes.
  • Testing: New tests added for schema validation and API handler.
  • Documentation Impact: No user-facing documentation updates required.
  • Contribution Guidelines: Read and agreed.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This is the extension-side half of CLO-1004. The cloud-side PR (in Roo-Code-Cloud) will consume TaskCommandName.CancelCommand and call ipcClient.cancelCommand() when the user triggers a cancel action. Both PRs are being developed in parallel, but this one must merge first.

Start a new Roo Code Cloud session on this branch

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Feb 20, 2026
…al commands

CLO-1004: Allow canceling a running command in Roo Code Cloud.

- Add CancelCommand to TaskCommandName enum and taskCommandSchema
- Handle CancelCommand in API IPC handler by calling handleTerminalOperation("abort")
- Add cancelCommand() convenience method to IpcClient
- Add tests for schema validation and API handler
@daniel-lxs daniel-lxs force-pushed the feat/clo-1004-cancel-command-ipc branch from 2bc731f to 3b27135 Compare February 20, 2026 17:59
roomote and others added 2 commits February 20, 2026 18:26
…d UI

When handleTerminalOperation("abort") is called via IPC CancelCommand, the
execa subprocess is killed and the process promise rejects. Previously, this
rejection was unhandled (isUserTimedOut was false), causing the error to
propagate up without emitting any TaskEvent, leaving the cloud UI stuck.

Changes:
- Add isTerminalAbortedExternally flag to Task class
- Set the flag in handleTerminalOperation before calling abort()
- Check the flag in executeCommandInTerminal catch block alongside isUserTimedOut
- When set, handle cleanly: say error, set didToolFailInCurrentTurn, return tool result
- Add "cancelled" status to CommandExecutionStatus discriminated union
- Add tests for both the external abort case and the unexpected error case
…sition

The cloud message parser only recognizes say:"command_output" to
transition pending commands. Using say:"error" left the pending
command stuck in the UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants