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