Avoid duplicate renders; set project-id on load#468
Conversation
Track the current manifest ID in ProjectDetails and skip render() when the manifest hasn't changed to prevent duplicate/expensive re-renders (components/project-details/index.js). Also add a render() helper and set the tpen-project-id attribute on tpen-project-details when the tpen-project-loaded event fires so the component receives the project ID and performs a controlled render (interfaces/project/index.html).
There was a problem hiding this comment.
Pull request overview
This PR optimizes the ProjectDetails component to prevent duplicate renders by tracking the current manifest ID. When the tpen-project-loaded event fires, a new render() helper function sets the tpen-project-id attribute on the component, which triggers a controlled render through the attributeChangedCallback.
Changes:
- Added duplicate render prevention in ProjectDetails by tracking
_currentManifestIdand skipping render when manifest hasn't changed - Added render() helper function in project/index.html to set tpen-project-id attribute on tpen-project-loaded event
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| components/project-details/index.js | Added _currentManifestId property and early return logic in render() to skip duplicate renders when manifest hasn't changed |
| interfaces/project/index.html | Added render() helper function and call in tpen-project-loaded event handler to set tpen-project-id attribute |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Static Review CommentsBranch: SummaryThis PR addresses issue #433 where the The root cause is a double-render: The approach is sound and minimal. There are a couple of correctness concerns around the comparison semantics.
Major Issues 🟠Issue 1: Reference-equality guard on array
|
thehabes
left a comment
There was a problem hiding this comment.
Change render guard to use a JSON string key of project.manifest to detect content changes and prevent duplicate renders. Rename _currentManifestId to _currentManifestKey and update the comparison to use JSON.stringify(project?.manifest ?? []) in components/project-details/index.js. In interfaces/project/index.html, rename render() to setProjectId() and call it on tpen-project-loaded to clarify intent. Includes minor whitespace cleanup.
Clear _currentManifestKey during component cleanup to avoid retaining stale manifest state. Also rename the top-level render() function in manage-project to applyProjectContext() and update its invocation to better reflect that it applies project context with permission checks.
This reverts commit 39591e1.
cubap
left a comment
There was a problem hiding this comment.
Worthwhile changes, but ultimately failed to satisfy the issue.
|
This does not fix #433, as there is a problem with digirati components we are using at the moment. |


Track the current manifest ID in ProjectDetails and skip render() when the manifest hasn't changed to prevent duplicate/expensive re-renders (components/project-details/index.js). Also add a render() helper and set the tpen-project-id attribute on tpen-project-details when the tpen-project-loaded event fires so the component receives the project ID and performs a controlled render (interfaces/project/index.html).