diff --git a/org/channel-tui-main.org b/org/channel-tui-main.org index 047fdff..b69aa2f 100644 --- a/org/channel-tui-main.org +++ b/org/channel-tui-main.org @@ -955,8 +955,8 @@ Event handlers + daemon I/O + main loop. (case ch (:CTRL-Q (setf (st :running) nil)) (:CTRL-P (command-palette-show-commands)) - (:CTRL-B (setf (st :sidebar-visible) (not (st :sidebar-visible))) - (setf (st :dirty) (list t t nil))) + (:CTRL-B (setf (st :sidebar-visible) (not (st :sidebar-visible))) + (setf (st :dirty) (list t t t))) (:CTRL-L (setf (st :dirty) (list t t t))) (t (if (st :dialog-stack) (let* ((dlg (car (st :dialog-stack))) diff --git a/org/channel-tui-view.org b/org/channel-tui-view.org index a7254a1..09889c9 100644 --- a/org/channel-tui-view.org +++ b/org/channel-tui-view.org @@ -21,7 +21,7 @@ 5. (char-width ch): returns the terminal column width of character CH. ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8. Used by word-wrap for accurate line counting (v0.7.0). -6. (view-status win): v0.7.0 — timestamp right-aligned at (- w 12) +6. (view-status win): v0.7.0 — timestamp right-aligned at (- chat-w 12) on line 2, focus info at :x 1. No overlap. ** Status Bar @@ -75,7 +75,7 @@ Returns a list of strings, one per line." (dotimes (col w) (cl-tty.backend:draw-text fb 0 (- h 1) (make-string w :initial-element #\Space) nil bg)) (cl-tty.backend:draw-text fb 1 (- h 1) left fg nil) - (cl-tty.backend:draw-text fb (- w (length right) 2) (- h 1) right fg nil))) + (cl-tty.backend:draw-text fb (- chat-w (length right) 2) (- h 1) right fg nil))) ;; v0.7.2: search-highlight — wrap matching text in **bold** for markdown @@ -98,6 +98,9 @@ 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)) + (or (st :sidebar-width) 30) 0)) + (chat-w (- w sidebar-w)) (msgs (st :messages)) (total (length msgs)) (max-lines (- h 4)) (is-search (st :search-mode)) (y 0)) (when is-search @@ -117,9 +120,9 @@ Returns a list of strings, one per line." (:user (let* ((top (format nil "┌─ you ~a ─" time)) (top-str (format nil "~a~a┐" top - (make-string (max 0 (- w (length top) 1)) :initial-element #\─))) - (body (cl-tty.box:word-wrap cs (- w 4))) - (pad (- w 3)) + (make-string (max 0 (- chat-w (length top) 1)) :initial-element #\─))) + (body (cl-tty.box:word-wrap cs (- chat-w 4))) + (pad (- chat-w 3)) (bot (format nil "└~a┘" (make-string (max 0 pad) :initial-element #\─))) (bdr (theme-color :user-border))) (push (list top-str bdr) pairs) @@ -131,12 +134,12 @@ Returns a list of strings, one per line." (:agent (let* ((hdr (format nil "── passepartout ~a " time)) (hdr-str (format nil "~a~a" hdr - (make-string (max 0 (- w (length hdr))) :initial-element #\─))) + (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 "")))) (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 (- w 2))) + (t (dolist (l (cl-tty.box:word-wrap cs (- chat-w 2))) (push (list l (theme-color :system)) pairs)))) (let ((gt (getf msg :gate-trace))) (when (and gt (eq role :agent)) @@ -153,7 +156,7 @@ Returns a list of strings, one per line." (d (or (getf (first tc) :duration) 0.0)) (extra (reduce #'+ tc :key (lambda (c) (length (cl-tty.box:word-wrap - (or (getf c :output) "") (- w 6))))))) + (or (getf c :output) "") (- chat-w 6))))))) (push (list (format nil "┌─ ~a ──── ~,1fs ── [+~d more] ────────┐" n d extra) (theme-color :tool-done)) pairs)) (dolist (call tc) @@ -166,15 +169,15 @@ Returns a list of strings, one per line." ((eq st :error) :tool-error) (t :tool-done)))) (pfx (cond ((eq st :error) "✗") ((eq st :running) "●") (t "✓"))) - (ol (when out (cl-tty.box:word-wrap out (- w 6)))) + (ol (when out (cl-tty.box:word-wrap out (- chat-w 6)))) (top (format nil "┌─ ~a ──── ~,1fs ─" name dur)) (top-str (format nil "~a~a┐" top - (make-string (max 0 (- w (length top) 1)) :initial-element #\─))) - (bot (format nil "└~a┘" (make-string (max 0 (- w 2)) :initial-element #\─)))) + (make-string (max 0 (- chat-w (length top) 1)) :initial-element #\─))) + (bot (format nil "└~a┘" (make-string (max 0 (- chat-w 2)) :initial-element #\─)))) (push (list top-str bc) pairs) (dolist (l ol) (push (list (format nil "│ ~a ~a~a│" pfx l - (make-string (max 0 (- w (length pfx) (length l) 4)) + (make-string (max 0 (- chat-w (length pfx) (length l) 4)) :initial-element #\Space)) bc) pairs)) (push (list bot bc) pairs)))))) (when (> i 0) @@ -182,8 +185,8 @@ Returns a list of strings, one per line." (flet ((h (s) (if (> (length s) 0) (subseq s 0 (or (position #\: s) 0)) ""))) (let ((ph (h pt)) (ch (h time))) (when (and (> (length ch) 0) (string/= ch ph)) - (let* ((pad (max 0 (floor (- w (length time) 2) 2))) - (rpad (- w (length time) 2 pad))) + (let* ((pad (max 0 (floor (- chat-w (length time) 2) 2))) + (rpad (- chat-w (length time) 2 pad))) (push (list (format nil "~a ~a ~a" (make-string pad :initial-element #\─) time @@ -230,7 +233,7 @@ Returns a list of strings, one per line." "Render the right-side sidebar panel with warm colors." (let* ((w (or (and (numberp w) (> w 0) w) 80)) (h (or (and (numberp h) (> h 0) h) 24)) - (x (- w (or (st :sidebar-width) 30))) + (x (- chat-w (or (st :sidebar-width) 30))) (y 0)) ;; Vertical separator (dotimes (row h)