Skip to content

Render pi-computed edit diffs in chat UIs#4076

Open
youknowriad wants to merge 2 commits into
trunkfrom
render-pi-edit-diffs
Open

Render pi-computed edit diffs in chat UIs#4076
youknowriad wants to merge 2 commits into
trunkfrom
render-pi-edit-diffs

Conversation

@youknowriad

@youknowriad youknowriad commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Fully authored with Claude Code: it audited every diff-rendering site in the repo, traced how pi's edit tool result details flow through IPC to each renderer, implemented the change, and ran lint/typecheck/tests. Visual appearance still needs human review (see below).

Proposed Changes

  • Agent file edits now display as real diffs in all three chat surfaces. Previously the CLI TUI showed every edit as "all lines removed, all lines added" (and, after the switch to pi's edit tool schema, silently showed nothing), while the desktop chat UIs (apps/ui classic and StudioCodeSession) showed no diff at all.
  • Instead of recomputing diffs, the renderers read the diff pi itself computed and attached to each edit tool result (details.diff). This is exactly what was applied to disk — including fuzzy-match and line-ending resolution — so what the user reviews always matches what happened, and the sandboxed renderers import nothing new.
  • Added/removed lines are tinted green/red in both desktop UIs, following each app's theming system, with new dark-aware --color-frame-diff-* tokens for the legacy renderer.
  • The validate_blocks tool now reports its auto-fix diff as a standard unified patch with 4 context lines via pi's generateUnifiedPatch, instead of a hand-rolled whole-file diff that included every unchanged line — smaller prompts for the model on large files. The ~100-line custom LCS implementation is deleted.

Testing Instructions

  • Run an agent session (desktop Assistant tab with StudioCodeSession, apps/ui chat, or node apps/cli/dist/cli/main.mjs) and ask it to edit a theme file; expand the Edit tool row.
  • Expect a line-numbered diff: green added lines, red removed lines, dim context, ... between distant hunks. In the TUI the diff is in the expandable preview (ctrl+o).
  • Verify both macOS light and dark appearance for the desktop surfaces.
  • npm run typecheck and npm test pass (one unrelated CLI e2e test is flaky under full-suite parallelism; passes in isolation).

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

🤖 Generated with Claude Code

…fied diff

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing bfd33d8 vs trunk

app-size

Metric trunk bfd33d8 Diff Change
App Size (Mac) 1345.38 MB 1345.38 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk bfd33d8 Diff Change
load 1118 ms 750 ms 368 ms 🟢 -32.9%

site-startup

Metric trunk bfd33d8 Diff Change
siteCreation 6527 ms 6480 ms 47 ms ⚪ 0.0%
siteStartup 1852 ms 2390 ms +538 ms 🔴 29.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants