fix: lower sidebar threshold to 60 cols, word-wrap agent messages

- Sidebar threshold lowered from 120 to 60 so it works on 83-col
  terminals
- Agent response text is now word-wrapped through cl-tty.box:word-wrap
  after markdown rendering, preventing text from bleeding past the
  terminal edge
This commit is contained in:
2026-05-14 15:31:00 -04:00
parent ad5b9669a6
commit 84ef4c3443
2 changed files with 6 additions and 5 deletions

View File

@@ -1033,7 +1033,7 @@ Event handlers + daemon I/O + main loop.
(cl-tty.backend:draw-text be 0 (- h 4) (make-string w :initial-element #\─)
(theme-color :separator) nil)
(view-input be w h)
(when (and (st :sidebar-visible) (>= w 120))
(when (and (st :sidebar-visible) (>= w 60))
(view-sidebar be w h))
(setf (st :dirty) (list nil nil nil)))
(let ((ds (st :dialog-stack)))

View File

@@ -98,7 +98,7 @@ Returns a list of strings, one per line."
(defun view-chat (fb w h)
(let* ((w (or (and (numberp w) (> w 0) w) 80))
(h (or (and (numberp h) (> h 0) h) 24))
(sidebar-w (if (and (st :sidebar-visible) (>= w 120))
(sidebar-w (if (and (st :sidebar-visible) (>= w 60))
(or (st :sidebar-width) 30) 0))
(chat-w (- w sidebar-w))
(msgs (st :messages)) (total (length msgs))
@@ -136,7 +136,8 @@ Returns a list of strings, one per line."
(hdr-str (format nil "~a~a" hdr
(make-string (max 0 (- chat-w (length hdr))) :initial-element #\─)))
(nodes (cl-tty.markdown:parse-blocks cs))
(body (or (and nodes (cl-tty.markdown:render-md nodes)) (list ""))))
(raw-body (or (and nodes (cl-tty.markdown:render-md nodes)) (list "")))
(body (mapcan (lambda (l) (cl-tty.box:word-wrap l (- chat-w 2))) raw-body)))
(push (list hdr-str (theme-color :agent-header)) pairs)
(dolist (l body) (push (list l (theme-color :agent-fg)) pairs))))
(t (dolist (l (cl-tty.box:word-wrap cs (- chat-w 2)))
@@ -283,7 +284,7 @@ Returns a list of strings, one per line."
(when sd (view-status fb w h))
(when cd (view-chat fb w h))
(when id (view-input fb w h))
(when (and (st :sidebar-visible) (>= w 120))
(when (and (st :sidebar-visible) (>= w 60))
(view-sidebar fb w h))
(setf (st :dirty) (list nil nil nil))))
#+END_SRC
@@ -591,7 +592,7 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
;; If view-sidebar were called with a nil fb it would error; this verifies
;; the guard in redraw protects the call.
(let ((fb nil) (w 100) (h 24))
(is (not (and (passepartout.channel-tui::st :sidebar-visible) (>= w 120))))))
(is (not (and (passepartout.channel-tui::st :sidebar-visible) (>= w 60))))))
(test test-status-bar-tokens
"v0.9.0: status bar uses :status-fg and :status-bg theme tokens."