fix(web): preserve newlines in code copy-paste

Quentin Gliech and Claude Opus 4.6 (1M context) created

Append a \n text node inside each .line span so copy-pasting from
the code block includes proper line breaks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Change summary

webui2/src/components/code/file-viewer.tsx | 3 +++
1 file changed, 3 insertions(+)

Detailed changes

webui2/src/components/code/file-viewer.tsx 🔗

@@ -95,6 +95,9 @@ function lineNumberTransformer(): ShikiTransformer {
   return {
     line(node, line) {
       node.properties["dataLineNumber"] = line;
+      // Append a \n text node inside each .line so copy-paste preserves newlines
+      // (we strip the inter-element whitespace nodes in code() below).
+      node.children.push({ type: "text", value: "\n" });
     },
     // Remove whitespace text nodes between .line spans — they create
     // empty anonymous table rows when using display: table-row.