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

Andrey Nering created

* `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

Change summary

internal/tui/components/chat/splash/splash.go | 3 +++
1 file changed, 3 insertions(+)

Detailed changes

internal/tui/components/chat/splash/splash.go 🔗

@@ -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)) {