summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-23 12:15:23 +0200
committerKujtim Hoxha <[email protected]>2025-04-24 16:40:36 +0200
commit6d05d5a7c3bf29bd0586504e8721550c8a10dc4c (patch)
tree12678fe762e0c301bb190a3750524fb4846de968
parent2c5003e3fc94766cf848962ea0ffe94875c35d2b (diff)
downloadopencode-6d05d5a7c3bf29bd0586504e8721550c8a10dc4c.tar.gz
opencode-6d05d5a7c3bf29bd0586504e8721550c8a10dc4c.zip
small changes
-rw-r--r--internal/tui/components/chat/editor.go25
-rw-r--r--internal/tui/components/chat/message.go4
-rw-r--r--internal/tui/tui.go1
3 files changed, 11 insertions, 19 deletions
diff --git a/internal/tui/components/chat/editor.go b/internal/tui/components/chat/editor.go
index 2d89803cd..bb431053a 100644
--- a/internal/tui/components/chat/editor.go
+++ b/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
}
diff --git a/internal/tui/components/chat/message.go b/internal/tui/components/chat/message.go
index b8e450079..bc6c19e40 100644
--- a/internal/tui/components/chat/message.go
+++ b/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,
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 9744c4cf2..213700d6c 100644
--- a/internal/tui/tui.go
+++ b/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