diff options
| author | adamdottv <[email protected]> | 2025-05-08 12:03:59 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-08 12:03:59 -0500 |
| commit | f41b7bbd0a0cc731fd7c471b7ee8b26f14a21755 (patch) | |
| tree | bd34e77a07516735a220c210d4930fbe2132a63b /internal/tui/components/chat/editor.go | |
| parent | e35ea2d448d1a3c9cf0a6fba1318e522fc61d1eb (diff) | |
| download | opencode-f41b7bbd0a0cc731fd7c471b7ee8b26f14a21755.tar.gz opencode-f41b7bbd0a0cc731fd7c471b7ee8b26f14a21755.zip | |
chore: refactoring status updates
Diffstat (limited to 'internal/tui/components/chat/editor.go')
| -rw-r--r-- | internal/tui/components/chat/editor.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/internal/tui/components/chat/editor.go b/internal/tui/components/chat/editor.go index 982415182..99991cdf7 100644 --- a/internal/tui/components/chat/editor.go +++ b/internal/tui/components/chat/editor.go @@ -12,9 +12,9 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "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/dialog" "github.com/opencode-ai/opencode/internal/tui/layout" "github.com/opencode-ai/opencode/internal/tui/styles" @@ -87,7 +87,8 @@ func (m *editorCmp) openEditor(value string) tea.Cmd { tmpfile, err := os.CreateTemp("", "msg_*.md") tmpfile.WriteString(value) if err != nil { - return util.ReportError(err) + status.Error(err.Error()) + return nil } tmpfile.Close() c := exec.Command(editor, tmpfile.Name()) //nolint:gosec @@ -96,14 +97,17 @@ func (m *editorCmp) openEditor(value string) tea.Cmd { c.Stderr = os.Stderr return tea.ExecProcess(c, func(err error) tea.Msg { if err != nil { - return util.ReportError(err) + status.Error(err.Error()) + return nil } content, err := os.ReadFile(tmpfile.Name()) if err != nil { - return util.ReportError(err) + status.Error(err.Error()) + return nil } if len(content) == 0 { - return util.ReportWarn("Message is empty") + status.Warn("Message is empty") + return nil } os.Remove(tmpfile.Name()) attachments := m.attachments @@ -121,7 +125,8 @@ func (m *editorCmp) Init() tea.Cmd { func (m *editorCmp) send() tea.Cmd { if m.app.CoderAgent.IsSessionBusy(m.session.ID) { - return util.ReportWarn("Agent is working, please wait...") + status.Warn("Agent is working, please wait...") + return nil } value := m.textarea.Value() @@ -153,7 +158,7 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil case dialog.AttachmentAddedMsg: if len(m.attachments) >= maxAttachments { - logging.ErrorPersist(fmt.Sprintf("cannot add more than %d images", maxAttachments)) + status.Error(fmt.Sprintf("cannot add more than %d images", maxAttachments)) return m, cmd } m.attachments = append(m.attachments, msg.Attachment) @@ -185,7 +190,8 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } if key.Matches(msg, editorMaps.OpenEditor) { if m.app.CoderAgent.IsSessionBusy(m.session.ID) { - return m, util.ReportWarn("Agent is working, please wait...") + status.Warn("Agent is working, please wait...") + return m, nil } value := m.textarea.Value() m.textarea.Reset() |
