From ca7015486d230192e94c51c0e5d014fc83a7a35f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 11 May 2026 05:17:44 -0500 Subject: feat(ai-vterm): surface surviving tmux sessions in the project picker Each project's tmux session is now named `` (default `aiv-`), so `tmux ls` can be filtered to AI-vterm's own sessions. After an Emacs crash the C-F9 project picker reads `tmux list-sessions`, matches surviving sessions back to their directories, and sorts those to the top: `[detached]` when only the tmux session is alive, `[running]` when a vterm buffer exists. The rest follow alphabetically. With tmux missing or no server running, it falls back to a plain alphabetical list. The picker's collection is a completion table that pins display order so Vertico doesn't re-sort and undo the active-first grouping. The prefix is a new `defcustom` rather than `claude-`, which collides with hand-rolled tmux sessions. Sessions named before this change use the bare basename and won't be matched afterward. One `tmux kill-server` clears any orphans. --- tests/test-ai-vterm--launch-command.el | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'tests/test-ai-vterm--launch-command.el') diff --git a/tests/test-ai-vterm--launch-command.el b/tests/test-ai-vterm--launch-command.el index c6b7ac2b..464c88b6 100644 --- a/tests/test-ai-vterm--launch-command.el +++ b/tests/test-ai-vterm--launch-command.el @@ -2,11 +2,12 @@ ;;; Commentary: ;; The launch command is what gets typed into a fresh vterm shell to bring -;; up Claude inside a per-project tmux session. The session is named after -;; the project basename so a second F9 on the same project reattaches to -;; the running Claude rather than spawning a new one. The trailing -;; `exec bash' keeps the tmux window alive if Claude exits, leaving the -;; session intact for recovery. +;; up Claude inside a per-project tmux session. The session is named +;; `cj/ai-vterm-tmux-session-prefix' + the project basename, so a second +;; F9 on the same project reattaches to the running Claude rather than +;; spawning a new one, and `tmux ls' output can be filtered to AI-vterm's +;; own sessions. The trailing `exec bash' keeps the tmux window alive if +;; Claude exits, leaving the session intact for recovery. ;;; Code: @@ -22,11 +23,12 @@ "tmux new-session -A " (cj/--ai-vterm-launch-command "/code/foo"))))) -(ert-deftest test-ai-vterm--launch-command-includes-session-name () - "Normal: the session name comes from the basename helper." - (let ((cj/ai-vterm-claude-command "claude")) +(ert-deftest test-ai-vterm--launch-command-includes-prefixed-session-name () + "Normal: the session name is the prefixed form from the name helper." + (let ((cj/ai-vterm-claude-command "claude") + (cj/ai-vterm-tmux-session-prefix "aiv-")) (should (string-match-p - " -s foo " + " -s aiv-foo " (cj/--ai-vterm-launch-command "/code/foo"))))) (ert-deftest test-ai-vterm--launch-command-includes-start-directory () @@ -52,9 +54,10 @@ (ert-deftest test-ai-vterm--launch-command-handles-spaces-in-basename () "Boundary: a basename with whitespace becomes hyphenated before quoting." - (let ((cj/ai-vterm-claude-command "claude")) + (let ((cj/ai-vterm-claude-command "claude") + (cj/ai-vterm-tmux-session-prefix "aiv-")) (should (string-match-p - " -s my-work " + " -s aiv-my-work " (cj/--ai-vterm-launch-command "/code/my work"))))) (provide 'test-ai-vterm--launch-command) -- cgit v1.2.3