fix: preserve inherited appearance for WebKit refresh
This commit is contained in:
@@ -264,9 +264,10 @@ struct BrowserPanelView: View {
|
||||
let paneOwnershipOverride: Bool?
|
||||
private let resolvedColorScheme: ColorScheme
|
||||
private let resolvedThemeBackgroundColor: NSColor
|
||||
/// Inherited SwiftUI appearance is observed only to refresh WebKit's
|
||||
/// system theme. It is never used to resolve browser toolbar colors.
|
||||
@Environment(\.colorScheme) private var inheritedColorScheme
|
||||
/// Appearance captured from the host before the parent injects the
|
||||
/// surface-resolved scheme. It is observed only to refresh WebKit's system
|
||||
/// theme and is never used to resolve browser toolbar colors.
|
||||
private let inheritedColorScheme: ColorScheme
|
||||
@Environment(\.cmuxCanvasInlineBrowserHosting) private var canvasInlineBrowserHosting
|
||||
@Environment(\.paneDropZone) private var paneDropZone
|
||||
/// Held detector instance used to summarize installed browsers rather than
|
||||
@@ -361,6 +362,7 @@ struct BrowserPanelView: View {
|
||||
portalPriority: Int,
|
||||
paneOwnershipOverride: Bool? = nil,
|
||||
resolvedColorScheme: ColorScheme,
|
||||
inheritedColorScheme: ColorScheme,
|
||||
resolvedThemeBackgroundColor: NSColor,
|
||||
onRequestPanelFocus: @escaping () -> Void
|
||||
) {
|
||||
@@ -372,6 +374,7 @@ struct BrowserPanelView: View {
|
||||
self.portalPriority = portalPriority
|
||||
self.paneOwnershipOverride = paneOwnershipOverride
|
||||
self.resolvedColorScheme = resolvedColorScheme
|
||||
self.inheritedColorScheme = inheritedColorScheme
|
||||
self.resolvedThemeBackgroundColor = resolvedThemeBackgroundColor
|
||||
self.onRequestPanelFocus = onRequestPanelFocus
|
||||
self._browserChromeStyle = State(initialValue: BrowserChromeStyle.resolve(
|
||||
|
||||
@@ -25,6 +25,10 @@ struct PanelContentView: View {
|
||||
let customSidebarUnread: SidebarUnreadModel = TerminalNotificationStore.shared.sidebarUnread
|
||||
let hasUnreadNotification: Bool
|
||||
let terminalAgentContext: String
|
||||
/// Appearance inherited from the host before this view injects the
|
||||
/// surface-resolved scheme for its rendered panel subtree. Browser WebKit
|
||||
/// system theming may observe this value; browser chrome must not.
|
||||
@Environment(\.colorScheme) private var inheritedColorScheme
|
||||
/// Explicit browser pane-ownership signal for hosts whose panels live outside
|
||||
/// the main `Workspace` tree (the Dock). `nil` keeps the main-area behavior.
|
||||
var paneOwnershipOverride: Bool? = nil
|
||||
@@ -77,6 +81,7 @@ struct PanelContentView: View {
|
||||
portalPriority: portalPriority,
|
||||
paneOwnershipOverride: paneOwnershipOverride,
|
||||
resolvedColorScheme: windowAppearance.resolvedColorScheme,
|
||||
inheritedColorScheme: inheritedColorScheme,
|
||||
resolvedThemeBackgroundColor: windowAppearance.resolvedChromeBackgroundColor,
|
||||
onRequestPanelFocus: onRequestPanelFocus
|
||||
)
|
||||
|
||||
@@ -137,4 +137,23 @@ import Testing
|
||||
#expect(alpha == 1)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func inheritedAppearanceOnlyChangeKeepsBrowserChromeStableForWebKitRefresh() {
|
||||
let surfaceScheme: ColorScheme = .light
|
||||
let beforeRefresh = resolvedBrowserChromeColorScheme(
|
||||
for: surfaceScheme,
|
||||
ambientColorScheme: .dark
|
||||
)
|
||||
let afterRefresh = resolvedBrowserChromeColorScheme(
|
||||
for: surfaceScheme,
|
||||
ambientColorScheme: .light
|
||||
)
|
||||
|
||||
// `BrowserPanelView` refreshes WebKit when this inherited value
|
||||
// changes, while the toolbar authority must remain unchanged.
|
||||
#expect(beforeRefresh == surfaceScheme)
|
||||
#expect(afterRefresh == surfaceScheme)
|
||||
#expect(afterRefresh == beforeRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user