aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ai-vterm--tmux-session-name.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-11 13:27:26 -0500
committerCraig Jennings <c@cjennings.net>2026-05-11 13:27:26 -0500
commitc14d6c8d0f669d694dd765d6f592ce6eb72c50f5 (patch)
tree26c45c9f9f77129a8440019a6825a24a1eea028d /tests/test-ai-vterm--tmux-session-name.el
parentde8659c61e47787c635ad9a6184fcef655ae89d2 (diff)
downloaddotemacs-c14d6c8d0f669d694dd765d6f592ce6eb72c50f5.tar.gz
dotemacs-c14d6c8d0f669d694dd765d6f592ce6eb72c50f5.zip
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.
Diffstat (limited to 'tests/test-ai-vterm--tmux-session-name.el')
-rw-r--r--tests/test-ai-vterm--tmux-session-name.el20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/test-ai-vterm--tmux-session-name.el b/tests/test-ai-vterm--tmux-session-name.el
index 8d9220ebd..073dc312a 100644
--- a/tests/test-ai-vterm--tmux-session-name.el
+++ b/tests/test-ai-vterm--tmux-session-name.el
@@ -5,8 +5,10 @@
;; the project's basename, so reopening the agent on the same project (e.g.
;; after an Emacs crash) reattaches to the same tmux session rather than
;; spawning a new one -- and the prefix lets `tmux ls' output be filtered
-;; down to AI-vterm's own sessions. Whitespace in the basename becomes
-;; hyphens so the name is safe to pass on a tmux command line.
+;; down to AI-vterm's own sessions. The basename is sanitized to a form
+;; tmux won't re-mangle: runs of whitespace become hyphens, and `.' / `:'
+;; (which tmux disallows in session names and silently rewrites to `_')
+;; become `_' up front so the computed name matches the real session.
;;; Code:
@@ -27,11 +29,19 @@
(should (equal (cj/--ai-vterm-tmux-session-name "/home/cjennings/projects/foo/")
"aiv-foo"))))
-(ert-deftest test-ai-vterm--tmux-session-name-dot-prefix-dir ()
- "Boundary: dot-prefix dirs preserve the dot (tmux accepts dots)."
+(ert-deftest test-ai-vterm--tmux-session-name-dots-become-underscores ()
+ "Boundary: tmux disallows `.' in session names and rewrites it to `_',
+so the basename's dots are sanitized to `_' up front -- `.emacs.d' must
+yield `aiv-_emacs_d', matching the session tmux actually creates."
(let ((cj/ai-vterm-tmux-session-prefix "aiv-"))
(should (equal (cj/--ai-vterm-tmux-session-name "/home/cjennings/.emacs.d")
- "aiv-.emacs.d"))))
+ "aiv-_emacs_d"))))
+
+(ert-deftest test-ai-vterm--tmux-session-name-colon-becomes-underscore ()
+ "Boundary: `:' is also disallowed by tmux in session names -> `_'."
+ (let ((cj/ai-vterm-tmux-session-prefix "aiv-"))
+ (should (equal (cj/--ai-vterm-tmux-session-name "/tmp/a:b")
+ "aiv-a_b"))))
(ert-deftest test-ai-vterm--tmux-session-name-space-becomes-hyphen ()
"Boundary: a space in the basename is replaced with a hyphen."