aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ai-vterm--displayed-agent-window.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-11 07:18:20 -0500
committerCraig Jennings <c@cjennings.net>2026-05-11 07:18:20 -0500
commit59b0854464ef29511a0d09f1e76fd1140e675833 (patch)
tree0c18aee463b4ff14f2fa6675e2cde6fc5f50bbdc /tests/test-ai-vterm--displayed-agent-window.el
parentde555fa8b48c5ed5f17c0a8db9de7ecb946aa75d (diff)
downloaddotemacs-59b0854464ef29511a0d09f1e76fd1140e675833.tar.gz
dotemacs-59b0854464ef29511a0d09f1e76fd1140e675833.zip
refactor(ai-vterm): rename Claude-specific names to a generic "agent"
I may add other terminal agents to this launcher (aider, an open-source LLM TUI), so the buffer prefix, the user knob, and the internal helpers shouldn't say "Claude". The module name (ai-vterm) and the `cj/ai-vterm-*` customs were already generic. This finishes the job: - buffer prefix `claude [<basename>]` -> `agent [<basename>]` (the `defconst` and the matching display-buffer-alist regex move together) - `cj/ai-vterm-claude-command` -> `cj/ai-vterm-agent-command` (the default still runs the `claude` CLI, with a docstring note on swapping it) - `cj/--ai-vterm-claude-buffers` / `-displayed-claude-window` / `-reuse-existing-claude` -> `-agent-*`, and their test files renamed to match - prose in the module commentary and docstrings, plus the matching test docstrings and buffer-name literals `vterm-config.el` hardcodes the same buffer prefix in `cj/--vterm-toggle-buffer-p` (F12 excludes agent buffers from its candidate set), so that literal moved too. Collapsing it into the shared `cj/--ai-vterm-name-prefix` is a cleanup for another day. After a reload, a project's buffer opens as `agent [foo]` instead of `claude [foo]`. Old buffers keep their names until killed. I also corrected two stale `eshell-vterm-config.el` references in ai-vterm.el docstrings (that module was split into `vterm-config.el`). Two things keep saying "Claude": the `cj/ai-vterm-agent-command` default value (the actual CLI), and the "Claude Code" example in `vterm-config.el`'s cursor-restore docstring (a concrete TUI example, not branding). 90 tests pass. `make validate-modules` clean.
Diffstat (limited to 'tests/test-ai-vterm--displayed-agent-window.el')
-rw-r--r--tests/test-ai-vterm--displayed-agent-window.el60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/test-ai-vterm--displayed-agent-window.el b/tests/test-ai-vterm--displayed-agent-window.el
new file mode 100644
index 00000000..f36ca9f5
--- /dev/null
+++ b/tests/test-ai-vterm--displayed-agent-window.el
@@ -0,0 +1,60 @@
+;;; test-ai-vterm--displayed-agent-window.el --- Tests for the displayed-window helper -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; The helper returns a window in the selected frame whose buffer
+;; satisfies `cj/--ai-vterm-buffer-p', or nil when no such window
+;; exists. Used by F9 dispatch and M-F9 in-place replacement.
+
+;;; Code:
+
+(require 'ert)
+
+(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-vterm)
+(require 'testutil-vterm-buffers)
+
+(ert-deftest test-ai-vterm--displayed-agent-window-no-buffers-returns-nil ()
+ "Boundary: no agent buffers anywhere -> nil."
+ (cj/test--kill-agent-buffers)
+ (save-window-excursion
+ (delete-other-windows)
+ (should-not (cj/--ai-vterm-displayed-agent-window))))
+
+(ert-deftest test-ai-vterm--displayed-agent-window-not-displayed-returns-nil ()
+ "Boundary: agent buffer exists but not in any window -> nil."
+ (cj/test--kill-agent-buffers)
+ (let ((b1 (get-buffer-create "agent [hidden]")))
+ (unwind-protect
+ (save-window-excursion
+ (delete-other-windows)
+ (should-not (cj/--ai-vterm-displayed-agent-window)))
+ (kill-buffer b1))))
+
+(ert-deftest test-ai-vterm--displayed-agent-window-returns-window-when-displayed ()
+ "Normal: agent buffer in a window -> returns that window."
+ (cj/test--kill-agent-buffers)
+ (let ((b1 (get-buffer-create "agent [shown]")))
+ (unwind-protect
+ (save-window-excursion
+ (delete-other-windows)
+ (let ((win (split-window-right)))
+ (set-window-buffer win b1)
+ (let ((result (cj/--ai-vterm-displayed-agent-window)))
+ (should (windowp result))
+ (should (eq (window-buffer result) b1)))))
+ (kill-buffer b1))))
+
+(ert-deftest test-ai-vterm--displayed-agent-window-ignores-non-agent-windows ()
+ "Boundary: only a non-agent buffer is displayed -> nil."
+ (cj/test--kill-agent-buffers)
+ (let ((other (get-buffer-create "regular-displayed-buffer")))
+ (unwind-protect
+ (save-window-excursion
+ (delete-other-windows)
+ (set-window-buffer (selected-window) other)
+ (should-not (cj/--ai-vterm-displayed-agent-window)))
+ (kill-buffer other))))
+
+(provide 'test-ai-vterm--displayed-agent-window)
+;;; test-ai-vterm--displayed-agent-window.el ends here