aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ai-vterm--pick-project.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-09 12:00:30 -0500
committerCraig Jennings <c@cjennings.net>2026-05-09 12:00:30 -0500
commitcf010ab76fc01725c6885b1e84732a48128523d0 (patch)
tree61c5e6a5a7d5e1d03749f61dcbfaf1e9c3019255 /tests/test-ai-vterm--pick-project.el
parent4e8e40c616a92a00e9d3d764fda6537792cec373 (diff)
downloaddotemacs-cf010ab76fc01725c6885b1e84732a48128523d0.tar.gz
dotemacs-cf010ab76fc01725c6885b1e84732a48128523d0.zip
feat(ai-vterm): show [running] in picker and F9 redisplays last-used
The C-F9 project picker now flags projects whose claude buffer is alive with a " [running]" suffix on the abbreviated path. I added `cj/--ai-vterm-format-candidate` to compute the display name and routed the picker through it. Before the change, the picker showed every candidate identically, so you couldn't tell at a glance whether picking a project would attach to an existing session or start a fresh one. F9 with two or more alive claude buffers used to open the project picker. That meant after toggling claude-A off, opening claude-B via C-F9, then toggling B off, the next F9 dropped into a picker rather than redisplaying B (the one you just toggled off). I renamed `redisplay-single` to `redisplay-recent` in `cj/--ai-vterm-dispatch` and broadened the trigger from "exactly one alive" to "one or more alive". F9 now redisplays the MRU claude buffer, so it consistently means "toggle THE claude I was last using". The project picker stays explicit on C-F9 for "start a different project", and M-F9 still picks among existing claudes. 2 new tests for the indicator (`format-candidate` flagged + unflagged), 2 dispatch tests renamed to match the new contract. 80 ai-vterm tests pass. Full make test green.
Diffstat (limited to 'tests/test-ai-vterm--pick-project.el')
-rw-r--r--tests/test-ai-vterm--pick-project.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-ai-vterm--pick-project.el b/tests/test-ai-vterm--pick-project.el
index 6fa2d185..fd5295bf 100644
--- a/tests/test-ai-vterm--pick-project.el
+++ b/tests/test-ai-vterm--pick-project.el
@@ -44,5 +44,26 @@
(cj/--ai-vterm-pick-project)
(should (equal (caar received-collection) "~/code/foo")))))
+(ert-deftest test-ai-vterm--format-candidate-flags-running-project ()
+ "Normal: a path whose claude buffer has a live process gets a [running] suffix."
+ (let* ((path (expand-file-name "~/code/already-running"))
+ (buffer-name (cj/--ai-vterm-buffer-name path))
+ (buf (get-buffer-create buffer-name)))
+ (unwind-protect
+ (cl-letf (((symbol-function 'cj/--ai-vterm-process-live-p)
+ (lambda (b) (eq b buf))))
+ (should (equal (cj/--ai-vterm-format-candidate path)
+ (format "%s [running]" (abbreviate-file-name path)))))
+ (kill-buffer buf))))
+
+(ert-deftest test-ai-vterm--format-candidate-omits-flag-when-not-running ()
+ "Boundary: a path with no buffer or no live process -> plain abbreviated path."
+ (let ((path (expand-file-name "~/code/not-running")))
+ ;; Make sure no claude buffer exists for this path.
+ (let ((bn (cj/--ai-vterm-buffer-name path)))
+ (when (get-buffer bn) (kill-buffer bn)))
+ (should (equal (cj/--ai-vterm-format-candidate path)
+ (abbreviate-file-name path)))))
+
(provide 'test-ai-vterm--pick-project)
;;; test-ai-vterm--pick-project.el ends here