Type: refactor · Area: src/streaming-frozen-tail.ts, src/renderer.ts, src/render-blocks.ts, src/streaming*.ts · Follow-up to #21 / #23
Cleanup findings from the #23 review, none blocking but each a real drift/maintenance risk:
-
Shared top-level render options (correctness-adjacent). RENDER_OPTS in streaming-frozen-tail.ts copies the { htmlFromIndent: true, indentedCode: true } literal that renderMarkdown hardcodes; the frozen/tail byte-parity depends on the two staying identical. Export one constant from renderer.ts and use it in both. (Small, safe — worth doing first.)
-
Shared group segmentation (fragility). settledTailStart re-encodes render-blocks' top-level grouping (isMultiTokenGroupKind hardcodes list/blockquote/indented-code; the settled whitelist hardcodes the rest). A future BlockKind that groups across blanks would freeze mid-group with no compile error and no fallback trip. Factor a groupEnd(source, tokens, i) / segmentation helper out of collectListGroup/collectBlockquoteGroup's existing next computation and have settledTailStart walk real group boundaries.
-
splitForStreaming public return shape. It now always carries blocks (the full tokenizeBlocks(content) array) on the exported result — a structural widening that broke in-repo deepEqual sites (patched with splitCore). Decide: keep tokens internal (return the wide type only to internal callers), or document the shape change on the public surface.
-
Duplicated completeTokens memo. The lazy complete-tokenizer pattern is copy-pasted between renderStreamingMarkdown and StreamingMarkdownRenderer.update (the latter now uses an instance cache; the string path still has its own). Extract a shared helper.
-
Minor: splitCore test helper duplicated across two test files; morphInnerHtml could delegate to morphInnerHtmlFrom(…, 0, …); bench table-printing boilerplate duplicated between sections.
Items 1 and 2 are the ones that guard correctness/parity; 3–5 are hygiene.
Type: refactor · Area:
src/streaming-frozen-tail.ts,src/renderer.ts,src/render-blocks.ts,src/streaming*.ts· Follow-up to #21 / #23Cleanup findings from the #23 review, none blocking but each a real drift/maintenance risk:
Shared top-level render options (correctness-adjacent).
RENDER_OPTSinstreaming-frozen-tail.tscopies the{ htmlFromIndent: true, indentedCode: true }literal thatrenderMarkdownhardcodes; the frozen/tail byte-parity depends on the two staying identical. Export one constant fromrenderer.tsand use it in both. (Small, safe — worth doing first.)Shared group segmentation (fragility).
settledTailStartre-encodes render-blocks' top-level grouping (isMultiTokenGroupKindhardcodes list/blockquote/indented-code; the settled whitelist hardcodes the rest). A futureBlockKindthat groups across blanks would freeze mid-group with no compile error and no fallback trip. Factor agroupEnd(source, tokens, i)/ segmentation helper out ofcollectListGroup/collectBlockquoteGroup's existingnextcomputation and havesettledTailStartwalk real group boundaries.splitForStreamingpublic return shape. It now always carriesblocks(the fulltokenizeBlocks(content)array) on the exported result — a structural widening that broke in-repodeepEqualsites (patched withsplitCore). Decide: keep tokens internal (return the wide type only to internal callers), or document the shape change on the public surface.Duplicated
completeTokensmemo. The lazy complete-tokenizer pattern is copy-pasted betweenrenderStreamingMarkdownandStreamingMarkdownRenderer.update(the latter now uses an instance cache; the string path still has its own). Extract a shared helper.Minor:
splitCoretest helper duplicated across two test files;morphInnerHtmlcould delegate tomorphInnerHtmlFrom(…, 0, …); bench table-printing boilerplate duplicated between sections.Items 1 and 2 are the ones that guard correctness/parity; 3–5 are hygiene.