inspector icon indicating copy to clipboard operation
inspector copied to clipboard

fix(client): auto-refresh and manual refresh for tools, resources, and prompts lists

Open STiFLeR7 opened this issue 6 months ago • 0 comments

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

  1. No auto-refresh on list_changed notifications: The onNotification callback only handled notifications/tasks/list_changed and notifications/tasks/status. Notifications for tools, resources, and prompts were received but never triggered a list refresh.

  2. 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: boolean parameter to listTools, listResources, listResourceTemplates, and listPrompts:
    • 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, and notifications/prompts/list_changed in the onNotification callback, calling the corresponding list functions with loadMore = false.
  • Used React useRef for each list function to avoid stale closure issues in the onNotification callback (which is registered once at connection time).
  • Updated prop forwarding to tab components to pass the loadMore parameter through.

client/src/components/ToolsTab.tsx

  • Updated listTools prop type to (loadMore?: boolean) => void.
  • Changed ListPane to call listTools(!!nextCursor) and show "Refresh Tools" when fully loaded.
  • Removed the disabled state on the button.

client/src/components/ResourcesTab.tsx

  • Updated listResources and listResourceTemplates prop types.
  • Applied the same ListPane pattern for both Resources and Resource Templates panes.

client/src/components/PromptsTab.tsx

  • Updated listPrompts prop type.
  • Applied the same ListPane pattern.

client/src/components/AppsTab.tsx

  • Updated listTools prop type in the AppsTabProps interface.

Testing

  • Full project build (tsc -b && vite build) passes with zero type errors.
  • Lint-staged (prettier) passes.

STiFLeR7 avatar May 21 '26 09:05 STiFLeR7