[Settings] Speed up page navigation; fix Advanced Paste double-load#47909
Draft
niels9001 wants to merge 1 commit into
Draft
[Settings] Speed up page navigation; fix Advanced Paste double-load#47909niels9001 wants to merge 1 commit into
niels9001 wants to merge 1 commit into
Conversation
- Enable NavigationCacheMode.Enabled in NavigablePage so pages inheriting it are kept warm by the Frame; re-navigation no longer rebuilds the XAML tree, ViewModel, file watchers and IPC handlers each time. - Drop EntranceThemeTransition from SettingsCardsAnimations. It replayed on every nav and produced a visible cards-in animation on top of an already slow construction. RepositionThemeTransition is preserved so SettingsExpander expand/collapse stays smooth. - AdvancedPastePage: stop calling UpdatePasteAIUIVisibility() and UpdateFoundryLocalUIAsync() in the Loaded handler. They only affect controls inside the (hidden) provider configuration dialog, and the Add/Edit handlers already call them right before ShowAsync. Removing the duplicate work eliminates the visible second reflow (the 'double load') and avoids an unnecessary Foundry Local process probe on every nav. - Guard RefreshEnabledState so dialog-only updates only run while the provider configuration dialog is actually open, preventing duplicate work on IPC general-settings broadcasts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Summary
Settings pages — Advanced Paste in particular — felt slow on navigation and visibly "loaded twice". This PR addresses three coupled root causes.
What was happening
<Frame x:Name="shellFrame" />had no caching and no page setNavigationCacheMode, so every nav click rebuilt a freshPageinstance, ViewModel, file watcher, and IPC subscriptions, and re-ranInitializeComponenton a 577-line / 41 KB XAML tree.SettingsCardsAnimationsbundled anEntranceThemeTransition(FromVerticalOffset=50) that fired every time a page came up.Loaded.UpdatePasteAIUIVisibility()andUpdateFoundryLocalUIAsync()ran on every nav even though both only touch controls inside the hidden provider-configuration dialog. The Add/Edit handlers already call them right beforeShowAsync(). TheLoadedwork produced a visible second reflow (the "double load") and, when the saved provider was Foundry Local, kicked off a process probe on every nav.Changes
NavigablePage.cs— SetNavigationCacheMode = NavigationCacheMode.Enabledin the base ctor. All pages inheritingNavigablePage(most settings pages) are now cached. Frame's defaultCacheSize=10is enough to hold every top-level module.OnNavigatedToandLoadedstill fire on each visit, so existing per-nav logic (element-targeting animation, hotkey conflict refresh) keeps working.App.xaml— RemovedEntranceThemeTransitionfromSettingsCardsAnimations. KeptRepositionThemeTransitionsoSettingsExpanderstill animates expand/collapse smoothly.AdvancedPastePage.xaml.cs—UpdatePasteAIUIVisibility()+await UpdateFoundryLocalUIAsync()calls from theLoadedhandler._isPasteAIProviderDialogOpentracking, set when the dialog opens and cleared in itsClosedhandler.RefreshEnabledState()now only runs the dialog-state updates while the dialog is actually open, so an IPC general-settings broadcast can no longer trigger a duplicate Foundry probe in the background.Result
Out of scope (potential follow-ups)
InitializePasteAIProviderState,MigrateLegacyAIEnablement,PropertyChangedwiring) off the UI thread.Validation