Skip to content

Commit 0ef9c83

Browse files
committed
Fixed tooltip glitch
1 parent 87ae105 commit 0ef9c83

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

interview_coder/AppModel.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ final class AppModel: NSObject, ObservableObject {
5050
@Published var availableSessions: [SessionInfo] = []
5151
@Published var selectedSessionURL: URL? = nil
5252
@Published var hotkeysEnabled: Bool = true
53+
@Published var tooltipsEnabled: Bool = true
5354
// Session preview overlays
5455
@Published var previewImported: ImportedFile? = nil
5556
@Published var previewText: String? = nil
@@ -220,6 +221,15 @@ final class AppModel: NSObject, ObservableObject {
220221
KeyboardMonitor.setManualInputOpen(true)
221222
updateWindowSizeForState(animated: false)
222223
}
224+
225+
// Manage tooltips to avoid stale hover popovers when app activates
226+
NotificationCenter.default.addObserver(forName: NSApplication.didResignActiveNotification, object: nil, queue: .main) { [weak self] _ in
227+
self?.tooltipsEnabled = false
228+
}
229+
NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: .main) { [weak self] _ in
230+
self?.tooltipsEnabled = false
231+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) { self?.tooltipsEnabled = true }
232+
}
223233
}
224234

225235
struct SessionInfo: Identifiable, Hashable {

interview_coder/PanelView.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ private var headerBar: some View { DragHost { headerContent }.zIndex(2) }
339339
progressActive: model.ttsProgress != nil,
340340
duration: model.ttsDuration,
341341
elapsed: model.ttsElapsed,
342+
tooltipsEnabled: model.tooltipsEnabled,
342343
onBack15: { model.skipBackward15() },
343344
onPlayPause: { model.toggleSpeakResponse() },
344345
onForward15: { model.skipForward15() },
@@ -1208,6 +1209,7 @@ private struct TTSControlsView: View, Equatable {
12081209
let progressActive: Bool
12091210
let duration: TimeInterval
12101211
let elapsed: TimeInterval
1212+
let tooltipsEnabled: Bool
12111213
let onBack15: () -> Void
12121214
let onPlayPause: () -> Void
12131215
let onForward15: () -> Void
@@ -1220,15 +1222,15 @@ private struct TTSControlsView: View, Equatable {
12201222

12211223
var body: some View {
12221224
HStack(spacing: 8) {
1223-
Button(action: onBack15) { Image(systemName: "gobackward.15") }.buttonStyle(.plain).help("Back 15s (⇧⌘,)")
1225+
Button(action: onBack15) { Image(systemName: "gobackward.15") }.buttonStyle(.plain).help(tooltipsEnabled ? "Back 15s (⇧⌘,)" : "")
12241226
Button(action: onPlayPause) {
12251227
HStack(spacing: 6) {
12261228
Image(systemName: isSpeaking ? "pause.circle" : "play.circle")
12271229
Text(isSpeaking ? "Pause (⌘;)" : "Play (⌘;)")
12281230
}
1229-
}.buttonStyle(.plain).help("Play/Pause TTS")
1230-
Button(action: onForward15) { Image(systemName: "goforward.15") }.buttonStyle(.plain).help("Forward 15s (⇧⌘.)")
1231-
Button(action: onToggleRate) { Text(rateIndex == 0 ? "1x" : (rateIndex == 1 ? "1.5x" : "2x")) }.buttonStyle(.plain).help("Toggle speed (⇧⌘;)")
1231+
}.buttonStyle(.plain).help(tooltipsEnabled ? "Play/Pause TTS" : "")
1232+
Button(action: onForward15) { Image(systemName: "goforward.15") }.buttonStyle(.plain).help(tooltipsEnabled ? "Forward 15s (⇧⌘.)" : "")
1233+
Button(action: onToggleRate) { Text(rateIndex == 0 ? "1x" : (rateIndex == 1 ? "1.5x" : "2x")) }.buttonStyle(.plain).help(tooltipsEnabled ? "Toggle speed (⇧⌘;)" : "")
12321234
if progressActive {
12331235
ProgressView().controlSize(.small).scaleEffect(0.75).frame(width: 14, height: 14)
12341236
} else if duration > 0 {
@@ -1237,7 +1239,7 @@ private struct TTSControlsView: View, Equatable {
12371239
let eStr = String(format: "%02d:%02d", e / 60, e % 60)
12381240
let dStr = String(format: "%02d:%02d", d / 60, d % 60)
12391241
Text("\(eStr)/\(dStr)").font(.caption).foregroundStyle(.secondary)
1240-
Button(action: onRestart) { Image(systemName: "gobackward") }.buttonStyle(.plain).help("Restart (⌘')")
1242+
Button(action: onRestart) { Image(systemName: "gobackward") }.buttonStyle(.plain).help(tooltipsEnabled ? "Restart (⌘')" : "")
12411243
}
12421244
}
12431245
.allowsHitTesting(isInteractive)

0 commit comments

Comments
 (0)