Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package config

Check failure on line 1 in internal/config/config.go

View workflow job for this annotation

GitHub Actions / lint-build-test

: cannot compile Go 1.23 code (typecheck)

import (
"encoding/json"
Expand All @@ -11,7 +11,7 @@
const (
appConfigDir = "aavshr-panda" // to not have name conflicts with other apps
configFileName = "config.json"
defaultModel = "gpt-4o-mini"
defaultModel = "o3-mini"
)

var (
Expand Down
28 changes: 25 additions & 3 deletions internal/ui/components/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ import (
tea "github.com/charmbracelet/bubbletea"
)

type SettingsMode int

const (
SettingsModeAPIKey SettingsMode = iota
SettingsModeLLMModel
)

type SettingsSubmitMsg struct {
APIKey string
APIKey string
LLMModel string
}

type SettingsModel struct {
inner textinput.Model
mode SettingsMode
msg SettingsSubmitMsg
}

func SettingsSubmitCmd(msg SettingsSubmitMsg) tea.Cmd {
Expand All @@ -24,7 +34,10 @@ func SettingsSubmitCmd(msg SettingsSubmitMsg) tea.Cmd {
func NewSettingsModel() SettingsModel {
inner := textinput.New()
inner.Placeholder = "Enter your API key..."
return SettingsModel{inner: inner}
return SettingsModel{
inner: inner,
mode: SettingsModeAPIKey,
}
}

func (m *SettingsModel) Focus() tea.Cmd {
Expand All @@ -49,7 +62,16 @@ func (m *SettingsModel) Update(msg interface{}) (SettingsModel, tea.Cmd) {
case tea.KeyEnter:
value := strings.TrimSpace(m.inner.Value())
if value != "" {
return *m, SettingsSubmitCmd(SettingsSubmitMsg{APIKey: m.inner.Value()})
if m.mode == SettingsModeAPIKey {
m.mode = SettingsModeLLMModel
m.inner.Placeholder = "Enter your LLM model (default o3-mini)..."
m.msg.APIKey = value
m.inner.SetValue("")
m.View()
} else {
m.msg.LLMModel = value
return *m, SettingsSubmitCmd(m.msg)
}
}
case tea.KeyEscape, tea.KeyCtrlC, tea.KeyCtrlD:
return *m, tea.Quit
Expand Down
1 change: 1 addition & 0 deletions internal/ui/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"slices"
"time"

"github.com/aavshr/panda/internal/config"

Check failure on line 11 in internal/ui/handlers.go

View workflow job for this annotation

GitHub Actions / lint-build-test

could not import github.com/aavshr/panda/internal/config (-: cannot compile Go 1.23 code) (typecheck)
"github.com/aavshr/panda/internal/db"
"github.com/aavshr/panda/internal/ui/components"
"github.com/aavshr/panda/internal/ui/styles"

Check failure on line 14 in internal/ui/handlers.go

View workflow job for this annotation

GitHub Actions / lint-build-test

could not import github.com/aavshr/panda/internal/ui/styles (-: cannot compile Go 1.23 code) (typecheck)
"github.com/aavshr/panda/internal/utils"

Check failure on line 15 in internal/ui/handlers.go

View workflow job for this annotation

GitHub Actions / lint-build-test

could not import github.com/aavshr/panda/internal/utils (-: cannot compile Go 1.23 code) (typecheck)
tea "github.com/charmbracelet/bubbletea"
)

Expand Down Expand Up @@ -101,6 +101,7 @@
func (m *Model) handleSettingsSubmitMsg(msg components.SettingsSubmitMsg) tea.Cmd {
savedConfig, err := config.Save(config.Config{
LLMAPIKey: msg.APIKey,
LLMModel: msg.LLMModel,
})
if err != nil {
return m.cmdError(fmt.Errorf("config.Save: %w", err))
Expand Down
Loading