diff options
Diffstat (limited to 'internal/tui/components/dialog')
| -rw-r--r-- | internal/tui/components/dialog/filepicker.go | 21 | ||||
| -rw-r--r-- | internal/tui/components/dialog/models.go | 3 | ||||
| -rw-r--r-- | internal/tui/components/dialog/theme.go | 5 |
3 files changed, 16 insertions, 13 deletions
diff --git a/internal/tui/components/dialog/filepicker.go b/internal/tui/components/dialog/filepicker.go index a61c8ef54..f747dc9af 100644 --- a/internal/tui/components/dialog/filepicker.go +++ b/internal/tui/components/dialog/filepicker.go @@ -18,6 +18,7 @@ import ( "github.com/opencode-ai/opencode/internal/config" "github.com/opencode-ai/opencode/internal/logging" "github.com/opencode-ai/opencode/internal/message" + "github.com/opencode-ai/opencode/internal/status" "github.com/opencode-ai/opencode/internal/tui/image" "github.com/opencode-ai/opencode/internal/tui/styles" "github.com/opencode-ai/opencode/internal/tui/theme" @@ -156,7 +157,7 @@ func (f *filepickerCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { path = f.cwd.Value() fileInfo, err := os.Stat(path) if err != nil { - logging.ErrorPersist("Invalid path") + status.Error("Invalid path") return f, cmd } isPathDir = fileInfo.IsDir() @@ -225,7 +226,7 @@ func (f *filepickerCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (f *filepickerCmp) addAttachmentToMessage() (tea.Model, tea.Cmd) { modeInfo := GetSelectedModel(config.Get()) if !modeInfo.SupportsAttachments { - logging.ErrorPersist(fmt.Sprintf("Model %s doesn't support attachments", modeInfo.Name)) + status.Error(fmt.Sprintf("Model %s doesn't support attachments", modeInfo.Name)) return f, nil } if isExtSupported(f.dirs[f.cursor].Name()) { @@ -233,17 +234,17 @@ func (f *filepickerCmp) addAttachmentToMessage() (tea.Model, tea.Cmd) { selectedFilePath := filepath.Join(f.cwdDetails.directory, "/", f.selectedFile) isFileLarge, err := image.ValidateFileSize(selectedFilePath, maxAttachmentSize) if err != nil { - logging.ErrorPersist("unable to read the image") + status.Error("unable to read the image") return f, nil } if isFileLarge { - logging.ErrorPersist("file too large, max 5MB") + status.Error("file too large, max 5MB") return f, nil } content, err := os.ReadFile(selectedFilePath) if err != nil { - logging.ErrorPersist("Unable read selected file") + status.Error("Unable read selected file") return f, nil } @@ -255,7 +256,7 @@ func (f *filepickerCmp) addAttachmentToMessage() (tea.Model, tea.Cmd) { return f, util.CmdHandler(AttachmentAddedMsg{attachment}) } if !isExtSupported(f.selectedFile) { - logging.ErrorPersist("Unsupported file") + status.Error("Unsupported file") return f, nil } return f, nil @@ -425,7 +426,7 @@ func readDir(path string, showHidden bool) []os.DirEntry { go func() { dirEntries, err := os.ReadDir(path) if err != nil { - logging.ErrorPersist(err.Error()) + status.Error(err.Error()) errChan <- err return } @@ -457,12 +458,12 @@ func readDir(path string, showHidden bool) []os.DirEntry { return sanitizedDirEntries - case err := <-errChan: - logging.ErrorPersist(fmt.Sprintf("Error reading directory %s", path), err) + case <-errChan: + status.Error(fmt.Sprintf("Error reading directory %s", path)) return []os.DirEntry{} case <-time.After(5 * time.Second): - logging.ErrorPersist(fmt.Sprintf("Timeout reading directory %s", path), nil) + status.Error(fmt.Sprintf("Timeout reading directory %s", path)) return []os.DirEntry{} } } diff --git a/internal/tui/components/dialog/models.go b/internal/tui/components/dialog/models.go index 77c2a02ac..9dc2fdffe 100644 --- a/internal/tui/components/dialog/models.go +++ b/internal/tui/components/dialog/models.go @@ -10,6 +10,7 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/opencode-ai/opencode/internal/config" "github.com/opencode-ai/opencode/internal/llm/models" + "github.com/opencode-ai/opencode/internal/status" "github.com/opencode-ai/opencode/internal/tui/layout" "github.com/opencode-ai/opencode/internal/tui/styles" "github.com/opencode-ai/opencode/internal/tui/theme" @@ -126,7 +127,7 @@ func (m *modelDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.switchProvider(1) } case key.Matches(msg, modelKeys.Enter): - util.ReportInfo(fmt.Sprintf("selected model: %s", m.models[m.selectedIdx].Name)) + status.Info(fmt.Sprintf("selected model: %s", m.models[m.selectedIdx].Name)) return m, util.CmdHandler(ModelSelectedMsg{Model: m.models[m.selectedIdx]}) case key.Matches(msg, modelKeys.Escape): return m, util.CmdHandler(CloseModelDialogMsg{}) diff --git a/internal/tui/components/dialog/theme.go b/internal/tui/components/dialog/theme.go index d35d3e2b6..1794bd631 100644 --- a/internal/tui/components/dialog/theme.go +++ b/internal/tui/components/dialog/theme.go @@ -4,6 +4,7 @@ import ( "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/opencode-ai/opencode/internal/status" "github.com/opencode-ai/opencode/internal/tui/layout" "github.com/opencode-ai/opencode/internal/tui/styles" "github.com/opencode-ai/opencode/internal/tui/theme" @@ -106,7 +107,8 @@ func (t *themeDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return t, util.CmdHandler(CloseThemeDialogMsg{}) } if err := theme.SetTheme(selectedTheme); err != nil { - return t, util.ReportError(err) + status.Error(err.Error()) + return t, nil } return t, util.CmdHandler(ThemeChangedMsg{ ThemeName: selectedTheme, @@ -195,4 +197,3 @@ func NewThemeDialogCmp() ThemeDialog { currentTheme: "", } } - |
