Skip to content

Commit de371aa

Browse files
authored
Fix community apply cancelling every time due to a focus race (#259)
fix: reactivate Codex before the community-apply rollback verification DreamSkin is an LSUIElement (menu-bar only, no Dock icon). Once its own confirmation alert closes, macOS never automatically hands focus back to Codex. That leaves document.visibilityState stuck on "hidden" in the Codex renderer, so captureActiveThemeThenApplyImported's rollback- snapshot verification spuriously fails and cancels every community apply within its full 12s/24-attempt retry budget, even though the visible theme content is correct. Confirmed live: the exact preserved rollback snapshot from a failed attempt passes injector --verify immediately when Codex is manually reactivated first, proving the snapshot content was never the problem.
1 parent 3714afe commit de371aa

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

macos/menubar-app/Sources/CodexDreamSkinMenuBar/AppDelegate.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
813813
)
814814
return
815815
}
816+
reactivateCodexBeforeTransaction()
816817
updateCommunityStage("正在保存当前主题、应用新主题并验证渲染…")
817818
ScriptRunner.run(
818819
script: transactionScript,
@@ -1283,6 +1284,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
12831284
NSApp.activate(ignoringOtherApps: true)
12841285
}
12851286

1287+
/// DreamSkin is an LSUIElement with no Dock icon or regular window, so
1288+
/// macOS does not automatically return focus to Codex once this app's own
1289+
/// alert closes. Without this, `document.visibilityState` in the Codex
1290+
/// renderer stays "hidden" for the confirm dialog's caller, so the
1291+
/// rollback-snapshot verification in captureActiveThemeThenApplyImported
1292+
/// spuriously fails and cancels every community apply even though the
1293+
/// visible theme content is correct.
1294+
private func reactivateCodexBeforeTransaction() {
1295+
NSRunningApplication.runningApplications(withBundleIdentifier: "com.openai.codex")
1296+
.first?.activate(options: [.activateIgnoringOtherApps])
1297+
}
1298+
12861299
private func showInfo(title: String, message: String) {
12871300
let alert = NSAlert()
12881301
alert.messageText = title

0 commit comments

Comments
 (0)