summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/tui/internal/app/app.go3
-rw-r--r--packages/tui/internal/components/chat/editor.go5
-rw-r--r--packages/tui/internal/tui/tui.go8
3 files changed, 15 insertions, 1 deletions
diff --git a/packages/tui/internal/app/app.go b/packages/tui/internal/app/app.go
index a70b3ca64..bd16036af 100644
--- a/packages/tui/internal/app/app.go
+++ b/packages/tui/internal/app/app.go
@@ -50,6 +50,9 @@ type SendMsg struct {
Text string
Attachments []opencode.FilePartParam
}
+type SetEditorContentMsg struct {
+ Text string
+}
type OptimisticMessageAddedMsg struct {
Message opencode.MessageUnion
}
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index 444f5bef1..6503d91e1 100644
--- a/packages/tui/internal/components/chat/editor.go
+++ b/packages/tui/internal/components/chat/editor.go
@@ -38,6 +38,7 @@ type EditorComponent interface {
Clear() (tea.Model, tea.Cmd)
Paste() (tea.Model, tea.Cmd)
Newline() (tea.Model, tea.Cmd)
+ SetValue(value string)
SetInterruptKeyInDebounce(inDebounce bool)
SetExitKeyInDebounce(inDebounce bool)
}
@@ -401,6 +402,10 @@ func (m *editorComponent) SetInterruptKeyInDebounce(inDebounce bool) {
m.interruptKeyInDebounce = inDebounce
}
+func (m *editorComponent) SetValue(value string) {
+ m.textarea.SetValue(value)
+}
+
func (m *editorComponent) SetExitKeyInDebounce(inDebounce bool) {
m.exitKeyInDebounce = inDebounce
}
diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.go
index 38b61efab..770e8ac01 100644
--- a/packages/tui/internal/tui/tui.go
+++ b/packages/tui/internal/tui/tui.go
@@ -390,6 +390,12 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
a.showCompletionDialog = false
a.app, cmd = a.app.SendChatMessage(context.Background(), msg.Text, msg.Attachments)
cmds = append(cmds, cmd)
+ case app.SetEditorContentMsg:
+ // Set the editor content without sending
+ a.editor.SetValue(msg.Text)
+ updated, cmd := a.editor.Focus()
+ a.editor = updated.(chat.EditorComponent)
+ cmds = append(cmds, cmd)
case dialog.CompletionDialogCloseMsg:
a.showCompletionDialog = false
a.fileCompletionActive = false
@@ -858,7 +864,7 @@ func (a appModel) executeCommand(command commands.Command) (tea.Model, tea.Cmd)
return nil
}
os.Remove(tmpfile.Name())
- return app.SendMsg{
+ return app.SetEditorContentMsg{
Text: string(content),
}
})