-
Notifications
You must be signed in to change notification settings - Fork 0
fix: tab slowness #940
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
fix: tab slowness #940
Conversation
|
Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information. |
commit: |
|
i added this to my pr to maybe help with slowness if you want to try it out: |
d21397b to
2bc7168
Compare
WalkthroughThis PR exposes a Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/visual-editor/src/vite-plugin/defaultLayoutData.ts (1)
318-321: Standardizing default Unsplash image URLs withw=1000is consistent and safeAll the updated
urlfields now use the same IDs plus aw=1000width cap, which should reduce payload size and keep defaults in sync with the placeholder utility. Since only static data changed and dimensions/slots are untouched, this is a low-risk, desirable tweak. Long term, you might consider centralizing these shared URLs/IDs to avoid copy‑paste drift.Also applies to: 398-401, 685-688, 804-807, 933-936, 1062-1065, 1784-1787, 1949-1952, 2112-2115, 2334-2337, 2492-2495, 2650-2653, 2829-2832, 2837-2840, 2845-2848, 2937-2940, 3077-3080, 3217-3220
packages/visual-editor/src/utils/VisualEditorProvider.tsx (1)
35-38: Good change to stabilizeQueryClientinstance; optional tweak to align with React Query docsMemoizing the
QueryClientlike this avoids re-creating it on every render, which should help with both cache stability and perf. This looks correct.If you want to align more closely with common React Query patterns (and avoid any confusion around
useMemosemantics), you could optionally switch to a lazyuseStateinitializer, which guarantees the factory only runs once per mount:- // Use useMemo to prevent creating a new QueryClient on every render - // QueryClient maintains internal caches, so creating new instances unnecessarily - // could lead to memory accumulation - const queryClient = React.useMemo(() => new QueryClient(), []); + // Create a single QueryClient instance per provider mount. + // QueryClient maintains internal caches, so we avoid re-instantiating it on re-renders. + const [queryClient] = React.useState(() => new QueryClient());packages/visual-editor/src/internal/components/LayoutEditor.tsx (1)
84-91: ResettinglayoutSaveStatebefore delete/publish matches the data-flow goal; consider memoizinghandlePublishClearing the local
layoutSaveStatebefore:
deleteLayoutSaveState()inclearHistory, andpublishLayout(data)inhandlePublishkeeps the in-memory view aligned with the intended “no pending save state” semantics and should help avoid re-sending stale history to Puck after those actions. Behaviorally this matches the PR’s objective.
For a small perf polish (since this is a hot-ish path for slowness work), you could memoize
handlePublishsoInternalLayoutEditordoesn’t see a new function on every render:- const handlePublish = (data?: any) => { - setLayoutSaveState(undefined); - publishLayout(data); - }; + const handlePublish = useCallback( + (data?: any) => { + setLayoutSaveState(undefined); + publishLayout(data); + }, + [setLayoutSaveState, publishLayout] + );This is non-blocking but may help reduce unnecessary child re-renders.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/visual-editor/src/internal/components/LayoutEditor.tsx(3 hunks)packages/visual-editor/src/internal/hooks/layout/useMessageReceivers.ts(1 hunks)packages/visual-editor/src/utils/VisualEditorProvider.tsx(1 hunks)packages/visual-editor/src/utils/imagePlaceholders.ts(1 hunks)packages/visual-editor/src/vite-plugin/defaultLayoutData.ts(16 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/visual-editor/src/internal/components/LayoutEditor.tsx (1)
packages/visual-editor/src/internal/hooks/layout/useMessageReceivers.ts (1)
useLayoutMessageReceivers(22-108)
🔇 Additional comments (4)
packages/visual-editor/src/utils/imagePlaceholders.ts (1)
5-7: Placeholder image IDs updated to fixed width look goodAppending
w=1000to the base IDs keeps behavior identical while constraining intrinsic size; matches the PR goal of lighter placeholder assets. No issues from this change in the existing URL-construction logic.packages/visual-editor/src/internal/hooks/layout/useMessageReceivers.ts (1)
103-107: ExposingsetLayoutSaveStatefrom the hook is appropriateReturning
setLayoutSaveStatealongsidelayoutSaveState/layoutSaveStateFetchedcleanly enables external flows (publish, clear history) to reset the save state without changing existing behavior.packages/visual-editor/src/internal/components/LayoutEditor.tsx (2)
62-63: ExtendinguseLayoutMessageReceiversusage to include the setter looks correctWiring
setLayoutSaveStatethrough fromuseLayoutMessageReceivers(localDev, puckConfig, streamDocument)is consistent with the hook’s return shape and enables the new flows below without changing existing consumers.
290-290: Prop wiring toInternalLayoutEditorupdated correctly to usehandlePublishSwitching the
publishLayoutprop to passhandlePublishensures the new “reset save state then publish” behavior is applied whereverInternalLayoutEditortriggers a publish, without changing its public API. This looks consistent with the rest of the component.
mkilpatrick
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.
LG. If we get other images for header/footer that can be a separate PR if you want to close this one out.
|
Confirmed with Ming that this is what we want for the Team Section. Header/Footer logo still pending, will open new PR if that is resolved. |
#935 added a deepEqual check for re-resolving all data which seemed to have helped a bit.
This PR adds additional save state management, which helps particularly when clearing local changes.
Reducing the placeholder image size seems to make the re-rendering a little faster.
There still is a delay when publishing and then switching tabs. I'm not entirely sure what is triggering it but the slowness seems to be on Puck's side. Puck has some slot performance improvements coming up, so I think we should take a look again after those are done.