From 5ffc0257ad6af7bb44ea17b72c0d306a303dc330 Mon Sep 17 00:00:00 2001 From: Untold Engine Date: Tue, 1 Dec 2026 08:23:13 -0700 Subject: [PATCH] Fix Swift 6 strict-concurrency warnings in InputSystem+Keyboard's text-focus check PR #1424 added a synchronous NSApp.keyWindow?.firstResponder check inside shouldHandleKey, a plain nonisolated instance method, producing 3 strict- concurrency warnings (NSApp, keyWindow, firstResponder are all MainActor- isolated). The swift6-guardrails CI check has a zero-warning budget, so this blocks every PR built off develop until fixed. shouldHandleKey is only ever called from an NSEvent local monitor handler, which AppKit always invokes on the main thread, so the isolation is genuinely held at runtime -- MainActor.assumeIsolated proves that to the compiler without marking the whole type @MainActor or threading async through its two call sites. --- .../UntoldEngine/Systems/InputSystem+Keyboard.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift b/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift index 0edc8180e..0ded7b159 100644 --- a/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift +++ b/Sources/UntoldEngine/Systems/InputSystem+Keyboard.swift @@ -140,7 +140,17 @@ public extension InputSystem { // real keyboard focus (click, cursor appears) without reliably posting it, so // this falls back to asking the key window directly what's actually focused // right now, rather than trusting a notification that may never have fired. - if let responder = NSApp.keyWindow?.firstResponder, responder is NSText { + // This method is only ever called from an NSEvent local monitor handler, which + // AppKit always invokes on the main thread, so the isolation is actually held — + // assumeIsolated just proves that to the compiler instead of marking this whole + // (nonisolated-callable) type @MainActor. + let hasTextResponder = MainActor.assumeIsolated { + if let responder = NSApp.keyWindow?.firstResponder, responder is NSText { + return true + } + return false + } + if hasTextResponder { return false } return true