diff --git a/ui/common/common.go b/ui/common/common.go index fbfdf345b5de4b44755c4a0efef744f0979b5209..7f10fe91d52dea154250638501dfab8e533f4a13 100644 --- a/ui/common/common.go +++ b/ui/common/common.go @@ -5,6 +5,7 @@ import ( "github.com/charmbracelet/soft-serve/ui/styles" ) +// Common is a struct all components should embed. type Common struct { Styles *styles.Styles Keymap *keymap.KeyMap @@ -12,6 +13,7 @@ type Common struct { Height int } +// SetSize sets the width and height of the common struct. func (c *Common) SetSize(width, height int) { c.Width = width c.Height = height diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go index 5020047b66100ebb0bfc584a73c9bca0ce864f87..9b05b21d1064c92769b60152ae43a341217d0d8e 100644 --- a/ui/pages/selection/selection.go +++ b/ui/pages/selection/selection.go @@ -114,6 +114,7 @@ func (s *Selection) Init() tea.Cmd { session := s.s.Session() environ := session.Environ() termExists := false + // Add TERM using pty.Term if it's not already set. for _, env := range environ { if strings.HasPrefix(env, "TERM=") { termExists = true @@ -188,7 +189,7 @@ func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } case selector.ActiveMsg: cmds = append(cmds, s.changeActive(msg)) - // reset readme position + // reset readme position when active item change s.readme.GotoTop() case tea.KeyMsg: switch { diff --git a/ui/ui.go b/ui/ui.go index 21c4ab3e00bd1b53e5836fbc8e6d506055c7d7dd..932664bc9e077916935d7f338408c0c152309d84 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -142,11 +142,11 @@ func (ui *UI) View() string { s := strings.Builder{} switch ui.state { case startState: - return "\n Loading..." + s.WriteString("Loading...") case errorState: err := ui.common.Styles.ErrorTitle.Render("Bummer") err += ui.common.Styles.ErrorBody.Render(ui.error.Error()) - return err + s.WriteString(err) case loadedState: s.WriteString(lipgloss.JoinVertical( lipgloss.Bottom, @@ -155,7 +155,7 @@ func (ui *UI) View() string { ui.footer.View(), )) default: - return "\n Unknown state :/ this is a bug!" + s.WriteString("Unknown state :/ this is a bug!") } return ui.common.Styles.App.Render(s.String()) }