v0.3.3: SIGWINCH, scroll clamp, /quit, /reconnect, history, message vector
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s
SIGWINCH: handle KEY_RESIZE (410) in main loop — re-measure screen, re-create status/chat/input windows at new dimensions, force redraw. Scroll clamp: PageUp clamped to (max 0 (- total 1)), prevents scrolling past message list end. Status bar shows 'msgs:N scroll:0'. /quit: saves :input-history to ~/.cache/passepartout/history (one line per entry, most recent first), sends goodbye handshake, sets :running nil. /reconnect: closes stale socket via disconnect-daemon, re-runs connect-daemon with retry backoff. Connection-loss detection: reader-loop counts consecutive nils; after 10, queues :disconnected event. Handler clears :connected/:busy, shows red system message. Load-history: reads ~/.cache/passepartout/history on startup, populates :input-history for up-arrow recall. Message vector: :messages init as adjustable vector with fill pointer. add-msg uses vector-push-extend (O(1) append). view-chat uses aref (O(1) access) instead of nth (O(n) for lists).
This commit is contained in:
@@ -28,7 +28,8 @@
|
||||
(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 :cursor-pos 0
|
||||
:messages (make-array 16 :adjustable t :fill-pointer 0)
|
||||
:scroll-offset 0 :busy nil :cursor-pos 0
|
||||
:dirty (list nil nil nil))))
|
||||
|
||||
(defun now ()
|
||||
@@ -59,7 +60,7 @@
|
||||
(setf (st :cursor-pos) (1- pos))))))
|
||||
|
||||
(defun add-msg (role content)
|
||||
(push (list :role role :content content :time (now)) (st :messages))
|
||||
(vector-push-extend (list :role role :content content :time (now)) (st :messages))
|
||||
(setf (st :dirty) (list t t nil)))
|
||||
|
||||
(defun queue-event (ev)
|
||||
|
||||
Reference in New Issue
Block a user