Skip to content

Clear per-call panels and other session-scoped UI state on server disconnect #1368

@cliffhall

Description

@cliffhall

Summary

The Tools / Prompts / Resources result panels and other per-session UI state are not cleared when the active InspectorClient disconnects, so the stale result of the last call against the previous server is shown in the next server's screens after the user reconnects.

Repro:

  1. Connect to server A (e.g. PlotRocket).
  2. From the Tools screen, run get_acts — the Results panel shows { "acts": [] }.
  3. Disconnect.
  4. Connect to server B (e.g. nightrider) and navigate to Tools.
  5. Expected: Results panel is empty ("Results will appear here").
  6. Actual: Results panel still shows { "acts": [] } from server A's get_acts call, alongside server B's tool list.

The same shape of bug applies to the prompt and resource result panels — their state lives in App.tsx and survives a disconnect/reconnect cycle.

Root cause

App.tsx owns several pieces of session-scoped UI state that are independent of the per-server state managers (managedToolsState, etc.) and are only ever cleared by their explicit onClear* handlers:

  • toolCallState (App.tsx:220)
  • getPromptState (App.tsx:223)
  • readResourceState (App.tsx:226)
  • currentLogLevel (App.tsx:214) — optimistic value, no echo to reset it

The existing disconnect listener at App.tsx:313-322 only resets activeServerId; it doesn't touch these. latencyMs is already reset correctly via the connectionStatus effect at App.tsx:284-286 — that's the pattern to follow.

The per-server state managers (managedToolsState etc.) are destroyed inside setupClientForServer when the user switches targets, but the call-panel state above sits one level up and isn't part of that teardown.

Proposed change

Extend the disconnect listener in App.tsx:313-322 (or add a sibling effect keyed on connectionStatus) to also clear:

  • setToolCallState(undefined)
  • setGetPromptState(undefined)
  • setReadResourceState(undefined)
  • setCurrentLogLevel(\"info\") — back to the default the next session will start at

Audit App.tsx for any other session-scoped UI state that should reset on disconnect (e.g. errorMessage — already cleared in places, but worth a pass) and clear those too. The per-server state-manager destroys in setupClientForServer should remain unchanged.

Acceptance criteria

  • After disconnecting from server A and connecting to server B, the Tools / Prompts / Resources result panels show their empty state, not the previous session's result.
  • currentLogLevel resets to \"info\" on disconnect so the Logs screen doesn't carry server A's level into server B.
  • Disconnect-driven clearing fires for all three disconnect paths already handled by the existing listener: explicit toggle, header Disconnect button, and mid-session transport failure.
  • App.test.tsx covers the disconnect → state-cleared transition for at least the tool-call panel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2Issues and PRs for v2

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions