diff --git a/passepartout b/passepartout index e0a37d5..0d2a8a6 100755 --- a/passepartout +++ b/passepartout @@ -379,40 +379,9 @@ case "$COMMAND" in export PASSEPARTOUT_DATA_DIR="${PASSEPARTOUT_DATA_DIR:-$SCRIPT_DIR}" if ! ss -tln 2>/dev/null | grep -q 9105 && ! netstat -tln 2>/dev/null | grep -q 9105; then echo "Starting daemon..." - # Start daemon in background — don't block TUI startup $0 daemon &>/dev/null & + sleep 2 fi - # Build TUI load script with proper paths - cat > /tmp/tui-load.lisp << LISPEOF -(load (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))) -(push (truename "$PASSEPARTOUT_DATA_DIR/") asdf:*central-registry*) -(ql:quickload :cl-tty :silent t) -(ql:quickload :passepartout :silent t) -(setf *debugger-hook* nil) -(let ((dir (pathname (format nil "~a/lisp/" (truename "$PASSEPARTOUT_DATA_DIR"))))) - (dolist (f '("channel-tui-state" "channel-tui-view" "channel-tui-main")) - (let* ((src (merge-pathnames (format nil "~a.lisp" f) dir)) - (fasl (merge-pathnames (format nil "~a.fasl" f) dir))) - (when (or (not (probe-file fasl)) - (< (file-write-date fasl) (file-write-date src))) - (let ((out (compile-file src :output-file fasl :verbose nil :print nil))) - (unless out - (format t "~%*** COMPILE FAILED: ~a ***~%" src)))) - (let ((r (load fasl :verbose nil :print nil))) - (unless r - (format t "~%*** LOAD FAILED: ~a ***~%" fasl))))) -(handler-case - (funcall (find-symbol "TUI-MAIN" "PASSEPARTOUT.CHANNEL-TUI")) - (error (c) - (ignore-errors - (with-open-file (f (merge-pathnames ".cache/passepartout/tui-crash.log" (user-homedir-pathname)) - :direction :output :if-exists :supersede :if-does-not-exist :create) - (format f "CRASH: ~a~%~%" c) (sb-debug:print-backtrace :count 50 :stream f) (finish-output f))) - (format t "~%=== TUI CRASH ===~%CRASH: ~a~%" c) - (format t "Full backtrace saved to ~~/.cache/passepartout/tui-crash.log~%") - (sleep 3) (finish-output)))) -(uiop:quit 0) -LISPEOF # Restore terminal on any exit (set -e can kill the script before the # explicit stty restore below if sbcl exits non-zero). cleanup() { stty icanon echo ixon 2>/dev/null; } @@ -426,12 +395,15 @@ LISPEOF stty -icanon -echo -ixon 2>/dev/null # Ensure COLORTERM is set for modern backend detection export COLORTERM="${COLORTERM:-truecolor}" - # Clear stale cl-tty cache to ensure latest backend-size fixes - find ~/.cache/common-lisp -name "*.fasl" -path "*cl-tty*" -delete 2>/dev/null - sbcl --noinform --load /tmp/tui-load.lisp + # Clear stale cache + find ~/.cache/common-lisp -name "*.fasl" -path "*passepartout*" -o -name "*.fasl" -path "*cl-tty*" -delete 2>/dev/null + sbcl --noinform \ + --load "$HOME/quicklisp/setup.lisp" \ + --eval '(push (truename "'"$PASSEPARTOUT_DATA_DIR"'/") asdf:*central-registry*)' \ + --eval '(ql:quickload :passepartout/tui)' \ + --eval '(in-package :passepartout)' \ + --eval '(passepartout.channel-tui:tui-main)' rc=$? - # Restore terminal cooked mode (also handled by trap cleanup above, - # but do it explicitly here for clarity). stty icanon echo ixon 2>/dev/null exit $rc ;;