add support for images (#144)
This commit is contained in:
parent
603a3e3c71
commit
9fec8df7d0
30 changed files with 1326 additions and 484 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/charmbracelet/bubbles/key"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/opencode-ai/opencode/internal/app"
|
||||
"github.com/opencode-ai/opencode/internal/message"
|
||||
"github.com/opencode-ai/opencode/internal/session"
|
||||
"github.com/opencode-ai/opencode/internal/tui/components/chat"
|
||||
"github.com/opencode-ai/opencode/internal/tui/layout"
|
||||
|
|
@ -52,7 +53,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
cmd := p.layout.SetSize(msg.Width, msg.Height)
|
||||
cmds = append(cmds, cmd)
|
||||
case chat.SendMsg:
|
||||
cmd := p.sendMessage(msg.Text)
|
||||
cmd := p.sendMessage(msg.Text, msg.Attachments)
|
||||
if cmd != nil {
|
||||
return p, cmd
|
||||
}
|
||||
|
|
@ -99,7 +100,7 @@ func (p *chatPage) clearSidebar() tea.Cmd {
|
|||
return p.layout.ClearRightPanel()
|
||||
}
|
||||
|
||||
func (p *chatPage) sendMessage(text string) tea.Cmd {
|
||||
func (p *chatPage) sendMessage(text string, attachments []message.Attachment) tea.Cmd {
|
||||
var cmds []tea.Cmd
|
||||
if p.session.ID == "" {
|
||||
session, err := p.app.Sessions.Create(context.Background(), "New Session")
|
||||
|
|
@ -115,7 +116,10 @@ func (p *chatPage) sendMessage(text string) tea.Cmd {
|
|||
cmds = append(cmds, util.CmdHandler(chat.SessionSelectedMsg(session)))
|
||||
}
|
||||
|
||||
p.app.CoderAgent.Run(context.Background(), p.session.ID, text)
|
||||
_, err := p.app.CoderAgent.Run(context.Background(), p.session.ID, text, attachments...)
|
||||
if err != nil {
|
||||
return util.ReportError(err)
|
||||
}
|
||||
return tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +138,7 @@ func (p *chatPage) View() string {
|
|||
func (p *chatPage) BindingKeys() []key.Binding {
|
||||
bindings := layout.KeyMapToSlice(keyMap)
|
||||
bindings = append(bindings, p.messages.BindingKeys()...)
|
||||
bindings = append(bindings, p.editor.BindingKeys()...)
|
||||
return bindings
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue