@@ -38,6 +38,7 @@ type model struct {
3838 // State
3939 isWorking bool
4040 cancel context.CancelFunc
41+ width int
4142
4243 // Views
4344 spinner spinner.Model
@@ -64,8 +65,6 @@ func initialModel(agent *agent.Agent) model {
6465 styles := t .Styles ()
6566 styles .Focused .CursorLine = styles .Focused .CursorLine .UnsetBackground ()
6667
67- t .MaxWidth = maxWidth - len (t .Prompt ) - 2 * textareaPadding
68-
6968 t .Focus ()
7069 t .SetHeight (1 )
7170 t .SetStyles (styles )
@@ -94,7 +93,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9493
9594 switch msg := msg .(type ) {
9695 case tea.WindowSizeMsg :
97- m .textarea .SetWidth (msg .Width )
96+ m .width = msg .Width
97+ m .textarea .SetWidth (msg .Width - textareaStyle .GetHorizontalFrameSize ())
9898 m .help .SetWidth (msg .Width )
9999 case tea.KeyPressMsg :
100100 switch {
@@ -299,10 +299,12 @@ func (m *model) mustRenderToolCallMarkdown(s string) string {
299299// mustRenderMarkdownWithStyle renders a string as markdown with the given style. It
300300// panics if there is a render error.
301301func (m * model ) mustRenderMarkdownWithStyle (s string , style ansi.StyleConfig ) string {
302- t , err := glamour .NewTermRenderer (
303- glamour .WithStyles (style ),
304- glamour .WithWordWrap (maxWidth ),
305- )
302+ options := []glamour.TermRendererOption {glamour .WithStyles (style )}
303+ if m .width > 0 {
304+ options = append (options , glamour .WithWordWrap (m .width ))
305+ }
306+
307+ t , err := glamour .NewTermRenderer (options ... )
306308 if err != nil {
307309 panic (err )
308310 }
0 commit comments