Skip to content

Fix task polling blocking the Run button#1134

Open
herakles-dev wants to merge 1 commit intomodelcontextprotocol:mainfrom
herakles-dev:fix/non-blocking-task-polling
Open

Fix task polling blocking the Run button#1134
herakles-dev wants to merge 1 commit intomodelcontextprotocol:mainfrom
herakles-dev:fix/non-blocking-task-polling

Conversation

@herakles-dev
Copy link

@herakles-dev herakles-dev commented Mar 9, 2026

Summary

The Run button in the Tools Tab is disabled while a task is polling, which prevents users from making concurrent tool calls during long-running task execution. This PR extracts the blocking polling loop into a background async function so callTool returns immediately after task creation.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

client/src/App.tsx:

  • Extract inline blocking while-loop from callTool into a new pollTaskInBackground() function
  • pollTaskInBackground runs asynchronously via void (fire-and-forget), updating toolResult state as the task progresses
  • callTool now returns the initial task result immediately after task creation, so the caller is not blocked

client/src/components/ToolsTab.tsx:

  • Remove isPollingTask from the Run button's disabled condition
  • Remove isPollingTask from the button label conditional — button shows "Running..." only during the initial callTool invocation, not during background polling

Net effect: The Run button stays enabled while tasks poll in the background, allowing concurrent tool calls. Task status updates still appear in the result pane via the existing setToolResult state updates.

Related Issues

Fixes #1077

Testing

  • Tested in UI mode
  • Tested in CLI mode
  • Tested with STDIO transport
  • Tested with SSE transport
  • Tested with Streamable HTTP transport
  • Added/updated automated tests
  • Manual testing performed

Test Results and/or Instructions

  1. Connect to an MCP server that supports tasks (returns 202 Accepted with task ID)
  2. Call a tool that creates a long-running task
  3. While the task is polling in the background, verify the Run button is enabled
  4. Click Run again to make a concurrent tool call — should work without waiting for the first task to complete

Local verification:

  • TypeScript compilation clean (npx tsc --noEmit --skipLibCheck — no errors)
  • Prettier formatting verified (npx prettier --check — all files pass)
  • Full test suite requires Node 22.7.5+ — CI will validate

Checklist

  • Code follows the style guidelines (ran npm run prettier-fix)
  • Self-review completed
  • Code is commented where necessary
  • Documentation updated (README, comments, etc.)

Breaking Changes

None. The isPollingTask state variable is still maintained in App.tsx and passed to ToolsTab.tsx — it's just no longer used to disable the Run button. Any code that reads isPollingTask for other purposes is unaffected.

Methodology

Built with Hercules Agentic Architecture — a human-supervised, 10-phase contribution framework:

  1. 7-gate pre-flight validation (competing PRs, claims, CLA, staleness)
  2. Tiered comprehension (4 levels: inline read, quick scan, deep clone, semantic RAG)
  3. Per-repo compliance matrix (auto-detect conventions, trailers, coverage)
  4. Spec-driven implementation with task tracking
  5. 10-check pre-submission gate (secrets scan, convention enforcement)

All outputs are human-reviewed and verified before submission.

Stack: Claude Code (Anthropic) · V11 Protocol · gh CLI · project CI suites

Extract the blocking while-loop task polling from callTool into a
separate pollTaskInBackground function that runs asynchronously.
callTool now returns immediately after task creation, keeping the
Run button enabled for concurrent tool calls during task execution.

Changes:
- Add pollTaskInBackground() that polls task status in the background
- callTool returns initial task result immediately instead of blocking
- Remove isPollingTask from Run button disabled condition and label

Closes modelcontextprotocol#1077
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.

Tools Tab Run button is blocked while a task is polling — prevents concurrent tool calls during task execution

1 participant