From 2cde87f08990adf78d5bc67a43a838f19277a792 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 11 May 2026 13:27:26 -0500 Subject: feat(ai-vterm): order the project picker by most-recently-used The picker's active group (projects with a live tmux session) used to sort alphabetically. It now leads with projects opened this session, most-recent first, then the rest of the active group alpha, then the no-session group alpha. An in-session list (`cj/--ai-vterm-mru'), pushed to the front by `cj/--ai-vterm-show-or-create' on every open, drives the order. An empty list reproduces the old alphabetical behavior. I also pulled in a fix: `cj/--ai-vterm-tmux-session-name' now sanitizes `.' and `:' in the basename to `_'. tmux disallows those chars in session names and silently rewrites them, so `.emacs.d' really runs in session `aiv-_emacs_d', not `aiv-.emacs.d'. The computed name never matched, so `.emacs.d' was wrongly treated as having no session and landed in the no-session picker group. (A crash-recovery would also spawn a duplicate instead of reattaching.) Sanitizing the same way tmux does keeps the names in sync. --- tests/test-ai-vterm--show-or-create.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/test-ai-vterm--show-or-create.el') diff --git a/tests/test-ai-vterm--show-or-create.el b/tests/test-ai-vterm--show-or-create.el index 0a3dbde5..01083f84 100644 --- a/tests/test-ai-vterm--show-or-create.el +++ b/tests/test-ai-vterm--show-or-create.el @@ -57,8 +57,10 @@ VARS is a plist of capture variable names: :calls, :strings, :returns, (kill-buffer name))) (ert-deftest test-ai-vterm--show-or-create-creates-when-buffer-missing () - "Normal: no existing buffer -> vterm called once, launch cmd sent." - (let ((name "agent [normal-create-test]")) + "Normal: no existing buffer -> vterm called once, launch cmd sent, the +project recorded at the front of the MRU list." + (let ((name "agent [normal-create-test]") + (cj/--ai-vterm-mru nil)) (test-ai-vterm--cleanup name) (unwind-protect (test-ai-vterm--with-mock-vterm (:calls calls :strings strings @@ -68,7 +70,8 @@ VARS is a plist of capture variable names: :calls, :strings, :returns, (should (equal strings (list (cj/--ai-vterm-launch-command "/tmp/some-project")))) (should (= returns 1)) - (should (equal ddir "/tmp/some-project"))) + (should (equal ddir "/tmp/some-project")) + (should (equal (car cj/--ai-vterm-mru) "/tmp/some-project"))) (test-ai-vterm--cleanup name)))) (ert-deftest test-ai-vterm--show-or-create-displays-existing-when-process-live () -- cgit v1.2.3