Skip to content

Deferred buffer display stuck on "Loading..." when session-strategy is 'prompt#482

Open
smagnuso wants to merge 1 commit intoxenodium:mainfrom
smagnuso:dev/smagnuson/resume_stuck
Open

Deferred buffer display stuck on "Loading..." when session-strategy is 'prompt#482
smagnuso wants to merge 1 commit intoxenodium:mainfrom
smagnuso:dev/smagnuson/resume_stuck

Conversation

@smagnuso
Copy link
Copy Markdown

When agent-shell-session-strategy is prompt and the user selects an existing session to resume, the shell buffer never appears and the minibuffer shows "Loading..." indefinitely.

The shell is actually ready (prompt displayed, session loaded, model set), but the buffer is never shown to the user.

Root cause:

In agent-shell--start, the deferred display at line ~2811 subscribes to session-selected:

(agent-shell-subscribe-to
:shell-buffer shell-buffer
:event 'session-selected
:on-event (lambda (_event)
(agent-shell--display-buffer shell-buffer)))

But in agent-shell--initiate-session-list-and-load (line ~4407), session-selected is emitted before the session resume/load request is sent - not after bootstrap completes. The remaining bootstrap steps (session
resume response, set_model, prompt display) happen asynchronously afterward, and the buffer display call can race or fail to make the buffer visible.

Fix:

Subscribe to prompt-ready instead of session-selected. This event fires once at the end of the full bootstrap chain, after the session is loaded, model is set, and the shell prompt is displayed.

  •         :event 'session-selected                                                                                                                                                                                   
    
  •         :event 'prompt-ready                                                                                                                                                                                       
    

Steps to reproduce:

  1. (setq agent-shell-session-strategy 'prompt)
  2. Start agent-shell
  3. Select an existing session to resume from the session picker
  4. Buffer never appears; "Loading..." persists in minibuffer
  5. Manually switching to the buffer (C-x b) shows it's ready with a prompt

When session-strategy is 'prompt, the buffer display is deferred
to avoid showing an empty buffer before the user selects a session.
However, it subscribes to 'session-selected, which fires before
the session resume/load and model set complete. This means the
buffer may never visibly appear if display-buffer runs before
bootstrap finishes, or the "Loading..." active message persists
indefinitely.

Subscribe to 'prompt-ready instead, which fires after the full
bootstrap chain (session load, model set, prompt display) completes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant