feat: show diff view for AI CV rewrites

The master-CV rewrite preview replaced text without showing what
changed -- the teardown flagged this as the biggest unmanaged AI risk
(a rewrite silently upgrading "assisted with migration" to "led
migration" was invisible). Add a "Show changes" toggle on the rewrite
preview panel that renders a word-level diff (before = current master
text or the targeted section's stored content, after = the AI's
rewrite) instead of the flat replacement text.

Defaults to off: an existing test proved diff-by-default breaks the
familiar plain-text read (word-fragmented spans aren't matchable as
one block), and it's a better UX default regardless -- read normally,
opt into the diff when you want the trust signal.

Uses the `diff` package (word-level diffWords) rather than hand-rolled
LCS; no existing dependency covers this, and it's a solved problem.
This commit is contained in:
cesnimda
2026-07-12 15:21:04 +02:00
parent 66384bda60
commit cbd045a0d3
7 changed files with 103 additions and 20 deletions
+8
View File
@@ -270,6 +270,14 @@ test('profile page rewrite tools use selected template and saved job context', a
expect(screen.getByText(/clearer, sharper positioning for backend platform roles/i)).toBeInTheDocument();
expect(screen.getByRole('heading', { name: /pdf carousel/i })).toBeInTheDocument();
const showChangesToggle = screen.getByText(/show changes/i);
fireEvent.click(showChangesToggle);
expect(screen.queryByText(/clearer, sharper positioning for backend platform roles/i)).not.toBeInTheDocument();
expect(screen.getByText(/Clearer/i)).toBeInTheDocument();
fireEvent.click(showChangesToggle);
expect(screen.getByText(/clearer, sharper positioning for backend platform roles/i)).toBeInTheDocument();
const buildCarouselButton = screen.getByRole('button', { name: /build pdf carousel/i });
fireEvent.click(buildCarouselButton);