Skip to content

Fix Shift+Enter, Option+Delete, Cmd+Delete in task form fields#541

Open
bborn wants to merge 2 commits into
mainfrom
task/3304-fix-keyboard-shortcuts-in-task-form-fiel
Open

Fix Shift+Enter, Option+Delete, Cmd+Delete in task form fields#541
bborn wants to merge 2 commits into
mainfrom
task/3304-fix-keyboard-shortcuts-in-task-form-fiel

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented May 15, 2026

Summary

  • The task form's title and details fields didn't respond to Shift+Enter, Option+Delete, or Cmd+Delete on modern macOS terminals (Ghostty, WezTerm, Kitty, iTerm2 with modifyOtherKeys).
  • Those terminals send CSI-u sequences like \x1b[13;2u and \x1b[127;9u, which Bubble Tea v1.3.10 emits as unknownCSISequenceMsg rather than tea.KeyMsg. The form only inspected tea.KeyMsg, so the keys went nowhere.
  • Translate the recognized CSI-u and xterm modifyOtherKeys sequences back into canonical tea.KeyMsg values at the top of FormModel.Update. The existing textinput/textarea bindings then do the work — no new edit logic.

Mappings applied:

  • Shift+Enter → newline in the body field
  • Option+Delete / Option+Backspace → delete previous word
  • Cmd+Delete / Cmd+Backspace → delete to start of line (matches macOS native behavior)
  • Cmd+Left / Cmd+Right → jump to line start / line end

Unknown CSI sequences pass through unchanged, so non-targeted behavior is identical to before.

Test plan

  • go test ./... — all packages pass
  • go test ./internal/ui/ -count=1 -race — clean under the race detector
  • go vet ./... — clean
  • New unit tests in internal/ui/key_csi_test.go exercise real unknownCSISequenceMsg values produced by a live Bubble Tea program and confirm each sequence maps to the right tea.KeyMsg (and that unknown / non-CSI messages pass through untouched).
  • New integration tests in internal/ui/form_modern_keys_test.go drive FormModel.Update and verify body/title edits for Shift+Enter, Option+Delete, and Cmd+Delete in both kitty and modifyOtherKeys forms — and confirm the legacy tea.KeyMsg paths still work.
  • Manual: open the new-task form in Ghostty/iTerm2 (modifyOtherKeys), type into details, press Shift+Enter for a newline, Option+Delete to remove a word, Cmd+Delete to clear the line.

Notes / limitations

  • Default macOS Terminal.app does not send these sequences unless "Use Option as Meta key" is enabled and/or modifyOtherKeys is requested. This PR doesn't enable the kitty keyboard protocol from our side — it just consumes the sequences if the terminal already sends them.

🤖 Generated with Claude Code

bborn and others added 2 commits May 15, 2026 14:16
Modern macOS terminals (Ghostty, WezTerm, Kitty, iTerm2 with
modifyOtherKeys) send CSI-u escape sequences for keys like Shift+Enter
and Cmd+Delete. Bubble Tea v1.3.10 reports these as unknownCSISequenceMsg
rather than tea.KeyMsg, so they never reached the textinput/textarea
bindings and silently did nothing in the new-task and edit-task forms.

Translate the recognized sequences back into canonical tea.KeyMsg values
at the top of FormModel.Update so the existing handlers do the work:

- Shift+Enter -> KeyEnter (textarea inserts newline)
- Option+Delete/Backspace -> alt+backspace (DeleteWordBackward)
- Cmd+Delete/Backspace -> ctrl+u (DeleteBeforeCursor)
- Cmd+Left / Cmd+Right -> ctrl+a / ctrl+e (line start/end)

Unknown CSI sequences pass through unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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