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 pathStyle := t.S().Base.Foreground(t.Success).PaddingLeft(2)
456 bodyStyle := t.S().Base.Foreground(t.FgMuted)
457 shortcutStyle := t.S().Base.Foreground(t.Success)
458
459 initText := lipgloss.JoinVertical(
460 lipgloss.Left,
461 titleStyle.Render("Would you like to initialize this project?"),
462 "",
463 pathStyle.Render(s.cwd()),
464 "",
465 bodyStyle.Render("When I initialize your codebase I examine the project and put the"),
466 bodyStyle.Render("result into a CRUSH.md file which serves as general context."),
467 "",
468 bodyStyle.Render("You can also initialize anytime via ")+shortcutStyle.Render("ctrl+p")+bodyStyle.Render("."),
469 "",
470 bodyStyle.Render("Would you like to initialize now?"),
471 )
472
473 yesButton := core.SelectableButton(core.ButtonOpts{
474 Text: "Yep!",
475 UnderlineIndex: 0,
476 Selected: !s.selectedNo,
477 })
478
479 noButton := core.SelectableButton(core.ButtonOpts{
480 Text: "Nope",
481 UnderlineIndex: 0,
482 Selected: s.selectedNo,
483 })
484
485 buttons := lipgloss.JoinHorizontal(lipgloss.Left, yesButton, " ", noButton)
486 remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
487
488 initContent := t.S().Base.AlignVertical(lipgloss.Bottom).PaddingLeft(1).Height(remainingHeight).Render(
489 lipgloss.JoinVertical(
490 lipgloss.Left,
491 initText,
492 "",
493 buttons,
494 ),
495 )
496
497 content = lipgloss.JoinVertical(
498 lipgloss.Left,
499 s.logoRendered,
500 "",
501 initContent,
502 )
503 } else {
504 parts := []string{
505 s.logoRendered,
506 s.infoSection(),
507 }
508 content = lipgloss.JoinVertical(lipgloss.Left, parts...)
509 }
510
511 return t.S().Base.
512 Width(s.width).
513 Height(s.height).
514 PaddingTop(SplashScreenPaddingY).
515 PaddingBottom(SplashScreenPaddingY).
516 Render(content)
517}
518
519func (s *splashCmp) Cursor() *tea.Cursor {
520 if s.needsAPIKey {
521 cursor := s.apiKeyInput.Cursor()
522 if cursor != nil {
523 return s.moveCursor(cursor)
524 }
525 } else if s.isOnboarding {
526 cursor := s.modelList.Cursor()
527 if cursor != nil {
528 return s.moveCursor(cursor)
529 }
530 } else {
531 return nil
532 }
533 return nil
534}
535
536func (s *splashCmp) isSmallScreen() bool {
537 // Consider a screen small if either the width is less than 40 or if the
538 // height is less than 20
539 return s.width < 55 || s.height < 20
540}
541
542func (s *splashCmp) infoSection() string {
543 t := styles.CurrentTheme()
544 infoStyle := t.S().Base.PaddingLeft(2)
545 if s.isSmallScreen() {
546 infoStyle = infoStyle.MarginTop(1)
547 }
548 return infoStyle.Render(
549 lipgloss.JoinVertical(
550 lipgloss.Left,
551 s.cwdPart(),
552 "",
553 s.currentModelBlock(),
554 "",
555 lipgloss.JoinHorizontal(lipgloss.Left, s.lspBlock(), s.mcpBlock()),
556 "",
557 ),
558 )
559}
560
561func (s *splashCmp) logoBlock() string {
562 t := styles.CurrentTheme()
563 logoStyle := t.S().Base.Padding(0, 2).Width(s.width)
564 if s.isSmallScreen() {
565 // If the width is too small, render a smaller version of the logo
566 // NOTE: 20 is not correct because [splashCmp.height] is not the
567 // *actual* window height, instead, it is the height of the splash
568 // component and that depends on other variables like compact mode and
569 // the height of the editor.
570 return logoStyle.Render(
571 logo.SmallRender(s.width - logoStyle.GetHorizontalFrameSize()),
572 )
573 }
574 return logoStyle.Render(
575 logo.Render(version.Version, false, logo.Opts{
576 FieldColor: t.Primary,
577 TitleColorA: t.Secondary,
578 TitleColorB: t.Primary,
579 CharmColor: t.Secondary,
580 VersionColor: t.Primary,
581 Width: s.width - logoStyle.GetHorizontalFrameSize(),
582 }),
583 )
584}
585
586func (s *splashCmp) moveCursor(cursor *tea.Cursor) *tea.Cursor {
587 if cursor == nil {
588 return nil
589 }
590 // Calculate the correct Y offset based on current state
591 logoHeight := lipgloss.Height(s.logoRendered)
592 if s.needsAPIKey {
593 infoSectionHeight := lipgloss.Height(s.infoSection())
594 baseOffset := logoHeight + SplashScreenPaddingY + infoSectionHeight
595 remainingHeight := s.height - baseOffset - lipgloss.Height(s.apiKeyInput.View()) - SplashScreenPaddingY
596 offset := baseOffset + remainingHeight
597 cursor.Y += offset
598 cursor.X = cursor.X + 1
599 } else if s.isOnboarding {
600 offset := logoHeight + SplashScreenPaddingY + s.logoGap() + 2
601 cursor.Y += offset
602 cursor.X = cursor.X + 1
603 }
604
605 return cursor
606}
607
608func (s *splashCmp) logoGap() int {
609 if s.height > 35 {
610 return LogoGap
611 }
612 return 0
613}
614
615// Bindings implements SplashPage.
616func (s *splashCmp) Bindings() []key.Binding {
617 if s.needsAPIKey {
618 return []key.Binding{
619 s.keyMap.Select,
620 s.keyMap.Back,
621 }
622 } else if s.isOnboarding {
623 return []key.Binding{
624 s.keyMap.Select,
625 s.keyMap.Next,
626 s.keyMap.Previous,
627 }
628 } else if s.needsProjectInit {
629 return []key.Binding{
630 s.keyMap.Select,
631 s.keyMap.Yes,
632 s.keyMap.No,
633 s.keyMap.Tab,
634 s.keyMap.LeftRight,
635 }
636 }
637 return []key.Binding{}
638}
639
640func (s *splashCmp) getMaxInfoWidth() int {
641 return min(s.width-2, 90) // 2 for left padding
642}
643
644func (s *splashCmp) cwdPart() string {
645 t := styles.CurrentTheme()
646 maxWidth := s.getMaxInfoWidth()
647 return t.S().Muted.Width(maxWidth).Render(s.cwd())
648}
649
650func (s *splashCmp) cwd() string {
651 cwd := config.Get().WorkingDir()
652 homeDir, err := os.UserHomeDir()
653 if err == nil && cwd != homeDir {
654 cwd = strings.ReplaceAll(cwd, homeDir, "~")
655 }
656 return cwd
657}
658
659func LSPList(maxWidth int) []string {
660 return lspcomponent.RenderLSPList(nil, lspcomponent.RenderOptions{
661 MaxWidth: maxWidth,
662 ShowSection: false,
663 })
664}
665
666func (s *splashCmp) lspBlock() string {
667 t := styles.CurrentTheme()
668 maxWidth := s.getMaxInfoWidth() / 2
669 section := t.S().Subtle.Render("LSPs")
670 lspList := append([]string{section, ""}, LSPList(maxWidth-1)...)
671 return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
672 lipgloss.JoinVertical(
673 lipgloss.Left,
674 lspList...,
675 ),
676 )
677}
678
679func MCPList(maxWidth int) []string {
680 return mcp.RenderMCPList(mcp.RenderOptions{
681 MaxWidth: maxWidth,
682 ShowSection: false,
683 })
684}
685
686func (s *splashCmp) mcpBlock() string {
687 t := styles.CurrentTheme()
688 maxWidth := s.getMaxInfoWidth() / 2
689 section := t.S().Subtle.Render("MCPs")
690 mcpList := append([]string{section, ""}, MCPList(maxWidth-1)...)
691 return t.S().Base.Width(maxWidth).PaddingRight(1).Render(
692 lipgloss.JoinVertical(
693 lipgloss.Left,
694 mcpList...,
695 ),
696 )
697}
698
699func (s *splashCmp) currentModelBlock() string {
700 cfg := config.Get()
701 agentCfg := cfg.Agents["coder"]
702 model := config.Get().GetModelByType(agentCfg.Model)
703 if model == nil {
704 return ""
705 }
706 t := styles.CurrentTheme()
707 modelIcon := t.S().Base.Foreground(t.FgSubtle).Render(styles.ModelIcon)
708 modelName := t.S().Text.Render(model.Name)
709 modelInfo := fmt.Sprintf("%s %s", modelIcon, modelName)
710 parts := []string{
711 modelInfo,
712 }
713
714 return lipgloss.JoinVertical(
715 lipgloss.Left,
716 parts...,
717 )
718}
719
720func (s *splashCmp) IsShowingAPIKey() bool {
721 return s.needsAPIKey
722}
723
724func (s *splashCmp) IsAPIKeyValid() bool {
725 return s.isAPIKeyValid
726}