Skip to content

Add cancel control for task polling#1729

Open
HarperZ9 wants to merge 1 commit into
modelcontextprotocol:mainfrom
HarperZ9:agent/cancel-task-polling
Open

Add cancel control for task polling#1729
HarperZ9 wants to merge 1 commit into
modelcontextprotocol:mainfrom
HarperZ9:agent/cancel-task-polling

Conversation

@HarperZ9

Copy link
Copy Markdown

Summary

Adds a cancel control for tool calls that are running as MCP tasks and currently being polled from the Tools tab.

Root cause

The app already exposed tasks/cancel through the Tasks tab, but a user who launched a tool as a task from the Tools tab only saw the disabled Polling Task... button. The active polling task ID was not stored in a way that Tools could cancel, and the polling loop could continue into tasks/get after a user wanted to stop it.

Changes

  • Track the active polling task ID/run in App.
  • Pass pollingTaskId and cancelTaskPolling into ToolsTab.
  • Render a scoped Cancel Task button while a tool task is actively polling.
  • Wake and stop the local polling delay after successful cancellation.
  • Guard against late tasks/get / tasks/result responses overwriting the cancelled state.
  • Add regression coverage for direct cancellation and an in-flight polling response race.

Closes #1039.

Validation

  • npm.cmd test -- --runTestsByPath src/__tests__/App.taskPolling.test.tsx --runInBand
  • npm.cmd run build-client
  • npm.cmd run lint
  • npx.cmd prettier --check client/src/App.tsx client/src/components/ToolsTab.tsx client/src/__tests__/App.taskPolling.test.tsx
  • git diff --check

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.

Can't cancel the polling task

1 participant