diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-05 05:28:58 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-05 05:28:58 -0500 |
| commit | 25da8650f12a90e622aa804d604a02e39f1867ef (patch) | |
| tree | 2a4996867b3e99603821986b4798d2378327b45c /tests/test-ai-term--live-tmux-sessions.el | |
| parent | 7cd8cd8c1f163cd9cc9f377557bf44b788be4bff (diff) | |
| download | dotemacs-25da8650f12a90e622aa804d604a02e39f1867ef.tar.gz dotemacs-25da8650f12a90e622aa804d604a02e39f1867ef.zip | |
feat(term): replace vterm with ghostel as the terminal engine
I swapped the terminal engine from vterm to ghostel (libghostty-vt) everywhere. term-config replaces vterm-config (the F12 terminal, the C-; x menu, tmux history capture), and ai-term replaces ai-vterm (the F9 Claude-agent launcher). ghostel renders the agent TUI without vterm's flicker under heavy streaming, and one engine now covers every terminal workflow.
Two behavior changes fall out of the swap. F9 launches in a terminal frame now: ghostel renders in TTY frames, so the old GUI-only guard is gone. Terminal windows no longer dim when unfocused: ghostel resolves its palette into the native module per-terminal, so there's no per-window color hook to dim through the way vterm had.
auto-dim drops its vterm color-advice path, the dashboard Terminal button launches ghostel, and the vterm and vterm-toggle packages are removed. The tmux pane-history and copy-mode machinery carried over unchanged. It keys on the pty tty, which ghostel exposes.
Diffstat (limited to 'tests/test-ai-term--live-tmux-sessions.el')
| -rw-r--r-- | tests/test-ai-term--live-tmux-sessions.el | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/test-ai-term--live-tmux-sessions.el b/tests/test-ai-term--live-tmux-sessions.el new file mode 100644 index 00000000..1952caed --- /dev/null +++ b/tests/test-ai-term--live-tmux-sessions.el @@ -0,0 +1,71 @@ +;;; test-ai-term--live-tmux-sessions.el --- Tests for cj/--ai-term-live-tmux-sessions -*- lexical-binding: t; -*- + +;;; Commentary: +;; Lists the live tmux sessions that carry the AI-term prefix so the +;; project picker can surface projects whose agent session survived an +;; Emacs crash. tmux being absent or no server running is a normal +;; "nothing to match" outcome, not an error -- the lister returns nil. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'ai-term) + +(defmacro test-ai-term--with-tmux-list (exit-code output &rest body) + "Run BODY with `process-file' mocked to a tmux list-sessions response. + +EXIT-CODE is what `process-file' returns (or the symbol `error' to +make it signal). OUTPUT is written to the stdout destination buffer." + (declare (indent 2)) + `(cl-letf (((symbol-function 'process-file) + (lambda (_program _infile destination _display &rest _args) + (when (eq ,exit-code 'error) + (error "tmux: command not found")) + (let ((buffer (cond + ((eq destination t) (current-buffer)) + ((bufferp destination) destination) + ((consp destination) + (and (eq (car destination) t) + (current-buffer)))))) + (when (bufferp buffer) + (with-current-buffer buffer (insert ,output)))) + ,exit-code))) + ,@body)) + +(ert-deftest test-ai-term--live-tmux-sessions-filters-to-prefix () + "Normal: only sessions starting with the AI-term prefix come back." + (let ((cj/ai-term-tmux-session-prefix "aiv-")) + (test-ai-term--with-tmux-list 0 "aiv-foo\nrandom-session\naiv-bar\n" + (should (equal (cj/--ai-term-live-tmux-sessions) + '("aiv-foo" "aiv-bar")))))) + +(ert-deftest test-ai-term--live-tmux-sessions-honors-custom-prefix () + "Normal: a non-default prefix is what gets matched." + (let ((cj/ai-term-tmux-session-prefix "em-")) + (test-ai-term--with-tmux-list 0 "em-foo\naiv-bar\nem-baz\n" + (should (equal (cj/--ai-term-live-tmux-sessions) + '("em-foo" "em-baz")))))) + +(ert-deftest test-ai-term--live-tmux-sessions-empty-output-yields-nil () + "Boundary: a running server with no matching sessions yields nil." + (let ((cj/ai-term-tmux-session-prefix "aiv-")) + (test-ai-term--with-tmux-list 0 "other-a\nother-b\n" + (should (null (cj/--ai-term-live-tmux-sessions)))))) + +(ert-deftest test-ai-term--live-tmux-sessions-no-server-yields-nil () + "Error: tmux exits non-zero (no server running) -> nil, not a signal." + (let ((cj/ai-term-tmux-session-prefix "aiv-")) + (test-ai-term--with-tmux-list 1 "no server running on /tmp/tmux-1000/default\n" + (should (null (cj/--ai-term-live-tmux-sessions)))))) + +(ert-deftest test-ai-term--live-tmux-sessions-tmux-missing-yields-nil () + "Error: tmux not installed -> `process-file' signals; lister returns nil." + (let ((cj/ai-term-tmux-session-prefix "aiv-")) + (test-ai-term--with-tmux-list 'error "" + (should (null (cj/--ai-term-live-tmux-sessions)))))) + +(provide 'test-ai-term--live-tmux-sessions) +;;; test-ai-term--live-tmux-sessions.el ends here |
