Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(desktop): preserve line breaks when repainting composer draft
Totopo2799e6fa53f828
diff --git a/apps/desktop/src/features/chat/composer/editor.ts b/apps/desktop/src/features/chat/composer/editor.tsindex d07c82364..4db3115a7 100644--- a/apps/desktop/src/features/chat/composer/editor.ts+++ b/apps/desktop/src/features/chat/composer/editor.ts@@ -378,6 +378,11 @@ export function paintEditorValue(// A private-use code point with no chip behind it is user text (for// example a Nerd Font glyph pasted from a terminal); keep it verbatim.}+ if (char === "\n") {+ flush();+ el.appendChild(document.createElement("br"));+ continue;+ }textBuffer += char;}flush();diff --git a/apps/desktop/test/composer-clipboard.test.mjs b/apps/desktop/test/composer-clipboard.test.mjsindex f62869511..ab567c200 100644--- a/apps/desktop/test/composer-clipboard.test.mjs+++ b/apps/desktop/test/composer-clipboard.test.mjs@@ -80,3 +80,51 @@ test("clipboard line endings normalize to the editor LF draft model", () => {assert.equal(normalizeClipboardLineEndings("no breaks"), "no breaks");assert.equal(normalizeClipboardLineEndings(""), "");});++test("paintEditorValue preserves line breaks across DOM rendering", async () => {+ const { paintEditorValue, readEditorValue } = await import("../src/features/chat/composer/editor.ts");+ // Simple mock DOM container+ const container = {+ childNodes: [],+ replaceChildren() {+ this.childNodes = [];+ },+ appendChild(node) {+ this.childNodes.push(node);+ return node;+ },+ };+ globalThis.document = {+ createTextNode(text) {+ return { nodeType: 3, nodeValue: text };+ },+ createElement(tagName) {+ return {+ nodeType: 1,+ tagName: tagName.toUpperCase(),+ classList: { contains: () => false },+ childNodes: [],+ };+ },+ };+ globalThis.Node = {+ ELEMENT_NODE: 1,+ TEXT_NODE: 3,+ };++ paintEditorValue(+ container,+ "line 1\n\nline 2",+ new Map(),+ () => "",+ () => {},+ () => {},+ );++ assert.equal(container.childNodes.length, 4);+ assert.equal(container.childNodes[0].nodeValue, "line 1");+ assert.equal(container.childNodes[1].tagName, "BR");+ assert.equal(container.childNodes[2].tagName, "BR");+ assert.equal(container.childNodes[3].nodeValue, "line 2");+ assert.equal(readEditorValue(container), "line 1\n\nline 2");+});