Skip to content

Keep nested lists and indentation in Chat messages - #666

Merged
lavaman131 merged 1 commit into
mainfrom
chat-nested-lists
Oct 17, 2026
Merged

lavaman131 merged 1 commit into
mainfrom
chat-nested-lists

Conversation

@lavaman131

Copy link
Copy Markdown
Collaborator

Chat showed a nested list as flat sibling bullets, even when the message text was correctly nested Markdown.

Cause

referenceRenderModel hides @chopin mentions before the Markdown is parsed, through projectedDisplayUnits in apps/web/src/chat/references.ts. That projection also collapsed every run of two or more spaces into one. The parser therefore saw this:

- parent
 - child        ← was "  - child" (or "    - child")

One space is not enough to nest, so the sub-items became siblings. The same collapse also removed indentation inside fenced code blocks and turned a two-space hard line break into a plain space.

Fix

The projection now drops only the extra space that a removed mention leaves behind. Ask @chopin about it still reads Ask about it, and every other space reaches the Markdown parser unchanged. The parser options, allowed elements and list CSS were already correct and are unchanged. Documents render through the editor rather than this path, so they are unaffected.

Tests

  • markdown.test.ts, "indentation keeps nested lists and code blocks intact": covers two-space and four-space nesting, a bullet list under an ordered item, code-block indentation, and the mention-gap space. It failed before the fix (four sibling <li>).
  • chat-composer.e2e.ts, "a sent message keeps its nested list nested": a person sends a three-level list from the composer, and the transcript must show it nested and indented. It failed before the fix, where the accessibility tree showed parent, child, grandchild and next as flat list items.
  • After the fix: bun test apps/web packages (2241 pass), bun run types, bun run ci, and the chat-composer, chat-mentions and chat-references e2e specs (20 passed).

Chat drew a nested list as flat sibling bullets. The message text was
correctly nested Markdown, but the display projection that hides @chopin
mentions also collapsed every run of two or more spaces to one before the
Markdown was parsed. That shrank a sub-item's two- or four-space indent to
one space, too little to nest. The same collapse removed the indentation
inside code blocks and the two trailing spaces of a hard line break.

The projection now drops only the space a removed mention leaves doubled,
so "Ask @chopin about it" still reads "Ask about it". Every other space
reaches the Markdown parser unchanged. Documents render through the editor,
not this path, so they are unaffected.

Assistant-model: Claude Opus 5.5 (fast)
Assistant-workflow: inline (fast subagents)
Assistant-verification: red-before-fix: markdown.test.ts "indentation keeps nested lists and code blocks intact" failed on the unfixed web app (two-space nested list rendered as four sibling <li>); chat-composer.e2e.ts "a sent message keeps its nested list nested" failed on the unfixed build (parent, child, grandchild and next as flat list items)
Assistant-verification: after fix: bun test apps/web packages passed (2241 pass, 0 fail); bun run types and bun run ci passed; chat-composer, chat-mentions and chat-references e2e passed (20)
Co-authored-by: Alex Lavaee <alexlavaee@microsoft.com>
@lavaman131 lavaman131 self-assigned this Oct 17, 2026
@lavaman131
lavaman131 merged commit 61fe221 into main Oct 17, 2026
24 checks passed
@lavaman131
lavaman131 deleted the chat-nested-lists branch October 17, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant