fix: connect-daemon retry + user-friendly feedback
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s

- connect-daemon: retry up to 3 times with 3s backoff instead of
  single 10s attempt. Shows 'Connecting...' while retrying.
- Failed attempts show attempt count and error detail.
- After all retries exhausted: shows TIP to start daemon first.
- Connection status bar already shows Connected/Disconnected.
- passepartout tui already auto-starts daemon if port 9105 is closed.

TUI integration: 7/7 pass.
This commit is contained in:
2026-05-06 10:46:44 -04:00
parent 9130e08e92
commit 39b6bef6e0
2 changed files with 44 additions and 18 deletions

View File

@@ -197,15 +197,28 @@
(sleep 0.5)))))
(defun connect-daemon (&optional (host "127.0.0.1") (port 9105))
(handler-case
(let ((s (usocket:socket-connect host port :timeout 10)))
(setf (st :stream) (usocket:socket-stream s) (st :connected) t)
(bt:make-thread (lambda () (reader-loop (st :stream))) :name "tui-reader")
(add-msg :system "* Connected *")
t)
(error (c)
(add-msg :system (format nil "* Connection failed: ~a *" c))
nil)))
(add-msg :system "* Connecting to daemon... *")
(loop for attempt from 1 to 3
for backoff = 0 then 3
do (sleep backoff)
(handler-case
(let ((s (usocket:socket-connect host port :timeout 5)))
(setf (st :stream) (usocket:socket-stream s)
(st :connected) t)
(bt:make-thread (lambda () (reader-loop (st :stream)))
:name "tui-reader")
(add-msg :system (format nil "* Connected v~a *" "0.2.0"))
(return-from connect-daemon t))
(usocket:connection-refused-error (c)
(when (= attempt 3)
(add-msg :system (format nil "* No daemon on port ~a after ~a attempts *"
port attempt))))
(error (c)
(add-msg :system (format nil "* Connection attempt ~a failed: ~a *"
attempt c))
(when (= attempt 3)
(add-msg :system "* TIP: run 'passepartout daemon' first *")))))
nil)
(defun disconnect-daemon ()
(when (st :stream)