Skip to content

fix(cli): make task cancel report unknown and finished tasks instead of claiming success - #4331

Merged
ruvnet merged 1 commit into
ruvnet:mainfrom
kevin9327:fix/task-cancel-finished-and-unknown
Oct 21, 2026
Merged

ruvnet merged 1 commit into
ruvnet:mainfrom
kevin9327:fix/task-cancel-finished-and-unknown

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Problem

ruflo task cancel and the task_cancel MCP tool have three related bugs:

  1. Unknown id reported as cancelled. For an id that doesn't exist, task_cancel returns { success: false, error: 'Task not found' } and doesn't throw. The CLI never checks success, so it prints ✓ Task task-missing cancelled / Previous status: undefined and exits 0. Scripts and agents treat that as success.
  2. Finished tasks get overwritten. Cancelling a task that is already completed, failed or cancelled sets its status to cancelled and replaces result and completedAt with the cancel reason, so the completed task's result is lost.
  3. Previous status: undefined. The CLI prints result.previousStatus, but task_cancel never returns that field, so this line is wrong even for a normal cancel.

Fix

  • task_cancel returns previousStatus. For a task that's already finished, it returns success: false with Task is already <status> and leaves the record unchanged.
  • task cancel checks success === false and exits 1 with Failed to cancel task <id>: <error>. With --format json it prints the raw result instead.

Cancelling a pending or in_progress task works as before. The ruflo-console callers only cancel open tasks, so they aren't affected.

Tests

__tests__/task-cancel.test.ts (5 cases): previousStatus on a normal cancel, a completed task keeps its result and completedAt, the CLI prints the previous status, and the CLI exits 1 for an unknown id and for an already-finished task. All 5 fail on main and pass with this change. task-list-total and status-tasks-all still pass.


AI-assistance note: I prepared this change with help from an AI coding assistant, then reviewed it and ran the tests myself.

@kevin9327
kevin9327 requested a review from ruvnet as a code owner October 21, 2026 00:15
@ruvnet
ruvnet merged commit cc7e765 into ruvnet:main Oct 21, 2026
111 checks passed
@ruvnet ruvnet mentioned this pull request Oct 21, 2026
ruvnet added a commit that referenced this pull request Oct 21, 2026
Patch release bundling two task-command correctness fixes:

- task cancel: task_cancel claimed success (and printed "Previous
  status: undefined") for a task id that doesn't exist or is already
  completed/failed/cancelled, and overwrote a finished task's result
  with the cancel reason. It now returns previousStatus, refuses to
  touch a finished task, and the CLI exits 1 instead of printing
  "cancelled" for either case (#4331).
- task status: the status box was titled "Task: undefined" for every
  task — the command read result.id, but task_status returns taskId,
  the field every other task tool uses (#4332).

Validated: both PRs' new test files (task-cancel.test.ts,
task-status-header.test.ts) pass (6/6), pnpm -r build clean, tsc
--noEmit clean, audit-umbrella-version-lockstep and
audit-leaf-versions-published both clean before publish.

Co-authored-by: r <r@x>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants