From b9f8f02e11c0f03a78255b379ec3ff06951831e8 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Tue, 8 Sep 2026 14:32:51 +0100 Subject: [PATCH] fix(maestro): fix diff double-spacing and add +/- markers Block spans + literal \n text nodes inside
 caused empty lines
between every diff line. Drop the text nodes, add unified-diff prefixes.

Co-Authored-By: Claude Opus 4.6 
---
 web/src/structuredRender.test.ts | 4 ++--
 web/src/structuredRender.ts      | 9 +++++----
 web/src/styles.css               | 1 +
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/web/src/structuredRender.test.ts b/web/src/structuredRender.test.ts
index 0b6e485..622739f 100644
--- a/web/src/structuredRender.test.ts
+++ b/web/src/structuredRender.test.ts
@@ -315,8 +315,8 @@ describe("buildTranscriptRow: tool diffs", () => {
     (el.querySelector(".st-tool-head") as HTMLButtonElement).click();
     const diff = el.querySelector(".st-diff") as HTMLElement;
     expect(diff).not.toBeNull();
-    expect(diff.querySelector(".st-ln-add")!.textContent).toBe("c");
-    expect(diff.querySelector(".st-ln-del")!.textContent).toBe("b");
+    expect(diff.querySelector(".st-ln-add")!.textContent).toBe("+ c");
+    expect(diff.querySelector(".st-ln-del")!.textContent).toBe("- b");
   });
 
   it("gives the diff its own horizontally-scrolling container", () => {
diff --git a/web/src/structuredRender.ts b/web/src/structuredRender.ts
index 31ef0a4..6b8e7f2 100644
--- a/web/src/structuredRender.ts
+++ b/web/src/structuredRender.ts
@@ -223,15 +223,16 @@ function buildDiffBlock(diff: { path: string; oldText?: string | null; newText:
   wrap.appendChild(label);
   const scroller = el("div", "st-diff");
   const pre = document.createElement("pre");
-  for (const line of computeDiffLines(diff.oldText, diff.newText)) {
+  const lines = computeDiffLines(diff.oldText, diff.newText);
+  const prefixes: Record = { add: "+ ", del: "- ", ctx: "  ", hunk: "", eof: "" };
+  for (const line of lines) {
     const span = document.createElement("span");
     span.className = `st-ln st-ln-${line.kind}`;
-    span.textContent = line.text;
+    span.textContent = (prefixes[line.kind] ?? "") + line.text;
     pre.appendChild(span);
-    pre.appendChild(document.createTextNode("\n"));
   }
   scroller.appendChild(pre);
-  makeCopyable(scroller, pre.textContent ?? "", "diff");
+  makeCopyable(scroller, lines.map((l) => (prefixes[l.kind] ?? "") + l.text).join("\n"), "diff");
   wrap.appendChild(scroller);
   return wrap;
 }
diff --git a/web/src/styles.css b/web/src/styles.css
index dbf0132..bd29a1e 100644
--- a/web/src/styles.css
+++ b/web/src/styles.css
@@ -2965,6 +2965,7 @@ input.leaf-rename:focus {
   display: block;
   white-space: pre;
   padding: 0 var(--sp-3);
+  line-height: 1.4;
 }
 
 .st-ln-add {