Skip to content

FE-665: Show word-level diff on staged edits in side-chat#107

Open
kostandinang wants to merge 2 commits into
ka/fe-673-side-chat-v2-edit-modefrom
ka/fe-665-staged-edit-diffs
Open

FE-665: Show word-level diff on staged edits in side-chat#107
kostandinang wants to merge 2 commits into
ka/fe-673-side-chat-v2-edit-modefrom
ka/fe-665-staged-edit-diffs

Conversation

@kostandinang
Copy link
Copy Markdown
Contributor

@kostandinang kostandinang commented May 7, 2026

What

Adds a <ContentDiff> word-level diff primitive and wires it into the side-chat staged-edit row.

Stacked on #105. First of two FE-665 slices — #108 wires the same primitive into PatchListOverlay.

Linear: FE-665.

Why

Today's staged-patch row shows only a summary like "Edit: rephrase wording" — users either trust the model or click Apply to find out what changed.

How

  • Pure, presentational, word-level diff via jsdiff. Renders nothing when inputs are equal or empty.
  • Side-chat popover row gets a <details> expander next to the summary. Non-edit rows / edits without diff data are unchanged.
  • Tints from the existing palette: Removed warm amber with strikethrough; Added cool blue.
  • Ladle story under Primitives / ContentDiff.
  • New dep: diff@^8.0.4.

Follow-up (unblocked by this)

Test plan

  • Stage an edit in side-chat → click chevron → word-level diff visible
  • Identical / empty diffs render nothing

@kostandinang kostandinang self-assigned this May 7, 2026
@kostandinang kostandinang marked this pull request as ready for review May 8, 2026 13:00
@cursor
Copy link
Copy Markdown

cursor Bot commented May 8, 2026

PR Summary

Low Risk
Low risk UI-only change that adds an optional diff expander for staged edit patches and a small new dependency (diff); main risk is minor rendering/UX regressions in the side-chat staged changes panel.

Overview
Adds a new ContentDiff primitive that renders a word-level before/after diff (and returns null when there’s no change), powered by the diff package.

Updates the side-chat staged changes list to optionally render an expandable <details> row for edit patches when currentContent/newContent are provided and differ, showing the inline ContentDiff preview. side-chat-host now enriches staged edit summaries with these before/after fields for the currently pinned item.

Includes new unit/RTL tests covering the diff component and the staged-edit expander behavior, plus a new Ladle primitives story for visual review, and adds diff@^8.0.4 to dependencies.

Reviewed by Cursor Bugbot for commit e2cbbab. Bugbot is set up for automated code reviews on this repo. Configure here.

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 8, 2026

🤖 Augment PR Summary

Summary: Adds word-level diff visualization for staged edit patches in Side Chat so users can preview “before vs after” changes before clicking Apply (FE-665).

Changes:

  • Introduced a new presentational <ContentDiff before after label?> primitive that computes word-level segments via diffWordsWithSpace and renders added/removed spans.
  • Wired the staged-patch row in side-chat-popover.tsx to show a per-row <details> expander when currentContent and newContent are present and differ.
  • Extended SideChatStagedPatchSummary with optional currentContent/newContent fields for back-compat.
  • Updated side-chat-host.tsx to populate the before/after pair from the pinned item’s current content and the staged edit’s proposed content (when anchored to the active item).
  • Added a Ladle story page (Primitives / ContentDiff) with multiple visual variants for design review.
  • Added unit/RTL coverage for both ContentDiff behavior and the staged-edit expander logic.
  • Added diff@^8.0.4 as a direct dependency.

Technical Notes: The diff UI renders nothing when there’s no effective change (identical inputs), and the expander is only shown for edit patches that include both strings and differ to avoid changing behavior for legacy staging paths.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2b2358e. Configure here.

Comment thread src/client/components/side-chat-popover.tsx Outdated
kostandinang and others added 2 commits May 11, 2026 11:43
Prevent the impact chip and discard button from drifting vertically when an edit diff is expanded so staged rows stay visually anchored to the summary line.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kostandinang kostandinang force-pushed the ka/fe-665-staged-edit-diffs branch from 958ea5b to e2cbbab Compare May 11, 2026 09:47
@kostandinang kostandinang changed the title FE-665: Visualise the changes after user submit changes to the spec (diffs) FE-665: Show word-level diff on staged edits in side-chat May 11, 2026
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