diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-18 14:06:46 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-18 14:06:46 -0500 |
| commit | eeafb35ff25a8fe060fd1f98b51a758bf88e2aa1 (patch) | |
| tree | f403d84ea5e90998dcda199c9f806d6cedd690bc /tests/test-ai-term--close.el | |
| parent | b426cd089503053fd203a034f3cbbe173252d5c3 (diff) | |
| download | dotemacs-eeafb35ff25a8fe060fd1f98b51a758bf88e2aa1.tar.gz dotemacs-eeafb35ff25a8fe060fd1f98b51a758bf88e2aa1.zip | |
fix(ai-term): key teardown session names off the buffer name
ghostel retargets default-directory via OSC 7 on every cd in the agent shell, so close (and quit with no project argument) computed the wrong aiv- session name after a cd. The kill then missed the real session and orphaned the agent, or hit a different project's session. The buffer name ("agent [basename]") never changes, so teardown now derives the basename from it.
Diffstat (limited to 'tests/test-ai-term--close.el')
| -rw-r--r-- | tests/test-ai-term--close.el | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test-ai-term--close.el b/tests/test-ai-term--close.el index 242bfd74..8b028351 100644 --- a/tests/test-ai-term--close.el +++ b/tests/test-ai-term--close.el @@ -36,8 +36,22 @@ (lambda (&rest _) (error "no tmux")))) (should (null (cj/--ai-term-kill-tmux-session "aiv-foo"))))) +(ert-deftest test-ai-term--close-buffer-session-from-name-after-cd () + "Regression: the session name comes from the immutable buffer name. +ghostel retargets `default-directory' via OSC 7 as the shell cds, so +deriving from it after a cd kills the wrong aiv- session (or misses, +orphaning the agent). The buffer name's basename never changes." + (let ((buf (get-buffer-create "agent [proj]")) + captured-session) + (with-current-buffer buf (setq-local default-directory "/tmp/elsewhere/")) + (cl-letf (((symbol-function 'cj/--ai-term-kill-tmux-session) + (lambda (s) (setq captured-session s) 0))) + (cj/--ai-term-close-buffer buf)) + (should (equal captured-session "aiv-proj")) + (should-not (buffer-live-p buf)))) + (ert-deftest test-ai-term--close-buffer-kills-session-and-buffer () - "Normal: derives the session from default-directory, kills it and the buffer." + "Normal: derives the session from the buffer name, kills it and the buffer." (let ((buf (get-buffer-create "agent [foo]")) captured-session) (with-current-buffer buf (setq-local default-directory "/tmp/foo/")) |
