splash.go

  1package splash
  2
  3import (
  4	"fmt"
  5	"strings"
  6	"time"
  7
  8	"github.com/charmbracelet/bubbles/v2/key"
  9	"github.com/charmbracelet/bubbles/v2/spinner"
 10	tea "github.com/charmbracelet/bubbletea/v2"
 11	"github.com/charmbracelet/catwalk/pkg/catwalk"
 12	"github.com/charmbracelet/crush/internal/agent"
 13	"github.com/charmbracelet/crush/internal/config"
 14	"github.com/charmbracelet/crush/internal/home"
 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				s.selectedNo = false
257				return s, s.initializeProject()
258			}
259		case key.Matches(msg, s.keyMap.No):
260			if s.needsAPIKey {
261				u, cmd := s.apiKeyInput.Update(msg)
262				s.apiKeyInput = u.(*models.APIKeyInput)
263				return s, cmd
264			}
265			if s.isOnboarding {
266				u, cmd := s.modelList.Update(msg)
267				s.modelList = u
268				return s, cmd
269			}
270			if s.needsProjectInit {
271				s.selectedNo = true
272				return s, s.initializeProject()
273			}
274		default:
275			if s.needsAPIKey {
276				u, cmd := s.apiKeyInput.Update(msg)
277				s.apiKeyInput = u.(*models.APIKeyInput)
278				return s, cmd
279			} else if s.isOnboarding {
280				u, cmd := s.modelList.Update(msg)
281				s.modelList = u
282				return s, cmd
283			}
284		}
285	case tea.PasteMsg:
286		if s.needsAPIKey {
287			u, cmd := s.apiKeyInput.Update(msg)
288			s.apiKeyInput = u.(*models.APIKeyInput)
289			return s, cmd
290		} else if s.isOnboarding {
291			var cmd tea.Cmd
292			s.modelList, cmd = s.modelList.Update(msg)
293			return s, cmd
294		}
295	case spinner.TickMsg:
296		u, cmd := s.apiKeyInput.Update(msg)
297		s.apiKeyInput = u.(*models.APIKeyInput)
298		return s, cmd
299	}
300	return s, nil
301}
302
303func (s *splashCmp) saveAPIKeyAndContinue(apiKey string) tea.Cmd {
304	if s.selectedModel == nil {
305		return nil
306	}
307
308	cfg := config.Get()
309	err := cfg.SetProviderAPIKey(string(s.selectedModel.Provider.ID), apiKey)
310	if err != nil {
311		return util.ReportError(fmt.Errorf("failed to save API key: %w", err))
312	}
313
314	// Reset API key state and continue with model selection
315	s.needsAPIKey = false
316	cmd := s.setPreferredModel(*s.selectedModel)
317	s.isOnboarding = false
318	s.selectedModel = nil
319	s.isAPIKeyValid = false
320
321	return tea.Batch(cmd, util.CmdHandler(OnboardingCompleteMsg{}))
322}
323
324func (s *splashCmp) initializeProject() tea.Cmd {
325	s.needsProjectInit = false
326
327	if err := config.MarkProjectInitialized(); err != nil {
328		return util.ReportError(err)
329	}
330	var cmds []tea.Cmd
331
332	cmds = append(cmds, util.CmdHandler(OnboardingCompleteMsg{}))
333	if !s.selectedNo {
334		cmds = append(cmds,
335			util.CmdHandler(chat.SessionClearedMsg{}),
336			util.CmdHandler(chat.SendMsg{
337				Text: agent.InitializePrompt(),
338			}),
339		)
340	}
341	return tea.Sequence(cmds...)
342}
343
344func (s *splashCmp) setPreferredModel(selectedItem models.ModelOption) tea.Cmd {
345	cfg := config.Get()
346	model := cfg.GetModel(string(selectedItem.Provider.ID), selectedItem.Model.ID)
347	if model == nil {
348		return util.ReportError(fmt.Errorf("model %s not found for provider %s", selectedItem.Model.ID, selectedItem.Provider.ID))
349	}
350
351	selectedModel := config.SelectedModel{
352		Model:           selectedItem.Model.ID,
353		Provider:        string(selectedItem.Provider.ID),
354		ReasoningEffort: model.DefaultReasoningEffort,
355		MaxTokens:       model.DefaultMaxTokens,
356	}
357
358	err := cfg.UpdatePreferredModel(config.SelectedModelTypeLarge, selectedModel)
359	if err != nil {
360		return util.ReportError(err)
361	}
362
363	// Now lets automatically setup the small model
364	knownProvider, err := s.getProvider(selectedItem.Provider.ID)
365	if err != nil {
366		return util.ReportError(err)
367	}
368	if knownProvider == nil {
369		// for local provider we just use the same model
370		err = cfg.UpdatePreferredModel(config.SelectedModelTypeSmall, selectedModel)
371		if err != nil {
372			return util.ReportError(err)
373		}
374	} else {
375		smallModel := knownProvider.DefaultSmallModelID
376		model := cfg.GetModel(string(selectedItem.Provider.ID), smallModel)
377		// should never happen
378		if model == nil {
379			err = cfg.UpdatePreferredModel(config.SelectedModelTypeSmall, selectedModel)
380			if err != nil {
381				return util.ReportError(err)
382			}
383			return nil
384		}
385		smallSelectedModel := config.SelectedModel{
386			Model:           smallModel,
387			Provider:        string(selectedItem.Provider.ID),
388			ReasoningEffort: model.DefaultReasoningEffort,
389			MaxTokens:       model.DefaultMaxTokens,
390		}
391		err = cfg.UpdatePreferredModel(config.SelectedModelTypeSmall, smallSelectedModel)
392		if err != nil {
393			return util.ReportError(err)
394		}
395	}
396	cfg.SetupAgents()
397	return nil
398}
399
400func (s *splashCmp) getProvider(providerID catwalk.InferenceProvider) (*catwalk.Provider, error) {
401	cfg := config.Get()
402	providers, err := config.Providers(cfg)
403	if err != nil {
404		return nil, err
405	}
406	for _, p := range providers {
407		if p.ID == providerID {
408			return &p, nil
409		}
410	}
411	return nil, nil
412}
413
414func (s *splashCmp) isProviderConfigured(providerID string) bool {
415	cfg := config.Get()
416	if _, ok := cfg.Providers.Get(providerID); ok {
417		return true
418	}
419	return false
420}
421
422func (s *splashCmp) View() string {
423	t := styles.CurrentTheme()
424	var content string
425	if s.needsAPIKey {
426		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
427		apiKeyView := t.S().Base.PaddingLeft(1).Render(s.apiKeyInput.View())
428		apiKeySelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
429			lipgloss.JoinVertical(
430				lipgloss.Left,
431				apiKeyView,
432			),
433		)
434		content = lipgloss.JoinVertical(
435			lipgloss.Left,
436			s.logoRendered,
437			apiKeySelector,
438		)
439	} else if s.isOnboarding {
440		modelListView := s.modelList.View()
441		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
442		modelSelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
443			lipgloss.JoinVertical(
444				lipgloss.Left,
445				t.S().Base.PaddingLeft(1).Foreground(t.Primary).Render("Choose a Model"),
446				"",
447				modelListView,
448			),
449		)
450		content = lipgloss.JoinVertical(
451			lipgloss.Left,
452			s.logoRendered,
453			modelSelector,
454		)
455	} else if s.needsProjectInit {
456		titleStyle := t.S().Base.Foreground(t.FgBase)
457		pathStyle := t.S().Base.Foreground(t.Success).PaddingLeft(2)
458		bodyStyle := t.S().Base.Foreground(t.FgMuted)
459		shortcutStyle := t.S().Base.Foreground(t.Success)
460
461		initText := lipgloss.JoinVertical(
462			lipgloss.Left,
463			titleStyle.Render("Would you like to initialize this project?"),
464			"",
465			pathStyle.Render(s.cwd()),
466			"",
467			bodyStyle.Render("When I initialize your codebase I examine the project and put the"),
468			bodyStyle.Render("result into a CRUSH.md file which serves as general context."),
469			"",
470			bodyStyle.Render("You can also initialize anytime via ")+shortcutStyle.Render("ctrl+p")+bodyStyle.Render("."),
471			"",
472			bodyStyle.Render("Would you like to initialize now?"),
473		)
474
475		yesButton := core.SelectableButton(core.ButtonOpts{
476			Text:           "Yep!",
477			UnderlineIndex: 0,
478			Selected:       !s.selectedNo,
479		})
480
481		noButton := core.SelectableButton(core.ButtonOpts{
482			Text:           "Nope",
483			UnderlineIndex: 0,
484			Selected:       s.selectedNo,
485		})
486
487		buttons := lipgloss.JoinHorizontal(lipgloss.Left, yesButton, "  ", noButton)
488		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
489
490		initContent := t.S().Base.AlignVertical(lipgloss.Bottom).PaddingLeft(1).Height(remainingHeight).Render(
491			lipgloss.JoinVertical(
492				lipgloss.Left,
493				initText,
494				"",
495				buttons,
496			),
497		)
498
499		content = lipgloss.JoinVertical(
500			lipgloss.Left,
501			s.logoRendered,
502			"",
503			initContent,
504		)
505	} else {
506		parts := []string{
507			s.logoRendered,
508			s.infoSection(),
509		}
510		content = lipgloss.JoinVertical(lipgloss.Left, parts...)
511	}
512
513	return t.S().Base.
514		Width(s.width).
515		Height(s.height).
516		PaddingTop(SplashScreenPaddingY).
517		PaddingBottom(SplashScreenPaddingY).
518		Render(content)
519}
520
521func (s *splashCmp) Cursor() *tea.Cursor {
522	if s.needsAPIKey {
523		cursor := s.apiKeyInput.Cursor()
524		if cursor != nil {
525			return s.moveCursor(cursor)
526		}
527	} else if s.isOnboarding {
528		cursor := s.modelList.Cursor()
529		if cursor != nil {
530			return s.moveCursor(cursor)
531		}
532	} else {
533		return nil
534	}
535	return nil
536}
537
538func (s *splashCmp) isSmallScreen() bool {
539	// Consider a screen small if either the width is less than 40 or if the
540	// height is less than 20
541	return s.width < 55 || s.height < 20
542}
543
544func (s *splashCmp) infoSection() string {
545	t := styles.CurrentTheme()
546	infoStyle := t.S().Base.PaddingLeft(2)
547	if s.isSmallScreen() {
548		infoStyle = infoStyle.MarginTop(1)
549	}
550	return infoStyle.Render(
551		lipgloss.JoinVertical(
552			lipgloss.Left,
553			s.cwdPart(),
554			"",
555			s.currentModelBlock(),
556			"",
557			lipgloss.JoinHorizontal(lipgloss.Left, s.lspBlock(), s.mcpBlock()),
558			"",
559		),
560	)
561}
562
563func (s *splashCmp) logoBlock() string {
564	t := styles.CurrentTheme()
565	logoStyle := t.S().Base.Padding(0, 2).Width(s.width)
566	if s.isSmallScreen() {
567		// If the width is too small, render a smaller version of the logo
568		// NOTE: 20 is not correct because [splashCmp.height] is not the
569		// *actual* window height, instead, it is the height of the splash
570		// component and that depends on other variables like compact mode and
571		// the height of the editor.
572		return logoStyle.Render(
573			logo.SmallRender(s.width - logoStyle.GetHorizontalFrameSize()),
574		)
575	}
576	return logoStyle.Render(
577		logo.Render(version.Version, false, logo.Opts{
578			FieldColor:   t.Primary,
579			TitleColorA:  t.Secondary,
580			TitleColorB:  t.Primary,
581			CharmColor:   t.Secondary,
582			VersionColor: t.Primary,
583			Width:        s.width - logoStyle.GetHorizontalFrameSize(),
584		}),
585	)
586}
587
588func (s *splashCmp) moveCursor(cursor *tea.Cursor) *tea.Cursor {
589	if cursor == nil {
590		return nil
591	}
592	// Calculate the correct Y offset based on current state
593	logoHeight := lipgloss.Height(s.logoRendered)
594	if s.needsAPIKey {
595		infoSectionHeight := lipgloss.Height(s.infoSection())
596		baseOffset := logoHeight + SplashScreenPaddingY + infoSectionHeight
597		remainingHeight := s.height - baseOffset - lipgloss.Height(s.apiKeyInput.View()) - SplashScreenPaddingY
598		offset := baseOffset + remainingHeight
599		cursor.Y += offset
600		cursor.X = cursor.X + 1
601	} else if s.isOnboarding {
602		offset := logoHeight + SplashScreenPaddingY + s.logoGap() + 2
603		cursor.Y += offset
604		cursor.X = cursor.X + 1
605	}
606
607	return cursor
608}
609
610func (s *splashCmp) logoGap() int {
611	if s.height > 35 {
612		return LogoGap
613	}
614	return 0
615}
616
617// Bindings implements SplashPage.
618func (s *splashCmp) Bindings() []key.Binding {
619	if s.needsAPIKey {
620		return []key.Binding{
621			s.keyMap.Select,
622			s.keyMap.Back,
623		}
624	} else if s.isOnboarding {
625		return []key.Binding{
626			s.keyMap.Select,
627			s.keyMap.Next,
628			s.keyMap.Previous,
629		}
630	} else if s.needsProjectInit {
631		return []key.Binding{
632			s.keyMap.Select,
633			s.keyMap.Yes,
634			s.keyMap.No,
635			s.keyMap.Tab,
636			s.keyMap.LeftRight,
637		}
638	}
639	return []key.Binding{}
640}
641
642func (s *splashCmp) getMaxInfoWidth() int {
643	return min(s.width-2, 90) // 2 for left padding
644}
645
646func (s *splashCmp) cwdPart() string {
647	t := styles.CurrentTheme()
648	maxWidth := s.getMaxInfoWidth()
649	return t.S().Muted.Width(maxWidth).Render(s.cwd())
650}
651
652func (s *splashCmp) cwd() string {
653	return home.Short(config.Get().WorkingDir())
654}
655
656func LSPList(maxWidth int) []string {
657	return lspcomponent.RenderLSPList(nil, lspcomponent.RenderOptions{
658		MaxWidth:    maxWidth,
659		ShowSection: false,
660	})
661}
662
663func (s *splashCmp) lspBlock() string {
664	t := styles.CurrentTheme()
665	maxWidth := s.getMaxInfoWidth() / 2
666	section := t.S().Subtle.Render("LSPs")
667	lspList := append([]string{section, ""}, LSPList(maxWidth-1)...)
668	return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
669		lipgloss.JoinVertical(
670			lipgloss.Left,
671			lspList...,
672		),
673	)
674}
675
676func MCPList(maxWidth int) []string {
677	return mcp.RenderMCPList(mcp.RenderOptions{
678		MaxWidth:    maxWidth,
679		ShowSection: false,
680	})
681}
682
683func (s *splashCmp) mcpBlock() string {
684	t := styles.CurrentTheme()
685	maxWidth := s.getMaxInfoWidth() / 2
686	section := t.S().Subtle.Render("MCPs")
687	mcpList := append([]string{section, ""}, MCPList(maxWidth-1)...)
688	return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
689		lipgloss.JoinVertical(
690			lipgloss.Left,
691			mcpList...,
692		),
693	)
694}
695
696func (s *splashCmp) currentModelBlock() string {
697	cfg := config.Get()
698	agentCfg := cfg.Agents[config.AgentCoder]
699	model := config.Get().GetModelByType(agentCfg.Model)
700	if model == nil {
701		return ""
702	}
703	t := styles.CurrentTheme()
704	modelIcon := t.S().Base.Foreground(t.FgSubtle).Render(styles.ModelIcon)
705	modelName := t.S().Text.Render(model.Name)
706	modelInfo := fmt.Sprintf("%s %s", modelIcon, modelName)
707	parts := []string{
708		modelInfo,
709	}
710
711	return lipgloss.JoinVertical(
712		lipgloss.Left,
713		parts...,
714	)
715}
716
717func (s *splashCmp) IsShowingAPIKey() bool {
718	return s.needsAPIKey
719}
720
721func (s *splashCmp) IsAPIKeyValid() bool {
722	return s.isAPIKeyValid
723}