Skip to content

Commit 0ba1e0e

Browse files
timvisherclaude
andcommitted
Hijack agent-shell-resume-session to use the session picker
Repurpose agent-shell-resume-session from an ID-prompt command into a session-picker entry point that calls agent-shell--start with :session-strategy 'prompt. Add a :show-session-id keyword to agent-shell--start that buffer-locally sets agent-shell-show-session-id, so users with an ID in hand can find it via their completion framework's fuzzy matching even when the variable is off globally. Closes agent-shell-ufm. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4b261b3 commit 0ba1e0e

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

‎README.org‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ A soft fork of [[https://github.com/xenodium/agent-shell][agent-shell]] with ext
2626
- Bug fix for upstream =shell-maker-define-major-mode= mode-map quoting — without it, every =agent-shell-mode= invocation emits =void-function keymap= because the bare keymap value gets spliced into a backquote that re-evaluates =(keymap ...)= as a function call (worth upstreaming separately)
2727
- Live-validate workflow doc (=.agents/commands/live-validate.md=) describing the batch-mode rendering verification used for rendering-pipeline changes
2828
- =gfm-mode= compose buffer for the interactive =agent-shell-queue-request=, replacing the read-string minibuffer prompt (non-interactive callers still pass =PROMPT= directly)
29+
- =agent-shell-resume-session= repurposed from an ID-prompt command into a session-picker entry point: opens the same fuzzy-completion picker that =agent-shell-session-strategy= ='prompt= uses, and force-shows session IDs in the picker (via a new =:show-session-id= keyword on =agent-shell--start=) so users with an ID in hand can find it via their completion framework
2930

3031
-----
3132

‎agent-shell.el‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,19 +1180,20 @@ Works from both shell and viewport buffers."
11801180
(agent-shell--display-buffer new-shell-buffer)))))
11811181

11821182
;;;###autoload
1183-
(defun agent-shell-resume-session (session-id)
1184-
"Resume an existing agent session by SESSION-ID.
1185-
1186-
Prompts for agent selection and starts a new shell that resumes
1187-
the session identified by SESSION-ID."
1188-
(interactive "sSession ID: ")
1189-
(when (string-empty-p (string-trim session-id))
1190-
(user-error "Session ID cannot be empty"))
1183+
(defun agent-shell-resume-session ()
1184+
"Resume an existing agent session via the session picker.
1185+
1186+
Prompts for agent selection, then starts a new shell that lists known
1187+
sessions and lets the user pick one to resume. Session IDs are shown
1188+
in the picker (overriding `agent-shell-show-session-id' for this shell)
1189+
so users who know an ID can find it via their completion framework."
1190+
(interactive)
11911191
(agent-shell--start :config (or (agent-shell--resolve-preferred-config)
11921192
(agent-shell-select-config
11931193
:prompt "Resume with agent: ")
11941194
(error "No agent config found"))
1195-
:session-id session-id
1195+
:session-strategy 'prompt
1196+
:show-session-id t
11961197
:new-session t))
11971198

11981199
;;;###autoload
@@ -2815,14 +2816,15 @@ FUNCTION should be a function accepting keyword arguments (&key ...)."
28152816
(list (car pair) (cdr pair)))
28162817
alist)))
28172818

2818-
(cl-defun agent-shell--start (&key config no-focus new-session session-strategy session-id fork-session-id outgoing-request-decorator)
2819+
(cl-defun agent-shell--start (&key config no-focus new-session session-strategy show-session-id session-id fork-session-id outgoing-request-decorator)
28192820
"Programmatically start shell with CONFIG.
28202821

28212822
See `agent-shell-make-agent-config' for config format.
28222823

28232824
Set NO-FOCUS to start in background.
28242825
Set NEW-SESSION to start a separate new session.
28252826
SESSION-STRATEGY overrides `agent-shell-session-strategy' buffer-locally.
2827+
SHOW-SESSION-ID overrides `agent-shell-show-session-id' buffer-locally.
28262828
SESSION-ID resumes an existing session by its id string.
28272829
FORK-SESSION-ID forks an existing session by its id string.
28282830
OUTGOING-REQUEST-DECORATOR is passed through to `acp-make-client'."
@@ -2922,6 +2924,8 @@ variable (see makunbound)"))
29222924
(map-put! agent-shell--state :fork-session-id fork-session-id))
29232925
(when session-strategy
29242926
(setq-local agent-shell-session-strategy session-strategy))
2927+
(when show-session-id
2928+
(setq-local agent-shell-show-session-id show-session-id))
29252929
;; Show deferred welcome text,
29262930
;; but first wipe buffer content.
29272931
(let ((inhibit-read-only t))

0 commit comments

Comments
 (0)