Fix browser panes rendering blank after reopen - #2141
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes blank browser panes after session reopen by decoupling construction-time URL loading from session restoration and introducing a unified Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant WS as Workspace
participant BP as BrowserPanel
participant WV as WKWebView
Note over WS,WV: Session Restore (new flow)
WS->>BP: newBrowserSurface(url: nil)
BP->>WV: makeWebView() – no initial navigation
WS->>BP: setPageZoomFactor(zoom)
WS->>BP: restoreSessionSnapshot(snapshot)
BP->>BP: restoreSessionNavigationHistory(back, fwd, currentURL)
BP->>BP: set usesRestoredSessionHistory, restoredHistoryCurrentURL
BP->>BP: currentURL = restoredURL
BP->>BP: shouldRenderWebView = true
BP->>WV: navigateWithoutInsecureHTTPPrompt(restoredURL, preserveHistory: true)
WV-->>BP: url KVO → currentURL updated
Note over WS,WV: Reload fallback (new)
WS->>BP: reload()
BP->>WV: webView.url?
WV-->>BP: nil / blank
BP->>BP: resolvedCurrentSessionHistoryURL() → fallbackURL
alt fallbackURL is valid
BP->>WV: navigateWithoutInsecureHTTPPrompt(fallbackURL)
else no fallback
BP->>WV: webView.reload()
end
Reviews (1): Last reviewed commit: "Fix browser pane restore after reopen" | Re-trigger Greptile |
| currentURL = snapshot.shouldRenderWebView ? restoredURL : nil | ||
| shouldRenderWebView = snapshot.shouldRenderWebView | ||
|
|
||
| guard snapshot.shouldRenderWebView, let restoredURL else { | ||
| refreshNavigationAvailability() | ||
| return | ||
| } |
There was a problem hiding this comment.
Blank WebView when
shouldRenderWebView is true but URL is unsanitizable
If snapshot.shouldRenderWebView is true but Self.sanitizedSessionHistoryURL(snapshot.urlString) returns nil (e.g. corrupt/missing URL in persisted data), the code sets shouldRenderWebView = true and currentURL = nil, then takes the early-return branch. The WebView will be rendered but completely blank rather than falling back to the new-tab/empty state.
The old code would have called newBrowserSurface(url: nil), leaving shouldRenderWebView = false (no navigation triggered), so the user would have seen a clean new-tab page instead.
In practice this can't happen with a valid session file because shouldRenderWebView is serialised from browserPanel.shouldRenderWebView, which is only set to true alongside a real navigation. But it's worth guarding explicitly so corrupt sessions degrade gracefully:
currentURL = (snapshot.shouldRenderWebView && restoredURL != nil) ? restoredURL : nil
shouldRenderWebView = snapshot.shouldRenderWebView && restoredURL != nilIngests all upstream fixes since 2026-03-22 including: - Fix Cmd+N crash: retain snapshot workspaces (manaflow-ai#2183, manaflow-ai#2181, manaflow-ai#2178, manaflow-ai#2173) - Fix browser pane restore after reopen (manaflow-ai#2141) - Fix Ghostty resize_split keybind (manaflow-ai#1899) - Reduce shell integration prompt latency (manaflow-ai#2109) - Fix command palette focus after terminal find (manaflow-ai#2089) - Add Codex CLI hooks (manaflow-ai#2103) - Add cmux.json custom commands (manaflow-ai#2011) - Fix window position restore on relaunch (manaflow-ai#2129) Conflict resolution: - BrowserPanel.swift: accepted upstream configureWebViewConfiguration() refactor (already includes our forMainFrameOnly:true CAPTCHA fix from PR manaflow-ai#1877) Fork-specific files preserved: - Sources/Panels/WebAuthn{Coordinator,BridgeJavaScript}.swift - Sources/FIDO2/module.modulemap - vendor/ctap2 submodule - cmux.entitlements (with camera/audio-input removed) - cmux.embedded.entitlements - .github/workflows/fork-{ci,release}.yml
Fixes #2137
Summary
Testing
./scripts/reload.sh --tag browser-blank-fix --launchSummary by cubic
Fixes #2137 by restoring browser panes via an explicit session-restore path. Reload now falls back to the restored URL to avoid blank pages after reopen.
restoreSessionSnapshotpath that restores history, current URL, andshouldRenderWebView, then navigates without constructor-time URL loading.url: nilto prevent premature loads; apply page zoom and devtools state after restoration.WKWebViewhas no live URL, navigate to the resolved current or last attempted URL.Written for commit 0b891ff. Summary will update on new commits.