From 84ef4c3443d03e62ee9c007df45645bda28a775c Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Thu, 14 May 2026 15:31:00 -0400 Subject: [PATCH] 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 --- org/channel-tui-main.org | 2 +- org/channel-tui-view.org | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/org/channel-tui-main.org b/org/channel-tui-main.org index b69aa2f..2ebb734 100644 --- a/org/channel-tui-main.org +++ b/org/channel-tui-main.org @@ -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))) diff --git a/org/channel-tui-view.org b/org/channel-tui-view.org index b563921..ee9abb1 100644 --- a/org/channel-tui-view.org +++ b/org/channel-tui-view.org @@ -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."