Files
multica/packages
Larry Lai da7451843b MUL-5494: feat(transcript): render tool events as diffs, content and terminal output (#6134)
* feat(transcript): make tool events readable — diffs, content, terminal output

The expanded transcript row printed a tool call's input as raw JSON, so an edit
showed `old_string`/`new_string` as escaped one-line literals — the one event
type where seeing *what changed* matters most. Tool results kept their JSON
string encoding, so every shell result read as a quoted blob with literal `\n`,
in the collapsed summary and in Copy all as well as in the body.

What each kind of event now renders as:

- A replacement reads as a diff. Unchanged runs fold to `⋯` with three lines of
  context either side, so a one-line change inside a large `old_string` is not
  buried in text that never moved.
- A whole-file write reads as plain content with a line count. There is no
  before side to compare against, so a `+` on all of it carries no information.
- A result is unwrapped once, everywhere it appears.

File mutations are identified by the *shape* of the input (`file_path` plus
`old_string`/`new_string`, or `content`), never by tool name: the presenter's
contract is to keep provider-native names verbatim, and those differ per
provider. The write mode keys on `content` rather than on "the before side is
empty", because an edit with an empty old_string is an insertion into a file
that already exists and still reads as a diff.

Highlighting reuses the rich-content engine (`lowlight` and the `.hljs-*` class
contract), so a file looks the same in a transcript as it does in a comment,
with no new dependency. Each side is highlighted as ONE block and then split at
newlines, re-opening the enclosing spans per line — highlighting line by line
would break every multi-line string, comment and template literal. Grammar
comes from the file extension; an unknown extension stays plain rather than
guessing. The hljs palette was scoped to `.rich-text-editor`; it now also
covers `.transcript-code`, with no colour definition duplicated.

Diffing is a small LCS over lines, degrading to a plain replacement block past
250k cells. Line numbers are deliberately absent: the transcript stores only
the tool input, so a snippet's position inside its file is not knowable here,
and relative numbers would read as file lines and mislead.

* fix(transcript): keep the show-all label off the line it covers

The fade overlay does not fully clear the clipped line, so the transparent
"Show all" label rendered on top of whatever text sat behind it — the two
interleaved character by character and neither was readable. Giving the button
an opaque surface separates them.

Pre-existing: any tool output long enough to clip hit it. It became routine
once whole-file writes started rendering their content.
2026-07-30 10:22:14 +08:00
..