CodeEditSourceEditor icon indicating copy to clipboard operation
CodeEditSourceEditor copied to clipboard

Fix code completion window visibility issues

Open lucasmotta opened this issue 3 months ago • 1 comments

Summary

https://github.com/user-attachments/assets/6a9ad280-54e0-4bcc-b015-6fc8a22e0660

Fixes intermittent visibility problems where the code completion window would not appear visually despite functioning correctly for keyboard navigation.

Fixes #351

Changes Made

  • Window Style Mask: Replaced problematic .nonactivatingPanel and .utilityWindow with .borderless
  • Window Hiding Behavior: Changed hidesOnDeactivate from true to false
  • Window Properties: Added canHide = false and acceptsMouseMovedEvents = true
  • Window Ordering: Improved window showing sequence in showWindow(attachedTo:)
  • Resource Cleanup: Added proper cleanup of notification observers in close()

Root Cause

The .nonactivatingPanel style mask was preventing the window from becoming key, which caused:

  • The console warning: canBecomeKeyWindow returned NO
  • Inconsistent window visibility despite functional keyboard navigation

Solution

Using .borderless provides the clean appearance needed for code completion while ensuring reliable window display. This style mask is ideal for popover-style UI elements as it gives full control over positioning and appearance without the activation issues.

Test Plan

  • [x] Code completion window appears consistently when triggered
  • [x] Keyboard navigation (up/down arrows, Tab, Escape) works correctly
  • [x] Window positioning and sizing work as expected
  • [x] No more canBecomeKeyWindow console warnings
  • [x] Window closes properly when focus is lost

🤖 Generated with Claude Code

lucasmotta avatar Sep 29 '25 17:09 lucasmotta

I haven't had a chance to play with this yet but we do want to allow the user to resize the window horizontally. Can we make sure that's still happening after removing the .resizable flag?

thecoolwinter avatar Sep 29 '25 23:09 thecoolwinter