webui: add diff display for patches

Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s2e9bdfb014ddec3ck
diff --git a/claudetool/patch.go b/claudetool/patch.go
index 815cf88..04ea942 100644
--- a/claudetool/patch.go
+++ b/claudetool/patch.go
@@ -13,6 +13,7 @@
 	"path/filepath"
 	"strings"
 
+	"github.com/pkg/diff"
 	"sketch.dev/claudetool/editbuf"
 	"sketch.dev/claudetool/patchkit"
 	"sketch.dev/llm"
@@ -264,8 +265,13 @@
 		fmt.Fprintf(response, "- WARNING: %q appears to be autogenerated. Patches were applied anyway.\n", input.Path)
 	}
 
+	diff := generateUnifiedDiff(input.Path, string(orig), string(patched))
+
 	// TODO: maybe report the patch result to the model, i.e. some/all of the new code after the patches and formatting.
-	return llm.ToolOut{LLMContent: llm.TextContent(response.String())}
+	return llm.ToolOut{
+		LLMContent: llm.TextContent(response.String()),
+		Display:    diff,
+	}
 }
 
 func parseGo(buf []byte) error {
@@ -318,3 +324,12 @@
 	strings.ToLower("DO NOT EDIT"),
 	strings.ToLower("export by"),
 }
+
+func generateUnifiedDiff(filePath, original, patched string) string {
+	buf := new(strings.Builder)
+	err := diff.Text(filePath, filePath, original, patched, buf)
+	if err != nil {
+		return fmt.Sprintf("(diff generation failed: %v)\n", err)
+	}
+	return buf.String()
+}