Skip to content

Commit c42a18a

Browse files
authored
Merge pull request #2098 from gtardif/revert_tui_changes
Revert "tui: improve tmux experience and simplify keyboard enhancements"
2 parents ddb7622 + f946c5d commit c42a18a

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

pkg/tui/tui.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ type appModel struct {
116116
// Focus state
117117
focusedPanel FocusedPanel
118118

119-
// keyboardEnhancements stores the last keyboard enhancements message.
120-
// When non-nil with Flags != 0, the terminal supports key disambiguation
121-
// (shift+enter, ctrl+i vs tab, etc.).
119+
// keyboardEnhancements stores the last keyboard enhancements message
122120
keyboardEnhancements *tea.KeyboardEnhancementsMsg
123121

122+
// keyboardEnhancementsSupported tracks whether the terminal supports keyboard enhancements
123+
keyboardEnhancementsSupported bool
124+
124125
// program holds a reference to the tea.Program so that we can
125126
// perform a full terminal release/restore cycle on focus events.
126127
program *tea.Program
@@ -246,20 +247,15 @@ func (m *appModel) SetProgram(p *tea.Program) {
246247
m.supervisor.SetProgram(p)
247248
}
248249

249-
// hasKeyboardEnhancements reports whether the terminal supports keyboard
250-
// enhancements (Kitty keyboard protocol). When true, keybindings like
251-
// shift+enter become available.
252-
func (m *appModel) hasKeyboardEnhancements() bool {
253-
return m.keyboardEnhancements != nil && m.keyboardEnhancements.Flags != 0
254-
}
255-
256250
// reapplyKeyboardEnhancements forwards the cached keyboard enhancements message
257-
// to the active editor so new/replaced instances pick up the terminal's key
258-
// disambiguation support.
251+
// to the active chat page and editor so new/replaced instances pick up the
252+
// terminal's key disambiguation support.
259253
func (m *appModel) reapplyKeyboardEnhancements() {
260254
if m.keyboardEnhancements == nil {
261255
return
262256
}
257+
updated, _ := m.chatPage.Update(*m.keyboardEnhancements)
258+
m.chatPage = updated.(chat.Page)
263259
editorModel, _ := m.editor.Update(*m.keyboardEnhancements)
264260
m.editor = editorModel.(editor.Editor)
265261
}
@@ -589,10 +585,14 @@ func (m *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
589585

590586
case tea.KeyboardEnhancementsMsg:
591587
m.keyboardEnhancements = &msg
592-
// Forward to editor (only component that uses it for keybinding config)
593-
editorModel, cmd := m.editor.Update(msg)
588+
m.keyboardEnhancementsSupported = msg.Flags != 0
589+
// Forward to content view
590+
updated, cmd := m.chatPage.Update(msg)
591+
m.chatPage = updated.(chat.Page)
592+
// Forward to editor
593+
editorModel, editorCmd := m.editor.Update(msg)
594594
m.editor = editorModel.(editor.Editor)
595-
return m, cmd
595+
return m, tea.Batch(cmd, editorCmd)
596596

597597
// --- Keyboard input ---
598598

@@ -1494,7 +1494,7 @@ func (m *appModel) Bindings() []key.Binding {
14941494
))
14951495

14961496
// Show newline help based on keyboard enhancement support
1497-
if m.hasKeyboardEnhancements() {
1497+
if m.keyboardEnhancementsSupported {
14981498
bindings = append(bindings, key.NewBinding(
14991499
key.WithKeys("shift+enter"),
15001500
key.WithHelp("Shift+Enter", "newline"),
@@ -2229,8 +2229,6 @@ func toFullscreenView(content, windowTitle string, working bool) tea.View {
22292229
view.MouseMode = tea.MouseModeCellMotion
22302230
view.BackgroundColor = styles.Background
22312231
view.WindowTitle = windowTitle
2232-
view.ReportFocus = true
2233-
view.KeyboardEnhancements.ReportEventTypes = true
22342232
if working {
22352233
view.ProgressBar = tea.NewProgressBar(tea.ProgressBarIndeterminate, 0)
22362234
}

0 commit comments

Comments
 (0)