aboutsummaryrefslogtreecommitdiff
path: root/modules/ai-term-sessions.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-20 08:36:14 -0500
committerCraig Jennings <c@cjennings.net>2026-07-20 08:36:14 -0500
commitd9a8a6382854bb06c3aac6a5a4779a48cc82b48a (patch)
tree833b5629f884b8acc52e76deb43775280ab8f0c1 /modules/ai-term-sessions.el
parent836b386e0a19fe49d35a65ea4d0faa63e6d6e1d2 (diff)
downloaddotemacs-d9a8a6382854bb06c3aac6a5a4779a48cc82b48a.tar.gz
dotemacs-d9a8a6382854bb06c3aac6a5a4779a48cc82b48a.zip
feat(ai-term): M-SPC cycles attached agents, M-S-SPC cycles all
M-SPC now steps only through attached agents (the ones with a live on-screen buffer), so the fast chord stays among what's already up. M-S-SPC steps through all active agents and attaches a detached tmux session when it lands on one, which is what M-SPC used to do. I moved the shared step logic into cj/--ai-term-step-among and added cj/--ai-term-attached-agent-dirs to filter the queue to attached buffers. I bound both chords globally and in eat-semi-char-mode-map so they work from inside an agent buffer. C-; a n keeps cycling all.
Diffstat (limited to 'modules/ai-term-sessions.el')
-rw-r--r--modules/ai-term-sessions.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/ai-term-sessions.el b/modules/ai-term-sessions.el
index 58532f7e..eb09d2e9 100644
--- a/modules/ai-term-sessions.el
+++ b/modules/ai-term-sessions.el
@@ -121,6 +121,23 @@ which the step materializes by attaching."
(lambda (a b)
(string< (cj/--ai-term-buffer-name a) (cj/--ai-term-buffer-name b))))))
+(defun cj/--ai-term-attached-agent-dirs ()
+ "Return project dirs that have a live agent BUFFER (attached only).
+
+Like `cj/--ai-term-active-agent-dirs' but excludes detached tmux
+sessions with no Emacs buffer -- this is the queue `cj/ai-term-next-attached'
+\(M-SPC) steps through, so the fast chord stays among agents already on
+screen. Detached sessions are reachable only via `cj/ai-term-next'
+\(M-S-SPC). Sorted by agent buffer name for a stable rotation."
+ (let ((live-names (mapcar #'buffer-name (cj/--ai-term-agent-buffers))))
+ (sort
+ (seq-filter
+ (lambda (dir)
+ (member (cj/--ai-term-buffer-name dir) live-names))
+ (cj/--ai-term-candidates))
+ (lambda (a b)
+ (string< (cj/--ai-term-buffer-name a) (cj/--ai-term-buffer-name b))))))
+
(defun cj/--ai-term-tmux-session-name (dir)
"Return the tmux session name for project directory DIR.