Fix Profile back-button loop after copiloting into an agent#94239
Draft
abzokhattab wants to merge 1 commit into
Draft
Fix Profile back-button loop after copiloting into an agent#94239abzokhattab wants to merge 1 commit into
abzokhattab wants to merge 1 commit into
Conversation
Redirect agents off guarded routes on every focus (fixes blank pane when navigating back onto a screen the split navigator keeps mounted) and use forceReplace so the stale guarded central-pane route is consumed instead of pushing Profile on top of it, which trapped users in a Profile <-> Profile loop on back navigation.
51 tasks
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.
Explanation of Change
This re-lands the every-focus agent redirect from #93683 (reverted as a deploy blocker) and fixes the regression it introduced (#94088).
Two competing bugs must be solved at once:
SettingsSplitNavigatorkeeps the owner's central-pane screen (e.g.SCREENS.SETTINGS.AGENTS.ROOT) mounted after copilot. A one-shotuseEffectkeyed onshouldRedirectnever re-fires when the agent navigates back onto that already-guarded screen, so the guard rendersnull→ blank pane. This requires redirecting on every focus.useFocusEffect, butNavigation.navigatedefaults to PUSH, stacking Profile on top of the stale guarded route:[Account] [Agents (guarded)] [Profile]. Back from Profile pops to the still-guarded Agents screen → focus re-fires → pushes Profile again → infinite loop, never reaching Account.Fix: Keep the every-focus
useFocusEffectredirect, but passforceReplace: trueso the redirect REPLACEs the stale guarded central-pane route instead of pushing on top of it:Back from Profile now pops to the unguarded
SCREENS.SETTINGS.ROOT(Account sidebar).forceReplacesetsaction.type = REPLACEinlinkTo, andgetMinimalActionpreserves that type while drilling into theSettingsSplitNavigator, so the REPLACE lands on the central-pane entry while the persistentSETTINGS.ROOTsidebar stays in place.Fixed Issues
$ #94088
Tests
Unit test
tests/unit/withAgentAccessDenied.test.tsxupdated and passing (asserts the{forceReplace: true}redirect, plus theuseFocusEffectmock).Offline tests
N/A — account switching is blocked while offline.
QA Steps
PR Author Checklist
### Fixed Issuessection above