From e83a055602ea2ad6cf8de5909bcbd8e44f2b5c22 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 20 Jul 2026 23:44:36 -0500 Subject: perf(ai-term): fetch the tmux session list once per launch The launch path spawned tmux list-sessions up to three times: in the project picker's sorting, in the launcher's fresh check, and again inside show-or-create. The list is now fetched once and threaded through; the cycling path still fetches its own. --- modules/ai-term-sessions.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'modules/ai-term-sessions.el') diff --git a/modules/ai-term-sessions.el b/modules/ai-term-sessions.el index eb09d2e9..57d735d1 100644 --- a/modules/ai-term-sessions.el +++ b/modules/ai-term-sessions.el @@ -351,8 +351,11 @@ the metadata keeps the order ALIST was built in." (cycle-sort-function . identity)) (complete-with-action action alist string predicate)))) -(defun cj/--ai-term-pick-project () +(defun cj/--ai-term-pick-project (&optional sessions) "Prompt for an AI-agent project; return its absolute path. +SESSIONS, when non-nil, is a pre-fetched result of +`cj/--ai-term-live-tmux-sessions', so a caller that already paid for the +tmux subprocess can thread it through instead of spawning another. Candidates come from `cj/--ai-term-candidates', ordered by `cj/--ai-term-sort-candidates' so projects with a live tmux session @@ -368,7 +371,7 @@ Signals `user-error' when no candidates exist." (append cj/ai-term-project-roots cj/ai-term-container-roots) ", "))) - (let* ((sessions (cj/--ai-term-live-tmux-sessions)) + (let* ((sessions (or sessions (cj/--ai-term-live-tmux-sessions))) (sorted (cj/--ai-term-sort-candidates candidates sessions)) (display-alist (mapcar (lambda (p) -- cgit v1.2.3