From 78d56ca79b415376b5eb3ab7a8ca6d9418a57ee9 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Fri, 9 Oct 2026 18:04:08 +0800 Subject: [PATCH] Make dark mode black instead of the system window grey The panel is a full-height strip that sits beside your work, where the system grey reads as a half-lit window next to a dark editor. Dark mode is now pure black, with card and row colours in one Theme file so both the panel background and the strip under the titlebar match. --- AGENTS.md | 6 ++++++ Sources/Prompt/PanelController.swift | 4 ++++ Sources/Prompt/PanelView.swift | 3 ++- Sources/Prompt/Theme.swift | 28 ++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Sources/Prompt/Theme.swift diff --git a/AGENTS.md b/AGENTS.md index c8ce578..c775f35 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,6 +31,12 @@ clicking an item copies it back to the clipboard. `setDone(_:ids:)`, `move(ids:to:)`) back the selection context menu, so one action applies to every selected item and image files are cleaned up once. Saves on every mutation. +- `Sources/Prompt/Theme.swift` — the panel's appearance-aware colours. Dark + mode is pure black rather than the system window grey (the panel is a + full-height strip beside your work, where grey reads as a half-lit window); + light mode keeps the system window colour. `Theme.background` is also handed + to the `NSPanel` so the strip under the transparent titlebar matches, and the + row colour stays slightly lighter than black so cards remain visible. - `Sources/Prompt/PanelView.swift` — the panel UI. Header (section switcher, search, add photos, close), item list, composer. Composer `# Name` creates/ switches sections. Click = select (Shift+click for a range); the selection diff --git a/Sources/Prompt/PanelController.swift b/Sources/Prompt/PanelController.swift index 69b2f66..73c09a4 100644 --- a/Sources/Prompt/PanelController.swift +++ b/Sources/Prompt/PanelController.swift @@ -56,6 +56,10 @@ final class PanelController: NSObject { panel.isMovableByWindowBackground = true panel.hidesOnDeactivate = false panel.isReleasedWhenClosed = false + panel.isOpaque = true + // Match the SwiftUI content so the titlebar strip and any resize flash + // do not show the system grey through. + panel.backgroundColor = Theme.background panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary] panel.contentView = NSHostingView(rootView: PanelView(store: Store.shared)) panel.setFrameAutosaveName("PromptPanel") diff --git a/Sources/Prompt/PanelView.swift b/Sources/Prompt/PanelView.swift index 85a4af1..2265c08 100644 --- a/Sources/Prompt/PanelView.swift +++ b/Sources/Prompt/PanelView.swift @@ -40,6 +40,7 @@ struct PanelView: View { composerField } .frame(minWidth: 300) + .background(Theme.backgroundSwiftUI) .background(shortcutButtons) .overlay(sectionSwitcher) .overlay(syncOverlay) @@ -248,7 +249,7 @@ struct PanelView: View { private func rowBackground(_ item: PromptItem) -> Color { if selection.contains(item.id) { return Color.accentColor.opacity(0.25) } - return Color.primary.opacity(0.05) + return Theme.rowSwiftUI } @ViewBuilder diff --git a/Sources/Prompt/Theme.swift b/Sources/Prompt/Theme.swift new file mode 100644 index 0000000..feef59d --- /dev/null +++ b/Sources/Prompt/Theme.swift @@ -0,0 +1,28 @@ +import AppKit +import SwiftUI + +/// Appearance-aware colours for the panel. +/// +/// Dark mode is pure black rather than the system window grey: the panel is a +/// full-height strip that sits beside your work, and the grey reads as a +/// half-lit window next to a dark editor or terminal. +enum Theme { + static func isDark(_ appearance: NSAppearance) -> Bool { + appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua + } + + /// The panel's own background (also handed to the NSPanel so the area under + /// the transparent titlebar matches). + static let background = NSColor(name: nil) { appearance in + isDark(appearance) ? .black : .windowBackgroundColor + } + + /// Card background, kept subtle but visible against pure black. + static let row = NSColor(name: nil) { appearance in + isDark(appearance) ? NSColor(white: 1, alpha: 0.07) : NSColor(white: 0, alpha: 0.05) + } + + /// Same colours for SwiftUI. + static let backgroundSwiftUI = Color(nsColor: background) + static let rowSwiftUI = Color(nsColor: row) +}