From e215f707a0186d7bfe78b4e1e3950d0f566ae9b2 Mon Sep 17 00:00:00 2001 From: pcarter Date: Wed, 8 Apr 2026 15:52:57 -0700 Subject: [PATCH] code on input --- app/page.tsx | 2 +- tests/unit.test.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/page.tsx b/app/page.tsx index e3d942e..1091738 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -676,7 +676,7 @@ export default function Home() { ) : ( msg.role === 'assistant' ?
- : msg.content && {msg.content} + : msg.content &&
)} {editingIndex === null && (
diff --git a/tests/unit.test.ts b/tests/unit.test.ts index 60bc80c..ec83efb 100644 --- a/tests/unit.test.ts +++ b/tests/unit.test.ts @@ -223,6 +223,15 @@ test('renderMarkdown: neutralizes data:text/html links', () => { assert.ok(!html.includes('data:text/html'), `data:text/html URL should be removed, got: ${html}`); }); +test('renderMarkdown: user message with mixed text and fenced code block renders both', () => { + // Simulates a user typing prose followed by a code snippet + const html = renderMarkdown('here is some code:\n\n```typescript\nconst x: number = 1;\n```'); + assert.ok(html.includes('

'), `prose should be in a paragraph, got: ${html}`); + assert.ok(html.includes('language-typescript'), `code fence should be highlighted as typescript, got: ${html}`); + assert.ok(html.includes('hljs'), `hljs class should be present, got: ${html}`); + assert.ok(html.includes('code-block'), `copy button wrapper should be present, got: ${html}`); +}); + // ── parseStreamError ───────────────────────────────────────────────────────── test('parseStreamError: 429 → rate limit message', () => { -- 2.51.2