Skip to content

fix: solve #1935 — browser panes no longer refresh on tab switch#1936

Open
github-actions[bot] wants to merge 1 commit intomainfrom
triage/issue-1935-22555695240
Open

fix: solve #1935 — browser panes no longer refresh on tab switch#1936
github-actions[bot] wants to merge 1 commit intomainfrom
triage/issue-1935-22555695240

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 1, 2026

Root cause

TabsContent previously rendered only the active tab's <TabView>. Switching tabs unmounted the inactive TabViewBrowserPane unmounted → usePersistentWebview cleanup moved the <webview> element to an off-screen container (document.body child at left: -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

TabsContent now renders all workspace tabs simultaneously. CSS (display: none) controls which tab is visible; the active tab wrapper gets display: flex, all others get display: none.

Because BrowserPane stays 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 usePersistentWebview hidden-container logic still runs correctly when a pane is destroyed (via destroyPersistentWebview) — that path is unaffected.

Changes

  • TabsContent/index.tsx — render all workspace tabs; CSS controls visibility
  • TabsContent/utils.tsgetWorkspaceTabsToRender helper (pure function)
  • TabsContent/TabsContent.test.ts — regression test verifying all workspace tabs are included in the render set

Tests

bun test apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabsContent.test.ts
# 3 pass, 0 fail

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).

  • Bug Fixes
    • Render all workspace tabs at once; only the active tab is visible (display: flex vs display: none).
    • Prevent webview reparenting that restarted the renderer and caused page reloads.
    • Add getWorkspaceTabsToRender helper and a regression test to ensure all workspace tabs are rendered.

Written for commit bbd514a. Summary will update on new commits.

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.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] browser refreshes upon switching tabs

0 participants