Notch stays open while the «Дела» popover is open
- isHeldOpen counts the open popover (only while the notch is expanded). - Any fold — ⌃, Escape, AppState hiding the island, setMode — clears the flag in AppState.mode's didSet, so a stale flag can neither hold the notch nor pop the menu up on the next opening. - When the popover closes with the pointer already away, the FSM gets mouseLeft, so the notch folds on its usual delay instead of waiting for the next hover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,11 @@ final class AppState: ObservableObject {
|
|||||||
static let shared = AppState()
|
static let shared = AppState()
|
||||||
|
|
||||||
// Island state
|
// Island state
|
||||||
@Published var mode: IslandMode = .hidden
|
@Published var mode: IslandMode = .hidden {
|
||||||
|
// The «Дела» popover lives only in the open notch: whatever folds it, the flag
|
||||||
|
// goes with it (a stale flag would hold the notch or pop the menu up later).
|
||||||
|
didSet { if mode != .expanded && botMenuOpen { botMenuOpen = false } }
|
||||||
|
}
|
||||||
@Published var view: IslandView = .overview {
|
@Published var view: IslandView = .overview {
|
||||||
didSet {
|
didSet {
|
||||||
// Any way into the chat (drop → "Задать вопрос", shortcuts…) lands in a brov-chat tab.
|
// Any way into the chat (drop → "Задать вопрос", shortcuts…) lands in a brov-chat tab.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ final class IslandWindowController: NSWindowController {
|
|||||||
let fsm = IslandStateMachine()
|
let fsm = IslandStateMachine()
|
||||||
|
|
||||||
private var wasInIsland = false
|
private var wasInIsland = false
|
||||||
|
private var botMenuSubscription: AnyCancellable?
|
||||||
private var frameTimer: Timer?
|
private var frameTimer: Timer?
|
||||||
private var keyMonitor: Any?
|
private var keyMonitor: Any?
|
||||||
private var viewSubscription: AnyCancellable?
|
private var viewSubscription: AnyCancellable?
|
||||||
@@ -181,6 +182,15 @@ final class IslandWindowController: NSWindowController {
|
|||||||
autoCloseSubscription = state.$autoCloseInterval.sink { [weak self] delay in
|
autoCloseSubscription = state.$autoCloseInterval.sink { [weak self] delay in
|
||||||
self?.fsm.homeToPetitDelay = delay
|
self?.fsm.homeToPetitDelay = delay
|
||||||
}
|
}
|
||||||
|
// «Дела» closed while the pointer is already away: fold as if it had just left,
|
||||||
|
// otherwise the notch would wait for the next hover.
|
||||||
|
botMenuSubscription = state.$botMenuOpen.dropFirst().removeDuplicates().sink { [weak self] open in
|
||||||
|
guard !open else { return }
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
guard let self, self.state.mode == .expanded, !self.wasInIsland else { return }
|
||||||
|
self.fsm.mouseLeft()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fsm.onTransition = { [weak self] from, to in
|
fsm.onTransition = { [weak self] from, to in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
@@ -231,6 +241,7 @@ final class IslandWindowController: NSWindowController {
|
|||||||
let s = AppState.shared
|
let s = AppState.shared
|
||||||
return s.pendingApproval != nil || (s.mode == .expanded && s.view.isTall)
|
return s.pendingApproval != nil || (s.mode == .expanded && s.view.isTall)
|
||||||
|| (s.mode == .expanded && s.translation != nil)
|
|| (s.mode == .expanded && s.translation != nil)
|
||||||
|
|| (s.mode == .expanded && s.botMenuOpen) // typing in «Дела»
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user