aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ai-vterm--agent-buffers.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
commit4000330e5e6536f64f404c1cabc8dc86d9556bb5 (patch)
treebb0ad65fb1cb9b1dba629998fe2983a9a3020fa7 /tests/test-ai-vterm--agent-buffers.el
parent56680633ea0e1b549fd7087c1f9d6d1abf9f0690 (diff)
downloaddotemacs-4000330e5e6536f64f404c1cabc8dc86d9556bb5.tar.gz
dotemacs-4000330e5e6536f64f404c1cabc8dc86d9556bb5.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--agent-buffers.el')
-rw-r--r--tests/test-ai-vterm--agent-buffers.el59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/test-ai-vterm--agent-buffers.el b/tests/test-ai-vterm--agent-buffers.el
new file mode 100644
index 00000000..57d01730
--- /dev/null
+++ b/tests/test-ai-vterm--agent-buffers.el
@@ -0,0 +1,59 @@
+;;; test-ai-vterm--agent-buffers.el --- Tests for cj/--ai-vterm-agent-buffers -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; The helper returns the list of buffers whose names start with the
+;; literal prefix "agent [". Order is the same order `buffer-list'
+;; gives them (most-recently-selected first). Non-agent buffers and
+;; buffers whose names merely contain the prefix as a substring are
+;; excluded.
+
+;;; 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--agent-buffers-empty-when-none-exist ()
+ "Boundary: no agent-prefixed buffers anywhere -> empty list."
+ (cj/test--kill-agent-buffers)
+ (unwind-protect
+ (should (null (cj/--ai-vterm-agent-buffers)))
+ (cj/test--kill-agent-buffers)))
+
+(ert-deftest test-ai-vterm--agent-buffers-returns-only-agent-buffers ()
+ "Normal: filters to only agent-prefixed buffers, leaves others alone."
+ (cj/test--kill-agent-buffers)
+ (let ((c1 (get-buffer-create "agent [a]"))
+ (c2 (get-buffer-create "agent [b]"))
+ (other (get-buffer-create "regular-buffer")))
+ (unwind-protect
+ (let ((result (cj/--ai-vterm-agent-buffers)))
+ (should (memq c1 result))
+ (should (memq c2 result))
+ (should-not (memq other result))
+ (should (= (length result) 2)))
+ (kill-buffer c1)
+ (kill-buffer c2)
+ (kill-buffer other))))
+
+(ert-deftest test-ai-vterm--agent-buffers-anchors-prefix-not-substring ()
+ "Boundary: 'foo agent [bar]' is not an agent buffer -- prefix anchored."
+ (cj/test--kill-agent-buffers)
+ (let ((not-agent (get-buffer-create "foo agent [bar]")))
+ (unwind-protect
+ (should-not (memq not-agent (cj/--ai-vterm-agent-buffers)))
+ (kill-buffer not-agent))))
+
+(ert-deftest test-ai-vterm--agent-buffers-bare-agent-not-included ()
+ "Boundary: 'agent' alone (no bracket) doesn't match the 'agent [' prefix."
+ (cj/test--kill-agent-buffers)
+ (let ((bare (get-buffer-create "agent")))
+ (unwind-protect
+ (should-not (memq bare (cj/--ai-vterm-agent-buffers)))
+ (kill-buffer bare))))
+
+(provide 'test-ai-vterm--agent-buffers)
+;;; test-ai-vterm--agent-buffers.el ends here