on main help sign in
chore: small ux changes
02d9affKujtim Hoxha
internal/tui/components/chat/splash/splash.go+38−36
@@ -38,8 +38,9 @@ type Splash interface {
38}
38}
39
39
40const (
40const (
41− SplashScreenPaddingX = 2 // Padding X for the splash screen
42 SplashScreenPaddingY = 1 // Padding Y for the splash screen
41 SplashScreenPaddingY = 1 // Padding Y for the splash screen
42+
43+ LogoGap = 6
43)
44)
44
45
45// OnboardingCompleteMsg is sent when onboarding is complete
46// OnboardingCompleteMsg is sent when onboarding is complete
@@ -56,6 +57,7 @@ type splashCmp struct {
56 needsAPIKey bool
57 needsAPIKey bool
57 selectedNo bool
58 selectedNo bool
58
59
60+ listHeight int
59 modelList *models.ModelListComponent
61 modelList *models.ModelListComponent
60 apiKeyInput *models.APIKeyInput
62 apiKeyInput *models.APIKeyInput
61 selectedModel *models.ModelOption
63 selectedModel *models.ModelOption
@@ -134,11 +136,10 @@ func (s *splashCmp) SetSize(width int, height int) tea.Cmd {
134 s.width = width
136 s.width = width
135 s.logoRendered = s.logoBlock()
137 s.logoRendered = s.logoBlock()
136 }
138 }
137− infoSectionHeight := lipgloss.Height(s.infoSection())
139+ // remove padding, logo height, gap, title space
138− listHeigh := min(40, height-(SplashScreenPaddingY*2)-lipgloss.Height(s.logoRendered)-2-infoSectionHeight)
140+ s.listHeight = s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2) - s.logoGap() - 2
139− listWidth := min(60, width-(SplashScreenPaddingX*2))
141+ listWidth := min(60, width)
140−
141− return s.modelList.SetSize(listWidth, listHeigh)
142+ return s.modelList.SetSize(listWidth, s.listHeight)
142}
143}
143
144
144// Update implements SplashPage.
145// Update implements SplashPage.
@@ -347,9 +348,8 @@ func (s *splashCmp) View() string {
347 t := styles.CurrentTheme()
348 t := styles.CurrentTheme()
348 var content string
349 var content string
349 if s.needsAPIKey {
350 if s.needsAPIKey {
350− infoSection := s.infoSection()
351− remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2) - lipgloss.Height(infoSection)
351+ remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
352− apiKeyView := s.apiKeyInput.View()
352+ apiKeyView := t.S().Base.PaddingLeft(1).Render(s.apiKeyInput.View())
353 apiKeySelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
353 apiKeySelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
354 lipgloss.JoinVertical(
354 lipgloss.JoinVertical(
355 lipgloss.Left,
355 lipgloss.Left,
@@ -359,13 +359,11 @@ func (s *splashCmp) View() string {
359 content = lipgloss.JoinVertical(
359 content = lipgloss.JoinVertical(
360 lipgloss.Left,
360 lipgloss.Left,
361 s.logoRendered,
361 s.logoRendered,
362− infoSection,
363 apiKeySelector,
362 apiKeySelector,
364 )
363 )
365 } else if s.isOnboarding {
364 } else if s.isOnboarding {
366− infoSection := s.infoSection()
367− remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2) - lipgloss.Height(infoSection)
368 modelListView := s.modelList.View()
365 modelListView := s.modelList.View()
366+ remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
369 modelSelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
367 modelSelector := t.S().Base.AlignVertical(lipgloss.Bottom).Height(remainingHeight).Render(
370 lipgloss.JoinVertical(
368 lipgloss.JoinVertical(
371 lipgloss.Left,
369 lipgloss.Left,
@@ -377,7 +375,6 @@ func (s *splashCmp) View() string {
377 content = lipgloss.JoinVertical(
375 content = lipgloss.JoinVertical(
378 lipgloss.Left,
376 lipgloss.Left,
379 s.logoRendered,
377 s.logoRendered,
380− infoSection,
381 modelSelector,
378 modelSelector,
382 )
379 )
383 } else if s.needsProjectInit {
380 } else if s.needsProjectInit {
@@ -441,8 +438,6 @@ func (s *splashCmp) View() string {
441 Width(s.width).
438 Width(s.width).
442 Height(s.height).
439 Height(s.height).
443 PaddingTop(SplashScreenPaddingY).
440 PaddingTop(SplashScreenPaddingY).
444− PaddingLeft(SplashScreenPaddingX).
445− PaddingRight(SplashScreenPaddingX).
446 PaddingBottom(SplashScreenPaddingY).
441 PaddingBottom(SplashScreenPaddingY).
447 Render(content)
442 Render(content)
448}
443}
@@ -476,40 +471,47 @@ func (s *splashCmp) infoSection() string {
476
471
477func (s *splashCmp) logoBlock() string {
472func (s *splashCmp) logoBlock() string {
478 t := styles.CurrentTheme()
473 t := styles.CurrentTheme()
479− const padding = 2
474+ return t.S().Base.Padding(0, 2).Width(s.width).Render(
480− return logo.Render(version.Version, false, logo.Opts{
475+ logo.Render(version.Version, false, logo.Opts{
481− FieldColor: t.Primary,
476+ FieldColor: t.Primary,
482− TitleColorA: t.Secondary,
477+ TitleColorA: t.Secondary,
483− TitleColorB: t.Primary,
478+ TitleColorB: t.Primary,
484− CharmColor: t.Secondary,
479+ CharmColor: t.Secondary,
485− VersionColor: t.Primary,
480+ VersionColor: t.Primary,
486− Width: s.width - (SplashScreenPaddingX * 2),
481+ Width: s.width - 4,
487− })
482+ }),
483+ )
488}
484}
489
485
490−func (m *splashCmp) moveCursor(cursor *tea.Cursor) *tea.Cursor {
486+func (s *splashCmp) moveCursor(cursor *tea.Cursor) *tea.Cursor {
491 if cursor == nil {
487 if cursor == nil {
492 return nil
488 return nil
493 }
489 }
494 // Calculate the correct Y offset based on current state
490 // Calculate the correct Y offset based on current state
495− logoHeight := lipgloss.Height(m.logoRendered)
491+ logoHeight := lipgloss.Height(s.logoRendered)
496− infoSectionHeight := lipgloss.Height(m.infoSection())
497− baseOffset := logoHeight + SplashScreenPaddingY + infoSectionHeight
498− if m.needsAPIKey {
492+ if s.needsAPIKey {
493+ infoSectionHeight := lipgloss.Height(s.infoSection())
494+ baseOffset := logoHeight + SplashScreenPaddingY + infoSectionHeight
499− remainingHeight := m.height - baseOffset - lipgloss.Height(m.apiKeyInput.View()) - SplashScreenPaddingY
495+ remainingHeight := s.height - baseOffset - lipgloss.Height(s.apiKeyInput.View()) - SplashScreenPaddingY
500 offset := baseOffset + remainingHeight
496 offset := baseOffset + remainingHeight
501 cursor.Y += offset
497 cursor.Y += offset
502− cursor.X = cursor.X + SplashScreenPaddingX
498+ cursor.X = cursor.X + 1
503− } else if m.isOnboarding {
499+ } else if s.isOnboarding {
504− listHeight := min(40, m.height-(SplashScreenPaddingY)-baseOffset)
500+ offset := logoHeight + SplashScreenPaddingY + s.logoGap() + 3
505− offset := m.height - listHeight + 2
506 cursor.Y += offset
501 cursor.Y += offset
507− cursor.X = cursor.X + SplashScreenPaddingX + 1
502+ cursor.X = cursor.X + 1
508 }
503 }
509
504
510 return cursor
505 return cursor
511}
506}
512
507
508+func (s *splashCmp) logoGap() int {
509+ if s.height > 35 {
510+ return LogoGap
511+ }
512+ return 0
513+}
514+
513// Bindings implements SplashPage.
515// Bindings implements SplashPage.
514func (s *splashCmp) Bindings() []key.Binding {
516func (s *splashCmp) Bindings() []key.Binding {
515 if s.needsAPIKey {
517 if s.needsAPIKey {
@@ -536,7 +538,7 @@ func (s *splashCmp) Bindings() []key.Binding {
536}
538}
537
539
538func (s *splashCmp) getMaxInfoWidth() int {
540func (s *splashCmp) getMaxInfoWidth() int {
539− return min(s.width-(SplashScreenPaddingX*2), 40)
541+ return min(s.width, 40)
540}
542}
541
543
542func (s *splashCmp) cwd() string {
544func (s *splashCmp) cwd() string {