fix: multi-value backend-size, minibuffer border+width, pre-existing warnings

- backend-size: nested multiple-value-bind/values instead of or+mv-bind
  (or discards secondary values), remove stale env-var pre-check
- Minibuffer: full chat-w width (respects sidebar), horizontal rule
  border, clear filter prompt line to avoid text overlap
- Filter prompt: (or filter "") prevents "NIL" display
- Dirty-flag redraw: skip when dialog-stack is non-nil (minibuffer
  covers the area, prevents flicker)
- Remove 3 unused variables: FOCUS, SENSOR, C (pre-existing warnings)
This commit is contained in:
2026-05-15 08:51:19 -04:00
parent f56ff4849f
commit c148570d4c

View File

@@ -207,10 +207,9 @@ Event handlers + daemon I/O + main loop.
(add-msg :system (format nil "~a: ~a (~d trigger~:p this session)" tag sev n)))) (add-msg :system (format nil "~a: ~a (~d trigger~:p this session)" tag sev n))))
(add-msg :system "No tags configured. Set TAG_CATEGORIES env var.")))) (add-msg :system "No tags configured. Set TAG_CATEGORIES env var."))))
;; /context command — section breakdown with token estimates ;; /context command — section breakdown with token estimates
((string-equal text "/context") ((string-equal text "/context")
(let* ((msg-count (length (st :messages))) (let* ((msg-count (length (st :messages)))
(focus (or (st :foveal-id) "none")) (id-tokens (min 200 (floor (+ 150 (length (or (st :focus-scope) ""))) 4)))
(id-tokens (min 200 (floor (+ 150 (length (or (st :focus-scope) ""))) 4)))
(tool-tokens (if (boundp 'passepartout::*cognitive-tool-registry*) (tool-tokens (if (boundp 'passepartout::*cognitive-tool-registry*)
(floor (* (hash-table-count passepartout::*cognitive-tool-registry*) 40) 4) (floor (* (hash-table-count passepartout::*cognitive-tool-registry*) 40) 4)
50)) 50))
@@ -642,7 +641,6 @@ supplied (e.g. \"/\"), pre-fill the select filter with it."
(msg-type (getf msg :type)) (msg-type (getf msg :type))
(action (getf payload :action)) (action (getf payload :action))
(level (getf msg :level)) (level (getf msg :level))
(sensor (getf payload :sensor))
(gate-trace (getf msg :gate-trace)) (gate-trace (getf msg :gate-trace))
(rule-count (getf payload :rule-count)) (rule-count (getf payload :rule-count))
(foveal-id (getf payload :foveal-id))) (foveal-id (getf payload :foveal-id)))
@@ -769,7 +767,8 @@ supplied (e.g. \"/\"), pre-fill the select filter with it."
:name "tui-reader") :name "tui-reader")
(return-from connect-daemon t)) (return-from connect-daemon t))
(usocket:connection-refused-error (c) (usocket:connection-refused-error (c)
(when (= attempt 3) (declare (ignore c))
(when (= attempt 3)
(add-msg :system (format nil "* No daemon on port ~a after ~a attempts *" (add-msg :system (format nil "* No daemon on port ~a after ~a attempts *"
port attempt)))) port attempt))))
(error (c) (error (c)
@@ -994,7 +993,8 @@ supplied (e.g. \"/\"), pre-fill the select filter with it."
;; Guard w and h before render (resize or other code may have set them to nil) ;; Guard w and h before render (resize or other code may have set them to nil)
(setq w (or (and (numberp w) (> w 0) w) 80) (setq w (or (and (numberp w) (> w 0) w) 80)
h (or (and (numberp h) (> h 0) h) 24)) h (or (and (numberp h) (> h 0) h) 24))
(when (or (first (st :dirty)) (second (st :dirty)) (third (st :dirty))) (when (and (or (first (st :dirty)) (second (st :dirty)) (third (st :dirty)))
(null (st :dialog-stack)))
(let* ((sidebar-w (if (and (st :sidebar-visible) (>= w 60)) (let* ((sidebar-w (if (and (st :sidebar-visible) (>= w 60))
(or (st :sidebar-width) 30) 0)) (or (st :sidebar-width) 30) 0))
(chat-w (- w sidebar-w))) (chat-w (- w sidebar-w)))
@@ -1011,48 +1011,55 @@ supplied (e.g. \"/\"), pre-fill the select filter with it."
(cl-tty.backend:end-sync be) (cl-tty.backend:end-sync be)
(setf (st :dirty) (list nil nil nil)))) (setf (st :dirty) (list nil nil nil))))
(let ((ds (st :dialog-stack))) (let ((ds (st :dialog-stack)))
(when ds (when ds
(cl-tty.backend:begin-sync be) (cl-tty.backend:begin-sync be)
(let* ((dlg (car ds)) (let* ((sidebar-w (if (and (st :sidebar-visible) (>= w 60))
(sel (cl-tty.dialog:dialog-content dlg)) (or (st :sidebar-width) 30) 0))
(filtered (cl-tty.select:select-filtered-options sel)) (chat-w (- w sidebar-w))
(sel-idx (cl-tty.select:select-selected-index sel)) (dlg (car ds))
(cnt (length filtered)) (sel (cl-tty.dialog:dialog-content dlg))
(filter (cl-tty.select:select-filter sel)) (filtered (cl-tty.select:select-filtered-options sel))
;; Bottom-anchored: filter at h-3, options above (sel-idx (cl-tty.select:select-selected-index sel))
(mh (min 15 (+ 1 cnt))) ;; +1 for title (cnt (length filtered))
(top (max 0 (- h 3 mh)))) (filter (cl-tty.select:select-filter sel))
;; Clear the full minibuffer area (top to h-2) (mh (min 15 (+ 1 cnt))) ;; +1 for title
(dotimes (r (min (- h 2 top) h)) (top (max 0 (- h 4 mh))))
(cl-tty.backend:draw-rect be 0 (+ top r) w 1 ;; Clear the minibuffer area
:bg (theme-color :status-bg))) (dotimes (r (min (- h 3 top) h))
;; Title line (cl-tty.backend:draw-rect be 0 (+ top r) chat-w 1
(cl-tty.backend:draw-text be 0 top :bg (theme-color :status-bg)))
(cl-tty.dialog:dialog-title dlg) ;; Top border line with title
(theme-color :accent) nil) (cl-tty.backend:draw-text be 0 top
;; Options (make-string chat-w :initial-element #\─)
(let ((y-off 1)) (theme-color :separator) nil)
(dolist (item filtered) (cl-tty.backend:draw-text be 1 top
(let* ((display-idx (first item)) (cl-tty.dialog:dialog-title dlg)
(option (third item)) (theme-color :accent) nil)
(title (getf option :title)) ;; Options
(cat (getf option :category)) (let ((y-off 1))
(sel-p (eql display-idx sel-idx)) (dolist (item filtered)
(text (if cat (format nil " ~a" title) (let* ((display-idx (first item))
(format nil " ~:[ ~;▸~] ~a" sel-p title))) (option (third item))
(row (+ top y-off))) (title (getf option :title))
(when (>= row (1- h)) (return)) (cat (getf option :category))
(cl-tty.backend:draw-text be 1 row text (sel-p (eql display-idx sel-idx))
(cond (cat (theme-color :dim)) (text (if cat (format nil " ~a" title)
(sel-p (theme-color :accent)) (format nil " ~:[ ~;▸~] ~a" sel-p title)))
(t (theme-color :agent-fg))) (row (+ top y-off)))
nil :bold sel-p) (when (>= row (1- h)) (return))
(incf y-off)))) (cl-tty.backend:draw-text be 1 row text
;; Filter prompt at h-3 (cond (cat (theme-color :dim))
(cl-tty.backend:draw-text be 0 (- h 3) (sel-p (theme-color :accent))
(format nil "> ~a" filter) (t (theme-color :agent-fg)))
(theme-color :input-prompt) nil)) nil :bold sel-p)
(cl-tty.backend:end-sync be)) (incf y-off))))
;; Filter prompt at h-3
(cl-tty.backend:draw-rect be 0 (- h 3) chat-w 1
:bg (theme-color :status-bg))
(cl-tty.backend:draw-text be 0 (- h 3)
(format nil "> ~a" (or filter ""))
(theme-color :input-prompt) nil))
(cl-tty.backend:end-sync be))
(sleep 0.1)) (sleep 0.1))
(progn (disconnect-daemon)))))) (progn (disconnect-daemon))))))
#+END_SRC #+END_SRC