From 528b84c1ee99dc4ae148e97ebeaf438918225a5b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 15 Oct 2026 07:01:43 +0000 Subject: [PATCH] fix(ui): PiP horizontal fill and Glance console window levels (CC-9, CC-26) Use the themed PiP background for horizontally scrolling rows so the HUD does not show a grey groupBand inset after the header strip was removed. Extract GlanceWindowLevels for the popover versus elevated console ordering and add a unit test pinning CC-26. Co-authored-by: Jay Wedgeworth --- Sources/CodeCaps/AppDelegate.swift | 2 +- Sources/CodeCaps/GlanceWindowLevels.swift | 16 +++++++++++++++ Sources/CodeCaps/PipWidget.swift | 4 +++- .../GlanceWindowLevelsTests.swift | 20 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Sources/CodeCaps/GlanceWindowLevels.swift create mode 100644 Tests/CodeCapsTests/GlanceWindowLevelsTests.swift diff --git a/Sources/CodeCaps/AppDelegate.swift b/Sources/CodeCaps/AppDelegate.swift index c6957af3..f740f346 100644 --- a/Sources/CodeCaps/AppDelegate.swift +++ b/Sources/CodeCaps/AppDelegate.swift @@ -600,7 +600,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe /// console if (and only while) the console would cover it. private func elevateConsole() { guard let consoleWindow else { return } - consoleWindow.level = NSWindow.Level(Int(CGWindowLevelForKey(.popUpMenuWindow)) + 1) + consoleWindow.level = GlanceWindowLevels.consoleAboveGlance glanceOcclusion.isOccluded = true // The PiP HUD is documented to stay "visible on top of all windows at // all times". The controller remembers the elevated console so a HUD diff --git a/Sources/CodeCaps/GlanceWindowLevels.swift b/Sources/CodeCaps/GlanceWindowLevels.swift new file mode 100644 index 00000000..db990c1f --- /dev/null +++ b/Sources/CodeCaps/GlanceWindowLevels.swift @@ -0,0 +1,16 @@ +import AppKit + +/// Window levels for Glance and the Settings/Console window (CC-26). +/// +/// The Glance popover uses AppKit's pop-up menu level. When Settings or +/// Console opens while Glance is visible, the console is raised one step above +/// so it is not trapped behind the popover. +enum GlanceWindowLevels { + static var glancePopover: NSWindow.Level { + NSWindow.Level(Int(CGWindowLevelForKey(.popUpMenuWindow))) + } + + static var consoleAboveGlance: NSWindow.Level { + NSWindow.Level(glancePopover.rawValue + 1) + } +} diff --git a/Sources/CodeCaps/PipWidget.swift b/Sources/CodeCaps/PipWidget.swift index 28b5426b..bb7af217 100644 --- a/Sources/CodeCaps/PipWidget.swift +++ b/Sources/CodeCaps/PipWidget.swift @@ -490,7 +490,9 @@ struct PipWidgetView: View { .padding(.vertical, PipMetrics.bodyVerticalPadding) } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) - .background(Theme.groupBand) + // Match the vertical rows panel: a grey `groupBand` read as the silver + // header strip the owner asked to remove (CC-9). + .background(background.fill) } /// The row whose platform detail is open, if the owner clicked one. `nil` diff --git a/Tests/CodeCapsTests/GlanceWindowLevelsTests.swift b/Tests/CodeCapsTests/GlanceWindowLevelsTests.swift new file mode 100644 index 00000000..48b5dc08 --- /dev/null +++ b/Tests/CodeCapsTests/GlanceWindowLevelsTests.swift @@ -0,0 +1,20 @@ +import AppKit +import XCTest +@testable import CodeCaps + +/// CC-26: Settings/Console must layer above the Glance popover when elevated. +@MainActor +final class GlanceWindowLevelsTests: XCTestCase { + func testConsoleElevatedAboveGlancePopover() { + XCTAssertGreaterThan( + GlanceWindowLevels.consoleAboveGlance.rawValue, + GlanceWindowLevels.glancePopover.rawValue, + "Settings/Console opened from Glance must not sit behind the popover" + ) + XCTAssertGreaterThan( + GlanceWindowLevels.glancePopover.rawValue, + NSWindow.Level.normal.rawValue, + "Glance popover is expected above ordinary document windows" + ) + } +}