on main help sign in
small changes
6d05d5aKujtim Hoxha
internal/tui/components/chat/editor.go+9−16
@@ -21,9 +21,7 @@ type editorCmp struct {
21 textarea textarea.Model
21 textarea textarea.Model
22}
22}
23
23
24−type FocusEditorMsg bool
24+type EditorKeyMaps struct {
25−
26−type focusedEditorKeyMaps struct {
27 Send key.Binding
25 Send key.Binding
28 OpenEditor key.Binding
26 OpenEditor key.Binding
29}
27}
@@ -34,10 +32,10 @@ type bluredEditorKeyMaps struct {
34 OpenEditor key.Binding
32 OpenEditor key.Binding
35}
33}
36
34
37−var KeyMaps = focusedEditorKeyMaps{
35+var editorMaps = EditorKeyMaps{
38 Send: key.NewBinding(
36 Send: key.NewBinding(
39− key.WithKeys("ctrl+s"),
37+ key.WithKeys("enter", "ctrl+s"),
40− key.WithHelp("ctrl+s", "send message"),
38+ key.WithHelp("enter", "send message"),
41 ),
39 ),
42 OpenEditor: key.NewBinding(
40 OpenEditor: key.NewBinding(
43 key.WithKeys("ctrl+e"),
41 key.WithKeys("ctrl+e"),
@@ -107,29 +105,24 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
107 m.session = msg
105 m.session = msg
108 }
106 }
109 return m, nil
107 return m, nil
110− case FocusEditorMsg:
111− if msg {
112− m.textarea.Focus()
113− return m, tea.Batch(textarea.Blink, util.CmdHandler(EditorFocusMsg(true)))
114− }
115 case tea.KeyMsg:
108 case tea.KeyMsg:
116 if key.Matches(msg, messageKeys.PageUp) || key.Matches(msg, messageKeys.PageDown) ||
109 if key.Matches(msg, messageKeys.PageUp) || key.Matches(msg, messageKeys.PageDown) ||
117 key.Matches(msg, messageKeys.HalfPageUp) || key.Matches(msg, messageKeys.HalfPageDown) {
110 key.Matches(msg, messageKeys.HalfPageUp) || key.Matches(msg, messageKeys.HalfPageDown) {
118 return m, nil
111 return m, nil
119 }
112 }
120− if key.Matches(msg, KeyMaps.OpenEditor) {
113+ if key.Matches(msg, editorMaps.OpenEditor) {
121 if m.app.CoderAgent.IsSessionBusy(m.session.ID) {
114 if m.app.CoderAgent.IsSessionBusy(m.session.ID) {
122 return m, util.ReportWarn("Agent is working, please wait...")
115 return m, util.ReportWarn("Agent is working, please wait...")
123 }
116 }
124 return m, openEditor()
117 return m, openEditor()
125 }
118 }
126 // if the key does not match any binding, return
119 // if the key does not match any binding, return
127− if m.textarea.Focused() && key.Matches(msg, KeyMaps.Send) {
120+ if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) {
128 return m, m.send()
121 return m, m.send()
129 }
122 }
130−
123+
131 // Handle Enter key
124 // Handle Enter key
132− if m.textarea.Focused() && msg.String() == "enter" {
125+ if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) {
133 value := m.textarea.Value()
126 value := m.textarea.Value()
134 if len(value) > 0 && value[len(value)-1] == '\\' {
127 if len(value) > 0 && value[len(value)-1] == '\\' {
135 // If the last character is a backslash, remove it and add a newline
128 // If the last character is a backslash, remove it and add a newline
@@ -163,7 +156,7 @@ func (m *editorCmp) GetSize() (int, int) {
163
156
164func (m *editorCmp) BindingKeys() []key.Binding {
157func (m *editorCmp) BindingKeys() []key.Binding {
165 bindings := []key.Binding{}
158 bindings := []key.Binding{}
166− bindings = append(bindings, layout.KeyMapToSlice(KeyMaps)...)
159+ bindings = append(bindings, layout.KeyMapToSlice(editorMaps)...)
167 return bindings
160 return bindings
168}
161}
169
162
internal/tui/components/chat/message.go+2−2
@@ -28,7 +28,7 @@ const (
28 assistantMessageType
28 assistantMessageType
29 toolMessageType
29 toolMessageType
30
30
31− maxResultHeight = 15
31+ maxResultHeight = 10
32)
32)
33
33
34var diffStyle = diff.NewStyleConfig(diff.WithShowHeader(false), diff.WithShowHunkHeader(false))
34var diffStyle = diff.NewStyleConfig(diff.WithShowHeader(false), diff.WithShowHunkHeader(false))
@@ -148,7 +148,7 @@ func renderAssistantMessage(
148 content = "*Finished without output*"
148 content = "*Finished without output*"
149 }
149 }
150
150
151− content = renderMessage(content, false, msg.ID == focusedUIMessageId, width, info...)
151+ content = renderMessage(content, false, true, width, info...)
152 messages = append(messages, uiMessage{
152 messages = append(messages, uiMessage{
153 ID: msg.ID,
153 ID: msg.ID,
154 messageType: assistantMessageType,
154 messageType: assistantMessageType,
internal/tui/tui.go−1
@@ -224,7 +224,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
224 a.app.Permissions.GrantPersistant(msg.Permission)
224 a.app.Permissions.GrantPersistant(msg.Permission)
225 case dialog.PermissionDeny:
225 case dialog.PermissionDeny:
226 a.app.Permissions.Deny(msg.Permission)
226 a.app.Permissions.Deny(msg.Permission)
227− cmd = util.CmdHandler(chat.FocusEditorMsg(true))
228 }
227 }
229 a.showPermissions = false
228 a.showPermissions = false
230 return a, cmd
229 return a, cmd