fix: fix panic on onboarding when no model is selected on the list

* `rm -r ~/.local/share/crush`
* run `crush`
* type something on the filter so no model is shown on the list
* press enter
* a panic happens

Fixes #285
This commit is contained in:
Andrey Nering
2025-07-24 15:52:46 -03:00
parent fa1cd6ad52
commit d6d5cbc68b

View File

@@ -196,6 +196,9 @@ func (s *splashCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
if s.isOnboarding && !s.needsAPIKey {
modelInx := s.modelList.SelectedIndex()
if modelInx == -1 {
return s, nil
}
items := s.modelList.Items()
selectedItem := items[modelInx].(completions.CompletionItem).Value().(models.ModelOption)
if s.isProviderConfigured(string(selectedItem.Provider.ID)) {