Detailed changes
@@ -71,7 +71,7 @@ type OAuth struct {
var _ Dialog = (*OAuth)(nil)
// newOAuth creates a new device flow component.
-func newOAuth(com *common.Common, provider catwalk.Provider, model config.SelectedModel, modelType config.SelectedModelType, oAuthProvider OAuthProvider) (*OAuth, error) {
+func newOAuth(com *common.Common, provider catwalk.Provider, model config.SelectedModel, modelType config.SelectedModelType, oAuthProvider OAuthProvider) (*OAuth, tea.Cmd) {
t := com.Styles
m := OAuth{}
@@ -101,7 +101,7 @@ func newOAuth(com *common.Common, provider catwalk.Provider, model config.Select
)
m.keyMap.Close = CloseKey
- return &m, nil
+ return &m, tea.Batch(m.spinner.Tick, m.oAuthProvider.initiateAuth)
}
// ID implements Dialog.
@@ -109,11 +109,6 @@ func (m *OAuth) ID() string {
return OAuthID
}
-// Init implements Dialog.
-func (m *OAuth) Init() tea.Cmd {
- return tea.Batch(m.spinner.Tick, m.oAuthProvider.initiateAuth)
-}
-
// HandleMsg handles messages and state transitions.
func (m *OAuth) HandleMsg(msg tea.Msg) Action {
switch msg := msg.(type) {
@@ -12,7 +12,7 @@ import (
"github.com/charmbracelet/crush/internal/ui/common"
)
-func NewOAuthCopilot(com *common.Common, provider catwalk.Provider, model config.SelectedModel, modelType config.SelectedModelType) (*OAuth, error) {
+func NewOAuthCopilot(com *common.Common, provider catwalk.Provider, model config.SelectedModel, modelType config.SelectedModelType) (*OAuth, tea.Cmd) {
return newOAuth(com, provider, model, modelType, &OAuthCopilot{})
}
@@ -12,7 +12,7 @@ import (
"github.com/charmbracelet/crush/internal/ui/common"
)
-func NewOAuthHyper(com *common.Common, provider catwalk.Provider, model config.SelectedModel, modelType config.SelectedModelType) (*OAuth, error) {
+func NewOAuthHyper(com *common.Common, provider catwalk.Provider, model config.SelectedModel, modelType config.SelectedModelType) (*OAuth, tea.Cmd) {
return newOAuth(com, provider, model, modelType, &OAuthHyper{})
}
@@ -1058,13 +1058,9 @@ func (m *UI) openOAuthHyperDialog(provider catwalk.Provider, model config.Select
return nil
}
- oAuthDialog, err := dialog.NewOAuthHyper(m.com, provider, model, modelType)
- if err != nil {
- return uiutil.ReportError(err)
- }
+ oAuthDialog, cmd := dialog.NewOAuthHyper(m.com, provider, model, modelType)
m.dialog.OpenDialog(oAuthDialog)
-
- return oAuthDialog.Init()
+ return cmd
}
func (m *UI) openOAuthCopilotDialog(provider catwalk.Provider, model config.SelectedModel, modelType config.SelectedModelType) tea.Cmd {
@@ -1073,13 +1069,9 @@ func (m *UI) openOAuthCopilotDialog(provider catwalk.Provider, model config.Sele
return nil
}
- oAuthDialog, err := dialog.NewOAuthCopilot(m.com, provider, model, modelType)
- if err != nil {
- return uiutil.ReportError(err)
- }
+ oAuthDialog, cmd := dialog.NewOAuthCopilot(m.com, provider, model, modelType)
m.dialog.OpenDialog(oAuthDialog)
-
- return oAuthDialog.Init()
+ return cmd
}
func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {