diff --git a/cmd/sidekick-tui/main.go b/cmd/sidekick-tui/main.go index e7441cd..5f05d55 100644 --- a/cmd/sidekick-tui/main.go +++ b/cmd/sidekick-tui/main.go @@ -161,21 +161,25 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { vpWidth := msg.Width - 4 // Account for viewportStyle padding and border vpHeight := msg.Height - headerHeight - inputHeight - 2 - r, _ := glamour.NewTermRenderer( - glamour.WithAutoStyle(), - glamour.WithWordWrap(vpWidth-2), - ) - m.renderer = r + if vpWidth > 0 && vpHeight > 0 { + r, err := glamour.NewTermRenderer( + glamour.WithStandardStyle("dark"), + glamour.WithWordWrap(vpWidth-2), + ) + if err == nil { + m.renderer = r + } - if !m.ready { - m.viewport = viewport.New(vpWidth, vpHeight) - m.ready = true - } else { - m.viewport.Width = vpWidth - m.viewport.Height = vpHeight + if !m.ready { + m.viewport = viewport.New(vpWidth, vpHeight) + m.ready = true + } else { + m.viewport.Width = vpWidth + m.viewport.Height = vpHeight + } + m.updateViewportContent() + m.viewport.GotoBottom() } - m.updateViewportContent() - m.viewport.GotoBottom() m.textarea.SetWidth(msg.Width - 4) @@ -189,6 +193,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyPgDown, tea.KeyCtrlD: m.viewport.HalfViewDown() return m, nil + case tea.KeyCtrlJ: + m.textarea.InsertString("\n") + return m, nil case tea.KeyEnter: v := m.textarea.Value() if strings.TrimSpace(v) == "" || m.isThinking {