The open source coding agent.
TypeScript
some small fixes
Kujtim Hoxhae4680caebb72
diff --git a/internal/config/config.go b/internal/config/config.goindex 88f3a1838b5..eec694450c3 100644--- a/internal/config/config.go+++ b/internal/config/config.go@@ -6,6 +6,7 @@ import ("fmt""log/slog""os"+ "path/filepath""strings""github.com/opencode-ai/opencode/internal/llm/models"@@ -735,16 +736,22 @@ func UpdateTheme(themeName string) error {// Get the config file pathconfigFile := viper.ConfigFileUsed()+ var configData []byteif configFile == "" {- // If no config file exists yet, create one with default settings- viper.Set("tui.theme", themeName)- return viper.SafeWriteConfig()- }-- // Read the existing config file- configData, err := os.ReadFile(configFile)- if err != nil {- return fmt.Errorf("failed to read config file: %w", err)+ homeDir, err := os.UserHomeDir()+ if err != nil {+ return fmt.Errorf("failed to get home directory: %w", err)+ }+ configFile = filepath.Join(homeDir, fmt.Sprintf(".%s.json", appName))+ logging.Info("config file not found, creating new one", "path", configFile)+ configData = []byte(`{}`)+ } else {+ // Read the existing config file+ data, err := os.ReadFile(configFile)+ if err != nil {+ return fmt.Errorf("failed to read config file: %w", err)+ }+ configData = data}// Parse the JSON@@ -770,7 +777,7 @@ func UpdateTheme(themeName string) error {return fmt.Errorf("failed to marshal config: %w", err)}- if err := os.WriteFile(configFile, updatedData, 0644); err != nil {+ if err := os.WriteFile(configFile, updatedData, 0o644); err != nil {return fmt.Errorf("failed to write config file: %w", err)}diff --git a/internal/tui/components/chat/message.go b/internal/tui/components/chat/message.goindex f8d721f19fd..5163ec73568 100644--- a/internal/tui/components/chat/message.go+++ b/internal/tui/components/chat/message.go@@ -30,11 +30,6 @@ const (maxResultHeight = 10)-// getDiffWidth returns the width for the diff formatting-func getDiffWidth(width int) int {- return width-}-type uiMessage struct {ID stringmessageType uiMessageTypediff --git a/internal/tui/components/core/status.go b/internal/tui/components/core/status.goindex ca02265e1b2..28120a430bd 100644--- a/internal/tui/components/core/status.go+++ b/internal/tui/components/core/status.go@@ -21,7 +21,7 @@ import (type StatusCmp interface {tea.Model- SetHelpMsg(string)+ SetHelpWidgetMsg(string)}type statusCmp struct {@@ -263,7 +263,7 @@ func (m statusCmp) model() string {Render(model.Name)}-func (m statusCmp) SetHelpMsg(s string) {+func (m statusCmp) SetHelpWidgetMsg(s string) {// Update the help widget text using the getHelpWidget functionhelpWidget = getHelpWidget(s)}diff --git a/internal/tui/components/logs/table.go b/internal/tui/components/logs/table.goindex b9386cb735e..8d59f967f0a 100644--- a/internal/tui/components/logs/table.go+++ b/internal/tui/components/logs/table.go@@ -63,6 +63,9 @@ func (i *tableCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {func (i *tableCmp) View() string {t := theme.CurrentTheme()+ defaultStyles := table.DefaultStyles()+ defaultStyles.Selected = defaultStyles.Selected.Foreground(t.Primary())+ i.table.SetStyles(defaultStyles)return styles.ForceReplaceBackgroundWithLipgloss(i.table.View(), t.Background())}@@ -116,7 +119,6 @@ func (i *tableCmp) setRows() {}func NewLogsTable() TableComponent {- t := theme.CurrentTheme()columns := []table.Column{{Title: "ID", Width: 4},{Title: "Time", Width: 4},@@ -124,11 +126,9 @@ func NewLogsTable() TableComponent {{Title: "Message", Width: 10},{Title: "Attributes", Width: 10},}- defaultStyles := table.DefaultStyles()- defaultStyles.Selected = defaultStyles.Selected.Foreground(t.Primary())+tableModel := table.New(table.WithColumns(columns),- table.WithStyles(defaultStyles),)tableModel.Focus()return &tableCmp{diff --git a/internal/tui/styles/huh.go b/internal/tui/styles/huh.godeleted file mode 100644index 8df454c1fd9..00000000000--- a/internal/tui/styles/huh.go+++ /dev/null@@ -1,159 +0,0 @@-package styles--import (- "github.com/charmbracelet/huh"- "github.com/charmbracelet/lipgloss"- "github.com/opencode-ai/opencode/internal/tui/theme"-)--// returns a huh.Theme configured with the current app theme colors-func HuhTheme() *huh.Theme {- t := huh.ThemeBase()- currentTheme := theme.CurrentTheme()-- // Base theme elements- bgColor := currentTheme.Background()- bgSecondaryColor := currentTheme.BackgroundSecondary()- textColor := currentTheme.Text()- textMutedColor := currentTheme.TextMuted()- primaryColor := currentTheme.Primary()- secondaryColor := currentTheme.Secondary()- // accentColor := currentTheme.Accent()- errorColor := currentTheme.Error()- successColor := currentTheme.Success()- // warningColor := currentTheme.Warning()- // infoColor := currentTheme.Info()- borderColor := currentTheme.BorderNormal()- borderFocusedColor := currentTheme.BorderFocused()-- // Focused styles- t.Focused.Base = t.Focused.Base.- BorderStyle(lipgloss.HiddenBorder()).- Background(bgColor).- BorderForeground(borderColor)-- t.Focused.Title = t.Focused.Title.- Foreground(textColor).- Background(bgColor)-- t.Focused.NoteTitle = t.Focused.NoteTitle.- Foreground(textColor).- Background(bgColor)-- t.Focused.Directory = t.Focused.Directory.- Foreground(textColor).- Background(bgColor)-- t.Focused.Description = t.Focused.Description.- Foreground(textMutedColor).- Background(bgColor)-- t.Focused.ErrorIndicator = t.Focused.ErrorIndicator.- Foreground(errorColor).- Background(bgColor)-- t.Focused.ErrorMessage = t.Focused.ErrorMessage.- Foreground(errorColor).- Background(bgColor)-- t.Focused.SelectSelector = t.Focused.SelectSelector.- Foreground(primaryColor).- Background(bgColor)-- t.Focused.NextIndicator = t.Focused.NextIndicator.- Foreground(primaryColor).- Background(bgColor)-- t.Focused.PrevIndicator = t.Focused.PrevIndicator.- Foreground(primaryColor).- Background(bgColor)-- t.Focused.Option = t.Focused.Option.- Foreground(textColor).- Background(bgColor)-- t.Focused.MultiSelectSelector = t.Focused.MultiSelectSelector.- Foreground(primaryColor).- Background(bgColor)-- t.Focused.SelectedOption = t.Focused.SelectedOption.- Foreground(successColor).- Background(bgColor)-- t.Focused.SelectedPrefix = t.Focused.SelectedPrefix.- Foreground(successColor).- Background(bgColor)-- t.Focused.UnselectedPrefix = t.Focused.UnselectedPrefix.- Foreground(textColor).- Background(bgColor)-- t.Focused.UnselectedOption = t.Focused.UnselectedOption.- Foreground(textColor).- Background(bgColor)-- t.Focused.FocusedButton = t.Focused.FocusedButton.- Foreground(bgColor).- Background(primaryColor).- BorderForeground(borderFocusedColor)-- t.Focused.BlurredButton = t.Focused.BlurredButton.- Foreground(textColor).- Background(bgSecondaryColor).- BorderForeground(borderColor)-- // Text input styles- t.Focused.TextInput.Cursor = t.Focused.TextInput.Cursor.- Foreground(secondaryColor).- Background(bgColor)-- t.Focused.TextInput.Placeholder = t.Focused.TextInput.Placeholder.- Foreground(textMutedColor).- Background(bgColor)-- t.Focused.TextInput.Prompt = t.Focused.TextInput.Prompt.- Foreground(primaryColor).- Background(bgColor)-- t.Focused.TextInput.Text = t.Focused.TextInput.Text.- Foreground(textColor).- Background(bgColor)-- // Blur and focus states should be similar- t.Blurred = t.Focused- t.Blurred.Base = t.Blurred.Base.- BorderStyle(lipgloss.HiddenBorder()).- Background(bgColor)-- // Help styles- t.Help.Ellipsis = t.Help.Ellipsis.- Foreground(textMutedColor).- Background(bgColor)-- t.Help.ShortKey = t.Help.ShortKey.- Foreground(primaryColor).- Background(bgColor)-- t.Help.ShortDesc = t.Help.ShortDesc.- Foreground(textMutedColor).- Background(bgColor)-- t.Help.ShortSeparator = t.Help.ShortSeparator.- Foreground(textMutedColor).- Background(bgColor)-- t.Help.FullKey = t.Help.FullKey.- Foreground(primaryColor).- Background(bgColor)-- t.Help.FullDesc = t.Help.FullDesc.- Foreground(textMutedColor).- Background(bgColor)-- t.Help.FullSeparator = t.Help.FullSeparator.- Foreground(textMutedColor).- Background(bgColor)-- return t-}-diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex cfaa7817078..28f94add791 100644--- a/internal/tui/tui.go+++ b/internal/tui/tui.go@@ -558,9 +558,9 @@ func (a appModel) View() string {}if !a.app.CoderAgent.IsBusy() {- a.status.SetHelpMsg("ctrl+? help")+ a.status.SetHelpWidgetMsg("ctrl+? help")} else {- a.status.SetHelpMsg("? help")+ a.status.SetHelpWidgetMsg("? help")}if a.showHelp {