Repository navigation
fix(webui): memoize MainContext value in Main - #2348
Merged
Merged
Conversation
Main rebuilt the MainContext value and its handleError and updateUser callbacks on every render. Every context consumer re-rendered each time, and effects that depend on those callbacks re-ran. Wrap handleError and updateUser in useCallback and the context value in useMemo, so their identity only changes when the underlying state or props do. Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
trivikr
force-pushed
the
webui-memoize-handleError
branch
from
October 19, 2026 04:40
e567791 to
7976adf
Compare
gnugomez
approved these changes
Oct 20, 2026
gnugomez
left a comment
Member
There was a problem hiding this comment.
At some point we need to consider moving this main context to something like zustand to better manage re-renders, for now this is a good improvement :)
This context has gotten too big, and any update to the context will trigger a re-render, is not that critical since it's not a context that updates very often tho.
netomi
added a commit
that referenced
this pull request
Oct 21, 2026
Render the real Main with a page whose query keeps failing through useReportedQuery, and check the dialog is reported once, closes, and stays closed. The existing tests stub a stable handleError, so they could not catch the report loop fixed in #2348; this test fails against the pre-#2348 Main. Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Co-authored-by: Thomas Neidhart <thomas.neidhart@gmail.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Mainrebuilt theMainContextvalue and itshandleErrorandupdateUsercallbacks on every render. This re-rendered all context consumers and re-ran effects that depend on those callbacks.Wrap
handleErrorandupdateUserinuseCallbackand the context value inuseMemo.