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 "No tags configured. Set TAG_CATEGORIES env var."))))
;; /context command — section breakdown with token estimates
((string-equal text "/context")
(let* ((msg-count (length (st :messages)))
(focus (or (st :foveal-id) "none"))
(id-tokens (min 200 (floor (+ 150 (length (or (st :focus-scope) ""))) 4)))
((string-equal text "/context")
(let* ((msg-count (length (st :messages)))
(id-tokens (min 200 (floor (+ 150 (length (or (st :focus-scope) ""))) 4)))
(tool-tokens (if (boundp 'passepartout::*cognitive-tool-registry*)
(floor (* (hash-table-count passepartout::*cognitive-tool-registry*) 40) 4)
50))
@@ -642,7 +641,6 @@ supplied (e.g. \"/\"), pre-fill the select filter with it."
(msg-type (getf msg :type))
(action (getf payload :action))
(level (getf msg :level))
(sensor (getf payload :sensor))
(gate-trace (getf msg :gate-trace))
(rule-count (getf payload :rule-count))
(foveal-id (getf payload :foveal-id)))
@@ -769,7 +767,8 @@ supplied (e.g. \"/\"), pre-fill the select filter with it."
:name "tui-reader")
(return-from connect-daemon t))
(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 *"
port attempt))))
(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)
(setq w (or (and (numberp w) (> w 0) w) 80)
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))
(or (st :sidebar-width) 30) 0))
(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)
(setf (st :dirty) (list nil nil nil))))
(let ((ds (st :dialog-stack)))
(when ds
(cl-tty.backend:begin-sync be)
(let* ((dlg (car ds))
(sel (cl-tty.dialog:dialog-content dlg))
(filtered (cl-tty.select:select-filtered-options sel))
(sel-idx (cl-tty.select:select-selected-index sel))
(cnt (length filtered))
(filter (cl-tty.select:select-filter sel))
;; Bottom-anchored: filter at h-3, options above
(mh (min 15 (+ 1 cnt))) ;; +1 for title
(top (max 0 (- h 3 mh))))
;; Clear the full minibuffer area (top to h-2)
(dotimes (r (min (- h 2 top) h))
(cl-tty.backend:draw-rect be 0 (+ top r) w 1
:bg (theme-color :status-bg)))
;; Title line
(cl-tty.backend:draw-text be 0 top
(cl-tty.dialog:dialog-title dlg)
(theme-color :accent) nil)
;; Options
(let ((y-off 1))
(dolist (item filtered)
(let* ((display-idx (first item))
(option (third item))
(title (getf option :title))
(cat (getf option :category))
(sel-p (eql display-idx sel-idx))
(text (if cat (format nil " ~a" title)
(format nil " ~:[ ~;▸~] ~a" sel-p title)))
(row (+ top y-off)))
(when (>= row (1- h)) (return))
(cl-tty.backend:draw-text be 1 row text
(cond (cat (theme-color :dim))
(sel-p (theme-color :accent))
(t (theme-color :agent-fg)))
nil :bold sel-p)
(incf y-off))))
;; Filter prompt at h-3
(cl-tty.backend:draw-text be 0 (- h 3)
(format nil "> ~a" filter)
(theme-color :input-prompt) nil))
(cl-tty.backend:end-sync be))
(when ds
(cl-tty.backend:begin-sync be)
(let* ((sidebar-w (if (and (st :sidebar-visible) (>= w 60))
(or (st :sidebar-width) 30) 0))
(chat-w (- w sidebar-w))
(dlg (car ds))
(sel (cl-tty.dialog:dialog-content dlg))
(filtered (cl-tty.select:select-filtered-options sel))
(sel-idx (cl-tty.select:select-selected-index sel))
(cnt (length filtered))
(filter (cl-tty.select:select-filter sel))
(mh (min 15 (+ 1 cnt))) ;; +1 for title
(top (max 0 (- h 4 mh))))
;; Clear the minibuffer area
(dotimes (r (min (- h 3 top) h))
(cl-tty.backend:draw-rect be 0 (+ top r) chat-w 1
:bg (theme-color :status-bg)))
;; Top border line with title
(cl-tty.backend:draw-text be 0 top
(make-string chat-w :initial-element #\─)
(theme-color :separator) nil)
(cl-tty.backend:draw-text be 1 top
(cl-tty.dialog:dialog-title dlg)
(theme-color :accent) nil)
;; Options
(let ((y-off 1))
(dolist (item filtered)
(let* ((display-idx (first item))
(option (third item))
(title (getf option :title))
(cat (getf option :category))
(sel-p (eql display-idx sel-idx))
(text (if cat (format nil " ~a" title)
(format nil " ~:[ ~;▸~] ~a" sel-p title)))
(row (+ top y-off)))
(when (>= row (1- h)) (return))
(cl-tty.backend:draw-text be 1 row text
(cond (cat (theme-color :dim))
(sel-p (theme-color :accent))
(t (theme-color :agent-fg)))
nil :bold sel-p)
(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))
(progn (disconnect-daemon))))))
#+END_SRC