[BUG] Webview output pollution — stale command headers & duplicated lines after reconnect/replay

Open 💬 2 comments Opened Jun 15, 2026 by chenmao1002

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

After a session reconnect / message replay, the Claude Code conversation webview (VS Code
extension v2.1.173, win32-x64) becomes visually polluted:

  • Tool-call/command header rows from EARLIER turns bleed into the current view.
  • The same line / content block is rendered TWICE (duplicate lines), most often around

tool-use header blocks.

  • Doing Developer: Reload Window while polluted (and restoring the old session) makes it

WORSE — the replay re-appends onto already-rendered DOM instead of replacing it.

This is purely a render-time artifact, NOT data corruption. I verified three layers directly
with PowerShell/CIM (not trusting any rendered output):

| Layer | Check | Result |
|--------------|-----------------------------------------|-----------------------------------------------------|
| Process | Get-CimInstance Win32_Process | Exactly 1 claude.exe, no orphan/zombie processes |
| Persistence | Parsed the 3 most recent *.jsonl files | Each file: 1 distinct sessionId, 0 duplicate uuid |
| Render | (inference from above) | Disk data clean → duplication is produced at render |

Process flags in play: --output-format stream-json --input-format stream-json
--include-partial-messages --replay-user-messages
.

Likely cause (code-level evidence from the shipped extension):

  1. Partial→final reconciliation desync — with --include-partial-messages, a reconnect leaves

the partial accumulator un-reset, so the final message is appended below the partial instead
of replacing it (esp. tool-use header blocks, which render as their own row).

  1. Replay double-emission — --replay-user-messages rehydrates the view without clearing the

existing webview DOM list first, so old headers stack back in.

  1. Amplifier (confirmed in code): extension.js sets retainContextWhenHidden: true

(minified retainContextWhenHidden:!0, 5 occurrences; VS Code default is false), keeping
stale DOM alive across hide/show so it can double-paint on replay.

Ownership: every layer is Anthropic-authored (claude.exe, extension.js, webview/index.js, and
the retainContextWhenHidden opt-in). VS Code core behaves as documented. This is a Claude Code
extension bug, not a VS Code-core bug.

What Should Happen?

On reconnect / replay / window reload, the webview should rehydrate idempotently:

  • Reset the partial-message accumulator on reconnect, so a final message REPLACES its partial

rather than being appended below it.

  • Clear (or diff against) the existing rendered message list BEFORE re-emitting persisted

messages, so replayed turns do not stack on top of already-rendered DOM.

  • Render messages idempotently keyed by uuid / (message id + content-block index), so the same

message can never appear twice regardless of how many times it is streamed or replayed.

Net effect: the conversation view should look identical to the on-disk transcript (which is
already clean), with no duplicated lines and no stale headers from previous turns — and a
Reload Window should never make the view worse.

Error Messages/Logs

Steps to Reproduce

Environment: Claude Code VS Code extension v2.1.173 (win32-x64), VS Code engine ^1.94.0,
Windows 10 Pro (19045). Process launched with --include-partial-messages --replay-user-messages.

  1. Open the Claude Code panel in VS Code and run a normal conversation with several turns that

include tool calls (so multiple tool-call header rows exist).

  1. Trigger a reconnect/replay of the live session — e.g. hide then re-show the panel, or run

Developer: Reload Window and RESTORE the previous Claude session.

  1. Observe the conversation view: tool-call headers from earlier turns reappear mixed into the

current view, and one or more content blocks/lines are rendered twice.

  1. Run Developer: Reload Window again (restoring the session) → the duplication grows instead

of clearing.

Verification that it is render-only, not data corruption (optional, PowerShell):

  • Get-CimInstance Win32_Process -Filter "Name='claude.exe'" → exactly 1 process, no orphans.
  • Parse the latest %USERPROFILE%\.claude\projects\<project>\*.jsonl → each file has a single

sessionId and zero duplicate uuid values, i.e. the persisted transcript is clean while the
rendered view is duplicated.

Workaround (verified effective):

  • Kill the process from the OS: Get-Process claude | Stop-Process -Force
  • Developer: Reload Window
  • Do NOT restore the old session — start a fresh one.
  • Avoid repeated Reload Window while polluted.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

v2.1.173

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

<img width="609" height="441" alt="Image" src="https://github.com/user-attachments/assets/80bace84-8865-4210-9a0a-b5d3b9fcf872" />

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗