Repository navigation
fix(alert): skip unchanged prefix nodes while streaming - #620
EnesKartal wants to merge 1 commit into
Conversation
|
Architecture Data flow Review ✨ Nothing flagged · reviewed Tip The CLI's 🪧 More tips
Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it. |
|
@EnesKartal is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
comark
@comark/angular
@comark/ansi
@comark/html
@comark/nuxt
@comark/react
@comark/svelte
@comark/vue
commit: |
Merging this PR will not alter performance1 warning
Comparing |
|
Thanks @EnesKartal, the fix is correct and the tests are great 🙏 One suggestion before we merge: instead of building a new tree with export function visit(document, checker, visitor, options?: { skip?: number })
export async function visitAsync(document, checker, visitor, options?: { skip?: number })
// in walkGenerator
let i = options?.skip ?? 0and then in the alert plugin: visit(state.tree, checker, visitor, { skip: state.reusableNodes?.length ?? 0 })Why:
Could you also add a case in Thanks! |
What
The built-in �lert plugin now skips state.reusableNodes during its post hook and only walks the newly parsed tail nodes (state.tree.nodes.slice(state.reusableNodes.length)).
Why
In { streaming: true } mode, state.tree.nodes prepends state.reusableNodes (completed prefix nodes from previous parses that have already run through post hooks) before running post plugins. Because �lert walked the entire state.tree via �isit, every streaming append rescanned all unchanged prefix nodes even when the document contained no alerts.
Added unit tests in est/plugins/alert-streaming.test.ts verifying that unchanged prefix nodes are not revisited during comark:post:alert on incremental appends while streamed alert blockquotes after a reused prefix still transform properly.
Fixes #513
Summary by CodeRabbit