Skip to content

fix(app): prevent stale session hover preview on refocus#18727

Merged
nexxeln merged 1 commit intodevfrom
fix/app-refocus-hover-preview
Mar 23, 2026
Merged

fix(app): prevent stale session hover preview on refocus#18727
nexxeln merged 1 commit intodevfrom
fix/app-refocus-hover-preview

Conversation

@nexxeln
Copy link
Copy Markdown
Member

@nexxeln nexxeln commented Mar 23, 2026

summary

  • clear sidebar hover state when the app loses focus so delayed hover previews do not survive alt-tab
  • only open the delayed session hover preview when the trigger is still actually hovered

@nexxeln nexxeln requested a review from adamdotdevin as a code owner March 23, 2026 07:19
@nexxeln nexxeln enabled auto-merge (squash) March 23, 2026 07:20
Copy link
Copy Markdown

@atharvau atharvau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Overall Assessment: ✅ LGTM with minor suggestions

Security: ✅ No issues found

  • Event listeners properly cleaned up in onCleanup
  • No security vulnerabilities detected

Bugs: ✅ Good fix

  • Addresses the stale session hover preview issue correctly
  • Proper event handler cleanup prevents memory leaks

Performance: ✅ Good

  • Event listener management is efficient
  • Document visibility API usage is appropriate

Style: ⚠️ Minor improvements needed

Issues:

  1. Duplicate event listener: The blur event has two listeners which could be confusing
  2. Code organization: The reset function could be moved closer to other utility functions

Test Coverage: ❌ Missing

  • No tests found covering this UI interaction behavior
  • Consider adding tests for the refocus/visibility change scenarios

Breaking Changes: ✅ None

  • This is a bug fix with no API changes

The fix correctly addresses the stale preview issue by resetting state on window blur and document visibility changes.

@nexxeln nexxeln merged commit 5ea9545 into dev Mar 23, 2026
13 checks passed
@nexxeln nexxeln deleted the fix/app-refocus-hover-preview branch March 23, 2026 07:25
Copy link
Copy Markdown

@atharvau atharvau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Comments

Solid UX Fix

This addresses an annoying UI state bug where hover previews persist when they shouldn't.

🔍 Analysis

Problem: Session hover previews remain visible after alt-tabbing or losing app focus, creating stale/confusing UI state.

Solution:

  1. Clear hover state on window blur and visibility change
  2. Add hover validation before opening delayed previews

What's Great

  1. Comprehensive State Management:

    • Handles both blur and visibilitychange events
    • Consolidates cleanup logic in reset() function
  2. Race Condition Fix:

    • Checks ref?.matches(':hover') before opening preview
    • Prevents delayed previews from opening when mouse has moved away
  3. Clean Code:

    • Extracted reset() function reduces duplication
    • Proper event listener cleanup in onCleanup

🔵 Minor Observations

  1. Event Duplication: Both stop and blur are attached to window 'blur' event:

    This is intentional but could be confusing. Consider combining or commenting.

  2. Browser Support: matches(':hover') is well-supported but worth noting for older browsers

💡 Suggestions

  1. Consider debouncing: If there are rapid focus/blur events, the state resets might be excessive

  2. Edge case: What happens if user hovers while window is not visible? Current code handles this correctly.

🎯 Verdict

APPROVE - This is a well-thought-out fix for a legitimate UX issue. The solution is comprehensive and handles multiple edge cases.

The hover state management is now more robust and user-friendly. Good attention to detail on the race condition prevention.

Copy link
Copy Markdown

@atharvau atharvau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Comments

Solid UX Fix

This addresses an annoying UI state bug where hover previews persist when they shouldn't.

🔍 Analysis

Problem: Session hover previews remain visible after alt-tabbing or losing app focus, creating stale/confusing UI state.

Solution:

  1. Clear hover state on window blur and visibility change
  2. Add hover validation before opening delayed previews

What's Great

  1. Comprehensive State Management:

    • Handles both blur and visibilitychange events
    • Consolidates cleanup logic in reset() function
  2. Race Condition Fix:

    • Checks ref?.matches(':hover') before opening preview
    • Prevents delayed previews from opening when mouse has moved away
  3. Clean Code:

    • Extracted reset() function reduces duplication
    • Proper event listener cleanup in onCleanup

🔵 Minor Observations

  1. Event Duplication: Both stop and blur are attached to window blur event. This is intentional but could be confusing - consider combining or commenting.

  2. Browser Support: matches(':hover') is well-supported but worth noting for older browsers

💡 Suggestions

  1. Consider debouncing: If there are rapid focus/blur events, the state resets might be excessive

  2. Edge case: What happens if user hovers while window is not visible? Current code handles this correctly.

🎯 Verdict

APPROVE - This is a well-thought-out fix for a legitimate UX issue. The solution is comprehensive and handles multiple edge cases.

The hover state management is now more robust and user-friendly. Good attention to detail on the race condition prevention.

burn2delete pushed a commit to burn2delete/symbolic that referenced this pull request Mar 24, 2026
Andres77872 pushed a commit to Andres77872/opencode that referenced this pull request Mar 26, 2026
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.

2 participants