fix(onboarding): fix y/n key press on model list and api key field (#402)

Andrey Nering created

A bug on onboarding made it impossible to press "y" and "n" on
onboarding, on both the model list and the API key field.

This also means that on some terminals, like the Windows Terminal,
pasting an API key would supress all "y" and "n" chars present in the
key, because these terminal receives an even for each character being
pressed.

Change summary

internal/tui/components/chat/splash/splash.go | 24 ++++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)

Detailed changes

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

@@ -262,30 +262,34 @@ func (s *splashCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 				return s, nil
 			}
 		case key.Matches(msg, s.keyMap.Yes):
-			if s.isOnboarding {
-				return s, nil
-			}
 			if s.needsAPIKey {
 				u, cmd := s.apiKeyInput.Update(msg)
 				s.apiKeyInput = u.(*models.APIKeyInput)
 				return s, cmd
 			}
-
+			if s.isOnboarding {
+				u, cmd := s.modelList.Update(msg)
+				s.modelList = u
+				return s, cmd
+			}
 			if s.needsProjectInit {
 				return s, s.initializeProject()
 			}
 		case key.Matches(msg, s.keyMap.No):
-			if s.isOnboarding {
-				return s, nil
-			}
 			if s.needsAPIKey {
 				u, cmd := s.apiKeyInput.Update(msg)
 				s.apiKeyInput = u.(*models.APIKeyInput)
 				return s, cmd
 			}
-
-			s.selectedNo = true
-			return s, s.initializeProject()
+			if s.isOnboarding {
+				u, cmd := s.modelList.Update(msg)
+				s.modelList = u
+				return s, cmd
+			}
+			if s.needsProjectInit {
+				s.selectedNo = true
+				return s, s.initializeProject()
+			}
 		default:
 			if s.needsAPIKey {
 				u, cmd := s.apiKeyInput.Update(msg)