1package splash
  2
  3import (
  4	"fmt"
  5	"os"
  6	"strings"
  7	"time"
  8
  9	"github.com/charmbracelet/bubbles/v2/key"
 10	"github.com/charmbracelet/bubbles/v2/spinner"
 11	tea "github.com/charmbracelet/bubbletea/v2"
 12	"github.com/charmbracelet/catwalk/pkg/catwalk"
 13	"github.com/charmbracelet/crush/internal/config"
 14	"github.com/charmbracelet/crush/internal/llm/prompt"
 15	"github.com/charmbracelet/crush/internal/tui/components/chat"
 16	"github.com/charmbracelet/crush/internal/tui/components/core"
 17	"github.com/charmbracelet/crush/internal/tui/components/core/layout"
 18	"github.com/charmbracelet/crush/internal/tui/components/dialogs/models"
 19	"github.com/charmbracelet/crush/internal/tui/components/logo"
 20	lspcomponent "github.com/charmbracelet/crush/internal/tui/components/lsp"
 21	"github.com/charmbracelet/crush/internal/tui/components/mcp"
 22	"github.com/charmbracelet/crush/internal/tui/exp/list"
 23	"github.com/charmbracelet/crush/internal/tui/styles"
 24	"github.com/charmbracelet/crush/internal/tui/util"
 25	"github.com/charmbracelet/crush/internal/version"
 26	"github.com/charmbracelet/lipgloss/v2"
 27)
 28
 29type Splash interface {
 30	util.Model
 31	layout.Sizeable
 32	layout.Help
 33	Cursor() *tea.Cursor
 34	// SetOnboarding controls whether the splash shows model selection UI
 35	SetOnboarding(bool)
 36	// SetProjectInit controls whether the splash shows project initialization prompt
 37	SetProjectInit(bool)
 38
 39	// Showing API key input
 40	IsShowingAPIKey() bool
 41
 42	// IsAPIKeyValid returns whether the API key is valid
 43	IsAPIKeyValid() bool
 44}
 45
 46const (
 47	SplashScreenPaddingY = 1 // Padding Y for the splash screen
 48
 49	LogoGap = 6
 50)
 51
 52// OnboardingCompleteMsg is sent when onboarding is complete
 53type (
 54	OnboardingCompleteMsg struct{}
 55	SubmitAPIKeyMsg       struct{}
 56)
 57
 58type splashCmp struct {
 59	width, height int
 60	keyMap        KeyMap
 61	logoRendered  string
 62
 63	// State
 64	isOnboarding     bool
 65	needsProjectInit bool
 66	needsAPIKey      bool
 67	selectedNo       bool
 68
 69	listHeight    int
 70	modelList     *models.ModelListComponent
 71	apiKeyInput   *models.APIKeyInput
 72	selectedModel *models.ModelOption
 73	isAPIKeyValid bool
 74	apiKeyValue   string
 75}
 76
 77func New() Splash {
 78	keyMap := DefaultKeyMap()
 79	listKeyMap := list.DefaultKeyMap()
 80	listKeyMap.Down.SetEnabled(false)
 81	listKeyMap.Up.SetEnabled(false)
 82	listKeyMap.HalfPageDown.SetEnabled(false)
 83	listKeyMap.HalfPageUp.SetEnabled(false)
 84	listKeyMap.Home.SetEnabled(false)
 85	listKeyMap.End.SetEnabled(false)
 86	listKeyMap.DownOneItem = keyMap.Next
 87	listKeyMap.UpOneItem = keyMap.Previous
 88
 89	modelList := models.NewModelListComponent(listKeyMap, "Find your fave", false)
 90	apiKeyInput := models.NewAPIKeyInput()
 91
 92	return &splashCmp{
 93		width:        0,
 94		height:       0,
 95		keyMap:       keyMap,
 96		logoRendered: "",
 97		modelList:    modelList,
 98		apiKeyInput:  apiKeyInput,
 99		selectedNo:   false,
100	}
101}
102
103func (s *splashCmp) SetOnboarding(onboarding bool) {
104	s.isOnboarding = onboarding
105}
106
107func (s *splashCmp) SetProjectInit(needsInit bool) {
108	s.needsProjectInit = needsInit
109}
110
111// GetSize implements SplashPage.
112func (s *splashCmp) GetSize() (int, int) {
113	return s.width, s.height
114}
115
116// Init implements SplashPage.
117func (s *splashCmp) Init() tea.Cmd {
118	return tea.Batch(s.modelList.Init(), s.apiKeyInput.Init())
119}
120
121// SetSize implements SplashPage.
122func (s *splashCmp) SetSize(width int, height int) tea.Cmd {
123	wasSmallScreen := s.isSmallScreen()
124	rerenderLogo := width != s.width
125	s.height = height
126	s.width = width
127	if rerenderLogo || wasSmallScreen != s.isSmallScreen() {
128		s.logoRendered = s.logoBlock()
129	}
130	// remove padding, logo height, gap, title space
131	s.listHeight = s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2) - s.logoGap() - 2
132	listWidth := min(60, width)
133	s.apiKeyInput.SetWidth(width - 2)
134	return s.modelList.SetSize(listWidth, s.listHeight)
135}
136
137// Update implements SplashPage.
138func (s *splashCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
139	switch msg := msg.(type) {
140	case tea.WindowSizeMsg:
141		return s, s.SetSize(msg.Width, msg.Height)
142	case models.APIKeyStateChangeMsg:
143		u, cmd := s.apiKeyInput.Update(msg)
144		s.apiKeyInput = u.(*models.APIKeyInput)
145		if msg.State == models.APIKeyInputStateVerified {
146			return s, tea.Tick(5*time.Second, func(t time.Time) tea.Msg {
147				return SubmitAPIKeyMsg{}
148			})
149		}
150		return s, cmd
151	case SubmitAPIKeyMsg:
152		if s.isAPIKeyValid {
153			return s, s.saveAPIKeyAndContinue(s.apiKeyValue)
154		}
155	case tea.KeyPressMsg:
156		switch {
157		case key.Matches(msg, s.keyMap.Back):
158			if s.isAPIKeyValid {
159				return s, nil
160			}
161			if s.needsAPIKey {
162				// Go back to model selection
163				s.needsAPIKey = false
164				s.selectedModel = nil
165				s.isAPIKeyValid = false
166				s.apiKeyValue = ""
167				s.apiKeyInput.Reset()
168				return s, nil
169			}
170		case key.Matches(msg, s.keyMap.Select):
171			if s.isAPIKeyValid {
172				return s, s.saveAPIKeyAndContinue(s.apiKeyValue)
173			}
174			if s.isOnboarding && !s.needsAPIKey {
175				selectedItem := s.modelList.SelectedModel()
176				if selectedItem == nil {
177					return s, nil
178				}
179				if s.isProviderConfigured(string(selectedItem.Provider.ID)) {
180					cmd := s.setPreferredModel(*selectedItem)
181					s.isOnboarding = false
182					return s, tea.Batch(cmd, util.CmdHandler(OnboardingCompleteMsg{}))
183				} else {
184					// Provider not configured, show API key input
185					s.needsAPIKey = true
186					s.selectedModel = selectedItem
187					s.apiKeyInput.SetProviderName(selectedItem.Provider.Name)
188					return s, nil
189				}
190			} else if s.needsAPIKey {
191				// Handle API key submission
192				s.apiKeyValue = strings.TrimSpace(s.apiKeyInput.Value())
193				if s.apiKeyValue == "" {
194					return s, nil
195				}
196
197				provider, err := s.getProvider(s.selectedModel.Provider.ID)
198				if err != nil || provider == nil {
199					return s, util.ReportError(fmt.Errorf("provider %s not found", s.selectedModel.Provider.ID))
200				}
201				providerConfig := config.ProviderConfig{
202					ID:      string(s.selectedModel.Provider.ID),
203					Name:    s.selectedModel.Provider.Name,
204					APIKey:  s.apiKeyValue,
205					Type:    provider.Type,
206					BaseURL: provider.APIEndpoint,
207				}
208				return s, tea.Sequence(
209					util.CmdHandler(models.APIKeyStateChangeMsg{
210						State: models.APIKeyInputStateVerifying,
211					}),
212					func() tea.Msg {
213						start := time.Now()
214						err := providerConfig.TestConnection(config.Get().Resolver())
215						// intentionally wait for at least 750ms to make sure the user sees the spinner
216						elapsed := time.Since(start)
217						if elapsed < 750*time.Millisecond {
218							time.Sleep(750*time.Millisecond - elapsed)
219						}
220						if err == nil {
221							s.isAPIKeyValid = true
222							return models.APIKeyStateChangeMsg{
223								State: models.APIKeyInputStateVerified,
224							}
225						}
226						return models.APIKeyStateChangeMsg{
227							State: models.APIKeyInputStateError,
228						}
229					},
230				)
231			} else if s.needsProjectInit {
232				return s, s.initializeProject()
233			}
234		case key.Matches(msg, s.keyMap.Tab, s.keyMap.LeftRight):
235			if s.needsAPIKey {
236				u, cmd := s.apiKeyInput.Update(msg)
237				s.apiKeyInput = u.(*models.APIKeyInput)
238				return s, cmd
239			}
240			if s.needsProjectInit {
241				s.selectedNo = !s.selectedNo
242				return s, nil
243			}
244		case key.Matches(msg, s.keyMap.Yes):
245			if s.needsAPIKey {
246				u, cmd := s.apiKeyInput.Update(msg)
247				s.apiKeyInput = u.(*models.APIKeyInput)
248				return s, cmd
249			}
250			if s.isOnboarding {
251				u, cmd := s.modelList.Update(msg)
252				s.modelList = u
253				return s, cmd
254			}
255			if s.needsProjectInit {
256				return s, s.initializeProject()
257			}
258		case key.Matches(msg, s.keyMap.No):
259			if s.needsAPIKey {
260				u, cmd := s.apiKeyInput.Update(msg)
261				s.apiKeyInput = u.(*models.APIKeyInput)
262				return s, cmd
263			}
264			if s.isOnboarding {
265				u, cmd := s.modelList.Update(msg)
266				s.modelList = u
267				return s, cmd
268			}
269			if s.needsProjectInit {
270				s.selectedNo = true
271				return s, s.initializeProject()
272			}
273		default:
274			if s.needsAPIKey {
275				u, cmd := s.apiKeyInput.Update(msg)
276				s.apiKeyInput = u.(*models.APIKeyInput)
277				return s, cmd
278			} else if s.isOnboarding {
279				u, cmd := s.modelList.Update(msg)
280				s.modelList = u
281				return s, cmd
282			}
283		}
284	case tea.PasteMsg:
285		if s.needsAPIKey {
286			u, cmd := s.apiKeyInput.Update(msg)
287			s.apiKeyInput = u.(*models.APIKeyInput)
288			return s, cmd
289		} else if s.isOnboarding {
290			var cmd tea.Cmd
291			s.modelList, cmd = s.modelList.Update(msg)
292			return s, cmd
293		}
294	case spinner.TickMsg:
295		u, cmd := s.apiKeyInput.Update(msg)
296		s.apiKeyInput = u.(*models.APIKeyInput)
297		return s, cmd
298	}
299	return s, nil
300}
301
302func (s *splashCmp) saveAPIKeyAndContinue(apiKey string) tea.Cmd {
303	if s.selectedModel == nil {
304		return nil
305	}
306
307	cfg := config.Get()
308	err := cfg.SetProviderAPIKey(string(s.selectedModel.Provider.ID), apiKey)
309	if err != nil {
310		return util.ReportError(fmt.Errorf("failed to save API key: %w", err))
311	}
312
313	// Reset API key state and continue with model selection
314	s.needsAPIKey = false
315	cmd := s.setPreferredModel(*s.selectedModel)
316	s.isOnboarding = false
317	s.selectedModel = nil
318	s.isAPIKeyValid = false
319
320	return tea.Batch(cmd, util.CmdHandler(OnboardingCompleteMsg{}))
321}
322
323func (s *splashCmp) initializeProject() tea.Cmd {
324	s.needsProjectInit = false
325
326	if err := config.MarkProjectInitialized(); err != nil {
327		return util.ReportError(err)
328	}
329	var cmds []tea.Cmd
330
331	cmds = append(cmds, util.CmdHandler(OnboardingCompleteMsg{}))
332	if !s.selectedNo {
333		cmds = append(cmds,
334			util.CmdHandler(chat.SessionClearedMsg{}),
335			util.CmdHandler(chat.SendMsg{
336				Text: prompt.Initialize(),
337			}),
338		)
339	}
340	return tea.Sequence(cmds...)
341}
342
343func (s *splashCmp) setPreferredModel(selectedItem models.ModelOption) tea.Cmd {
344	cfg := config.Get()
345	model := cfg.GetModel(string(selectedItem.Provider.ID), selectedItem.Model.ID)
346	if model == nil {
347		return util.ReportError(fmt.Errorf("model %s not found for provider %s", selectedItem.Model.ID, selectedItem.Provider.ID))
348	}
349
350	selectedModel := config.SelectedModel{
351		Model:           selectedItem.Model.ID,
352		Provider:        string(selectedItem.Provider.ID),
353		ReasoningEffort: model.DefaultReasoningEffort,
354		MaxTokens:       model.DefaultMaxTokens,
355	}
356
357	err := cfg.UpdatePreferredModel(config.SelectedModelTypeLarge, selectedModel)
358	if err != nil {
359		return util.ReportError(err)
360	}
361
362	// Now lets automatically setup the small model
363	knownProvider, err := s.getProvider(selectedItem.Provider.ID)
364	if err != nil {
365		return util.ReportError(err)
366	}
367	if knownProvider == nil {
368		// for local provider we just use the same model
369		err = cfg.UpdatePreferredModel(config.SelectedModelTypeSmall, selectedModel)
370		if err != nil {
371			return util.ReportError(err)
372		}
373	} else {
374		smallModel := knownProvider.DefaultSmallModelID
375		model := cfg.GetModel(string(selectedItem.Provider.ID), smallModel)
376		// should never happen
377		if model == nil {
378			err = cfg.UpdatePreferredModel(config.SelectedModelTypeSmall, selectedModel)
379			if err != nil {
380				return util.ReportError(err)
381			}
382			return nil
383		}
384		smallSelectedModel := config.SelectedModel{
385			Model:           smallModel,
386			Provider:        string(selectedItem.Provider.ID),
387			ReasoningEffort: model.DefaultReasoningEffort,
388			MaxTokens:       model.DefaultMaxTokens,
389		}
390		err = cfg.UpdatePreferredModel(config.SelectedModelTypeSmall, smallSelectedModel)
391		if err != nil {
392			return util.ReportError(err)
393		}
394	}
395	cfg.SetupAgents()
396	return nil
397}
398
399func (s *splashCmp) getProvider(providerID catwalk.InferenceProvider) (*catwalk.Provider, error) {
400	providers, err := config.Providers()
401	if err != nil {
402		return nil, err
403	}
404	for _, p := range providers {
405		if p.ID == providerID {
406			return &p, nil
407		}
408	}
409	return nil, nil
410}
411
412func (s *splashCmp) isProviderConfigured(providerID string) bool {
413	cfg := config.Get()
414	if _, ok := cfg.Providers.Get(providerID); ok {
415		return true
416	}
417	return false
418}
419
420func (s *splashCmp) View() string {
421	t := styles.CurrentTheme()
422	var content string
423	if s.needsAPIKey {
424		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
425		apiKeyView := t.S().Base.PaddingLeft(1).Render(s.apiKeyInput.View())
426		apiKeySelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
427			lipgloss.JoinVertical(
428				lipgloss.Left,
429				apiKeyView,
430			),
431		)
432		content = lipgloss.JoinVertical(
433			lipgloss.Left,
434			s.logoRendered,
435			apiKeySelector,
436		)
437	} else if s.isOnboarding {
438		modelListView := s.modelList.View()
439		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
440		modelSelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
441			lipgloss.JoinVertical(
442				lipgloss.Left,
443				t.S().Base.PaddingLeft(1).Foreground(t.Primary).Render("Choose a Model"),
444				"",
445				modelListView,
446			),
447		)
448		content = lipgloss.JoinVertical(
449			lipgloss.Left,
450			s.logoRendered,
451			modelSelector,
452		)
453	} else if s.needsProjectInit {
454		titleStyle := t.S().Base.Foreground(t.FgBase)
455		bodyStyle := t.S().Base.Foreground(t.FgMuted)
456		shortcutStyle := t.S().Base.Foreground(t.Success)
457
458		initText := lipgloss.JoinVertical(
459			lipgloss.Left,
460			titleStyle.Render("Would you like to initialize this project?"),
461			"",
462			bodyStyle.Render("When I initialize your codebase I examine the project and put the"),
463			bodyStyle.Render("result into a CRUSH.md file which serves as general context."),
464			"",
465			bodyStyle.Render("You can also initialize anytime via ")+shortcutStyle.Render("ctrl+p")+bodyStyle.Render("."),
466			"",
467			bodyStyle.Render("Would you like to initialize now?"),
468		)
469
470		yesButton := core.SelectableButton(core.ButtonOpts{
471			Text:           "Yep!",
472			UnderlineIndex: 0,
473			Selected:       !s.selectedNo,
474		})
475
476		noButton := core.SelectableButton(core.ButtonOpts{
477			Text:           "Nope",
478			UnderlineIndex: 0,
479			Selected:       s.selectedNo,
480		})
481
482		buttons := lipgloss.JoinHorizontal(lipgloss.Left, yesButton, "  ", noButton)
483		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
484
485		initContent := t.S().Base.AlignVertical(lipgloss.Bottom).PaddingLeft(1).Height(remainingHeight).Render(
486			lipgloss.JoinVertical(
487				lipgloss.Left,
488				initText,
489				"",
490				buttons,
491			),
492		)
493
494		content = lipgloss.JoinVertical(
495			lipgloss.Left,
496			s.logoRendered,
497			"",
498			initContent,
499		)
500	} else {
501		parts := []string{
502			s.logoRendered,
503			s.infoSection(),
504		}
505		content = lipgloss.JoinVertical(lipgloss.Left, parts...)
506	}
507
508	return t.S().Base.
509		Width(s.width).
510		Height(s.height).
511		PaddingTop(SplashScreenPaddingY).
512		PaddingBottom(SplashScreenPaddingY).
513		Render(content)
514}
515
516func (s *splashCmp) Cursor() *tea.Cursor {
517	if s.needsAPIKey {
518		cursor := s.apiKeyInput.Cursor()
519		if cursor != nil {
520			return s.moveCursor(cursor)
521		}
522	} else if s.isOnboarding {
523		cursor := s.modelList.Cursor()
524		if cursor != nil {
525			return s.moveCursor(cursor)
526		}
527	} else {
528		return nil
529	}
530	return nil
531}
532
533func (s *splashCmp) isSmallScreen() bool {
534	// Consider a screen small if either the width is less than 40 or if the
535	// height is less than 20
536	return s.width < 55 || s.height < 20
537}
538
539func (s *splashCmp) infoSection() string {
540	t := styles.CurrentTheme()
541	infoStyle := t.S().Base.PaddingLeft(2)
542	if s.isSmallScreen() {
543		infoStyle = infoStyle.MarginTop(1)
544	}
545	return infoStyle.Render(
546		lipgloss.JoinVertical(
547			lipgloss.Left,
548			s.cwd(),
549			"",
550			s.currentModelBlock(),
551			"",
552			lipgloss.JoinHorizontal(lipgloss.Left, s.lspBlock(), s.mcpBlock()),
553			"",
554		),
555	)
556}
557
558func (s *splashCmp) logoBlock() string {
559	t := styles.CurrentTheme()
560	logoStyle := t.S().Base.Padding(0, 2).Width(s.width)
561	if s.isSmallScreen() {
562		// If the width is too small, render a smaller version of the logo
563		// NOTE: 20 is not correct because [splashCmp.height] is not the
564		// *actual* window height, instead, it is the height of the splash
565		// component and that depends on other variables like compact mode and
566		// the height of the editor.
567		return logoStyle.Render(
568			logo.SmallRender(s.width - logoStyle.GetHorizontalFrameSize()),
569		)
570	}
571	return logoStyle.Render(
572		logo.Render(version.Version, false, logo.Opts{
573			FieldColor:   t.Primary,
574			TitleColorA:  t.Secondary,
575			TitleColorB:  t.Primary,
576			CharmColor:   t.Secondary,
577			VersionColor: t.Primary,
578			Width:        s.width - logoStyle.GetHorizontalFrameSize(),
579		}),
580	)
581}
582
583func (s *splashCmp) moveCursor(cursor *tea.Cursor) *tea.Cursor {
584	if cursor == nil {
585		return nil
586	}
587	// Calculate the correct Y offset based on current state
588	logoHeight := lipgloss.Height(s.logoRendered)
589	if s.needsAPIKey {
590		infoSectionHeight := lipgloss.Height(s.infoSection())
591		baseOffset := logoHeight + SplashScreenPaddingY + infoSectionHeight
592		remainingHeight := s.height - baseOffset - lipgloss.Height(s.apiKeyInput.View()) - SplashScreenPaddingY
593		offset := baseOffset + remainingHeight
594		cursor.Y += offset
595		cursor.X = cursor.X + 1
596	} else if s.isOnboarding {
597		offset := logoHeight + SplashScreenPaddingY + s.logoGap() + 2
598		cursor.Y += offset
599		cursor.X = cursor.X + 1
600	}
601
602	return cursor
603}
604
605func (s *splashCmp) logoGap() int {
606	if s.height > 35 {
607		return LogoGap
608	}
609	return 0
610}
611
612// Bindings implements SplashPage.
613func (s *splashCmp) Bindings() []key.Binding {
614	if s.needsAPIKey {
615		return []key.Binding{
616			s.keyMap.Select,
617			s.keyMap.Back,
618		}
619	} else if s.isOnboarding {
620		return []key.Binding{
621			s.keyMap.Select,
622			s.keyMap.Next,
623			s.keyMap.Previous,
624		}
625	} else if s.needsProjectInit {
626		return []key.Binding{
627			s.keyMap.Select,
628			s.keyMap.Yes,
629			s.keyMap.No,
630			s.keyMap.Tab,
631			s.keyMap.LeftRight,
632		}
633	}
634	return []key.Binding{}
635}
636
637func (s *splashCmp) getMaxInfoWidth() int {
638	return min(s.width-2, 90) // 2 for left padding
639}
640
641func (s *splashCmp) cwd() string {
642	cwd := config.Get().WorkingDir()
643	t := styles.CurrentTheme()
644	homeDir, err := os.UserHomeDir()
645	if err == nil && cwd != homeDir {
646		cwd = strings.ReplaceAll(cwd, homeDir, "~")
647	}
648	maxWidth := s.getMaxInfoWidth()
649	return t.S().Muted.Width(maxWidth).Render(cwd)
650}
651
652func LSPList(maxWidth int) []string {
653	return lspcomponent.RenderLSPList(nil, lspcomponent.RenderOptions{
654		MaxWidth:    maxWidth,
655		ShowSection: false,
656	})
657}
658
659func (s *splashCmp) lspBlock() string {
660	t := styles.CurrentTheme()
661	maxWidth := s.getMaxInfoWidth() / 2
662	section := t.S().Subtle.Render("LSPs")
663	lspList := append([]string{section, ""}, LSPList(maxWidth-1)...)
664	return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
665		lipgloss.JoinVertical(
666			lipgloss.Left,
667			lspList...,
668		),
669	)
670}
671
672func MCPList(maxWidth int) []string {
673	return mcp.RenderMCPList(mcp.RenderOptions{
674		MaxWidth:    maxWidth,
675		ShowSection: false,
676	})
677}
678
679func (s *splashCmp) mcpBlock() string {
680	t := styles.CurrentTheme()
681	maxWidth := s.getMaxInfoWidth() / 2
682	section := t.S().Subtle.Render("MCPs")
683	mcpList := append([]string{section, ""}, MCPList(maxWidth-1)...)
684	return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
685		lipgloss.JoinVertical(
686			lipgloss.Left,
687			mcpList...,
688		),
689	)
690}
691
692func (s *splashCmp) currentModelBlock() string {
693	cfg := config.Get()
694	agentCfg := cfg.Agents["coder"]
695	model := config.Get().GetModelByType(agentCfg.Model)
696	if model == nil {
697		return ""
698	}
699	t := styles.CurrentTheme()
700	modelIcon := t.S().Base.Foreground(t.FgSubtle).Render(styles.ModelIcon)
701	modelName := t.S().Text.Render(model.Name)
702	modelInfo := fmt.Sprintf("%s %s", modelIcon, modelName)
703	parts := []string{
704		modelInfo,
705	}
706
707	return lipgloss.JoinVertical(
708		lipgloss.Left,
709		parts...,
710	)
711}
712
713func (s *splashCmp) IsShowingAPIKey() bool {
714	return s.needsAPIKey
715}
716
717func (s *splashCmp) IsAPIKeyValid() bool {
718	return s.isAPIKeyValid
719}