-
Notifications
You must be signed in to change notification settings - Fork 303
Revert "tui: improve tmux experience and simplify keyboard enhancements" #2098
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,11 +116,12 @@ type appModel struct { | |
| // Focus state | ||
| focusedPanel FocusedPanel | ||
|
|
||
| // keyboardEnhancements stores the last keyboard enhancements message. | ||
| // When non-nil with Flags != 0, the terminal supports key disambiguation | ||
| // (shift+enter, ctrl+i vs tab, etc.). | ||
| // keyboardEnhancements stores the last keyboard enhancements message | ||
| keyboardEnhancements *tea.KeyboardEnhancementsMsg | ||
|
|
||
| // keyboardEnhancementsSupported tracks whether the terminal supports keyboard enhancements | ||
| keyboardEnhancementsSupported bool | ||
|
|
||
| // program holds a reference to the tea.Program so that we can | ||
| // perform a full terminal release/restore cycle on focus events. | ||
| program *tea.Program | ||
|
|
@@ -246,20 +247,15 @@ func (m *appModel) SetProgram(p *tea.Program) { | |
| m.supervisor.SetProgram(p) | ||
| } | ||
|
|
||
| // hasKeyboardEnhancements reports whether the terminal supports keyboard | ||
| // enhancements (Kitty keyboard protocol). When true, keybindings like | ||
| // shift+enter become available. | ||
| func (m *appModel) hasKeyboardEnhancements() bool { | ||
| return m.keyboardEnhancements != nil && m.keyboardEnhancements.Flags != 0 | ||
| } | ||
|
|
||
| // reapplyKeyboardEnhancements forwards the cached keyboard enhancements message | ||
| // to the active editor so new/replaced instances pick up the terminal's key | ||
| // disambiguation support. | ||
| // to the active chat page and editor so new/replaced instances pick up the | ||
| // terminal's key disambiguation support. | ||
| func (m *appModel) reapplyKeyboardEnhancements() { | ||
| if m.keyboardEnhancements == nil { | ||
| return | ||
| } | ||
| updated, _ := m.chatPage.Update(*m.keyboardEnhancements) | ||
| m.chatPage = updated.(chat.Page) | ||
| editorModel, _ := m.editor.Update(*m.keyboardEnhancements) | ||
| m.editor = editorModel.(editor.Editor) | ||
| } | ||
|
|
@@ -589,10 +585,14 @@ func (m *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | |
|
|
||
| case tea.KeyboardEnhancementsMsg: | ||
| m.keyboardEnhancements = &msg | ||
| // Forward to editor (only component that uses it for keybinding config) | ||
| editorModel, cmd := m.editor.Update(msg) | ||
| m.keyboardEnhancementsSupported = msg.Flags != 0 | ||
| // Forward to content view | ||
| updated, cmd := m.chatPage.Update(msg) | ||
| m.chatPage = updated.(chat.Page) | ||
| // Forward to editor | ||
| editorModel, editorCmd := m.editor.Update(msg) | ||
| m.editor = editorModel.(editor.Editor) | ||
| return m, cmd | ||
| return m, tea.Batch(cmd, editorCmd) | ||
|
|
||
| // --- Keyboard input --- | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 LIKELY: Keyboard enhancements may not reach all nested components The code forwards Impact: Some nested UI components may not properly configure keyboard shortcuts that depend on terminal capabilities. Recommendation: Verify that the messages component and its inline edit textarea properly handle keyboard enhancement messages. |
||
|
|
||
|
|
@@ -1494,7 +1494,7 @@ func (m *appModel) Bindings() []key.Binding { | |
| )) | ||
|
|
||
| // Show newline help based on keyboard enhancement support | ||
| if m.hasKeyboardEnhancements() { | ||
| if m.keyboardEnhancementsSupported { | ||
| bindings = append(bindings, key.NewBinding( | ||
| key.WithKeys("shift+enter"), | ||
| key.WithHelp("Shift+Enter", "newline"), | ||
|
|
@@ -2229,8 +2229,6 @@ func toFullscreenView(content, windowTitle string, working bool) tea.View { | |
| view.MouseMode = tea.MouseModeCellMotion | ||
| view.BackgroundColor = styles.Background | ||
| view.WindowTitle = windowTitle | ||
| view.ReportFocus = true | ||
| view.KeyboardEnhancements.ReportEventTypes = true | ||
| if working { | ||
| view.ProgressBar = tea.NewProgressBar(tea.ProgressBarIndeterminate, 0) | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 CONFIRMED: Removed view config may prevent keyboard enhancement detection This revert removes The problem: If the view no longer requests keyboard enhancement events via Impact: The Recommendation: Either keep |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 CONFIRMED: Chat page lacks keyboard enhancement tracking
The
reapplyKeyboardEnhancements()method forwards the keyboard enhancements message to both the chat page and editor. However, the chat page component (pkg/tui/page/chat/chat.go) does not have akeyboardEnhancementsSupportedfield like the editor does.Impact: If the chat page needs to make decisions based on keyboard enhancement support (e.g., keybinding configuration for inline editing), it won't have that information available after reapply.
Recommendation: Consider adding a
keyboardEnhancementsSupportedfield to the chat page component, similar to the editor component.