"""Diff viewer component for showing before/after file changes.""" from __future__ import annotations import difflib def render_diff(old_text: str, new_text: str, filepath: str = "") -> str: """Return a syntax-highlighted unified diff as HTML.""" diff = difflib.unified_diff( old_text.splitlines(keepends=True), new_text.splitlines(keepends=True), fromfile=f"a/{filepath}", tofile=f"b/{filepath}", ) lines = list(diff) if not lines: return "
No changes.
" html_parts = [ "