mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 11:14:23 +01:00
cleanup diff, cleanup agent
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/kujtimiihoxha/termai/internal/app"
|
||||
"github.com/kujtimiihoxha/termai/internal/llm/agent"
|
||||
"github.com/kujtimiihoxha/termai/internal/tui/layout"
|
||||
"github.com/kujtimiihoxha/termai/internal/tui/styles"
|
||||
"github.com/kujtimiihoxha/termai/internal/tui/util"
|
||||
@@ -168,11 +167,6 @@ func (m *editorCmp) Send() tea.Cmd {
|
||||
return util.ReportWarn("Assistant is still working on the previous message")
|
||||
}
|
||||
|
||||
a, err := agent.NewCoderAgent(m.app)
|
||||
if err != nil {
|
||||
return util.ReportError(err)
|
||||
}
|
||||
|
||||
content := strings.Join(m.editor.GetBuffer().Lines(), "\n")
|
||||
if len(content) == 0 {
|
||||
return util.ReportWarn("Message is empty")
|
||||
@@ -181,7 +175,7 @@ func (m *editorCmp) Send() tea.Cmd {
|
||||
m.cancelMessage = cancel
|
||||
go func() {
|
||||
defer cancel()
|
||||
a.Generate(ctx, m.sessionID, content)
|
||||
m.app.CoderAgent.Generate(ctx, m.sessionID, content)
|
||||
m.cancelMessage = nil
|
||||
}()
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/charmbracelet/bubbles/key"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/kujtimiihoxha/termai/internal/app"
|
||||
"github.com/kujtimiihoxha/termai/internal/llm/agent"
|
||||
"github.com/kujtimiihoxha/termai/internal/session"
|
||||
"github.com/kujtimiihoxha/termai/internal/tui/components/chat"
|
||||
"github.com/kujtimiihoxha/termai/internal/tui/layout"
|
||||
@@ -23,6 +22,7 @@ type chatPage struct {
|
||||
|
||||
type ChatKeyMap struct {
|
||||
NewSession key.Binding
|
||||
Cancel key.Binding
|
||||
}
|
||||
|
||||
var keyMap = ChatKeyMap{
|
||||
@@ -30,6 +30,10 @@ var keyMap = ChatKeyMap{
|
||||
key.WithKeys("ctrl+n"),
|
||||
key.WithHelp("ctrl+n", "new session"),
|
||||
),
|
||||
Cancel: key.NewBinding(
|
||||
key.WithKeys("ctrl+x"),
|
||||
key.WithHelp("ctrl+x", "cancel"),
|
||||
),
|
||||
}
|
||||
|
||||
func (p *chatPage) Init() tea.Cmd {
|
||||
@@ -106,15 +110,8 @@ func (p *chatPage) sendMessage(text string) tea.Cmd {
|
||||
}
|
||||
cmds = append(cmds, util.CmdHandler(chat.SessionSelectedMsg(session)))
|
||||
}
|
||||
// TODO: move this to a service
|
||||
a, err := agent.NewCoderAgent(p.app)
|
||||
if err != nil {
|
||||
return util.ReportError(err)
|
||||
}
|
||||
go func() {
|
||||
a.Generate(context.Background(), p.session.ID, text)
|
||||
}()
|
||||
|
||||
p.app.CoderAgent.Generate(context.Background(), p.session.ID, text)
|
||||
return tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user