fix(webview): reset background to white for external pages to prevent dark bleeding
- commit
- 7a529eb9c51fe22cb1d7bf828c917508a93242f4
- author
- brice · · 2026-01-24 04:59 UTC
- committer
- brice · · 2026-01-24 05:14 UTC
- parent
- 8ea382a
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +29 -0
M internal/infrastructure/webkit/webview.go +6 -0
| @@ -905,6 +905,12 @@ func (wv *WebView) SetBackgroundColor(r, g, b, a float32) { | |||
| 905 | 905 | wv.inner.SetBackgroundColor(rgba) | |
| 906 | 906 | } | |
| 907 | 907 | ||
| 908 | + | // ResetBackgroundToDefault sets WebView background to white (browser default). | |
| 909 | + | // Used for external pages to prevent dark background from bleeding through. | |
| 910 | + | func (wv *WebView) ResetBackgroundToDefault() { | |
| 911 | + | wv.SetBackgroundColor(1.0, 1.0, 1.0, 1.0) | |
| 912 | + | } | |
| 913 | + | ||
| 908 | 914 | // Show makes the WebView widget visible. | |
| 909 | 915 | // This should be called after the WebView is ready to be displayed. | |
| 910 | 916 | func (wv *WebView) Show() { | |
| @@ -905,6 +905,12 @@ func (wv *WebView) SetBackgroundColor(r, g, b, a float32) { | |||||
| 905 | wv.inner.SetBackgroundColor(rgba) | 905 | wv.inner.SetBackgroundColor(rgba) | ||
| 906 | } | 906 | } | ||
| 907 | 907 | ||||
| 908 | + | // ResetBackgroundToDefault sets WebView background to white (browser default). | |||
| 909 | + | // Used for external pages to prevent dark background from bleeding through. | |||
| 910 | + | func (wv *WebView) ResetBackgroundToDefault() { | |||
| 911 | + | wv.SetBackgroundColor(1.0, 1.0, 1.0, 1.0) | |||
| 912 | + | } | |||
| 913 | + | ||||
| 908 | // Show makes the WebView widget visible. | 914 | // Show makes the WebView widget visible. | ||
| 909 | // This should be called after the WebView is ready to be displayed. | 915 | // This should be called after the WebView is ready to be displayed. | ||
| 910 | func (wv *WebView) Show() { | 916 | func (wv *WebView) Show() { | ||
M internal/ui/coordinator/content.go +23 -0
| @@ -24,6 +24,12 @@ import ( | |||
| 24 | 24 | const ( | |
| 25 | 25 | aboutBlankURI = "about:blank" | |
| 26 | 26 | logURLMaxLen = 80 | |
| 27 | + | ||
| 28 | + | // Dark theme background color (#0a0a0b) as float32 RGBA values | |
| 29 | + | darkBgR = 0.039 | |
| 30 | + | darkBgG = 0.039 | |
| 31 | + | darkBgB = 0.043 | |
| 32 | + | darkBgA = 1.0 | |
| 27 | 33 | ) | |
| 28 | 34 | ||
| 29 | 35 | // ContentCoordinator manages WebView lifecycle, title tracking, and content attachment. | |
| @@ -936,6 +942,23 @@ func (c *ContentCoordinator) onLoadCommitted(ctx context.Context, paneID entity. | |||
| 936 | 942 | return | |
| 937 | 943 | } | |
| 938 | 944 | ||
| 945 | + | // Set appropriate background color based on page type to prevent dark background bleeding. | |
| 946 | + | switch { | |
| 947 | + | case strings.HasPrefix(url, "dumb://"): | |
| 948 | + | // Internal pages: apply themed background | |
| 949 | + | theme, ok := c.getCurrentTheme() | |
| 950 | + | if ok && theme.prefersDark { | |
| 951 | + | wv.SetBackgroundColor(darkBgR, darkBgG, darkBgB, darkBgA) | |
| 952 | + | } else { | |
| 953 | + | wv.ResetBackgroundToDefault() | |
| 954 | + | } | |
| 955 | + | case strings.HasPrefix(url, "about:"): | |
| 956 | + | // Keep pool background (no action) | |
| 957 | + | default: | |
| 958 | + | // External pages: white background | |
| 959 | + | wv.ResetBackgroundToDefault() | |
| 960 | + | } | |
| 961 | + | ||
| 939 | 962 | // Show the WebView now that content is being painted | |
| 940 | 963 | // (WebViews are hidden on creation to avoid white flash) | |
| 941 | 964 | // Skip showing if this is about:blank but the pane is loading a different URL | |
| @@ -24,6 +24,12 @@ import ( | |||||
| 24 | const ( | 24 | const ( | ||
| 25 | aboutBlankURI = "about:blank" | 25 | aboutBlankURI = "about:blank" | ||
| 26 | logURLMaxLen = 80 | 26 | logURLMaxLen = 80 | ||
| 27 | + | ||||
| 28 | + | // Dark theme background color (#0a0a0b) as float32 RGBA values | |||
| 29 | + | darkBgR = 0.039 | |||
| 30 | + | darkBgG = 0.039 | |||
| 31 | + | darkBgB = 0.043 | |||
| 32 | + | darkBgA = 1.0 | |||
| 27 | ) | 33 | ) | ||
| 28 | 34 | ||||
| 29 | // ContentCoordinator manages WebView lifecycle, title tracking, and content attachment. | 35 | // ContentCoordinator manages WebView lifecycle, title tracking, and content attachment. | ||
| @@ -936,6 +942,23 @@ func (c *ContentCoordinator) onLoadCommitted(ctx context.Context, paneID entity. | |||||
| 936 | return | 942 | return | ||
| 937 | } | 943 | } | ||
| 938 | 944 | ||||
| 945 | + | // Set appropriate background color based on page type to prevent dark background bleeding. | |||
| 946 | + | switch { | |||
| 947 | + | case strings.HasPrefix(url, "dumb://"): | |||
| 948 | + | // Internal pages: apply themed background | |||
| 949 | + | theme, ok := c.getCurrentTheme() | |||
| 950 | + | if ok && theme.prefersDark { | |||
| 951 | + | wv.SetBackgroundColor(darkBgR, darkBgG, darkBgB, darkBgA) | |||
| 952 | + | } else { | |||
| 953 | + | wv.ResetBackgroundToDefault() | |||
| 954 | + | } | |||
| 955 | + | case strings.HasPrefix(url, "about:"): | |||
| 956 | + | // Keep pool background (no action) | |||
| 957 | + | default: | |||
| 958 | + | // External pages: white background | |||
| 959 | + | wv.ResetBackgroundToDefault() | |||
| 960 | + | } | |||
| 961 | + | ||||
| 939 | // Show the WebView now that content is being painted | 962 | // Show the WebView now that content is being painted | ||
| 940 | // (WebViews are hidden on creation to avoid white flash) | 963 | // (WebViews are hidden on creation to avoid white flash) | ||
| 941 | // Skip showing if this is about:blank but the pane is loading a different URL | 964 | // Skip showing if this is about:blank but the pane is loading a different URL | ||