From 2410671a2db63ea566b618831cf076aaab3a7f1a Mon Sep 17 00:00:00 2001 From: Amit Ghadge Date: Sun, 15 Nov 2026 14:10:05 -0800 Subject: [PATCH] Conch.app: the scene shows through terminals, and behind Settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit background_through let a terminal's background through at its percentage, but the box the terminal sits in and the pane's card under it painted the same colour at the same opacity, so three layers of 70% made a pane 97% solid and the scene never showed in a terminal. While the scene shows through, only the terminal paints its background (SceneLook.underTerminal), and a pane lets in exactly `through` — seen live in a test copy with Ghostty: moon, snow and trees under the text. Settings had no scene at all: it now draws the window's scene, its sidebar and page frosted as the main window's frame is, the cards solid. Co-Authored-By: Claude Opus 5.5 --- macos/Sources/ConchApp/SceneView.swift | 4 ++-- macos/Sources/ConchApp/SettingsWindow.swift | 19 ++++++++++++++++--- macos/Sources/ConchKit/Backgrounds.swift | 13 +++++++++++++ .../ConchKitTests/BackgroundsTests.swift | 13 +++++++++++++ 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/macos/Sources/ConchApp/SceneView.swift b/macos/Sources/ConchApp/SceneView.swift index 22c71b29..0ca69a1d 100644 --- a/macos/Sources/ConchApp/SceneView.swift +++ b/macos/Sources/ConchApp/SceneView.swift @@ -19,9 +19,9 @@ extension Theme { /// background, or nothing, so the scene shows. static var ground: Color { scene.on ? .clear : window } /// A pane's background, as far as the scene shows through it. - static var paneFill: Color { window.opacity(scene.paneOpacity) } + static var paneFill: Color { window.opacity(scene.underTerminal) } /// The same behind a pane's terminal, for AppKit. - static var paneTerminal: NSColor { terminal.withAlphaComponent(scene.paneOpacity) } + static var paneTerminal: NSColor { terminal.withAlphaComponent(scene.underTerminal) } } /// A surface of the frame — the sidebar, the tab bar, the status bar — diff --git a/macos/Sources/ConchApp/SettingsWindow.swift b/macos/Sources/ConchApp/SettingsWindow.swift index f57360d6..bf33352e 100644 --- a/macos/Sources/ConchApp/SettingsWindow.swift +++ b/macos/Sources/ConchApp/SettingsWindow.swift @@ -223,14 +223,18 @@ struct SettingsView: View { @ObservedObject var model: SettingsModel /// The theme on screen, a preview included. @ObservedObject var look: ShownTheme + /// For [app] background: the window's scene behind Settings too. + @ObservedObject var store: Store @State private var query = "" @FocusState private var searching: Bool var schema: [SettingsSection] { model.form?.payload.schema ?? [] } var body: some View { + let scene = store.appLook.scene HStack(spacing: 0) { sidebar.frame(width: 248) + .background { if scene.on { Frost(color: Theme.side) } } Rectangle().fill(Theme.line).frame(width: 1) ZStack(alignment: .bottom) { VStack(spacing: 0) { @@ -256,10 +260,19 @@ struct SettingsView: View { if let t = model.toast { SettingsToast(text: t).padding(18).transition(.move(edge: .top).combined(with: .opacity)) } } .animation(.spring(response: 0.3, dampingFraction: 0.8), value: model.toast) - .background(Theme.window) + // Frosted over the scene as the main window's frame is; the + // cards on it keep their own colour, so their text reads. + .background { if scene.on { Frost(color: Theme.window) } else { Theme.window } } } .frame(minWidth: 900, minHeight: 600) - .background(Theme.window) + .background { + let shown = scene.showing(project: nil) + if shown.scene != .none { + SceneView(scene: shown).ignoresSafeArea() + } else { + Theme.window + } + } .preferredColorScheme(look.theme.light ? .light : .dark) // A new theme repaints every view that reads this, in place: not // .id, as the main window does, which would make the window anew — @@ -984,7 +997,7 @@ final class SettingsWindow { styleMask: [.titled, .closable, .resizable, .miniaturizable], backing: .buffered, defer: false) w.title = "conch Settings" w.isReleasedWhenClosed = false - w.contentView = NSHostingView(rootView: SettingsView(model: model, look: model.store.look)) + w.contentView = NSHostingView(rootView: SettingsView(model: model, look: model.store.look, store: model.store)) look = model.store.look.$theme.sink { [weak w] t in w?.appearance = NSAppearance(named: t.light ? .aqua : .darkAqua) w?.backgroundColor = Theme.ns(t.chrome) diff --git a/macos/Sources/ConchKit/Backgrounds.swift b/macos/Sources/ConchKit/Backgrounds.swift index 82f447a6..9b301001 100644 --- a/macos/Sources/ConchKit/Backgrounds.swift +++ b/macos/Sources/ConchKit/Backgrounds.swift @@ -199,6 +199,19 @@ public struct SceneLook: Equatable, Sendable { /// A pane's opacity: solid with no scene, whatever through says. public var paneOpacity: Double { on ? 1 - through : 1 } + /// The layers under a terminal — the box it sits in and the pane's + /// card — paint this much of their colour. The terminal paints its own + /// background at paneOpacity, so while the scene shows through they + /// paint nothing: each at paneOpacity too, three layers of 70% made + /// a pane 97% solid and the scene never showed in a terminal. + public var underTerminal: Double { paneOpacity < 1 ? 0 : 1 } + + /// How solid a pane ends up, its layers stacked: the terminal's own + /// background over the box and the card. + public var paneCoverage: Double { + 1 - (1 - paneOpacity) * (1 - underTerminal) * (1 - underTerminal) + } + /// Whether it moves now: never when asked to be still, when macOS's /// Reduce Motion is on, or in Low Power Mode. public func moves(reduceMotion: Bool, lowPower: Bool) -> Bool { diff --git a/macos/Tests/ConchKitTests/BackgroundsTests.swift b/macos/Tests/ConchKitTests/BackgroundsTests.swift index 779c9090..b7e2962c 100644 --- a/macos/Tests/ConchKitTests/BackgroundsTests.swift +++ b/macos/Tests/ConchKitTests/BackgroundsTests.swift @@ -198,4 +198,17 @@ import Testing #expect(start + Fireworks.burst <= Fireworks.duration) } } + + // A terminal shows the scene by exactly `through`: only the terminal + // paints its background, not the box and the card under it as well. + @Test func throughIsWhatAPaneLetsIn() { + for t in [0.1, 0.24, 0.3, 0.6] { + let l = SceneLook(scene: .pines, through: t) + #expect(abs((1 - l.paneCoverage) - t) < 1e-9) + #expect(l.underTerminal == 0) + } + // Solid panes, and no scene: everything paints, nothing shows. + #expect(SceneLook(scene: .pines, through: 0).underTerminal == 1 && SceneLook(scene: .pines).paneCoverage == 1) + #expect(SceneLook(scene: .none, through: 0.4).underTerminal == 1 && SceneLook(scene: .none, through: 0.4).paneCoverage == 1) + } }