@devries-cameron20 / t3code Mirror · read-only / commits / adfdcb67b3
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 04:15 UTC

fix(web): copied task lists keep their nested items and code blocks (#14778)

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

Soroush Baraouf committed Oct 18, 2026 at 15:31 UTC adfdcb67b3044836f4dc8c6d76bc5cb6915a7162
2 files changed +21 -4
apps/web/src/markdown-clipboard.test.ts
+16 -2
@@ -167,13 +167,13 @@ describe("serializeRenderedMarkdownFragment", () => {
167 parentChecked: false,
168 childChecked: true,
169 parent: "- [ ] Parent",
170 - child: " - [x] Child",
170 + child: " - [x] Child",
171 },
172 {
173 parentChecked: true,
174 childChecked: false,
175 parent: "- [x] Parent",
176 - child: " - [ ] Child",
176 + child: " - [ ] Child",
177 },
178 ])("copies $parent with $child", ({ parentChecked, childChecked, parent, child }) => {
179 const parentContent = parentLayout === "loose" ? new FakeElement("P") : new FakeElement("LI");
@@ -206,6 +206,20 @@ describe("serializeRenderedMarkdownFragment", () => {
206 });
207 });
208
209 + it("indents a code block under a numbered task item by the number width only", () => {
210 + const checkbox = new FakeElement("INPUT", [], { type: "checkbox" });
211 + checkbox.checked = true;
212 + const item = new FakeElement("LI").append(
213 + new FakeElement("P").append(checkbox, new FakeText(" Run the tests")),
214 + renderedCodeBlock(["pnpm test"]),
215 + );
216 + const container = new FakeElement("DIV").append(new FakeElement("OL").append(item));
217 +
218 + expect(serializeRenderedMarkdownFragment(asNode(container))).toBe(
219 + "1. [x] Run the tests\n\n ```\n pnpm test\n ```",
220 + );
221 + });
222 +
223 it("copies the complete quote, source, and comment instead of the comment-only chip label", () => {
224 const citation = {
225 version: 1 as const,
apps/web/src/markdown-clipboard.ts
+5 -2
@@ -112,14 +112,17 @@ function serializeListItem(item: Element, ordered: boolean, index: number): stri
112 ':scope > input[type="checkbox"], :scope > p > input[type="checkbox"]',
113 );
114 const task = checkbox ? `[${(checkbox as HTMLInputElement).checked ? "x" : " "}] ` : "";
115 - const marker = ordered ? `${index}. ${task}` : `- ${task}`;
115 + const bullet = ordered ? `${index}. ` : "- ";
116 + const marker = `${bullet}${task}`;
117 let content = serializeChildren(item)
118 .replace(/\n{3,}/g, "\n\n")
119 .trim();
120 if (!item.querySelector(":scope > p")) {
121 content = content.replace(/\n{2,}/g, "\n");
122 }
122 - const continuationIndent = " ".repeat(marker.length);
123 + // Nested content lines up with the item text, which starts after the bullet;
124 + // a task box is part of that text, not of the list marker.
125 + const continuationIndent = " ".repeat(bullet.length);
126 const [first = "", ...rest] = content.split("\n");
127 return [
128 `${marker}${first}`,