fix(client): auto-refresh and manual refresh for tools, resources, and prompts lists
Summary
Resolves #1292
After the server emits notifications/tools/list_changed, notifications/resources/list_changed, or notifications/prompts/list_changed, the corresponding panel in the Inspector UI now automatically re-fetches the list from page 1 and replaces the stale state. Additionally, the list buttons remain enabled after the initial load, allowing users to manually refresh at any time.
Problem
-
No auto-refresh on
list_changednotifications: TheonNotificationcallback only handlednotifications/tasks/list_changedandnotifications/tasks/status. Notifications for tools, resources, and prompts were received but never triggered a list refresh. -
No manual refresh possible: Once a list was fully loaded (no
nextCursor), the List button was disabled (isButtonDisabled={!nextCursor && items.length > 0}), making it impossible for users to manually refresh.
Changes
client/src/App.tsx
- Added a
loadMore: booleanparameter tolistTools,listResources,listResourceTemplates, andlistPrompts:loadMore = true→ append response to existing state (pagination)loadMore = false(default) → replace state from page 1 (refresh)
- Added handlers for
notifications/tools/list_changed,notifications/resources/list_changed, andnotifications/prompts/list_changedin theonNotificationcallback, calling the corresponding list functions withloadMore = false. - Used React
useReffor each list function to avoid stale closure issues in theonNotificationcallback (which is registered once at connection time). - Updated prop forwarding to tab components to pass the
loadMoreparameter through.
client/src/components/ToolsTab.tsx
- Updated
listToolsprop type to(loadMore?: boolean) => void. - Changed
ListPaneto calllistTools(!!nextCursor)and show "Refresh Tools" when fully loaded. - Removed the disabled state on the button.
client/src/components/ResourcesTab.tsx
- Updated
listResourcesandlistResourceTemplatesprop types. - Applied the same ListPane pattern for both Resources and Resource Templates panes.
client/src/components/PromptsTab.tsx
- Updated
listPromptsprop type. - Applied the same ListPane pattern.
client/src/components/AppsTab.tsx
- Updated
listToolsprop type in theAppsTabPropsinterface.
Testing
- Full project build (
tsc -b && vite build) passes with zero type errors. - Lint-staged (prettier) passes.