Skip to content

Structural cleanup from #23 review (shared render opts, group segmentation, split return type) #32

Description

@jonathanKingston

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:

  1. 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.)

  2. 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.

  3. 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.

  4. 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.

  5. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions