Repository navigation
Studio: bound the code highlighter cache for tool cells, previews and READMEs - #10609
Merged
danielhanchen merged 4 commits intoOct 5, 2026
Merged
Conversation
tool-code-cell imported the default @streamdown/code plugin, whose token cache has no cap. Use the bounded createCodePlugin with the chat throttle off so a growing tool fence is not kept as every prefix.
ToolCodeCell skips shiki while streaming, so throttle: false never ran. Keep the bounded createCodePlugin import swap only.
This comment has been minimized.
This comment has been minimized.
# Conflicts: # studio/frontend/src/components/assistant-ui/tool-code-cell.tsx
…ugin Markdown previews and model READMEs also used the @streamdown/code export, whose token cache never evicts; editable previews mint an entry per edit. Share one createCodePlugin instance across the three surfaces so they keep a single set of Shiki highlighters, and replace the tool-cell AST test with a tree-wide guard against runtime imports of @streamdown/code.
Member
|
Review record for #10609, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#411. 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
|
danielhanchen
pushed a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9230.
@streamdown/code1.1.1 memoises every tokenisation in a module-levelMapthat is never evicted. Chat already uses the boundedcreateCodePluginfromcode-plugin.ts, but three surfaces still imported the package export:tool-code-cell.tsx: one entry per finished tool cell (the cell renders plain while streaming, so it is not per refresh window).markdown-preview.tsx: one entry per distinct document. Editable previews (recipe note nodes, prompt storage) mint one per edit.model-readme.tsx: one entry per README.All three now import a single shared
createCodePlugin()instance fromshared-code-plugin.ts, so they keep one set of Shiki highlighters as before and the cache is capped at 512 fences / 512K characters. Same engine and default themes as the package export.tests/streamdown-code-bounded.test.tsfails on any runtime import of@streamdown/codeundersrc/(type imports are allowed) and checks the three surfaces use the shared plugin.Measurements (Node 24, forced GC, real plugin code)
@streamdown/codeexportToken parity (content, colours, both themes) against the package export: identical on Python, JS, TS, bash, JSON, YAML, Rust, plain text and an unknown language, with a theme-swap negative control detected. The one difference is a
c++fence, where the bounded plugin resolves the alias and coloursreturnas a keyword, matching chat.npm run typecheckpasses andnpm testpasses (10101/10101).Before / after
Markdown attachment preview of the same
.mdfile on the merge base (left) and this PR (right). The Python block is identical. In thec++block, the bounded plugin resolves the alias, soreturnand0are now coloured (returnlight-theme colour#24292E->#D73A49); this is the only token whose style changed.