feat(macos): bring reconnect forward when a UI surface opens mid-backoff#18
Merged
Conversation
After PR #16 added exponential reconnect backoff (up to 5 min), a disconnected bulb could sit on a multi-minute backoff with no way to hurry it short of hitting Reconnect. Opening the menu-bar dropdown only called `refreshIfConnected`, a no-op while disconnected. Treat opening a UI surface as a fresh chance to reach the bulb: rename the shared open handler to `refreshOnOpen`, and when we're mid auto-reconnect (dropped but not manually disconnected) reset the backoff and pull the next attempt forward (~0.5 s) — the same bring-forward `handlePathChange` already uses on a network change. A connected light still just re-reads its values, and a deliberate disconnect is left untouched, so opening the menu never resurrects it. Wired into both open events that shared the old method: the menu-bar dropdown (`menuWillOpen`) and the controls window's `onAppear` (under auto-sync).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
After #16 added exponential reconnect backoff (15 s -> 5 min ceiling), a disconnected bulb could sit on a multi-minute backoff with no quick way to hurry it short of hitting Reconnect. Opening the menu-bar dropdown only called
refreshIfConnected, which is a no-op while disconnected.This treats opening a UI surface as a fresh chance to reach the bulb -- but only when we're actually mid auto-reconnect:
How
refreshIfConnected->refreshOnOpenand added the mid-reconnect branch. The bring-forward reuses the exactresetReconnectBackoff()+scheduleNextPoll(after: 0.5)thathandlePathChangeuses on a network change, and relies onpollTick's existing guards so it can't stack onto an in-flight connect.menuWillOpen) and the controls window'sonAppear(still gated onautoSync).Testing
swift build-- cleanswift test-- 15/15 passDispatchSource/NWPathMonitor) isn't covered by the suite, so the bring-forward was reasoned against the existinghandlePathChangeflow rather than unit-tested.