diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-20 23:44:36 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-20 23:44:36 -0500 |
| commit | e83a055602ea2ad6cf8de5909bcbd8e44f2b5c22 (patch) | |
| tree | f6475411a629139751d4316e8560e071b4cec270 /modules/ai-term-backend-eat.el | |
| parent | 3a39d41f396bdd825074d7264ebb72149b8cd3b9 (diff) | |
| download | dotemacs-e83a055602ea2ad6cf8de5909bcbd8e44f2b5c22.tar.gz dotemacs-e83a055602ea2ad6cf8de5909bcbd8e44f2b5c22.zip | |
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.
Diffstat (limited to 'modules/ai-term-backend-eat.el')
| -rw-r--r-- | modules/ai-term-backend-eat.el | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/ai-term-backend-eat.el b/modules/ai-term-backend-eat.el index a7781128..906abd00 100644 --- a/modules/ai-term-backend-eat.el +++ b/modules/ai-term-backend-eat.el @@ -100,8 +100,11 @@ typed into a bare shell. Returns the poll timer." (cancel-timer timer)))))) timer)) -(defun cj/--ai-term-show-or-create (dir name &optional agent-command) +(defun cj/--ai-term-show-or-create (dir name &optional agent-command sessions) "Show or create the AI-term buffer for project DIR with buffer NAME. +SESSIONS, when non-nil, is a pre-fetched +`cj/--ai-term-live-tmux-sessions' list threaded from the caller so the +launch path pays for the tmux subprocess once. If a buffer named NAME exists with a live process, display it. If the buffer exists but its process is dead, kill it and recreate. If @@ -135,7 +138,8 @@ buffer." ;; session gets the project /color injected below; a reattach carries ;; whatever color the running Claude already has. (let ((fresh (not (cj/--ai-term-session-active-p - dir (cj/--ai-term-live-tmux-sessions))))) + dir (or sessions + (cj/--ai-term-live-tmux-sessions)))))) ;; `eat' switches to its buffer in the selected window before our ;; display-buffer-alist rule can route it; `save-window-excursion' ;; reverts that, and the explicit display-buffer below routes the buffer |
