inspector
inspector copied to clipboard
Handle task completion notifications to skip polling delay
Summary
- Adds a
taskNotificationResolverRefthat holds the in-progress poll's{ taskId, resolve }while the polling loop is running - The
notifications/tasks/statushandler now callsresolve()when a terminal status (completed,failed, orcancelled) arrives for the task being polled - The polling loop now uses
Promise.racebetween the poll-interval timer and the notification signal, so whichever fires first unblocks the loop
Problem
The task polling loop in callTool waited a full pollInterval milliseconds via setTimeout before every tasks/get call. Even when the server sent a notifications/tasks/status notification indicating the task was done, the inspector ignored it and continued sleeping until the timer expired. With long poll intervals this caused a noticeable (or very long) delay before the result appeared.
Test plan
- [x] New test:
App.taskNotification.test.tsx— verifies thattasks/getis called promptly after a terminal notification arrives, even whenpollIntervalis 10 s (well abovewaitFor's 1 s timeout, so the test would time out without the fix) - [x] Second test verifies a notification for a different task does not interfere with the current poll
- [x] All 517 tests pass locally
Fixes #1037