Desktop: inline `show_widget` widgets are re-mounted on tab switch and lose all in-page state; a filled-in form submits nothing
Environment
- Claude desktop app, Code tab, macOS 26.5.2 (25F84)
- Claude Code version reported in the session log: 2.1.288 (
entrypoint: claude-desktop) - Built-in visualize tool:
mcp__visualize__read_me,mcp__visualize__show_widget
What happened
The assistant rendered a 40-item triage form with show_widget: three buttons per item, selections held in a JavaScript object, and a button that calls sendPrompt(...) with the result. I marked the whole form (a long pass). When I switched tabs in the app and came back, and in some other situations I could not pin down, every button had reset. Pressing the send button showed the widget's own "nothing marked" message: the widget had been re-mounted and its script re-run, so the in-memory state was gone. All input was lost.
Steps to reproduce
- In a Code-tab session, have the assistant render a widget whose script keeps state in a variable (for example buttons that set
aria-pressedand record the choice in an object) and has a button that sends the state withsendPrompt. - Click several buttons.
- Switch to another tab in the app, then switch back.
- Observed: the buttons are back to their initial state and the state object is empty.
Expected
Either the widget keeps its DOM and script state across tab switches and re-entry, or the tool's guidance says clearly that widgets can be re-mounted at any time and names a supported way to persist state.
Why it matters
The guidance returned by read_me encourages input-collecting widgets (it has sections on forms, quizzes and validating input before submit) and says nothing about re-mounting or persistence. I found no documentation of the widget lifecycle in the public Claude Code docs either. An assistant following the guidance will build forms that silently discard the user's work.
Possibly related
#88670 reports MCP UI widgets re-mounting on session re-entry and not keeping collapse state. This report is about the built-in visualize widget, a tab switch as the trigger, and loss of script state and user input.
Not verified
I did not test whether localStorage or sessionStorage are available to a show_widget widget, or whether state survives scrolling the widget out of view. The re-mount is inferred from the symptoms (controls reset, script state empty); I did not inspect the app.