From 5cb67724c70cb6d0799ca4e441e0a572db22e175 Mon Sep 17 00:00:00 2001 From: onevcat Date: Mon, 8 Jun 2026 22:09:49 +0900 Subject: [PATCH] Fix command palette color-scheme flicker on first open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The palette card forced a color scheme computed from `NSColor.windowBackgroundColor.isLightColor` inside `body`. That dynamic color resolves against the current drawing appearance context, which isn't settled on the palette's first render, so in Light mode the card briefly flashed the wrong scheme on open and only corrected on the next re-render (e.g. the first keystroke). Drop the forced override entirely and let the card inherit the ambient `@Environment(\.colorScheme)` — which already reflects the window's appearance, is correct on the first render, and updates reactively. Also removes the now-unused `isLightColor` NSColor extension (its `luminance` helper stays; it's still used by the Ghostty theme code). The selected-row dark-scheme override from the legibility fix is unaffected. --- .../Views/CommandPaletteOverlayView.swift | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/supacode/Features/CommandPalette/Views/CommandPaletteOverlayView.swift b/supacode/Features/CommandPalette/Views/CommandPaletteOverlayView.swift index e9fa92fc..206a9844 100644 --- a/supacode/Features/CommandPalette/Views/CommandPaletteOverlayView.swift +++ b/supacode/Features/CommandPalette/Views/CommandPaletteOverlayView.swift @@ -203,10 +203,6 @@ private struct CommandPaletteCard: View { Color(nsColor: .windowBackgroundColor) } - private var colorScheme: ColorScheme { - NSColor.windowBackgroundColor.isLightColor ? .light : .dark - } - var body: some View { VStack(alignment: .leading, spacing: 0) { CommandPaletteQuery(query: $query, isTextFieldFocused: isQueryFocused) { event in @@ -233,7 +229,6 @@ private struct CommandPaletteCard: View { .glassEffect(.regular, in: RoundedRectangle(cornerRadius: 14)) .shadow(radius: 32, x: 0, y: 12) .padding(Self.padding) - .environment(\.colorScheme, colorScheme) } } @@ -874,9 +869,3 @@ private func commandPaletteShortcutSymbols(for index: Int) -> [String] { private func commandPaletteShortcutLabel(for index: Int) -> String { "Cmd+\(index + 1)" } - -extension NSColor { - fileprivate var isLightColor: Bool { - luminance > 0.5 - } -} -- 2.51.2