fix: solve #1935 — browser panes no longer refresh on tab switch#1936
Open
github-actions[bot] wants to merge 1 commit intomainfrom
Open
fix: solve #1935 — browser panes no longer refresh on tab switch#1936github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Keep all workspace tab views mounted simultaneously and use CSS (display:none) to show/hide inactive tabs. Previously, TabsContent only rendered the active tab; switching tabs unmounted the inactive TabView, which unmounted BrowserPane and caused usePersistentWebview to move the <webview> element to an off-screen container. In Electron, reparenting a <webview> between DOM nodes destroys and recreates its renderer process, triggering a full page reload and losing all in-page state. With all TabViews kept mounted, BrowserPane never unmounts on a tab switch, the <webview> stays in its original container, and no reload occurs. Adds getWorkspaceTabsToRender helper and a regression test.
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.
Root cause
TabsContentpreviously rendered only the active tab's<TabView>. Switching tabs unmounted the inactiveTabView→BrowserPaneunmounted →usePersistentWebviewcleanup moved the<webview>element to an off-screen container (document.bodychild atleft: -9999px).In Electron, moving a
<webview>element between DOM parents destroys and recreates its underlying renderer process — causing a full page reload and losing all in-page state (logged-in sessions, unsaved form data, dev-tool state, etc.).The fix
TabsContentnow renders all workspace tabs simultaneously. CSS (display: none) controls which tab is visible; the active tab wrapper getsdisplay: flex, all others getdisplay: none.Because
BrowserPanestays mounted for every tab, the<webview>element never moves between DOM parents on a tab switch. No reparenting → no renderer process restart → no page reload.The
usePersistentWebviewhidden-container logic still runs correctly when a pane is destroyed (viadestroyPersistentWebview) — that path is unaffected.Changes
TabsContent/index.tsx— render all workspace tabs; CSS controls visibilityTabsContent/utils.ts—getWorkspaceTabsToRenderhelper (pure function)TabsContent/TabsContent.test.ts— regression test verifying all workspace tabs are included in the render setTests
Closes #1935
Summary by cubic
Keep all workspace tab views mounted and toggle visibility with CSS so switching tabs no longer reloads Electron webviews, preserving in-page state (closes #1935).
Written for commit bbd514a. Summary will update on new commits.