Skip to content

fix(vscode): prevent missing text during streaming - #4390

Open
oltolm wants to merge 1 commit into
MoonshotAI:mainfrom
oltolm:fix/vscode-duplicate-step-keys
Open

oltolm wants to merge 1 commit into
MoonshotAI:mainfrom
oltolm:fix/vscode-duplicate-step-keys

Conversation

@oltolm

@oltolm oltolm commented Oct 25, 2026

Copy link
Copy Markdown

Requirement or Bug

Related to #4158. Fix missing streamed text when repeated engine step numbers cause duplicate React keys.

Bug Reproduction Steps

See linked issue.

Root Cause

Engine step numbers restart for each core turn. Follow-up turns can therefore append steps with repeated numbers to the same assistant message without emitting another TurnBegin.

Using those numbers as React keys produced duplicate sibling keys and incorrect reconciliation, which could omit or leave stale streamed text until the view reloaded. Compaction steps could introduce the same collision.

This is a fundamental fix: React step identity no longer depends on engine numbering.

Code Changes

 ChatMessage
   StepContent
-    key={step.n}
+    key={globalIndex}

 ToolRenderers
   SubagentStep
-    key={step.n}
+    key={index}

Steps are append-only, so their array positions provide stable identities. Added regress for repeated step numbers in both main-message and subagent step lists.

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
VS Code chat rendering when engine step numbers repeat Duplicate React keys could omit or leave stale text during streaming Every appended main or subagent step retains a distinct React identity None; duplicate keys were invalid React usage N/A

Affected modules and coverage:

  • ChatMessage.tsx: regression renders two main steps with the same engine number and verifies that both remain visible without duplicate-key errors.
  • ToolRenderers.tsx: regression expands a subagent tool with repeated step numbers and verifies both steps.
  • Both regressions fail with the old keys and pass with this change.
  • pnpm --dir apps/vscode run typecheck: passed.
  • pnpm --dir apps/vscode run build: passed.
  • pnpm lint: passed.
  • Full VS Code suite: 382 tests passed; three failures remain in UNC-path,-tag, and replay-display tests outside this diff.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2429899

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-25T10:29:34.389951Z
We couldn’t complete this review. Comment @codex review to try again.
c87dee3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Follow-up engine turns can reuse step numbers within an assistant message. Using those numbers as React keys caused duplicate keys and incorrect reconciliation, which could omit streamed text until the view reloaded.

Key main and subagent steps by their append-only array positions instead. Add regressions for repeated step numbers in both step lists.
@oltolm
oltolm force-pushed the fix/vscode-duplicate-step-keys branch from c87dee3 to 2429899 Compare October 25, 2026 17:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant