v0.8.0: Information Radiator, Command Palette, TrueColor Themes, Setup Wizard
- Sidebar: permanent 42-col panel with 7 data panels (Gate Trace, Focus, Rules, Context gauge, Files, Cost, Protection); 4-window Croatoan layout at >=120 cols, toggle via Ctrl+X+B - Command palette: Ctrl+P overlay with fuzzy-filtered categorized items, keyboard navigation, Enter to execute; view-palette rendering - TrueColor themes: 4 new presets (nord, tokyonight, catppuccin, monokai) with 27 hex keys via theme-hex-to-rgb - Setup wizard: Ctrl+\ /setup 4-step overlay (provider, key, memory, save) writing .env with in-TUI rendering - Daemon enrichment: dispatcher block counts, cost session summary, modified files tracking, context usage percentage - Daemon fixes: fboundp guards for count-tokens/provider-token-cost, tool registry save/restore in safety tests, SELF_BUILD_MODE cleanup - 139 tests pass across all suites (0 failures)
This commit is contained in:
@@ -296,9 +296,9 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
||||
(:approval :gate-approval)
|
||||
(t :dim)))
|
||||
(prefix (case result
|
||||
(:passed " \u2713 ")
|
||||
(:blocked " \u2717 ")
|
||||
(:approval " \u2192 ")
|
||||
(:passed " ✓ ")
|
||||
(:blocked " ✗ ")
|
||||
(:approval " → ")
|
||||
(t " ? ")))
|
||||
(text (format nil "~a~a~@[~a~]~@[~a~]"
|
||||
prefix name
|
||||
@@ -307,6 +307,195 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
||||
(push (cons text (list :fgcolor color)) lines)))
|
||||
(nreverse lines)))
|
||||
|
||||
(in-package :passepartout.channel-tui)
|
||||
|
||||
(defun view-sidebar (win)
|
||||
"Render 42-column sidebar with 7 panels: Gate Trace, Focus, Rules, Context, Files, Cost, Protection."
|
||||
(clear win)
|
||||
(box win (theme-color :border) (theme-color :background))
|
||||
(let* ((w (or (width win) 42))
|
||||
(h (or (height win) 24))
|
||||
(y 1)
|
||||
(gate-trace (st :gate-trace))
|
||||
(foveal-id (st :foveal-id))
|
||||
(rule-count (or (st :rule-count) 0))
|
||||
(context-usage (st :context-usage))
|
||||
(modified-files (st :modified-files))
|
||||
(session-cost (st :session-cost))
|
||||
(block-counts (st :block-counts)))
|
||||
;; Panel 1: Gate Trace
|
||||
(add-string win "── Gate Trace ──" :y y :x 1 :n (- w 2) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(if gate-trace
|
||||
(dolist (entry (passepartout::gate-trace-lines gate-trace))
|
||||
(when (< y (1- h))
|
||||
(add-string win (car entry) :y y :x 2 :n (- w 4)
|
||||
:fgcolor (or (getf (cdr entry) :fgcolor) (theme-color :dim)))
|
||||
(incf y)))
|
||||
(add-string win " (no trace)" :y y :x 2 :n (- w 4) :fgcolor (theme-color :dim)))
|
||||
;; Panel 2: Focus
|
||||
(incf y)
|
||||
(add-string win "── Focus ──" :y y :x 1 :n (- w 2) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(add-string win (format nil " ~a" (or foveal-id "(none)")) :y y :x 2 :n (- w 4) :fgcolor (theme-color :focus-map))
|
||||
;; Panel 3: Rules
|
||||
(incf y 2)
|
||||
(add-string win "── Rules ──" :y y :x 1 :n (- w 2) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(add-string win (format nil " Rules: ~d" rule-count) :y y :x 2 :n (- w 4) :fgcolor (theme-color :rule-count))
|
||||
;; Panel 4: Context gauge
|
||||
(incf y 2)
|
||||
(add-string win "── Context ──" :y y :x 1 :n (- w 2) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(let* ((pct (or context-usage 0))
|
||||
(bar-width 30)
|
||||
(filled (min bar-width (floor (* pct bar-width) 100)))
|
||||
(gauge-color (cond ((< pct 50) (theme-color :connected))
|
||||
((< pct 80) (theme-color :warning))
|
||||
((< pct 95) (theme-color :tool-running))
|
||||
(t (theme-color :error)))))
|
||||
(add-string win (format nil " [~a~a] ~d%"
|
||||
(make-string filled :initial-element #\█)
|
||||
(make-string (- bar-width filled) :initial-element #\░)
|
||||
pct)
|
||||
:y y :x 2 :n (- w 4) :fgcolor gauge-color))
|
||||
;; Panel 5: Files
|
||||
(incf y 2)
|
||||
(add-string win "── Files ──" :y y :x 1 :n (- w 2) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(if modified-files
|
||||
(dolist (f modified-files)
|
||||
(when (< y (1- h))
|
||||
(let ((fp (getf f :filepath))
|
||||
(added (getf f :lines-added))
|
||||
(removed (getf f :lines-removed)))
|
||||
(add-string win (format nil " ~a~@[ +~d~]~@[ -~d~]"
|
||||
(subseq fp (max 0 (- (length fp) 30)))
|
||||
(when (> added 0) added)
|
||||
(when (> removed 0) removed))
|
||||
:y y :x 2 :n (- w 4) :fgcolor (theme-color :agent))
|
||||
(incf y))))
|
||||
(add-string win " (no changes)" :y y :x 2 :n (- w 4) :fgcolor (theme-color :dim)))
|
||||
;; Panel 6: Cost
|
||||
(incf y 2)
|
||||
(add-string win "── Cost ──" :y y :x 1 :n (- w 2) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(if session-cost
|
||||
(progn
|
||||
(add-string win (format nil " Total: $~,4f" (getf session-cost :total))
|
||||
:y y :x 2 :n (- w 4) :fgcolor (theme-color :agent))
|
||||
(incf y)
|
||||
(add-string win (format nil " Calls: ~d" (getf session-cost :calls))
|
||||
:y y :x 2 :n (- w 4) :fgcolor (theme-color :agent)))
|
||||
(add-string win " (no data)" :y y :x 2 :n (- w 4) :fgcolor (theme-color :dim)))
|
||||
;; Panel 7: Protection
|
||||
(incf y 2)
|
||||
(add-string win "── Protection ──" :y y :x 1 :n (- w 2) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(if (and block-counts (> (getf block-counts :total) 0))
|
||||
(let ((by-gate (getf block-counts :by-gate)))
|
||||
(dolist (entry (subseq by-gate 0 (min (length by-gate) 6)))
|
||||
(when (< y (1- h))
|
||||
(add-string win (format nil " ~a: ~d" (car entry) (cdr entry))
|
||||
:y y :x 2 :n (- w 4) :fgcolor (theme-color :gate-blocked))
|
||||
(incf y))))
|
||||
(add-string win " (no blocks)" :y y :x 2 :n (- w 4) :fgcolor (theme-color :dim)))
|
||||
(refresh win)
|
||||
(- y 1)))
|
||||
|
||||
(defun palette-filter (items query)
|
||||
"Return items from categorized list whose :name or :desc contains QUERY (case-insensitive)."
|
||||
(if (or (null query) (string= query ""))
|
||||
items
|
||||
(let ((q (string-downcase query)))
|
||||
(loop for group in items
|
||||
for category = (getf group :category)
|
||||
for gitems = (getf group :items)
|
||||
for filtered = (loop for item in gitems
|
||||
when (or (search q (string-downcase (getf item :name)))
|
||||
(search q (string-downcase (or (getf item :desc) ""))))
|
||||
collect item)
|
||||
when filtered
|
||||
collect (list :category category :items filtered)))))
|
||||
|
||||
(defun view-palette (win)
|
||||
"Render centered command palette overlay with filtered items, selection highlight."
|
||||
(clear win)
|
||||
(box win (theme-color :border) (theme-color :background))
|
||||
(let* ((w (or (width win) 50))
|
||||
(h (or (height win) 20))
|
||||
(y 1)
|
||||
(query (or (st :palette-filter) ""))
|
||||
(items (palette-filter (st :palette-items) query))
|
||||
(selected (st :palette-selected-idx))
|
||||
(flat-index 0)
|
||||
(visible-start (max 0 (- selected (floor (- h 6) 2)))))
|
||||
(add-string win (format nil " Command Palette ") :y y :x 2 :n (- w 4) :fgcolor (theme-color :accent))
|
||||
(incf y)
|
||||
(add-string win (format nil " > ~a" (if (> (length query) 0) query "type to filter..."))
|
||||
:y y :x 2 :n (- w 4) :fgcolor (theme-color :input) :attributes '(:underline t))
|
||||
(incf y)
|
||||
(dolist (group items)
|
||||
(let ((category (getf group :category))
|
||||
(gitems (getf group :items)))
|
||||
(when (and gitems (< y (1- h)))
|
||||
(incf y)
|
||||
(add-string win (format nil "── ~a ──" category) :y y :x 2 :n (- w 4) :fgcolor (theme-color :dim))
|
||||
(dolist (item gitems)
|
||||
(when (< y (1- h))
|
||||
(incf y)
|
||||
(let* ((name (getf item :name))
|
||||
(desc (getf item :desc))
|
||||
(shortcut (getf item :shortcut))
|
||||
(is-selected (= flat-index selected))
|
||||
(fg (if is-selected (theme-color :accent) (theme-color :agent))))
|
||||
(when is-selected
|
||||
(add-string win (make-string (- w 4) :initial-element #\Space) :y y :x 2 :n (- w 4)
|
||||
:fgcolor (theme-color :dim) :bgcolor (theme-color :accent)))
|
||||
(add-string win (format nil " ~a" name) :y y :x 3 :n (- w 6) :fgcolor fg)
|
||||
(when (and shortcut (> (- w 6) (+ 4 (length shortcut))))
|
||||
(add-string win shortcut :y y :x (- w (length shortcut) 3) :n (length shortcut) :fgcolor (theme-color :dim)))
|
||||
(incf flat-index)))))))
|
||||
(add-string win (format nil " ↑↓ Navigate Enter Execute Esc Close")
|
||||
:y (- h 1) :x 2 :n (- w 4) :fgcolor (theme-color :dim))
|
||||
(refresh win)
|
||||
(- h 1)))
|
||||
|
||||
(defun view-wizard (win)
|
||||
"Render setup wizard overlay: step title, prompt, input, error, progress."
|
||||
(clear win)
|
||||
(box win (theme-color :border) (theme-color :background))
|
||||
(let* ((w (or (width win) 60))
|
||||
(h (or (height win) 15))
|
||||
(y 1)
|
||||
(steps (passepartout.channel-tui::wizard-steps))
|
||||
(step-idx (st :wizard-step))
|
||||
(step (when (< step-idx (length steps)) (nth step-idx steps)))
|
||||
(prompt (getf step :prompt))
|
||||
(title (getf step :title))
|
||||
(total (length steps))
|
||||
(error-msg (st :wizard-error))
|
||||
(input (or (st :wizard-input) "")))
|
||||
(add-string win "Setup Wizard" :y y :x 2 :n (- w 4) :fgcolor (theme-color :accent))
|
||||
(incf y 2)
|
||||
(add-string win (format nil "Step ~d/~d" (1+ step-idx) total) :y y :x 2 :n (- w 4) :fgcolor (theme-color :dim))
|
||||
(incf y)
|
||||
(when title
|
||||
(add-string win title :y y :x 3 :n (- w 6) :fgcolor (theme-color :accent))
|
||||
(incf y))
|
||||
(when prompt
|
||||
(add-string win prompt :y y :x 3 :n (- w 6) :fgcolor (theme-color :agent))
|
||||
(incf y))
|
||||
(incf y)
|
||||
(add-string win (format nil "> ~a" input) :y y :x 3 :n (- w 6) :fgcolor (theme-color :input))
|
||||
(incf y)
|
||||
(when error-msg
|
||||
(add-string win (format nil "! ~a" error-msg) :y y :x 3 :n (- w 6) :fgcolor (theme-color :error))
|
||||
(incf y))
|
||||
(add-string win "Enter=Next Esc=Cancel Bksp=Edit" :y (- h 2) :x 2 :n (- w 4) :fgcolor (theme-color :dim))
|
||||
(refresh win)
|
||||
(- h 1)))
|
||||
|
||||
(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||
(ql:quickload :fiveam :silent t))
|
||||
|
||||
@@ -414,3 +603,48 @@ ASCII < 128 = 1. CJK, fullwidth, emoji = 2. Combining marks = 0. Tab = 8."
|
||||
(passepartout.channel-tui::init-state)
|
||||
(let ((cg (passepartout.channel-tui::st :collapsed-gates)))
|
||||
(is (null cg))))
|
||||
|
||||
(in-package :passepartout-tui-view-tests)
|
||||
|
||||
(test test-theme-hex-string-keys-exist
|
||||
"v0.8.0: all 27 theme keys are present in *tui-theme*."
|
||||
(let* ((theme passepartout.channel-tui::*tui-theme*)
|
||||
(required '(:user :agent :system :input :timestamp :help :error :warning
|
||||
:connected :disconnected :busy :idle
|
||||
:gate-passed :gate-blocked :gate-approval :hitl
|
||||
:tool-running :tool-success :tool-failure :tool-output
|
||||
:scroll-indicator :border :background
|
||||
:rule-count :focus-map
|
||||
:dim :highlight :accent)))
|
||||
(dolist (key required)
|
||||
(is (getf theme key) (format nil "~a should be defined" key)))))
|
||||
|
||||
(test test-theme-presets-count
|
||||
"v0.8.0: 8 presets defined: dark, light, solarized, gruvbox, nord, tokyonight, catppuccin, monokai."
|
||||
(let* ((presets passepartout.channel-tui::*tui-theme-presets*)
|
||||
(names '(:dark :light :solarized :gruvbox :nord :tokyonight :catppuccin :monokai)))
|
||||
(dolist (name names)
|
||||
(is (getf presets name) (format nil "~a preset should exist" name)))))
|
||||
|
||||
(test test-palette-filter-matches-substring
|
||||
"Contract v0.8.0: palette-filter returns items matching query."
|
||||
(let* ((items (list (list :category "Session" :items
|
||||
(list (list :name "/focus" :desc "Set context" :shortcut nil :action nil)
|
||||
(list :name "/scope" :desc "Change scope" :shortcut nil :action nil)))))
|
||||
(filtered (passepartout.channel-tui::palette-filter items "focus")))
|
||||
(is (= 1 (length (getf (first filtered) :items))))
|
||||
(is (string= "/focus" (getf (first (getf (first filtered) :items)) :name)))))
|
||||
|
||||
(test test-palette-filter-case-insensitive
|
||||
"Contract v0.8.0: palette-filter is case-insensitive."
|
||||
(let* ((items (list (list :category "View" :items
|
||||
(list (list :name "/theme" :desc "Switch color" :shortcut nil :action nil)))))
|
||||
(filtered (passepartout.channel-tui::palette-filter items "THEME")))
|
||||
(is (= 1 (length (getf (first filtered) :items))))))
|
||||
|
||||
(test test-palette-filter-no-match-empty
|
||||
"Contract v0.8.0: palette-filter returns empty categories on no match."
|
||||
(let* ((items (list (list :category "View" :items
|
||||
(list (list :name "/theme" :desc "Colors" :shortcut nil :action nil)))))
|
||||
(filtered (passepartout.channel-tui::palette-filter items "xyznonexistent")))
|
||||
(is (null (getf (first filtered) :items)))))
|
||||
|
||||
Reference in New Issue
Block a user