Repository navigation
Conversation
TextNodeRenderable.requestRender() did `this.parent?.requestRender()`, which becomes a no-op when a node is transiently detached (parent === null) while still being mutated — e.g. during a SolidJS <For>/<Index> re-key. The render request is lost and streaming text freezes mid-update. Retain a RenderContext reference threaded down on every attach (add, replace, insertBefore, including StyledText fan-out), seeded in RootTextNodeRenderable, and fall back to it in requestRender() when parent is null. A node that was never attached still reaches no context.
JSap0914
requested review from
Hona,
kommander,
msmps and
simonklee
as code owners
June 14, 2026 04:07
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR ensures render requests aren’t lost when a TextNodeRenderable becomes temporarily detached by retaining and propagating a RenderContext reference throughout the text-node subtree.
Changes:
- Retain a
RenderContextonTextNodeRenderable, propagate it to descendants, and fall back to it whenparent === null. - Update node insertion paths (
add,insertAt,set) to propagate the current context to newly attached children. - Add tests validating render request propagation for detached nodes and nested descendants.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/src/renderables/TextNode.ts | Retains/propagates RenderContext and uses it as a fallback for detached nodes’ requestRender() calls. |
| packages/core/src/renderables/TextNode.test.ts | Adds coverage for render request propagation behavior on detach, including nested descendants and orphans. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) { | ||
| super(options) | ||
| this.textParent = textParent | ||
| this._ctx = ctx |
Comment on lines
63
to
87
| public requestRender(): void { | ||
| this.markDirty() | ||
| this.parent?.requestRender() | ||
| if (this.parent) { | ||
| this.parent.requestRender() | ||
| } else { | ||
| // Detached (parent === null) but possibly still being mutated: fall back to | ||
| // the retained RenderContext so the render request is not silently dropped. | ||
| this._ctx?.requestRender() | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Propagate the active RenderContext down this text-node subtree. The reference is | ||
| * retained even after the node is later detached (parent === null) so a still-updating | ||
| * detached node can keep reaching the renderer via requestRender(). | ||
| */ | ||
| protected setRenderContext(ctx: RenderContext | undefined): void { | ||
| if (this._ctx === ctx) return | ||
| this._ctx = ctx | ||
| for (const child of this._children) { | ||
| if (typeof child !== "string") { | ||
| child.setRenderContext(ctx) | ||
| } | ||
| } | ||
| } |
Comment on lines
+1098
to
+1100
| function makeRoot(ctx: RenderContext) { | ||
| return new RootTextNodeRenderable(ctx, { id: "root" }, undefined as unknown as TextRenderable) | ||
| } |
Contributor
|
@JSap0914 please address the review commets |
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 #1147
TextNodeRenderable.requestRender()didthis.parent?.requestRender(), which becomes a silent no-op exactly when a node is transiently detached (parent === null) while still being mutated — the normal state during a SolidJS<For>/<Index>re-key. The render request is lost, so streaming text can freeze mid-update until the tree rebuilds.Each node now retains the active
RenderContext(threaded down on every attach —add,replace,insertBefore, including theStyledTextfan-out, and seeded inRootTextNodeRenderable). Whenparentisnull,requestRender()falls back to that retained context, so a detached-but-still-updating node self-heals. A node that was never attached still reaches no context, and the attached happy path is unchanged.How I verified
render request propagationblock toTextNode.test.ts(3 cases): a detached node forwards to its retained context; a nested descendant self-heals when the whole subtree is detached; a never-attached orphan never reaches a context.bun test src/renderables/TextNode.test.ts→ 55 pass; broaderTextNode + Markdownsuites → 210 pass / 0 fail.TextNode.tsmakes the two behavioral tests fail (render request count plateaus at 2), confirming they guard the fix.oxlint --deny-warningsandoxfmt --checkclean on the changed files.