Fix terminal notch lifecycle so open/close, hover, outside-click, focus, and opacity stay consistent.

fix: stabilize terminal notch open/close, focus, and opacity

Improve terminal tab behavior in notch by preventing hover re-open races, keeping outside-click close logic accurate, and reliably restoring terminal opacity/translucency after remounts. Also ensure terminal receives focus on open and resigns cleanly on close so keyboard input and close/open cycles behave consistently.
This commit is contained in:
Soham Sharma 2026-04-24 16:31:45 +08:00
commit f39785f920
5 changed files with 128 additions and 14 deletions

View file

@ -102,6 +102,7 @@ struct ExpandedItem {
class DynamicIslandViewCoordinator: ObservableObject {
static let shared = DynamicIslandViewCoordinator()
private var cancellables = Set<AnyCancellable>()
private var hoverOpenSuppressedUntil: Date = .distantPast
private static let tabOrder: [NotchViews] = [.home, .shelf, .timer, .stats, .colorPicker, .notes, .clipboard, .terminal, .extensionExperience]
@ -246,6 +247,14 @@ class DynamicIslandViewCoordinator: ObservableObject {
enforceMinimumNotchWidth()
}
var isHoverOpenSuppressed: Bool {
Date() < hoverOpenSuppressedUntil
}
func suppressHoverOpen(for duration: TimeInterval = 0.35) {
hoverOpenSuppressedUntil = Date().addingTimeInterval(max(0, duration))
}
private func handleStatsTabTransition(from oldValue: NotchViews, to newValue: NotchViews) {
guard oldValue != newValue else { return }
if newValue == .stats && Defaults[.enableStatsFeature] {