* fix(app): clear per-call panels and log level on disconnect (#1368) Session-scoped UI state owned by App.tsx — the Tools / Prompts / Resources result panels (`toolCallState` / `getPromptState` / `readResourceState`) and the optimistic `currentLogLevel` — survived a disconnect/reconnect cycle, so server B's screens showed server A's last result. Extend the existing `disconnect` listener to reset all four back to empty / "info", alongside the activeServerId + modal-flag resets it already does. This covers all three disconnect paths the listener handles (explicit toggle, header Disconnect button, mid-session transport failure). `latencyMs` continues to reset via the connectionStatus effect. Adds App.test.tsx covering the disconnect → tool-call-panel-cleared and log-level-reset transition, mocking the InspectorClient (a fake EventTarget), the per-server state managers, the core hooks, and InspectorView. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(app): assert all four panels reset on disconnect (#1368) Address PR review: the disconnect test asserted only toolCallState and currentLogLevel. Extend the InspectorView double with prompt/resource status spans and get-prompt/read-resource buttons so the test fills and then asserts the reset of all four pieces of session-scoped state (tool / prompt / resource panels + log level), fully matching the "reset on disconnect" contract. Retitle the test accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5c5e5ab754
commit
905b80a88c
1 changed files with 272 additions and 0 deletions
|
|
@ -350,6 +350,15 @@ function App() {
|
|||
// failure / process exit) and avoids the first-render-clobbers-new-id
|
||||
// trap that watching connectionStatus has (status starts as
|
||||
// "disconnected" for the new client before connect() runs).
|
||||
//
|
||||
// This is also where session-scoped UI state that lives in App.tsx
|
||||
// (rather than inside the per-server state managers) gets reset, so the
|
||||
// next server's screens don't show server A's last result. The per-call
|
||||
// panels (`toolCallState` / `getPromptState` / `readResourceState`) and
|
||||
// the optimistic `currentLogLevel` all survive a disconnect/reconnect
|
||||
// cycle otherwise — see #1368. `latencyMs` resets via the
|
||||
// `connectionStatus` effect above instead because it has its own
|
||||
// connecting-edge ref to coordinate with.
|
||||
useEffect(() => {
|
||||
if (!inspectorClient) return;
|
||||
const onDisconnect = () => {
|
||||
|
|
@ -357,6 +366,12 @@ function App() {
|
|||
// Drop the open flag too — without this the modal would pop back the
|
||||
// next time `initializeResult` re-becomes truthy (e.g. reconnect).
|
||||
setConnectionInfoModalOpen(false);
|
||||
// Clear the per-call result panels so the next session starts empty.
|
||||
setToolCallState(undefined);
|
||||
setGetPromptState(undefined);
|
||||
setReadResourceState(undefined);
|
||||
// Back to the default level the next session begins at.
|
||||
setCurrentLogLevel("info");
|
||||
};
|
||||
inspectorClient.addEventListener("disconnect", onDisconnect);
|
||||
return () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue