From a399fc33298d367428491647b2159a9c7e243aa6 Mon Sep 17 00:00:00 2001 From: Florent Lothon Date: Wed, 6 May 2026 16:10:57 +0200 Subject: [PATCH] fix: start playback from selected page and install key monitor in pinned mode Two bugs fixed: 1. Clicking a page in the sidebar then pressing Play always started from page 1 instead of the selected page. Root cause: the `sidebarSelection` setter wrapped the `currentPageIndex` update in `DispatchQueue.main.async`, deferring it asynchronously. Since SwiftUI binding setters are already called on the main thread, this wrapper was unnecessary and caused `run()` to read the stale value (0) before the update applied. Fix: remove the async dispatch so `currentPageIndex` is updated synchronously on selection. 2. `showPinned()` was the only display mode not calling `installKeyMonitor()`, so the ESC key did not work to dismiss the overlay in pinned mode. Co-Authored-By: Claude Sonnet 4.6 --- Textream/Textream/ContentView.swift | 6 ++---- Textream/Textream/NotchOverlayController.swift | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Textream/Textream/ContentView.swift b/Textream/Textream/ContentView.swift index 773eb95..5e1d444 100644 --- a/Textream/Textream/ContentView.swift +++ b/Textream/Textream/ContentView.swift @@ -532,10 +532,8 @@ Happy presenting! [wave] get: { service.currentPageIndex }, set: { newValue in if let index = newValue { - DispatchQueue.main.async { - withAnimation(.easeInOut(duration: 0.15)) { - service.currentPageIndex = index - } + withAnimation(.easeInOut(duration: 0.15)) { + service.currentPageIndex = index } } } diff --git a/Textream/Textream/NotchOverlayController.swift b/Textream/Textream/NotchOverlayController.swift index d705171..09fa4e2 100644 --- a/Textream/Textream/NotchOverlayController.swift +++ b/Textream/Textream/NotchOverlayController.swift @@ -263,6 +263,8 @@ class NotchOverlayController: NSObject { if settings.notchDisplayMode == .followMouse { startMouseTracking() } + + installKeyMonitor() } private func showFollowCursor(settings: NotchSettings, screen: NSScreen) {