aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-06 18:12:34 -0500
committerCraig Jennings <c@cjennings.net>2026-06-06 18:12:34 -0500
commit1a097b7e45e958f5849098689c27955ce335a8f1 (patch)
treeb5b1802487c5884a19a71794c758f436bf627dd0 /tests
parent57df2015f93d54db60a8765868ba9c5fc70b4a65 (diff)
downloaddotemacs-1a097b7e45e958f5849098689c27955ce335a8f1.tar.gz
dotemacs-1a097b7e45e958f5849098689c27955ce335a8f1.zip
fix(ai-term): keep the window split when closing an agent
M-F9 close deleted the agent's window, collapsing the layout. Close now swaps that window to the working buffer and kills the agent buffer, so the split stays put. F9 hide still collapses the split. Close no longer does.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-ai-term--close.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test-ai-term--close.el b/tests/test-ai-term--close.el
index 654e85f0..4098c091 100644
--- a/tests/test-ai-term--close.el
+++ b/tests/test-ai-term--close.el
@@ -13,7 +13,9 @@
(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--kill-tmux-session-runs-kill-session ()
"Normal: invokes `tmux kill-session -t <session>'."
@@ -58,6 +60,35 @@
(should (buffer-live-p buf)))
(when (buffer-live-p buf) (kill-buffer buf)))))
+(ert-deftest test-ai-term--close-buffer-keeps-window-split ()
+ "Regression: closing an agent in a split keeps its window in the layout,
+showing a non-agent buffer, instead of deleting the split. Craig's M-F9
+annoyance -- a close must not tear down the window arrangement (the F9 hide
+toggle is what collapses the split; close should not)."
+ (cj/test--kill-agent-buffers)
+ (let ((work (get-buffer-create "*test-close-keep-work*"))
+ (agent (get-buffer-create "agent [close-keep]")))
+ (with-current-buffer agent (setq-local default-directory "/tmp/close-keep/"))
+ (unwind-protect
+ (save-window-excursion
+ (delete-other-windows)
+ (set-window-buffer (selected-window) work)
+ (let ((agent-win (split-window (selected-window) nil 'below)))
+ (set-window-buffer agent-win agent)
+ (should-not (one-window-p))
+ (cl-letf (((symbol-function 'cj/--ai-term-kill-tmux-session)
+ (lambda (_s) 0)))
+ (cj/--ai-term-close-buffer agent))
+ ;; The window survives the close ...
+ (should (window-live-p agent-win))
+ (should-not (one-window-p))
+ ;; ... now showing a non-agent buffer ...
+ (should-not (cj/--ai-term-buffer-p (window-buffer agent-win)))
+ ;; ... and the agent buffer itself is gone.
+ (should-not (buffer-live-p agent))))
+ (when (get-buffer "*test-close-keep-work*") (kill-buffer "*test-close-keep-work*"))
+ (cj/test--kill-agent-buffers))))
+
(ert-deftest test-ai-term--close-target-current-agent-buffer ()
"Normal: returns the current buffer when it is an agent buffer."
(let ((buf (get-buffer-create "agent [cur]")))