Deferred buffer display stuck on "Loading..." when session-strategy is 'prompt#482
Open
smagnuso wants to merge 1 commit intoxenodium:mainfrom
Open
Deferred buffer display stuck on "Loading..." when session-strategy is 'prompt#482smagnuso wants to merge 1 commit intoxenodium:mainfrom
smagnuso wants to merge 1 commit intoxenodium:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Steps to reproduce: