test: reproduce #1637 — browser pane reloads on tab switch#1638
Closed
github-actions[bot] wants to merge 1 commit into
Closed
test: reproduce #1637 — browser pane reloads on tab switch#1638github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Add a failing test that proves usePersistentWebview reparents the <webview> element between an active container and a hidden off-screen container each time a tab is switched away and back. In Electron, reparenting a <webview> element triggers a full page reload, which loses all page state (scroll position, form inputs, etc.). Also export `sanitizeUrl` to enable direct unit testing; add 8 passing tests covering the URL-normalisation logic. Closes #1637
Collaborator
|
Closing: stale bot-generated test reproduction stub with no follow-up activity. |
Contributor
Author
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
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.
What the bug is
When a user navigates away from a tab containing a browser pane and then switches back, the in-app browser reloads its page from scratch, losing all state (scroll position, form inputs, etc.).
What code is affected and why
The root cause is in
usePersistentWebview.ts. The hook manages a module-levelwebviewRegistry(aMap<paneId, WebviewTag>) and an off-screenhiddenContainer. WhenBrowserPaneunmounts (tab switch away), itsuseEffectcleanup appends the<webview>element to the hidden container:When
BrowserPaneremounts (tab switch back), the effect "reclaims" the webview:In Electron, appending a
<webview>element to a different parent destroys and recreates its renderer process, which fully reloads the page. The code even acknowledges this implicitly — thehandleDomReadyhandler re-registers a newwebContentsIdafter "DOM reparenting" — but no attempt is made to prevent the reparenting in the first place.What the test does
usePersistentWebview.test.tscontains:8 passing
sanitizeUrltests — baseline coverage for the URL-normalization helper (also exported so it can be tested directly).1 failing bug-reproduction test — simulates the three-step DOM lifecycle that causes the reload:
active-containerhidden-container← reparent Bump react-dom from 18.3.1 to 19.2.0 #1active-container← reparent Bump lucide-react from 0.468.0 to 0.546.0 #2The test asserts
parentHistoryshould equal["active-container"](i.e., no reparenting ever). It fails becauseparentHistoryis["active-container", "hidden-container", "active-container"], proving the reparenting — and therefore the reload — occurs.The fix will need to keep the webview in a single parent and toggle CSS
display/visibilityinstead of moving it between containers.Closes #1637