Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(web): stop wrapping partial code block selections in markdown fences (#5069)

Tai Nguyenc4556ab23751
diff --git a/apps/web/src/markdown-clipboard.ts b/apps/web/src/markdown-clipboard.ts
index 86965eebf..f56b3a492 100644
--- a/apps/web/src/markdown-clipboard.ts
+++ b/apps/web/src/markdown-clipboard.ts
@@ -301,6 +301,17 @@ export function chatMarkdownClipboardPayload(
if (range.collapsed) continue;
const container = document.createElement("div");
container.appendChild(range.cloneContents());
+ const ancestor = range.commonAncestorContainer;
+ const ancestorElement =
+ ancestor.nodeType === Node.ELEMENT_NODE ? (ancestor as Element) : ancestor.parentElement;
+ if (ancestorElement?.closest("pre")) {
+ const text = range.toString();
+ if (text) {
+ texts.push(text);
+ htmls.push(sanitizedHtmlFrom(container));
+ }
+ continue;
+ }
const text = serializeRenderedMarkdownFragment(container);
if (!text) continue;
texts.push(text);