@devries-cameron20 / t3code-1 / commits / 725573f358
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): double-click selects the whole inline code span (#26639)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 28, 2026 at 17:12 UTC 725573f35850b3414f2e71a55ea7b8412fcfac1e
2 files changed +27
apps/web/src/components/ChatMarkdown.browser.test.tsx
+16
@@ -328,6 +328,22 @@ describe("ChatMarkdown headings", () => {
328 });
329 });
330
331 +describe("ChatMarkdown inline code selection", () => {
332 + it("selects the whole inline code span on double-click, but only a word in fenced code", async () => {
333 + setup();
334 + await using screen = await renderText(
335 + "Run `migration-gate --dry-run` first.\n\n```txt\nfenced-block word\n```",
336 + );
337 + await userEvent.dblClick(screen.getByText("migration-gate --dry-run"));
338 + expect(window.getSelection()?.toString()).toBe("migration-gate --dry-run");
339 +
340 + window.getSelection()?.removeAllRanges();
341 + const fenced = screen.container.querySelector("pre code")!;
342 + await userEvent.dblClick(fenced, { position: { x: 4, y: 4 } });
343 + expect(window.getSelection()?.toString()).toBe("fenced");
344 + });
345 +});
346 +
347 describe("ChatMarkdown Windows file links", () => {
348 const environmentId = EnvironmentId.make("env-windows");
349 const renderWindows = (text: string, parseRawHtml: boolean) =>
apps/web/src/components/ChatMarkdown.tsx
+11
@@ -74,6 +74,7 @@ import React, {
74 Suspense,
75 type ComponentProps,
76 type ClipboardEvent as ReactClipboardEvent,
77 + type MouseEvent as ReactMouseEvent,
78 use,
79 memo,
80 useLayoutEffect,
@@ -942,6 +943,11 @@ function markdownHeadingRenderer(level: 1 | 2 | 3 | 4 | 5 | 6) {
943 };
944 }
945
946 +// Native word selection stops at hyphens and dots, so a double-click takes the whole span.
947 +function selectInlineCode(event: ReactMouseEvent<HTMLElement>) {
948 + window.getSelection()?.selectAllChildren(event.currentTarget);
949 +}
950 +
951 const CHAT_MARKDOWN_COMPONENTS = {
952 h1: markdownHeadingRenderer(1),
953 h2: markdownHeadingRenderer(2),
@@ -1334,6 +1340,11 @@ const CHAT_MARKDOWN_COMPONENTS = {
1340 inlineCodeFilePathCandidate(codeText) ?? codeText.trim(),
1341 );
1342 }
1343 + return (
1344 + <code {...props} className={className} onDoubleClick={selectInlineCode}>
1345 + {children}
1346 + </code>
1347 + );
1348 }
1349 return (
1350 <code {...props} className={className}>