summaryrefslogtreecommitdiffhomepage
path: root/internal/tui/page
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-05-08 12:03:59 -0500
committeradamdottv <[email protected]>2025-05-08 12:03:59 -0500
commitf41b7bbd0a0cc731fd7c471b7ee8b26f14a21755 (patch)
treebd34e77a07516735a220c210d4930fbe2132a63b /internal/tui/page
parente35ea2d448d1a3c9cf0a6fba1318e522fc61d1eb (diff)
downloadopencode-f41b7bbd0a0cc731fd7c471b7ee8b26f14a21755.tar.gz
opencode-f41b7bbd0a0cc731fd7c471b7ee8b26f14a21755.zip
chore: refactoring status updates
Diffstat (limited to 'internal/tui/page')
-rw-r--r--internal/tui/page/chat.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/internal/tui/page/chat.go b/internal/tui/page/chat.go
index afb9c8a4c..46609fdd0 100644
--- a/internal/tui/page/chat.go
+++ b/internal/tui/page/chat.go
@@ -7,9 +7,9 @@ import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/opencode-ai/opencode/internal/app"
- "github.com/opencode-ai/opencode/internal/logging"
"github.com/opencode-ai/opencode/internal/message"
"github.com/opencode-ai/opencode/internal/session"
+ "github.com/opencode-ai/opencode/internal/status"
"github.com/opencode-ai/opencode/internal/tui/components/chat"
"github.com/opencode-ai/opencode/internal/tui/layout"
"github.com/opencode-ai/opencode/internal/tui/util"
@@ -26,9 +26,9 @@ type chatPage struct {
}
type ChatKeyMap struct {
- NewSession key.Binding
- Cancel key.Binding
- ToggleTools key.Binding
+ NewSession key.Binding
+ Cancel key.Binding
+ ToggleTools key.Binding
}
var keyMap = ChatKeyMap{
@@ -74,16 +74,17 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
p.session = msg
case chat.CompactSessionMsg:
if p.session.ID == "" {
- return p, util.ReportWarn("No active session to compact.")
+ status.Warn("No active session to compact.")
+ return p, nil
}
// Run compaction in background
go func(sessionID string) {
err := p.app.CoderAgent.CompactSession(context.Background(), sessionID)
if err != nil {
- logging.ErrorPersist(fmt.Sprintf("Compaction failed: %v", err))
+ status.Error(fmt.Sprintf("Compaction failed: %v", err))
} else {
- logging.InfoPersist("Conversation compacted successfully.")
+ status.Info("Conversation compacted successfully.")
}
}(p.session.ID)
@@ -130,13 +131,14 @@ func (p *chatPage) sendMessage(text string, attachments []message.Attachment) te
if p.session.ID == "" {
newSession, err := p.app.Sessions.Create(context.Background(), "New Session")
if err != nil {
- return util.ReportError(err)
+ status.Error(err.Error())
+ return nil
}
p.session = newSession
// Update the current session in the session manager
session.SetCurrentSession(newSession.ID)
-
+
cmd := p.setSidebar()
if cmd != nil {
cmds = append(cmds, cmd)
@@ -146,7 +148,8 @@ func (p *chatPage) sendMessage(text string, attachments []message.Attachment) te
_, err := p.app.CoderAgent.Run(context.Background(), p.session.ID, text, attachments...)
if err != nil {
- return util.ReportError(err)
+ status.Error(err.Error())
+ return nil
}
return tea.Batch(cmds...)
}