Skip to content

Commit 332243d

Browse files
committed
small changes
1 parent 4d9082c commit 332243d

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

internal/tui/components/chat/editor.go

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ type editorCmp struct {
2121
textarea textarea.Model
2222
}
2323

24-
type FocusEditorMsg bool
25-
26-
type focusedEditorKeyMaps struct {
24+
type EditorKeyMaps struct {
2725
Send key.Binding
2826
OpenEditor key.Binding
2927
}
@@ -34,10 +32,10 @@ type bluredEditorKeyMaps struct {
3432
OpenEditor key.Binding
3533
}
3634

37-
var KeyMaps = focusedEditorKeyMaps{
35+
var editorMaps = EditorKeyMaps{
3836
Send: key.NewBinding(
39-
key.WithKeys("ctrl+s"),
40-
key.WithHelp("ctrl+s", "send message"),
37+
key.WithKeys("enter", "ctrl+s"),
38+
key.WithHelp("enter", "send message"),
4139
),
4240
OpenEditor: key.NewBinding(
4341
key.WithKeys("ctrl+e"),
@@ -107,29 +105,24 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
107105
m.session = msg
108106
}
109107
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-
}
115108
case tea.KeyMsg:
116109
if key.Matches(msg, messageKeys.PageUp) || key.Matches(msg, messageKeys.PageDown) ||
117110
key.Matches(msg, messageKeys.HalfPageUp) || key.Matches(msg, messageKeys.HalfPageDown) {
118111
return m, nil
119112
}
120-
if key.Matches(msg, KeyMaps.OpenEditor) {
113+
if key.Matches(msg, editorMaps.OpenEditor) {
121114
if m.app.CoderAgent.IsSessionBusy(m.session.ID) {
122115
return m, util.ReportWarn("Agent is working, please wait...")
123116
}
124117
return m, openEditor()
125118
}
126119
// 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) {
128121
return m, m.send()
129122
}
130-
123+
131124
// Handle Enter key
132-
if m.textarea.Focused() && msg.String() == "enter" {
125+
if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) {
133126
value := m.textarea.Value()
134127
if len(value) > 0 && value[len(value)-1] == '\\' {
135128
// If the last character is a backslash, remove it and add a newline
@@ -163,7 +156,7 @@ func (m *editorCmp) GetSize() (int, int) {
163156

164157
func (m *editorCmp) BindingKeys() []key.Binding {
165158
bindings := []key.Binding{}
166-
bindings = append(bindings, layout.KeyMapToSlice(KeyMaps)...)
159+
bindings = append(bindings, layout.KeyMapToSlice(editorMaps)...)
167160
return bindings
168161
}
169162

internal/tui/components/chat/message.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828
assistantMessageType
2929
toolMessageType
3030

31-
maxResultHeight = 15
31+
maxResultHeight = 10
3232
)
3333

3434
var diffStyle = diff.NewStyleConfig(diff.WithShowHeader(false), diff.WithShowHunkHeader(false))
@@ -148,7 +148,7 @@ func renderAssistantMessage(
148148
content = "*Finished without output*"
149149
}
150150

151-
content = renderMessage(content, false, msg.ID == focusedUIMessageId, width, info...)
151+
content = renderMessage(content, false, true, width, info...)
152152
messages = append(messages, uiMessage{
153153
ID: msg.ID,
154154
messageType: assistantMessageType,

internal/tui/tui.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
224224
a.app.Permissions.GrantPersistant(msg.Permission)
225225
case dialog.PermissionDeny:
226226
a.app.Permissions.Deny(msg.Permission)
227-
cmd = util.CmdHandler(chat.FocusEditorMsg(true))
228227
}
229228
a.showPermissions = false
230229
return a, cmd

0 commit comments

Comments
 (0)