Webview renderer throws "Unhandled case: [object Object]" on session resume for internal-state record types
Environment
- Extension: Anthropic Claude Code v2.1.141 (win32-x64)
- OS: Windows 11 Home 10.0.26200
- VS Code: Standard channel (not Insiders)
- Reproduced in session:
41a14b94-b937-48ff-b6d5-f8e1f102ddd8 - Workspace:
c:\Users\prvtk\DEV\AI Cheif of Staff
Steps to reproduce
- Have an existing Claude Code session that contains internal-state records of types
queue-operation,last-prompt, orfile-history-snapshotin its JSONL transcript (any active session of nontrivial length will have these). - Close the panel / restart VS Code.
- Resume that session via the extension's "Resume" action.
- The renderer replays the historical transcript and emits the text
Unhandled case: [object Object]as part of the rendered transcript, where one of those internal records should have been (silently) skipped.
Expected behavior
Session resume should display the historical user/assistant/system/attachment messages cleanly. Internal-state records like queue operations and file-history snapshots should be filtered out before reaching the renderer, or handled with a no-op case.
Actual behavior
The text Unhandled case: [object Object] is rendered inline in the chat transcript. The bug fires once per resume (at the first internal-state record encountered) and the rest of the transcript renders. The model context is unaffected — only the visual playback breaks.
Root cause (from local investigation)
The compiled webview bundle at:
<vscode-extensions>/anthropic.claude-code-2.1.141-win32-x64/webview/index.js
contains a switch statement (single occurrence of the string "Unhandled case") that handles top-level message types. Searching the bundle for type-name string literals:
| Top-level type value | Present in bundle? |
|---|---|
| assistant | yes |
| user | yes |
| system | yes |
| attachment | yes |
| queue-operation | no |
| last-prompt | no |
| file-history-snapshot | no |
During a live session these three record types are written to the session JSONL on disk but apparently not piped to the webview, so the bug doesn't manifest. On resume, the extension replays every line of the JSONL through the renderer, which hits the default branch of the switch and throws:
throw new Error("Unhandled case: " + obj);
// → caught and rendered, with obj.toString() = "[object Object]"
Suggested fix (one of)
- Filter at the boundary: in the session-replay code path, skip records whose
typeisqueue-operation,last-prompt, orfile-history-snapshotbefore they reach the renderer. Cleanest fix; these are bookkeeping, not UI content. - No-op cases in the renderer: add
case "queue-operation": case "last-prompt": case "file-history-snapshot": return null;to the switch. Less ideal — the renderer shouldn't be receiving these at all — but simpler PR. - Loosen the exhaustiveness check: change
throw new Error(...)toconsole.warn(...) && return null. Quietens the symptom but loses the type-safety value of the exhaustive switch for future types.
Evidence — relevant log excerpt
From <appdata>/Code/logs/<session-date>/window1/exthost/Anthropic.claude-code/Claude VSCode.log, around 2026-05-14 11:32:39:
2026-05-14 11:32:38.572 [info] Received message from webview: {"type":"launch_claude","channelId":"d0frx1pa7t","cwd":"c:\\Users\\prvtk\\DEV\\AI Cheif of Staff","resume":"41a14b94-b937-48ff-b6d5-f8e1f102ddd8",...}
2026-05-14 11:32:38.573 [info] Launching Claude on channel: d0frx1pa7t
2026-05-14 11:32:39.469 [info] Spawning Claude with SDK query function - cwd: c:\Users\prvtk\DEV\AI Cheif of Staff, permission mode: acceptEdits, version: 2.1.141, ...
2026-05-14 11:32:39.469 [info] Received message from webview: {"type":"io_message","channelId":"d0frx1pa7t","message":{"type":"user","uuid":"...","session_id":"","parent_tool_use_id":null,"message":{"role":"user","content":[{"type":"text","text":"Unhandled case: [object Object]\nView output logs · Troubleshooting resources Error here now."}]}},"done":false}
The io_message of type user at 11:32:39.469 is the renderer fallback being lifted back into the message stream by the webview (not actual user input).
Workaround (for users hitting this)
Don't resume sessions until this lands — start fresh each time. The bug only fires on resume; live sessions render correctly. The historical conversation context is still on disk and intact; only the visual playback is broken.
Diagnostic notes for the maintainer
- Type counts in the affected 1.75 MB session: assistant=270, user=141, attachment=121, queue-operation=46, last-prompt=43, file-history-snapshot=38, system=13.
- Attachment sub-types observed (all rendered correctly, so the bug is purely on top-level types):
hook_success,hook_system_message,deferred_tools_delta,hook_additional_context,todo_reminder,edited_text_file,command_permissions,date_change,skill_listing,mcp_instructions_delta. - The "user message containing the error text" pattern in logs is a search-key: filter
Claude VSCode.logforUnhandled caseto find every occurrence in a user's environment.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗