Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

chore(md-view): Task 2 review fold-ins

review2d65a7f2dbd9
diff --git a/CLAUDE.md b/CLAUDE.md
index 5bb49e185..681ee949c 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1537,7 +1537,12 @@ session.
Monaco is wired in `renderer/editor/monaco-setup.ts` (language workers bundled via Vite
`?worker` — no CDN; CSP `worker-src` allows them). Markdown rendering is shared in
-`renderer/lib/markdown.ts` (`marked` + DOMPurify sanitize).
+`renderer/lib/markdown.ts` (`marked` + DOMPurify sanitize). Terminal OUTPUT (the ⌘M output view)
+goes through `renderer/lib/terminalOutputMarkdown.ts` instead: a private `Marked` instance with
+`breaks` on (output is line-oriented — without it `ls -l` joined into one paragraph) that renders
+raw-HTML tokens as escaped TEXT (a program's `<stdin>` is not markup; parsed as HTML, DOMPurify
+stripped it) and trims capture-pane's trailing padding. The escape is on the `html` token, never a
+global pre-escape of `<`, which would double-escape code spans/fences.
### Webview keep-alive across project switches (browser/web nodes)
diff --git a/src/renderer/lib/terminalOutputMarkdown.test.ts b/src/renderer/lib/terminalOutputMarkdown.test.ts
index 36701768a..cdc18c8e0 100644
--- a/src/renderer/lib/terminalOutputMarkdown.test.ts
+++ b/src/renderer/lib/terminalOutputMarkdown.test.ts
@@ -58,6 +58,14 @@ describe('renderTerminalOutput', () => {
expect(html).not.toContain('javascript:')
})
+ it('renders a CRLF capture exactly like its LF twin (padding before the \\r included)', () => {
+ // Characterization, not a regression pin: JS's /m `$` already treats \r as a line terminator
+ // and marked normalizes \r\n, so this held before the explicit \r strip — it guards both.
+ expect(renderTerminalOutput('```\r\na \r\nb\t\r\n```\r\nx \r\ny\r\n\r\n')).toBe(
+ renderTerminalOutput('```\na\nb\n```\nx\ny')
+ )
+ })
+
it('renders empty input as empty', () => {
expect(renderTerminalOutput('')).toBe('')
expect(renderTerminalOutput('\n\n \n')).toBe('')
diff --git a/src/renderer/lib/terminalOutputMarkdown.ts b/src/renderer/lib/terminalOutputMarkdown.ts
index 571cda726..8491bac25 100644
--- a/src/renderer/lib/terminalOutputMarkdown.ts
+++ b/src/renderer/lib/terminalOutputMarkdown.ts
@@ -35,6 +35,8 @@ const terminalMarked = new Marked({
breaks: true,
gfm: true,
renderer: {
+ // Positional `(html, block)` is marked 12's Renderer signature; marked 13+ passes ONE token
+ // object instead, so an upgrade must rewrite this hook (the tests would go red, not silent).
html(html: string, block?: boolean): string {
if (!block) return escapeHtml(html)
// A block-level html token swallows every line up to the next blank line; show it as the
@@ -44,9 +46,10 @@ const terminalMarked = new Marked({
}
})
-/** Strip trailing whitespace from every line, then the trailing blank lines capture-pane pads. */
+/** Strip trailing whitespace (and a CRLF capture's `\r` — explicit, though JS's /m `$` and marked's
+ * own CRLF normalization already cover it) from every line, then capture-pane's blank-line pad. */
function trimCapture(text: string): string {
- return text.replace(/[ \t]+$/gm, '').replace(/\s+$/, '')
+ return text.replace(/[ \t\r]+$/gm, '').replace(/\s+$/, '')
}
export function renderTerminalOutput(text: string): string {