From c42d94c465876b3dccfd4244b5efc15f2d3b8bf1 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Thu, 24 Apr 2025 13:01:32 +0200 Subject: small fixes --- internal/tui/components/chat/editor.go | 5 ----- internal/tui/components/chat/list.go | 22 ++++++++++++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'internal/tui/components/chat') diff --git a/internal/tui/components/chat/editor.go b/internal/tui/components/chat/editor.go index bb431053a..12ed3019f 100644 --- a/internal/tui/components/chat/editor.go +++ b/internal/tui/components/chat/editor.go @@ -116,11 +116,6 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return m, openEditor() } - // if the key does not match any binding, return - if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) { - return m, m.send() - } - // Handle Enter key if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) { value := m.textarea.Value() diff --git a/internal/tui/components/chat/list.go b/internal/tui/components/chat/list.go index 3ed98f6b8..9333cc9e9 100644 --- a/internal/tui/components/chat/list.go +++ b/internal/tui/components/chat/list.go @@ -83,6 +83,14 @@ func (m *messagesCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.rendering = false return m, nil + case tea.KeyMsg: + if key.Matches(msg, messageKeys.PageUp) || key.Matches(msg, messageKeys.PageDown) || + key.Matches(msg, messageKeys.HalfPageUp) || key.Matches(msg, messageKeys.HalfPageDown) { + u, cmd := m.viewport.Update(msg) + m.viewport = u + cmds = append(cmds, cmd) + } + case renderFinishedMsg: m.rendering = false m.viewport.GotoBottom() @@ -141,10 +149,6 @@ func (m *messagesCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } - u, cmd := m.viewport.Update(msg) - m.viewport = u - cmds = append(cmds, cmd) - spinner, cmd := m.spinner.Update(msg) m.spinner = spinner cmds = append(cmds, cmd) @@ -352,6 +356,16 @@ func (m *messagesCmp) help() string { styles.BaseStyle.Foreground(styles.Forground).Bold(true).Render("esc"), styles.BaseStyle.Foreground(styles.ForgroundDim).Bold(true).Render(" to exit cancel"), ) + } else { + text += lipgloss.JoinHorizontal( + lipgloss.Left, + styles.BaseStyle.Foreground(styles.ForgroundDim).Bold(true).Render("press "), + styles.BaseStyle.Foreground(styles.Forground).Bold(true).Render("enter"), + styles.BaseStyle.Foreground(styles.ForgroundDim).Bold(true).Render(" to send the message,"), + styles.BaseStyle.Foreground(styles.ForgroundDim).Bold(true).Render(" write"), + styles.BaseStyle.Foreground(styles.Forground).Bold(true).Render(" \\"), + styles.BaseStyle.Foreground(styles.ForgroundDim).Bold(true).Render(" and enter to add a new line"), + ) } return styles.BaseStyle. Width(m.width). -- cgit v1.2.3