-
Notifications
You must be signed in to change notification settings - Fork 4k
Introduce TransientNode #12822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce TransientNode #12822
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
5cb8af0 to
f5842b6
Compare
8cafff6 to
ec390ec
Compare
9725ff2 to
9b06d11
Compare
ec390ec to
9f51720
Compare
📉 Python coverage change detectedThe Python unit test coverage has decreased by 0.0000%
✅ Coverage change is within normal range. Coverage by files
|
📉 Frontend coverage change detectedThe frontend unit test (vitest) coverage has decreased by 0.0100%
✅ Coverage change is within normal range. |
9f51720 to
24a81bd
Compare
9b06d11 to
17554c5
Compare
3fc0e6d to
db19c5d
Compare
a093ee0 to
8056447
Compare
db19c5d to
74be12a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new TransientNode class to the render tree architecture, implementing the visitor pattern for this new node type across the codebase.
- Adds
TransientNodeas a new type ofAppNodethat can hold transient element nodes with an optional anchor node - Updates the visitor pattern interface and all existing visitor implementations to support
TransientNode - Includes comprehensive unit tests for the new
TransientNodeclass and its debug visitor implementation
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/lib/src/render-tree/TransientNode.ts | New class implementing AppNode interface for transient nodes with anchor and transient element storage |
| frontend/lib/src/render-tree/TransientNode.test.ts | Comprehensive unit tests for TransientNode constructor, visitor pattern, and debug output |
| frontend/lib/src/render-tree/visitors/AppNodeVisitor.interface.ts | Adds visitTransientNode method to visitor interface |
| frontend/lib/src/render-tree/visitors/DebugVisitor.ts | Implements visitTransientNode with tree-like debug output formatting and updates imports |
| frontend/lib/src/render-tree/visitors/DebugVisitor.test.ts | Adds test coverage for TransientNode debug visitor functionality and updates imports |
| frontend/lib/src/render-tree/visitors/*.ts | Stub implementations throwing "Method not implemented" errors for five visitor classes |
| frontend/lib/src/render-tree/visitors/RenderNodeVisitor.tsx | Returns null for transient nodes with explanatory comment |
| frontend/lib/src/render-tree/BlockNode.test.ts | Updates mock visitors to include visitTransientNode stub |
| frontend/lib/src/render-tree/ElementNode.test.ts | Updates mock visitors to include visitTransientNode stub |
| frontend/lib/src/AppNode.ts | Exports TransientNode and NO_SCRIPT_RUN_ID |
| frontend/lib/src/index.ts | Adds TransientNode to public exports |
74be12a to
fbcb3ff
Compare
8056447 to
89832ac
Compare
fbcb3ff to
a1b1835
Compare
89832ac to
7b3b980
Compare
a1b1835 to
ece38f4
Compare
7b3b980 to
3aeebea
Compare
ece38f4 to
e89016a
Compare
3aeebea to
ba77f88
Compare
frontend/lib/src/render-tree/visitors/FilterMainScriptElementsVisitor.ts
Show resolved
Hide resolved
070a633 to
5ea7844
Compare
ba77f88 to
50071ab
Compare
50071ab to
990657a
Compare
990657a to
e49ccdb
Compare
| if (node.anchor) { | ||
| result += `${childPrefix}├── anchor:\n` | ||
| const anchorVisitor = new DebugVisitor(childPrefix + "│ ", true) | ||
| result += node.anchor.accept(anchorVisitor) | ||
| } | ||
|
|
||
| if (node.transientNodes.length > 0) { | ||
| result += `${childPrefix}└── transient nodes:\n` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tree connector logic is incorrect. The anchor section always uses ├── (line 96), but if there are no transient nodes, the anchor should be the last child and use └── instead.
Impact: When a TransientNode has an anchor but no transient nodes, the debug output will show incorrect tree structure with dangling connectors.
Fix: The connector should be conditional:
if (node.anchor) {
const hasTransientNodes = node.transientNodes.length > 0
const anchorConnector = hasTransientNodes ? "├──" : "└──"
result += `${childPrefix}${anchorConnector} anchor:\n`
const anchorChildPrefix = childPrefix + (hasTransientNodes ? "│ " : " ")
const anchorVisitor = new DebugVisitor(anchorChildPrefix, true)
result += node.anchor.accept(anchorVisitor)
}| if (node.anchor) { | |
| result += `${childPrefix}├── anchor:\n` | |
| const anchorVisitor = new DebugVisitor(childPrefix + "│ ", true) | |
| result += node.anchor.accept(anchorVisitor) | |
| } | |
| if (node.transientNodes.length > 0) { | |
| result += `${childPrefix}└── transient nodes:\n` | |
| if (node.anchor) { | |
| const hasTransientNodes = node.transientNodes.length > 0 | |
| const anchorConnector = hasTransientNodes ? "├──" : "└──" | |
| result += `${childPrefix}${anchorConnector} anchor:\n` | |
| const anchorChildPrefix = childPrefix + (hasTransientNodes ? "│ " : " ") | |
| const anchorVisitor = new DebugVisitor(anchorChildPrefix, true) | |
| result += node.anchor.accept(anchorVisitor) | |
| } | |
| if (node.transientNodes.length > 0) { | |
| result += `${childPrefix}└── transient nodes:\n` |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
lukasmasuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍

Describe your changes
Now we will add some transiency. Transient is special, so we will implement a TransientNode. This change includes adding a method to every visitor and adding an implementation for the DebugVisitor.
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.