Skip to content

fix(studio): block-split long backslash lines without inline lex (#11376) - #11501

Merged
wasimysaid merged 4 commits into
unslothai:mainfrom
Souravrajvi0:feat/studio-marked-block-split-0141
Oct 2, 2026
Merged

wasimysaid merged 4 commits into
unslothai:mainfrom
Souravrajvi0:feat/studio-marked-block-split-0141

Conversation

@Souravrajvi0

Copy link
Copy Markdown
Contributor

Summary

Fixes #11376. Studio chat block splitting no longer calls marked's full Lexer.lex (block + inline). Production paths now use a vendored blockTokens splitter aligned with vercel/streamdown#608, so a single long line of backslashes (paths, regex, escaped JSON) no longer costs seconds per render.

Changes

  • Add parse-markdown-blocks.ts (blockTokens + same merge rules as streamdown 2.5; incremental reuse deferred until we bump streamdown)
  • Wire streaming-render-schedule, streaming-markdown, and latex to the fast splitter
  • Pin [email protected] to match streamdown's nested marked
  • Regression tests: equivalence with streamdown 2.5 on a 200k backslash line + perf guard

Follow-up

Drop the vendored module once a published streamdown release includes #608.

…lothai#11376)

Vend streamdown's blockTokens splitter (vercel/streamdown#608) for Studio
chat block boundaries so marked's inline pass is not run during splits.
Pin [email protected] to match streamdown's renderer and add regression tests.
@Souravrajvi0
Souravrajvi0 force-pushed the feat/studio-marked-block-split-0141 branch from 069376f to 06a1a17 Compare September 23, 2026 03:15
@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and dropped the saved-history reconciliation commit (#11500). This branch is now only the block splitter, [email protected] pin, and parse-markdown-blocks-perf tests (7 files).

@danielhanchen danielhanchen self-assigned this Oct 1, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Review record for #11501, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#288.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 0b591a6ba (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] on studio/frontend/src/lib/parse-markdown-blocks.ts (on the mirror)

@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
+
+// streamdown 2.5 parseMarkdownIntoBlocks with blockTokens instead of Lexer.lex (vercel/streamdown#608):
+// inline lexing of one long backslash line costs seconds (#11376). Drop when streamdown is bumped past #608.
+
+import { Lexer, type Token } from "marked";
+
+const footnoteReferencePattern = /\[\^[\w-]{1,200}\](?!:)/;
+const footnoteDefinitionPattern = /\[\^[\w-]{1,200}\]:/;
+const openingTagPattern = /<([A-Za-z][\w:-]*)[\s>/]/;

P2 Badge Skip void tags before choosing the tracked HTML tag

Because this pattern now matches the slash in a self-closing tag, currentBlock.match(...) stops at a leading <br/> and the void-element check prevents the later container from being pushed. For example, <br/>\n<div>\n\ninside\n\n</div> is split into five blocks here, whereas Streamdown keeps the <div> and its contents together; rendering those blocks independently auto-closes the opening tag and places its contents outside the container. Scan past leading void/self-closing matches to find an unclosed container tag.

Useful? React with 👍 / 👎.

Accepted on the mirror

Reply from danielhanchen:

Fixed in 56e8f00: the opening tag pattern is now streamdown 2.5's /<(\w+)[\s>]/, and the parity test covers
before a

.

Round 2: reviewed mirror 345e7c2045 (this PR's 56e8f005b)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 345e7c2045

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 345e7c2045 (this PR's 56e8f005b).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@wasimysaid
wasimysaid merged commit c5f1f79 into unslothai:main Oct 2, 2026
18 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio: a long single line with backslashes costs seconds per render in Marked's inline tokenizer

3 participants