From 83aff10ef607f2b3857ffc619b4125b4bf6d347c Mon Sep 17 00:00:00 2001 From: Adam Borbas Date: Thu, 16 Jul 2026 18:32:07 +0200 Subject: [PATCH 1/2] Keep dim on transient .inactive scene phase ScreenManager.handleScenePhase lumped .inactive with .background and cleared isDimmed for both, so pulling down Control/Notification Center (which yields .inactive without backgrounding) defeated the stay-awake dim while the app was still foreground. Only clear the dim on a true .background trip; .inactive now does nothing, mirroring SessionManager.handleScenePhase's treatment. Co-Authored-By: Claude Opus 4.8 --- Hemera/Screen/ScreenManager.swift | 7 ++++++- HemeraTests/Screen/ScreenManagerTests.swift | 23 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Hemera/Screen/ScreenManager.swift b/Hemera/Screen/ScreenManager.swift index eb07a70..f5bc34b 100644 --- a/Hemera/Screen/ScreenManager.swift +++ b/Hemera/Screen/ScreenManager.swift @@ -177,11 +177,16 @@ final class ScreenManager { if stayAwake && !isDimmed { resetInactivityTimer() } - case .background, .inactive: + case .background: cancelInactivityTimer() if isDimmed { isDimmed = false } + case .inactive: + // Transient interruptions (Control Center, Notification Center, + // incoming calls) yield `.inactive` without backgrounding the app. + // Keep the current dim state so it survives them. + break @unknown default: break } diff --git a/HemeraTests/Screen/ScreenManagerTests.swift b/HemeraTests/Screen/ScreenManagerTests.swift index db015e5..8534e89 100644 --- a/HemeraTests/Screen/ScreenManagerTests.swift +++ b/HemeraTests/Screen/ScreenManagerTests.swift @@ -1,3 +1,4 @@ +import SwiftUI import Testing @testable import Hemera @@ -61,4 +62,26 @@ struct ScreenManagerTests { #expect(screenManager.isDimmed == true) } + // MARK: - Scene Phase + + @Test func handleScenePhase_inactive_whileDimmed_keepsDim() { + screenManager.stayAwake = true + screenManager.executePreviewDim() + #expect(screenManager.isDimmed == true) + + screenManager.handleScenePhase(.inactive) + + #expect(screenManager.isDimmed == true) + } + + @Test func handleScenePhase_background_whileDimmed_clearsDim() { + screenManager.stayAwake = true + screenManager.executePreviewDim() + #expect(screenManager.isDimmed == true) + + screenManager.handleScenePhase(.background) + + #expect(screenManager.isDimmed == false) + } + } From 1268f37e40477775383613341598267b00341389 Mon Sep 17 00:00:00 2001 From: Adam Borbas Date: Thu, 16 Jul 2026 21:41:27 +0200 Subject: [PATCH 2/2] Use block comment form for .inactive scene-phase note Co-Authored-By: Claude Opus 4.8 --- Hemera/Screen/ScreenManager.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Hemera/Screen/ScreenManager.swift b/Hemera/Screen/ScreenManager.swift index f5bc34b..56cf0a1 100644 --- a/Hemera/Screen/ScreenManager.swift +++ b/Hemera/Screen/ScreenManager.swift @@ -183,9 +183,11 @@ final class ScreenManager { isDimmed = false } case .inactive: - // Transient interruptions (Control Center, Notification Center, - // incoming calls) yield `.inactive` without backgrounding the app. - // Keep the current dim state so it survives them. + /** + Transient interruptions (Control Center, Notification Center, + incoming calls) yield `.inactive` without backgrounding the app. + Keep the current dim state so it survives them. + */ break @unknown default: break