[PR #8275] fix(prompt-input): handle Shift+Enter before IME check to prevent stuck state #12685

Closed
opened 2026-02-16 18:17:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8275

State: closed
Merged: Yes


Summary

Fixes two related issues with newline input in the prompt:

  1. Ctrl+J, Ctrl+Enter, Alt+Enter don't work - The input_newline keybind was defined in config but never used; only Shift+Enter was hardcoded
  2. Shift+Enter intermittently stops working - The IME composing check blocks all Enter-based keybinds when the composing signal gets stuck

Problem

Issue 1: Keybinds not implemented

The config defines input_newline: 'shift+return,ctrl+return,alt+return,ctrl+j' but the code only checked for event.shiftKey && event.key === 'Enter'. This meant Ctrl+J and other alternatives never worked.

Issue 2: IME composing state gets stuck

The IME composing check ran before the newline handler. If the composing signal got stuck in true state (e.g., if compositionend event never fired), all Enter keypresses were ignored.

This manifests as:

  • Newline keybinds work initially
  • At some point they stop working entirely
  • Only deleting the session restores functionality

Solution

  1. Use proper keybind matching - Import parseKeybind/matchKeybind and use the config's input_newline keybind instead of hardcoding
  2. Move newline check before IME check - Newline keybinds are never used for IME input
  3. Reset composing on focus loss - Safety net to prevent stuck state

Testing

  • All existing tests pass (47 keybind tests, 12 app tests)
  • Typecheck passes
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8275 **State:** closed **Merged:** Yes --- ## Summary Fixes two related issues with newline input in the prompt: 1. **Ctrl+J, Ctrl+Enter, Alt+Enter don't work** - The `input_newline` keybind was defined in config but never used; only Shift+Enter was hardcoded 2. **Shift+Enter intermittently stops working** - The IME composing check blocks all Enter-based keybinds when the composing signal gets stuck ## Problem ### Issue 1: Keybinds not implemented The config defines `input_newline: 'shift+return,ctrl+return,alt+return,ctrl+j'` but the code only checked for `event.shiftKey && event.key === 'Enter'`. This meant Ctrl+J and other alternatives never worked. ### Issue 2: IME composing state gets stuck The IME composing check ran before the newline handler. If the `composing` signal got stuck in `true` state (e.g., if `compositionend` event never fired), all Enter keypresses were ignored. This manifests as: - Newline keybinds work initially - At some point they stop working entirely - Only deleting the session restores functionality ## Solution 1. **Use proper keybind matching** - Import `parseKeybind`/`matchKeybind` and use the config's `input_newline` keybind instead of hardcoding 2. **Move newline check before IME check** - Newline keybinds are never used for IME input 3. **Reset composing on focus loss** - Safety net to prevent stuck state ## Testing - All existing tests pass (47 keybind tests, 12 app tests) - Typecheck passes
yindo added the pull-request label 2026-02-16 18:17:34 -05:00
yindo closed this issue 2026-02-16 18:17:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12685