MoonshotAI / MoonshotAI/kimi-code

web: turn file-change cards show no stats/diff for Write calls and replace_all Edits

Open
#3,100 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Summary

In the web UI, the per-turn "N files changed" summary card aggregates file changes per tool call. Two cases currently produce no usable result:

  1. Write calls: the file row shows no +x/-y stats, and clicking the row/card opens the raw file instead of a diff view.
  2. Edit calls with replace_all: true: same symptom — no stats, no diff.

Additionally, when any file in the card is affected, the card header hides the aggregate +x/-y totals as well.

Steps to reproduce

  1. Open the web UI against a running backend.
  2. Run a session where the agent creates a file with the Write tool (or performs an Edit with replace_all: true).
  3. Look at the turn's file-change card: the affected file row has no stats; clicking it opens the file, not a diff.

Root cause (from the shipped web bundle, 0.37.2)

Inspecting the bundled frontend code, the turn-changes aggregation works roughly like:

  • The aggregator routes write to a dedicated branch that sets hasWrite = true and statsIncomplete = true and never computes a diff (only edit/multi_edit go through the diff builder).
  • The diff-builder helper returns null for anything that is not edit/multi_edit, and explicitly returns null for edits with replace_all === true.
  • The card's click handler decides openFile vs openDiff based on hasWrite, rather than on whether a computed diff actually exists.
  • The header aggregate is hidden when any entry has statsIncomplete.

So the data (path, content / old_string / new_string) is all present in the history frames — this is purely a presentation-layer gap.

Suggested behavior

  • Write (new file / overwrite): build an all-additions diff from "" -> content, matching what #2274 proposed for the live preview panel. Show stats from that diff.
  • Edit with replace_all: true: build a representative diff from old_string -> new_string (a single-occurrence view is still far more useful than nothing).
  • Click handler: prefer openDiff whenever a diff exists, regardless of hasWrite.
  • Longer term, the ideal fix is server-side: record the real before/after content at execution time so overwrite Writes, append mode, and replace_all multiplicities can be rendered accurately instead of approximated from args.

Environment

  • kimi-code 0.37.2 (single-binary), macOS arm64
  • Web UI in Chrome

Related

  • #2268 / #2274 covered the Write live preview panel (closed unmerged); this issue is about the turn summary card, which is a separate code path.

Happy to provide bundle-level details (function shapes / exact guards) if useful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the turn-change aggregator, diff-builder, and card click handler in the web frontend, then reproduce the Write and replace_all cases against a running backend. Trace the existing edit/multi_edit diff path and the related live preview behavior. Done means affected rows show stats, open diffs, and the card header retains aggregate totals when a diff can be computed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.