aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ai-term--dispatch.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-05 05:28:58 -0500
committerCraig Jennings <c@cjennings.net>2026-06-05 05:28:58 -0500
commitebdf9e466b0e1f86e9b7d76650ac32408273e7a7 (patch)
treedab9b453f3a93c324b5388b3843502a088c7ed46 /tests/test-ai-term--dispatch.el
parentc094b2e4e64530379a9cb273303308a9affcabf6 (diff)
downloaddotemacs-ebdf9e466b0e1f86e9b7d76650ac32408273e7a7.tar.gz
dotemacs-ebdf9e466b0e1f86e9b7d76650ac32408273e7a7.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--dispatch.el')
-rw-r--r--tests/test-ai-term--dispatch.el70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/test-ai-term--dispatch.el b/tests/test-ai-term--dispatch.el
new file mode 100644
index 00000000..91b5e1bc
--- /dev/null
+++ b/tests/test-ai-term--dispatch.el
@@ -0,0 +1,70 @@
+;;; test-ai-term--dispatch.el --- Tests for cj/--ai-term-dispatch -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; The dispatch helper is a pure decision function used by F9.
+;; Returns one of (toggle-off . WIN), (redisplay-recent . BUF),
+;; or (pick-project) based on whether an agent buffer is currently
+;; displayed and whether any alive agent buffers exist. Tests mock
+;; the two underlying helpers so the dispatch logic can be exercised
+;; without touching real windows.
+
+;;; Code:
+
+(require 'ert)
+(require 'cl-lib)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory))
+(require 'ai-term)
+(require 'testutil-ghostel-buffers)
+
+(ert-deftest test-ai-term--dispatch-window-displayed-returns-toggle-off ()
+ "Normal: displayed agent window -> (toggle-off . WIN)."
+ (let ((sentinel-win 'fake-window))
+ (cl-letf (((symbol-function 'cj/--ai-term-displayed-agent-window)
+ (lambda (&optional _frame) sentinel-win)))
+ (should (equal (cj/--ai-term-dispatch)
+ (cons 'toggle-off sentinel-win))))))
+
+(ert-deftest test-ai-term--dispatch-no-window-single-buffer-returns-redisplay-recent ()
+ "Normal: no displayed agent, one alive buffer -> redisplay-recent + buffer."
+ (cj/test--kill-agent-buffers)
+ (let ((b1 (get-buffer-create "agent [single]")))
+ (unwind-protect
+ (cl-letf (((symbol-function 'cj/--ai-term-displayed-agent-window)
+ (lambda (&optional _frame) nil))
+ ((symbol-function 'cj/--ai-term-agent-buffers)
+ (lambda () (list b1))))
+ (should (equal (cj/--ai-term-dispatch)
+ (cons 'redisplay-recent b1))))
+ (kill-buffer b1))))
+
+(ert-deftest test-ai-term--dispatch-no-window-multiple-buffers-returns-redisplay-recent ()
+ "Normal: no displayed agent, 2+ alive buffers -> redisplay-recent + MRU.
+F9 redisplays the most-recently-selected agent (head of buffer-list
+order) rather than opening the project picker, so the user toggles
+THE agent they were last using. Other agents are reachable via M-F9."
+ (cj/test--kill-agent-buffers)
+ (let ((b1 (get-buffer-create "agent [a]"))
+ (b2 (get-buffer-create "agent [b]")))
+ (unwind-protect
+ (cl-letf (((symbol-function 'cj/--ai-term-displayed-agent-window)
+ (lambda (&optional _frame) nil))
+ ((symbol-function 'cj/--ai-term-agent-buffers)
+ (lambda () (list b1 b2))))
+ (should (equal (cj/--ai-term-dispatch)
+ (cons 'redisplay-recent b1))))
+ (kill-buffer b1)
+ (kill-buffer b2))))
+
+(ert-deftest test-ai-term--dispatch-no-window-zero-buffers-returns-pick-project ()
+ "Boundary: no displayed agent, zero alive buffers -> pick-project."
+ (cj/test--kill-agent-buffers)
+ (cl-letf (((symbol-function 'cj/--ai-term-displayed-agent-window)
+ (lambda (&optional _frame) nil))
+ ((symbol-function 'cj/--ai-term-agent-buffers)
+ (lambda () nil)))
+ (should (equal (cj/--ai-term-dispatch) '(pick-project)))))
+
+(provide 'test-ai-term--dispatch)
+;;; test-ai-term--dispatch.el ends here