The best way to control Claude Code, Codex and more from any computer or phone
fix(web): a line typed after a composer list is sent after the list (#38414)
Julius Marminge committed
Nov 17, 2026 at 19:12 UTC
3e1b7c4e93d7f3d035d14296ebf45e373914ae8c
3 files changed
+59
-11
apps/web/src/composer-list-split.browser.test.ts
+2
-2
@@ -60,7 +60,7 @@ function storedDraft(editor: Editor) {
60
61
describe("Backspace at the start of a line", () => {
62
it.each([
63
- ["- a\n```\nl1\nl2\n```", "- a\nl1\nl2"],
63
+ ["- a\n```\nl1\nl2\n```", "- a\n\nl1\nl2"],
64
["p\n```ts\nl1\n```", "p\nl1"],
65
])("removes the fence of %j rather than joining its code up", (value, expected) => {
66
using editor = makeEditor(value);
@@ -95,6 +95,6 @@ describe("blocks that a list item or quote cannot hold", () => {
95
editor.view.dispatch(editor.state.tr.setSelection(TextSelection.atEnd(editor.state.doc)));
96
const lines = buildTiptapContent("one\ntwo", (name) => ({ label: name, description: null }));
97
editor.commands.insertContent(lines);
98
- expect(storedDraft(editor)).toBe("- a\none\ntwo");
98
+ expect(storedDraft(editor)).toBe("- a\n\none\ntwo");
99
});
100
});
apps/web/src/composer-rich-text-doc.test.ts
+31
-2
@@ -315,7 +315,7 @@ describe("composer rich text document model", () => {
315
"- [ ] parent\n - [ ] child\n - [ ] sibling\n- [ ] uncle",
316
"- [ ] empty task follows\n- [ ]",
317
"- [ ] **bold** task with @README.md",
318
- "para\n- [ ] task\npara",
318
+ "para\n- [ ] task\n\npara",
319
"- [ ]No space stays literal",
320
"-[ ] also literal",
321
"@README.md explain this",
@@ -499,7 +499,7 @@ describe("composer rich text document model", () => {
499
"- **bold** item with @README.md",
500
"- [ ] task\n- bullet after",
501
"- bullet\n- [x] task after",
502
- "para\n- item\npara",
502
+ "para\n- item\n\npara",
503
"\t- tab indented\n\t- again",
504
" - leading indent only",
505
"- item\n\n- after a blank",
@@ -608,6 +608,35 @@ describe("composer rich text document model", () => {
608
});
609
});
610
611
+ describe("a paragraph after a list", () => {
612
+ const skillLabelFor = (name: string) => ({ label: name, description: null });
613
+ it.each([
614
+ ["a numbered list", "1. a\n2. b\n3. c", 0],
615
+ ["a bullet list", "- a\n- b", 0],
616
+ ["a task list", "- [ ] a", 0],
617
+ ["a bullet list and an empty line", "- a", 1],
618
+ ])(
619
+ "is written after a blank line after %s, or Markdown folds it into the last item",
620
+ (_kind, list, emptyLines) => {
621
+ const listJson = buildDocJson(list, skillLabelFor);
622
+ const doc = ProseMirrorNode.fromJSON(schema, {
623
+ type: "doc",
624
+ content: [
625
+ ...listJson.content,
626
+ ...Array.from({ length: emptyLines }, () => ({ type: "paragraph" })),
627
+ { type: "paragraph", content: [{ type: "text", text: "d" }] },
628
+ ],
629
+ });
630
+ doc.check();
631
+ expect(doc.childCount).toBe(2 + emptyLines);
632
+ const { value } = serializeEditorDoc(doc);
633
+ expect(value).toBe(`${list}\n\n${"\n".repeat(emptyLines)}d`);
634
+ const reopened = ProseMirrorNode.fromJSON(schema, buildDocJson(value, skillLabelFor));
635
+ expect(reopened.toJSON()).toEqual(doc.toJSON());
636
+ },
637
+ );
638
+ });
639
+
640
describe("a dash rule after a paragraph", () => {
641
const paragraph = (text: string) => ({ type: "paragraph", content: [{ type: "text", text }] });
642
const rule = (source: string) => ({ type: "horizontalRule", attrs: { source } });
apps/web/src/composer-rich-text-doc.ts
+26
-7
@@ -1090,11 +1090,21 @@ export function buildTiptapContent(
1090
openQuote.content.push(entry.quote.inline);
1091
continue;
1092
}
1093
- // The serializer separates a quote from the prose after it with one blank line; it is not an empty paragraph.
1094
- const quoteSeparator =
1095
- openQuote !== null && isProseLine(entry, true) && isProseLine(entries[entryIndex + 1], false);
1093
+ // The serializer separates a quote or list from the prose after it with one blank line; it is not an empty paragraph.
1094
+ // After a list it precedes any empty paragraphs the user left, so those survive.
1095
+ let proseIndex = entryIndex + 1;
1096
+ if (openQuote === null && rootLists.length > 0 && isProseLine(entry, true)) {
1097
+ while (isProseLine(entries[proseIndex], true)) proseIndex += 1;
1098
+ }
1099
+ const blockSeparator =
1100
+ (openQuote !== null || rootLists.length > 0) &&
1101
+ isProseLine(entry, true) &&
1102
+ isProseLine(entries[proseIndex], false);
1103
flushQuote();
1097
- if (quoteSeparator) continue;
1104
+ if (blockSeparator) {
1105
+ flushLists();
1106
+ continue;
1107
+ }
1108
if ("code" in entry) {
1109
flushLists();
1110
blocks.push(entry.code);
@@ -1239,9 +1249,18 @@ function horizontalRuleSource(block: ProseMirrorNode): string {
1249
return typeof source === "string" && source ? source : "---";
1250
}
1251
1242
-// A blank line keeps prose out of a quote (lazy continuation) and a dash rule from
1252
+// A blank line keeps prose out of a quote or list (lazy continuation) and a dash rule from
1253
// underlining the line above into a setext heading; an empty paragraph already separates them.
1244
-function needsBlankLineBetween(previous: ProseMirrorNode, block: ProseMirrorNode): boolean {
1254
+function needsBlankLineBetween(blocks: readonly ProseMirrorNode[], index: number): boolean {
1255
+ const previous = blocks[index - 1]!;
1256
+ const block = blocks[index]!;
1257
+ const isEmptyParagraph = (node: ProseMirrorNode | undefined) =>
1258
+ node?.type.name === "paragraph" && node.content.size === 0;
1259
+ if (LIST_NODE_NAMES.has(previous.type.name)) {
1260
+ let next = index;
1261
+ while (isEmptyParagraph(blocks[next])) next += 1;
1262
+ return blocks[next]?.type.name === "paragraph";
1263
+ }
1264
if (previous.type.name === "blockquote") {
1265
return block.type.name === "paragraph" && block.content.size > 0;
1266
}
@@ -1718,7 +1737,7 @@ function serializeDoc(doc: ProseMirrorNode): RichDocMap {
1737
let pmBlockStart = 0;
1738
blocks.forEach((block, blockIndex) => {
1739
if (blockIndex > 0 && !isTrailingLineAfterRule(doc, blockIndex)) pushBreakRun(acc);
1721
- if (blockIndex > 0 && needsBlankLineBetween(blocks[blockIndex - 1]!, block)) {
1740
+ if (blockIndex > 0 && needsBlankLineBetween(blocks, blockIndex)) {
1741
pushBlankLineRun(acc, pmBlockStart + 1);
1742
}
1743
if (LIST_NODE_NAMES.has(block.type.name)) {