Skip to content

Keep chat prompt overlays outside streamed output - #943

Open
Gleek wants to merge 1 commit into
xenodium:mainfrom
Gleek:fix/chat-prompt-front-advance
Open

Gleek wants to merge 1 commit into
xenodium:mainfrom
Gleek:fix/chat-prompt-front-advance

Conversation

@Gleek

@Gleek Gleek commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

In chat mode, streaming responses cause frequent relabeling of the entire conversation. This is expensive in long sessions: my CPU profiles showed prompt discovery taking roughly half the sampled CPU time. With multiple such sessions running in parallel Emacs bogs down quite considerably.

21118  79% - timer-event-handler
21089  79%  - apply
12639  47%   - agent-shell-chat--relabel-buffer
12635  47%    - agent-shell-chat--relabel
11962  44%     - agent-shell-chat--label-prompts
11584  43%      - agent-shell-chat--prompt-runs
 8416  31%         next-single-property-change
 2907  10%         agent-shell-chat--prompt-face-p

Disclaimer: agent-shell is v0.87.10

From what I understand the prompt overlays include text inserted at their start.

Since streamed output is inserted immediately before the live prompt, those overlays can expand over the output and hide it. Relabeling adjusts their boundaries to reveal the output.

This change gives prompt overlays front-advance so they move with the prompt automatically.
Ordinary streaming skips prompt relabelling, while response headings continue to update.
Submissions, restores, etc, would retain full relabelling.

Checklist

  • I agree to communicate (PR description and comments) with the author myself (not AI-generated).
  • I've reviewed all code in PR myself and will vouch for its quality.
  • I've read and followed the Contributing guidelines.
  • I've filed a feature request/discussion for a new feature.
  • I'm making visual changes, so I'm including screenshots so you can view and discuss.
  • I've added tests where applicable.
  • I've updated documentation where necessary.
  • I've run M-x checkdoc and M-x byte-compile-file.

@Gleek
Gleek marked this pull request as ready for review November 12, 2026 15:24
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