summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/components
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tui/internal/components')
-rw-r--r--packages/tui/internal/components/chat/editor.go28
-rw-r--r--packages/tui/internal/components/chat/messages.go4
2 files changed, 31 insertions, 1 deletions
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index c5ecdc21d..0c52ca84c 100644
--- a/packages/tui/internal/components/chat/editor.go
+++ b/packages/tui/internal/components/chat/editor.go
@@ -224,10 +224,17 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case dialog.CompletionSelectedMsg:
switch msg.Item.ProviderID {
case "commands":
- commandName := strings.TrimPrefix(msg.Item.Value, "/")
+ command := msg.Item.RawData.(commands.Command)
+ if command.Custom {
+ m.SetValue("/" + command.PrimaryTrigger() + " ")
+ return m, nil
+ }
+
updated, cmd := m.Clear()
m = updated.(*editorComponent)
cmds = append(cmds, cmd)
+
+ commandName := strings.TrimPrefix(msg.Item.Value, "/")
cmds = append(cmds, util.CmdHandler(commands.ExecuteCommandMsg(m.app.Commands[commands.CommandName(commandName)])))
return m, tea.Batch(cmds...)
case "files":
@@ -481,6 +488,25 @@ func (m *editorComponent) Submit() (tea.Model, tea.Cmd) {
}
var cmds []tea.Cmd
+ if strings.HasPrefix(value, "/") {
+ value = value[1:]
+ commandName := strings.Split(value, " ")[0]
+ command := m.app.Commands[commands.CommandName(commandName)]
+ if command.Custom {
+ args := strings.TrimPrefix(value, command.PrimaryTrigger()+" ")
+ cmds = append(
+ cmds,
+ util.CmdHandler(app.SendCommand{Command: string(command.Name), Args: args}),
+ )
+
+ updated, cmd := m.Clear()
+ m = updated.(*editorComponent)
+ cmds = append(cmds, cmd)
+
+ return m, tea.Batch(cmds...)
+ }
+ }
+
attachments := m.textarea.GetAttachments()
prompt := app.Prompt{Text: value, Attachments: attachments}
diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go
index 97c529721..a299d65af 100644
--- a/packages/tui/internal/components/chat/messages.go
+++ b/packages/tui/internal/components/chat/messages.go
@@ -174,6 +174,10 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.viewport.GotoBottom()
m.tail = true
return m, nil
+ case app.SendCommand:
+ m.viewport.GotoBottom()
+ m.tail = true
+ return m, nil
case dialog.ThemeSelectedMsg:
m.cache.Clear()
m.loading = true