Some checks failed
Deploy (Gitea) / deploy (push) Failing after 3s
- Tab completion: Tab key autocompletes / commands (Tab handler in on-key) - Multi-line input: backslash + Enter inserts literal newline instead of sending - /help command: displays full command listing with descriptions - Activity indicator: :busy flag shows "...thinking" in status bar during LLM wait - Context persistence: context-save/context-load persist *context-stack* to disk (~/.cache/passepartout/context.lisp). Auto-restores on skill load. Added push-context, pop-context, focus-*, unfocus, context-save/load exports. - Theming: *tui-theme* plist with semantic color roles, /theme command View functions (view-chat, view-status, view-input) use theme-color - TUI test suite: 19 tests, 53 checks (100% pass) - Context test suite: 2 tests, 6 checks (100% pass) - Total: 5 suites, 81 checks, 0 failures
52 lines
1.7 KiB
Common Lisp
52 lines
1.7 KiB
Common Lisp
(defpackage :passepartout.gateway-tui
|
|
(:use :cl :croatoan :passepartout :usocket :bordeaux-threads)
|
|
(:export :tui-main :st :add-msg :now :input-string
|
|
:queue-event :drain-queue :init-state
|
|
:view-status :view-chat :view-input :redraw
|
|
:on-key :on-daemon-msg :send-daemon
|
|
:connect-daemon :disconnect-daemon
|
|
:*tui-theme* :theme-color))
|
|
(in-package :passepartout.gateway-tui)
|
|
|
|
(defvar *state* nil)
|
|
(defvar *event-queue* nil)
|
|
(defvar *event-lock* (bt:make-lock "tui-event-lock"))
|
|
|
|
(defvar *tui-theme*
|
|
'(:user :green :agent :white :system :yellow :input :cyan
|
|
:connected :green :disconnected :red :timestamp :yellow)
|
|
"Color theme plist. Keys are semantic roles, values are Croatoan colors.")
|
|
|
|
(defun theme-color (role)
|
|
"Returns the Croatoan color for a semantic role."
|
|
(or (getf *tui-theme* role) :white))
|
|
|
|
(defun st (key) (getf *state* key))
|
|
(defun (setf st) (val key) (setf (getf *state* key) val))
|
|
|
|
(defun init-state ()
|
|
(setf *state*
|
|
(list :running t :mode :chat :connected nil :stream nil
|
|
:input-buffer nil :input-history nil :input-hpos 0
|
|
:messages nil :scroll-offset 0 :busy nil
|
|
:dirty (list nil nil nil))))
|
|
|
|
(defun now ()
|
|
(multiple-value-bind (h m) (get-decoded-time)
|
|
(format nil "~2,'0d:~2,'0d" h m)))
|
|
|
|
(defun input-string ()
|
|
(coerce (reverse (st :input-buffer)) 'string))
|
|
|
|
(defun add-msg (role content)
|
|
(push (list :role role :content content :time (now)) (st :messages))
|
|
(setf (st :dirty) (list t t nil)))
|
|
|
|
(defun queue-event (ev)
|
|
(bt:with-lock-held (*event-lock*) (push ev *event-queue*)))
|
|
|
|
(defun drain-queue ()
|
|
(bt:with-lock-held (*event-lock*)
|
|
(let ((evs (nreverse *event-queue*)))
|
|
(setf *event-queue* nil) evs)))
|