small changes

Kujtim Hoxha created

Change summary

internal/tui/components/chat/editor.go  | 25 +++++++++----------------
internal/tui/components/chat/message.go |  4 ++--
internal/tui/tui.go                     |  1 -
3 files changed, 11 insertions(+), 19 deletions(-)

Detailed changes

internal/tui/components/chat/editor.go 🔗

@@ -21,9 +21,7 @@ type editorCmp struct {
 	textarea textarea.Model
 }
 
-type FocusEditorMsg bool
-
-type focusedEditorKeyMaps struct {
+type EditorKeyMaps struct {
 	Send       key.Binding
 	OpenEditor key.Binding
 }
@@ -34,10 +32,10 @@ type bluredEditorKeyMaps struct {
 	OpenEditor key.Binding
 }
 
-var KeyMaps = focusedEditorKeyMaps{
+var editorMaps = EditorKeyMaps{
 	Send: key.NewBinding(
-		key.WithKeys("ctrl+s"),
-		key.WithHelp("ctrl+s", "send message"),
+		key.WithKeys("enter", "ctrl+s"),
+		key.WithHelp("enter", "send message"),
 	),
 	OpenEditor: key.NewBinding(
 		key.WithKeys("ctrl+e"),
@@ -107,29 +105,24 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			m.session = msg
 		}
 		return m, nil
-	case FocusEditorMsg:
-		if msg {
-			m.textarea.Focus()
-			return m, tea.Batch(textarea.Blink, util.CmdHandler(EditorFocusMsg(true)))
-		}
 	case tea.KeyMsg:
 		if key.Matches(msg, messageKeys.PageUp) || key.Matches(msg, messageKeys.PageDown) ||
 			key.Matches(msg, messageKeys.HalfPageUp) || key.Matches(msg, messageKeys.HalfPageDown) {
 			return m, nil
 		}
-		if key.Matches(msg, KeyMaps.OpenEditor) {
+		if key.Matches(msg, editorMaps.OpenEditor) {
 			if m.app.CoderAgent.IsSessionBusy(m.session.ID) {
 				return m, util.ReportWarn("Agent is working, please wait...")
 			}
 			return m, openEditor()
 		}
 		// if the key does not match any binding, return
-		if m.textarea.Focused() && key.Matches(msg, KeyMaps.Send) {
+		if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) {
 			return m, m.send()
 		}
-		
+
 		// Handle Enter key
-		if m.textarea.Focused() && msg.String() == "enter" {
+		if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) {
 			value := m.textarea.Value()
 			if len(value) > 0 && value[len(value)-1] == '\\' {
 				// If the last character is a backslash, remove it and add a newline
@@ -163,7 +156,7 @@ func (m *editorCmp) GetSize() (int, int) {
 
 func (m *editorCmp) BindingKeys() []key.Binding {
 	bindings := []key.Binding{}
-	bindings = append(bindings, layout.KeyMapToSlice(KeyMaps)...)
+	bindings = append(bindings, layout.KeyMapToSlice(editorMaps)...)
 	return bindings
 }
 

internal/tui/components/chat/message.go 🔗

@@ -28,7 +28,7 @@ const (
 	assistantMessageType
 	toolMessageType
 
-	maxResultHeight = 15
+	maxResultHeight = 10
 )
 
 var diffStyle = diff.NewStyleConfig(diff.WithShowHeader(false), diff.WithShowHunkHeader(false))
@@ -148,7 +148,7 @@ func renderAssistantMessage(
 			content = "*Finished without output*"
 		}
 
-		content = renderMessage(content, false, msg.ID == focusedUIMessageId, width, info...)
+		content = renderMessage(content, false, true, width, info...)
 		messages = append(messages, uiMessage{
 			ID:          msg.ID,
 			messageType: assistantMessageType,

internal/tui/tui.go 🔗

@@ -224,7 +224,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			a.app.Permissions.GrantPersistant(msg.Permission)
 		case dialog.PermissionDeny:
 			a.app.Permissions.Deny(msg.Permission)
-			cmd = util.CmdHandler(chat.FocusEditorMsg(true))
 		}
 		a.showPermissions = false
 		return a, cmd