Skip to content

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

Closed

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.

Activity

  1. added
    v2
    on May 27, 2026
  2. added theissue type on May 27, 2026
  3. sampathreddy22 commented on May 31, 2026

    @sampathreddy22

    Implemented a fix in sampathreddy22/inspector — PR #1391.

    The core change is a useEffect in App.tsx keyed on connectionStatus that resets session state when the connection drops ("disconnected" or "error"). This covers the call-panel results and log level as described in the issue.

    One additional thing I noticed while testing locally: after reconnecting to a different server, the previous server's tool list was still visible in the Tools panel until the new server's list loaded. So the fix also clears tools, prompts, resources, resourceTemplates, and their corresponding selection state (selectedTool, selectedPrompt, selectedResource) on disconnect. The new server repopulates these via its normal list* calls on connect, so the only visible difference is the panel briefly shows empty state rather than stale data from the previous session.

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

  4. self-assigned this
    on May 31, 2026
  5. added this to the v2.0.0 milestone on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

v2

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions