Skip to content

Fix keyboard input not working on Firefox/Safari (#507) #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jfuginay
Copy link
Contributor

@jfuginay jfuginay commented Aug 22, 2025

Problem

Users reported being unable to type anything when using Firefox on Mac, as well as Safari on various platforms. This was a critical issue affecting cross-browser compatibility.

Root Cause

The issue was caused by multiple factors:

  1. DirectKeyboardManager interference: The DirectKeyboardManager was creating a hidden input element even on desktop browsers, which could steal focus from the terminal
  2. Focus management: Firefox/Safari handle focus differently than Chrome, and the session-view element wasn't getting focus properly
  3. Event target detection: The keyboard event handler wasn't properly checking for null/undefined targets in Firefox/Safari

Solution

1. Fixed DirectKeyboardManager

  • Removed automatic creation of hidden input on initialization
  • Hidden input is now only created when actually needed (for mobile devices)
  • This prevents the hidden input from interfering with keyboard events on desktop

2. Improved Focus Management

  • Added immediate focus to session-view element when lifecycle is set up
  • Ensures keyboard events are properly captured in Firefox/Safari
  • Added slight delay to keyboard event listener attachment for DOM readiness

3. Enhanced Browser Compatibility

  • Fixed event target detection to handle null/undefined cases
  • Added optional chaining for better browser support
  • Improved closest() method checks with fallback for older browsers

4. Added Debugging

  • Added logging to help diagnose keyboard event issues
  • Logs key events, target element, and active element for troubleshooting

Testing

Confirmed working by author:

  • Keyboard input now works on Firefox (Mac)
  • Keyboard input now works on Safari (Mac)
  • Chrome functionality remains unchanged
  • Mobile keyboard handling is preserved

Screenshots

The author has screenshots confirming the fix works on both Firefox and Safari.
Screenshot 2025-08-21 at 7 56 13 PM
Screenshot 2025-08-21 at 7 56 06 PM
Screenshot 2025-08-21 at 7 55 52 PM
Screenshot 2025-08-21 at 8 16 07 PM

Fixes

Closes #507

- Fixed DirectKeyboardManager creating hidden input on desktop, which was stealing focus
- Added immediate focus to session-view element for Firefox/Safari compatibility
- Improved browser compatibility for event target detection
- Added debugging logs to help diagnose keyboard event issues
- Fixed optional chaining for better browser support

Fixes amantus-ai#507
@jfuginay
Copy link
Contributor Author

I think we got off on the wrong foot. Just a dude genuinely trying to help.

@jfuginay
Copy link
Contributor Author

Screenshot 2025-08-22 at 9 54 00 PM

Link to dmg I compiled to test my fix locally:

https://drive.google.com/file/d/1jU_xvcUJd4xmKtsu7UrA8wFMk8NLePKF/view?usp=drive_link

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.

Cannot type anything on firefox mac
1 participant