summaryrefslogtreecommitdiffhomepage
path: root/internal/tui
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-13 14:37:05 +0200
committerKujtim Hoxha <[email protected]>2025-04-21 13:41:27 +0200
commitcdc5f209dccdc980714f2ca1aeb52133d6e93cce (patch)
tree02fe97994dfce7f2e842be7b4c5170f534220eee /internal/tui
parent3ad983db0f2c08826d56cb5de274d706c95b3353 (diff)
downloadopencode-cdc5f209dccdc980714f2ca1aeb52133d6e93cce.tar.gz
opencode-cdc5f209dccdc980714f2ca1aeb52133d6e93cce.zip
cleanup diff, cleanup agent
Diffstat (limited to 'internal/tui')
-rw-r--r--internal/tui/components/repl/editor.go8
-rw-r--r--internal/tui/page/chat.go15
2 files changed, 7 insertions, 16 deletions
diff --git a/internal/tui/components/repl/editor.go b/internal/tui/components/repl/editor.go
index b1e39e655..b659775e0 100644
--- a/internal/tui/components/repl/editor.go
+++ b/internal/tui/components/repl/editor.go
@@ -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
}()
diff --git a/internal/tui/page/chat.go b/internal/tui/page/chat.go
index 9b9924909..439c89e1f 100644
--- a/internal/tui/page/chat.go
+++ b/internal/tui/page/chat.go
@@ -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...)
}