Skip to content

fix: clear session-scoped UI state on server disconnect#1393

Closed
sampathreddy22 wants to merge 1 commit into
modelcontextprotocol:mainfrom
sampathreddy22:fix/clear-session-state-on-disconnect
Closed

fix: clear session-scoped UI state on server disconnect#1393
sampathreddy22 wants to merge 1 commit into
modelcontextprotocol:mainfrom
sampathreddy22:fix/clear-session-state-on-disconnect

Conversation

@sampathreddy22
Copy link
Copy Markdown

Summary

When switching between servers, the Tools/Prompts/Resources result panels were still showing output from the previous session. The root cause is that App.tsx holds several pieces of session-scoped state that are never reset when the connection drops.

Changes:

  • Added a useEffect keyed on connectionStatus that clears session state on "disconnected" or "error"
  • Resets call-panel results: toolResult, promptContent, resourceContent, resourceContentMap
  • Resets logLevel to "info"
  • Also clears the server-fetched lists (tools, prompts, resources, resourceTemplates) and their selection state — without this, the previous server's tool list was still visible in the Tools panel until the new server's list loaded

All three disconnect paths are covered: explicit disconnect, reconnect/restart toggle, and mid-session transport failure.

@sampathreddy22
Copy link
Copy Markdown
Author

@claude review

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.

1 participant