Repository navigation
Fix blurred Google Sheets canvas rendering - #8697
Conversation
📝 WalkthroughWalkthroughThe browser now clears custom WebKit user-agent overrides for embedded web views and uses a separate user-agent for auxiliary URLSession requests. Popup, navigation, creation, and reload paths apply the embedded identity, with regression coverage for navigation. ChangesEmbedded WebKit identity
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 24 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (24 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes blurred canvas rendering in Google Sheets by removing the forced standalone Safari user-agent from embedded
Confidence Score: 4/5Production changes are correct and well-scoped; the regression test's teardown skips panel.close(), leaving automation coordinators live after the test exits. The production fix is straightforward and the auxiliary URLSession paths correctly retain a Safari UA. The regression test calls panel.webView.stopLoading() in its defer but never calls panel.close(), which is how every other panel test in the suite tears down. close() cancels the hidden-web-view discard manager and invalidates automation coordinators; skipping it leaves those objects live and risks cross-test interference in CI, which the PR description specifically calls the runtime test authority. cmuxTests/BrowserPanelTests.swift — the new regression test needs panel.close() in its defer and should pass renderInitialNavigation: false to match every other BrowserPanel test construction in the suite. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[WKWebView created] -->|applyEmbeddedWebKitIdentity| B[customUserAgent = nil\nnative embedded identity]
C[navigate / reload / popup] -->|applyEmbeddedWebKitIdentity| B
D[URLSession auxiliary request\nsearch suggestions / favicon] -->|auxiliaryRequestUserAgent| E[User-Agent: Safari string]
B --> F{Google Sheets UA check}
E -. not seen by WebKit page .-> F
F -->|embedded WebKit UA| G[canvas backing/CSS ratio 2.0 — sharp]
F -->|Safari standalone UA| H[canvas backing/CSS ratio 0.5 — blurred]
Reviews (6): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
| switch scheme { | ||
| case "about", "applewebdata", "cmux-diff-viewer", "data", "file": | ||
| allowsNudge = true | ||
| default: | ||
| allowsNudge = false |
There was a problem hiding this comment.
blob: excluded from nudge allowlist — may regress blob-loaded local content
blob: is listed in browserEmbeddedNavigationSchemes as embeddable content, meaning cmux can navigate a WKWebView to a blob: URL via browserLoadRequest. After this change, any such navigation sets allowsNudge = false, so the transient geometry nudge — and its render-state kickstart — will be silently skipped. If cmux generates blob URLs for local application content (e.g. a PDF preview or an embedded document viewer) that currently relies on the nudge to recover from a hidden-host reveal, those surfaces will regress to the pre-nudge stale-paint behavior with no error or warning.
There was a problem hiding this comment.
Addressed in dc47cd5: blob is explicitly included in isRemoteWebOrigin, so blob navigations retain the first-sized reveal nudge and restore it synchronously. The current policy only disables the nudge for unsupported/unknown schemes.
— Claude Code
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Sources/Panels/BrowserPanel.swift (1)
967-978: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCentralize first-sized-reveal nudge configuration on navigation start
browserLoadRequestis the only place currently callingbrowserPortalConfigureFirstSizedRevealGeometryNudge(...), but navigation can also start via directwebView.load(...), history traversal (webView.goBack()/goForward()), and reload. Make the configure-before-mark policy the single source of truth for browser navigations so WKNavigationDelegate/same-document reloads cannot observe stale nudge flags.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Sources/Panels/BrowserPanel.swift` around lines 967 - 978, Centralize the configure-before-mark first-sized-reveal nudge policy used by browser navigations instead of limiting it to browserLoadRequest. Update the relevant WKWebView navigation entry points, including direct loads, history traversal, reloads, and same-document navigation, to invoke browserPortalConfigureFirstSizedRevealGeometryNudge before marking or handling navigation-start flags, while preserving existing file and prepared-request loading behavior.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmuxTests/BrowserPortalRemoteNavigationRevealTests.swift`:
- Around line 70-71: Replace the live Google URL load in the test around
browserLoadRequest with a direct invocation of the navigation policy
configuration being asserted, or use a local fake URL/server if the request path
must be exercised. Keep the test focused on the synchronous policy side effect
and ensure it never contacts an external host or relies on a fixed non-zero
port.
---
Outside diff comments:
In `@Sources/Panels/BrowserPanel.swift`:
- Around line 967-978: Centralize the configure-before-mark first-sized-reveal
nudge policy used by browser navigations instead of limiting it to
browserLoadRequest. Update the relevant WKWebView navigation entry points,
including direct loads, history traversal, reloads, and same-document
navigation, to invoke browserPortalConfigureFirstSizedRevealGeometryNudge before
marking or handling navigation-start flags, while preserving existing file and
prepared-request loading behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6ff13fa5-d744-4b83-b984-339c8f27aa6a
📒 Files selected for processing (4)
Sources/BrowserPortalWebViewRenderingState.swiftSources/Panels/BrowserPanel.swiftcmux.xcodeproj/project.pbxprojcmuxTests/BrowserPortalRemoteNavigationRevealTests.swift
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Sources/BrowserPortalWebViewRenderingState.swift (1)
106-119: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winFail closed until a navigation URL configures the policy.
The default
trueauthorizes a nudge when a load path misses configuration. Default this tofalse;browserPortalConfigureFirstSizedRevealGeometryNudge(forNavigationURL:)should be the sole authority that enables it.Proposed fix
- .boolValue ?? true + .boolValue ?? falseAs per path instructions, “fail closed when the source is absent.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Sources/BrowserPortalWebViewRenderingState.swift` around lines 106 - 119, Update the getter for browserPortalAllowsFirstSizedRevealGeometryNudge to default to false when no associated value exists. Keep browserPortalConfigureFirstSizedRevealGeometryNudge(forNavigationURL:) as the sole path that enables the policy, preserving configured values unchanged.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@Sources/BrowserPortalWebViewRenderingState.swift`:
- Around line 106-119: Update the getter for
browserPortalAllowsFirstSizedRevealGeometryNudge to default to false when no
associated value exists. Keep
browserPortalConfigureFirstSizedRevealGeometryNudge(forNavigationURL:) as the
sole path that enables the policy, preserving configured values unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: bd641926-427a-4fac-b9ec-8e3cea844260
📒 Files selected for processing (7)
Sources/BrowserPortalWebViewRenderingState.swiftSources/Panels/BrowserNavigationDelegate.swiftSources/Panels/BrowserPopupWindowController.swiftSources/Panels/BrowserPrewarmedWebViewPool.swiftcmux.xcodeproj/project.pbxprojcmuxTests/BrowserPortalRemoteNavigationRevealTests.swiftcmuxTests/BrowserPrewarmedWebViewPoolTests.swift
|
Addressed the CodeRabbit fail-closed finding from review 4768837367 in the current head (6b55250). The finding targeted browserPortalAllowsFirstSizedRevealGeometryNudge and browserPortalConfigureFirstSizedRevealGeometryNudge(forNavigationURL:), but the controlled same-URL WKWebView experiment disproved the geometry-policy hypothesis. The current head removes that property, configuration function, and all PR-added call sites rather than retaining a policy with either default. The fix now acts at the demonstrated boundary by restoring native embedded WebKit identity. Live tagged verification on the reported Sheet now shows devicePixelRatio 2 and a 2166 x 1232 backing canvas for 1083 x 616 CSS (2.0 on both axes; the bad build was 0.5). |
Summary
Closes #8657
Root cause evidence
The same public Google Sheet was loaded in controlled stock WKWebViews:
Layer wrapping, synchronous geometry nudging, and hide/resize/reveal remained sharp in isolation, so the prior geometry hypothesis was rejected.
Validation
Review notes