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 infoSection := s.infoSection()
499
500 remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2) - lipgloss.Height(infoSection)
501
502 initContent := t.S().Base.AlignVertical(lipgloss.Bottom).PaddingLeft(1).Height(remainingHeight).Render(
503 lipgloss.JoinVertical(
504 lipgloss.Left,
505 initText,
506 "",
507 buttons,
508 ),
509 )
510
511 content = lipgloss.JoinVertical(
512 lipgloss.Left,
513 s.logoRendered,
514 infoSection,
515 initContent,
516 )
517 } else {
518 parts := []string{
519 s.logoRendered,
520 s.infoSection(),
521 }
522 content = lipgloss.JoinVertical(lipgloss.Left, parts...)
523 }
524
525 return t.S().Base.
526 Width(s.width).
527 Height(s.height).
528 PaddingTop(SplashScreenPaddingY).
529 PaddingBottom(SplashScreenPaddingY).
530 Render(content)
531}
532
533func (s *splashCmp) Cursor() *tea.Cursor {
534 if s.needsAPIKey {
535 cursor := s.apiKeyInput.Cursor()
536 if cursor != nil {
537 return s.moveCursor(cursor)
538 }
539 } else if s.isOnboarding {
540 cursor := s.modelList.Cursor()
541 if cursor != nil {
542 return s.moveCursor(cursor)
543 }
544 } else {
545 return nil
546 }
547 return nil
548}
549
550func (s *splashCmp) isSmallScreen() bool {
551 // Consider a screen small if either the width is less than 40 or if the
552 // height is less than 20
553 return s.width < 55 || s.height < 20
554}
555
556func (s *splashCmp) infoSection() string {
557 t := styles.CurrentTheme()
558 infoStyle := t.S().Base.PaddingLeft(2)
559 if s.isSmallScreen() {
560 infoStyle = infoStyle.MarginTop(1)
561 }
562 return infoStyle.Render(
563 lipgloss.JoinVertical(
564 lipgloss.Left,
565 s.cwd(),
566 "",
567 lipgloss.JoinHorizontal(lipgloss.Left, s.lspBlock(), s.mcpBlock()),
568 "",
569 ),
570 )
571}
572
573func (s *splashCmp) logoBlock() string {
574 t := styles.CurrentTheme()
575 logoStyle := t.S().Base.Padding(0, 2).Width(s.width)
576 if s.isSmallScreen() {
577 // If the width is too small, render a smaller version of the logo
578 // NOTE: 20 is not correct because [splashCmp.height] is not the
579 // *actual* window height, instead, it is the height of the splash
580 // component and that depends on other variables like compact mode and
581 // the height of the editor.
582 return logoStyle.Render(
583 logo.SmallRender(s.width - logoStyle.GetHorizontalFrameSize()),
584 )
585 }
586 return logoStyle.Render(
587 logo.Render(version.Version, false, logo.Opts{
588 FieldColor: t.Primary,
589 TitleColorA: t.Secondary,
590 TitleColorB: t.Primary,
591 CharmColor: t.Secondary,
592 VersionColor: t.Primary,
593 Width: s.width - logoStyle.GetHorizontalFrameSize(),
594 }),
595 )
596}
597
598func (s *splashCmp) moveCursor(cursor *tea.Cursor) *tea.Cursor {
599 if cursor == nil {
600 return nil
601 }
602 // Calculate the correct Y offset based on current state
603 logoHeight := lipgloss.Height(s.logoRendered)
604 if s.needsAPIKey {
605 infoSectionHeight := lipgloss.Height(s.infoSection())
606 baseOffset := logoHeight + SplashScreenPaddingY + infoSectionHeight
607 remainingHeight := s.height - baseOffset - lipgloss.Height(s.apiKeyInput.View()) - SplashScreenPaddingY
608 offset := baseOffset + remainingHeight
609 cursor.Y += offset
610 cursor.X = cursor.X + 1
611 } else if s.isOnboarding {
612 offset := logoHeight + SplashScreenPaddingY + s.logoGap() + 2
613 cursor.Y += offset
614 cursor.X = cursor.X + 1
615 }
616
617 return cursor
618}
619
620func (s *splashCmp) logoGap() int {
621 if s.height > 35 {
622 return LogoGap
623 }
624 return 0
625}
626
627// Bindings implements SplashPage.
628func (s *splashCmp) Bindings() []key.Binding {
629 if s.needsAPIKey {
630 return []key.Binding{
631 s.keyMap.Select,
632 s.keyMap.Back,
633 }
634 } else if s.isOnboarding {
635 return []key.Binding{
636 s.keyMap.Select,
637 s.keyMap.Next,
638 s.keyMap.Previous,
639 }
640 } else if s.needsProjectInit {
641 return []key.Binding{
642 s.keyMap.Select,
643 s.keyMap.Yes,
644 s.keyMap.No,
645 s.keyMap.Tab,
646 s.keyMap.LeftRight,
647 }
648 }
649 return []key.Binding{}
650}
651
652func (s *splashCmp) getMaxInfoWidth() int {
653 return min(s.width-2, 40) // 2 for left padding
654}
655
656func (s *splashCmp) cwd() string {
657 cwd := config.Get().WorkingDir()
658 t := styles.CurrentTheme()
659 homeDir, err := os.UserHomeDir()
660 if err == nil && cwd != homeDir {
661 cwd = strings.ReplaceAll(cwd, homeDir, "~")
662 }
663 maxWidth := s.getMaxInfoWidth()
664 return t.S().Muted.Width(maxWidth).Render(cwd)
665}
666
667func LSPList(maxWidth int) []string {
668 t := styles.CurrentTheme()
669 lspList := []string{}
670 lsp := config.Get().LSP.Sorted()
671 if len(lsp) == 0 {
672 return []string{t.S().Base.Foreground(t.Border).Render("None")}
673 }
674 for _, l := range lsp {
675 iconColor := t.Success
676 if l.LSP.Disabled {
677 iconColor = t.FgMuted
678 }
679 lspList = append(lspList,
680 core.Status(
681 core.StatusOpts{
682 IconColor: iconColor,
683 Title: l.Name,
684 Description: l.LSP.Command,
685 },
686 maxWidth,
687 ),
688 )
689 }
690 return lspList
691}
692
693func (s *splashCmp) lspBlock() string {
694 t := styles.CurrentTheme()
695 maxWidth := s.getMaxInfoWidth() / 2
696 section := t.S().Subtle.Render("LSPs")
697 lspList := append([]string{section, ""}, LSPList(maxWidth-1)...)
698 return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
699 lipgloss.JoinVertical(
700 lipgloss.Left,
701 lspList...,
702 ),
703 )
704}
705
706func MCPList(maxWidth int) []string {
707 t := styles.CurrentTheme()
708 mcpList := []string{}
709 mcps := config.Get().MCP.Sorted()
710 if len(mcps) == 0 {
711 return []string{t.S().Base.Foreground(t.Border).Render("None")}
712 }
713 for _, l := range mcps {
714 iconColor := t.Success
715 if l.MCP.Disabled {
716 iconColor = t.FgMuted
717 }
718 mcpList = append(mcpList,
719 core.Status(
720 core.StatusOpts{
721 IconColor: iconColor,
722 Title: l.Name,
723 Description: l.MCP.Command,
724 },
725 maxWidth,
726 ),
727 )
728 }
729 return mcpList
730}
731
732func (s *splashCmp) mcpBlock() string {
733 t := styles.CurrentTheme()
734 maxWidth := s.getMaxInfoWidth() / 2
735 section := t.S().Subtle.Render("MCPs")
736 mcpList := append([]string{section, ""}, MCPList(maxWidth-1)...)
737 return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
738 lipgloss.JoinVertical(
739 lipgloss.Left,
740 mcpList...,
741 ),
742 )
743}
744
745func (s *splashCmp) IsShowingAPIKey() bool {
746 return s.needsAPIKey
747}
748
749func (s *splashCmp) IsAPIKeyValid() bool {
750 return s.isAPIKeyValid
751}