Skip to content

Fix floating bar notification collapse state#5736

Merged
kodjima33 merged 1 commit intomainfrom
fix/floating-bar-notification-collapse
Mar 17, 2026
Merged

Fix floating bar notification collapse state#5736
kodjima33 merged 1 commit intomainfrom
fix/floating-bar-notification-collapse

Conversation

@kodjima33
Copy link
Copy Markdown
Collaborator

Summary

  • track hover state on the actual floating control bar instead of the full notification container
  • use that explicit hover state when collapsing after a notification dismisses
  • prevent the compact floating line from staying expanded because the cursor was inside the old notification frame

Verification

  • xcrun swift build -c debug --package-path Desktop

@kodjima33 kodjima33 merged commit d046563 into main Mar 17, 2026
2 checks passed
@kodjima33 kodjima33 deleted the fix/floating-bar-notification-collapse branch March 17, 2026 06:57
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 17, 2026

Greptile Summary

This PR fixes a UI bug where the compact floating bar would incorrectly remain in its expanded state after a notification was dismissed, caused by the hover-detection logic checking the entire window frame (including the now-gone notification area) rather than the actual control bar.

Key changes:

  • Adds isHoveringBar: Bool to FloatingControlBarState as the single source of truth for whether the cursor is over the actual bar chrome.
  • Moves the .onHover modifier from the outer body VStack (which encompassed the notification view) down to barChrome only, and extracts the handler into handleBarHover(_:) which also writes state.isHoveringBar.
  • Replaces frame.contains(NSEvent.mouseLocation) in dismissNotification() with state.isHoveringBar, so the post-dismiss target size correctly reflects bar hover state rather than the stale full-window-frame hit test.

Confidence Score: 5/5

  • This PR is safe to merge — the changes are tightly scoped, logically correct, and address a well-defined UI regression with a clean solution.
  • The fix is minimal and targeted: it adds one state property, moves one modifier, and replaces one hit-test call. The new isHoveringBar flag is set synchronously in the hover handler before any window resize occurs, so there are no timing or race-condition concerns. The @MainActor-annotated state ensures thread safety. No existing logic paths are altered other than the notification-dismiss resize decision.
  • No files require special attention.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/FloatingControlBar/FloatingControlBarState.swift Adds isHoveringBar: Bool published property to track explicit bar hover state — a clean, minimal state addition that enables the fix in the window layer.
desktop/Desktop/Sources/FloatingControlBar/FloatingControlBarView.swift Moves .onHover from the full notification+bar VStack to barChrome only, and extracts it into handleBarHover which now also sets state.isHoveringBar. This correctly scopes hover tracking to the bar itself rather than the entire window frame.
desktop/Desktop/Sources/FloatingControlBar/FloatingControlBarWindow.swift In dismissNotification(), replaces frame.contains(NSEvent.mouseLocation) with state.isHoveringBar to determine post-dismiss size — this is the core bug fix, preventing the bar from remaining expanded when the cursor was in the notification area but not over the bar.

Sequence Diagram

sequenceDiagram
    participant User
    participant barChrome as barChrome (.onHover)
    participant State as FloatingControlBarState
    participant Window as FloatingControlBarWindow

    Note over User, Window: Notification is showing (window is tall)

    User->>barChrome: cursor enters bar area
    barChrome->>State: isHoveringBar = true
    barChrome->>Window: resizeForHover(expanded: true)

    User->>Window: clicks dismiss (xmark button)
    Window->>State: currentNotification = nil
    Window->>State: read isHoveringBar → true
    Window->>Window: targetSize = expandedBarSize
    Window->>Window: resizeAnchored(expandedBarSize)

    Note over User, Window: Bar stays expanded ✓ (cursor is over bar)

    User->>barChrome: cursor leaves bar
    barChrome->>State: isHoveringBar = false
    barChrome->>Window: resizeForHover(expanded: false)
    Window->>Window: resizeAnchored(minBarSize)

    Note over User, Window: Bar correctly collapses ✓

    Note over User, Window: Bug scenario (BEFORE fix)
    User->>Window: cursor was only in notification area
    User->>Window: clicks dismiss
    Window->>Window: frame.contains(mouseLocation) → true (stale frame)
    Window->>Window: targetSize = expandedBarSize ✗ (wrong!)
    Note over User, Window: Bar incorrectly stays expanded
Loading

Last reviewed commit: e762131

Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
## Summary
- track hover state on the actual floating control bar instead of the
full notification container
- use that explicit hover state when collapsing after a notification
dismisses
- prevent the compact floating line from staying expanded because the
cursor was inside the old notification frame

## Verification
- xcrun swift build -c debug --package-path Desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant