-
Notifications
You must be signed in to change notification settings - Fork 4k
Add ability to clear transient nodes when the script is run #13166
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
Add ability to clear transient nodes when the script is run #13166
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!
|
166ebfd to
9966041
Compare
49e6614 to
381caa5
Compare
9966041 to
7a0fd9d
Compare
871237f to
4ee9200
Compare
7a0fd9d to
3da75d7
Compare
4ee9200 to
48bbf15
Compare
3da75d7 to
58d3103
Compare
48bbf15 to
5d534f8
Compare
58d3103 to
bc67db4
Compare
5d534f8 to
112771e
Compare
44ddeb0 to
35899df
Compare
45e1c2d to
3ec60af
Compare
35899df to
88c3674
Compare
3ec60af to
9484285
Compare
88c3674 to
f8815fa
Compare
9484285 to
df0d3ed
Compare
📉 Python coverage change detectedThe Python unit test coverage has decreased by 0.0047%
✅ Coverage change is within normal range. Coverage by files
|
df0d3ed to
e6b4f56
Compare
f8815fa to
997f776
Compare
e6b4f56 to
75bb6e7
Compare
997f776 to
6650f56
Compare
|
Something seems broken with this PR, it seems to contain all the changes from the already merged #12826. Maybe try to bring it up-to-date with develop? |
6650f56 to
87ca7e4
Compare
87ca7e4 to
ca76a32
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 implements a mechanism to clear transient nodes from the render tree when a script is rerun, preventing transient elements from persisting inappropriately between script executions.
Key Changes:
- Introduces a new visitor pattern implementation (
ClearTransientNodesVisitor) that traverses the render tree and replaces transient nodes with their anchors - Adds fragment ID filtering to ensure only relevant fragments are processed during partial reruns
- Integrates the clearing logic into the App component to execute before script runs
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/lib/src/render-tree/visitors/ClearTransientNodeVisitor.ts |
New visitor class that implements the logic to replace transient nodes with their anchor nodes, respecting fragment ID filtering |
frontend/lib/src/render-tree/visitors/ClearTransientNodeVisitor.test.ts |
Comprehensive test suite covering visitor behavior for element nodes, transient nodes, block nodes, and fragment ID filtering |
frontend/lib/src/render-tree/AppRoot.ts |
Adds clearTransientNodes method that delegates to the new visitor to clear transient nodes from the render tree |
frontend/lib/src/render-tree/AppRoot.test.ts |
Tests for the new clearTransientNodes method, verifying it correctly clears transient nodes and respects fragment IDs |
frontend/app/src/App.tsx |
Integrates transient node clearing into the script run flow by calling clearTransientNodes before updating the script run ID |
frontend/lib/src/render-tree/visitors/ClearStaleNodeVisitor.ts |
Updates import path for AppNodeVisitor to use a relative import, improving consistency with other visitor files |
frontend/lib/src/render-tree/visitors/ClearTransientNodeVisitor.ts
Outdated
Show resolved
Hide resolved
frontend/lib/src/render-tree/visitors/ClearTransientNodeVisitor.test.ts
Outdated
Show resolved
Hide resolved
frontend/lib/src/render-tree/visitors/ClearTransientNodeVisitor.ts
Outdated
Show resolved
Hide resolved
ca76a32 to
aa1e7f8
Compare
SummaryThis PR adds the ability to clear transient nodes from the render tree when a script is re-run. The implementation:
The purpose is to ensure transient elements (like status messages, spinners) don't persist inappropriately between script runs. Code QualityOverall AssessmentThe code follows the existing visitor pattern well and is consistent with Issues Found1. Naming Inconsistency (Minor)
This is inconsistent with 2. App.tsx setState Pattern (Minor Observation) this.setState(prevState => ({
elements: prevState.elements.clearTransientNodes(fragmentIdsThisRun),
scriptRunId,
}))This is correct and follows React best practices. Test CoverageStrengths
Potential Gaps
it("returns undefined when transient node has no anchor", () => {
const transientWithNoAnchor = new TransientNode(
"script_run_id",
undefined, // no anchor
[text("Transient")],
Date.now()
)
const visitor = new ClearTransientNodesVisitor([])
expect(visitor.visitTransientNode(transientWithNoAnchor)).toBeUndefined()
})
Backwards CompatibilityAssessment: No Breaking Changes
Security & RiskLow Risk
Potential Risk: Fragment ID Handling The fragment ID filtering logic mirrors
This appears to be the intended behavior based on the test cases. Recommendations
VerdictAPPROVED: The implementation is solid, follows established patterns, and includes comprehensive test coverage. The naming inconsistency and missing explicit test case for undefined anchors are minor issues that don't block merging. The changes are backwards compatible and pose no security risks. This is an automated AI review. Please verify the feedback and use your judgment. |
aa1e7f8 to
3f26b82
Compare
|
@cursor review |
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.
✅ Bugbot reviewed your changes and found no bugs!
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
Added a mechanism to clear transient nodes from the render tree when rerunning a script. This ensures that transient elements don't persist inappropriately between runs.
The implementation:
clearTransientNodesmethod toAppRootthat replaces transient nodes with their anchorsClearTransientNodesVisitorclass that handles the traversal and replacement logicTesting Plan
AppRoot.clearTransientNodesto verify it correctly delegates to the visitorClearTransientNodesVisitorto verify it correctly handles different node typesContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.