Skip to content

Mark restored prompts with comint-highlight-prompt - #794

Merged
xenodium merged 1 commit into
xenodium:mainfrom
OSadovy:restored-prompt-face
Aug 22, 2026
Merged

Mark restored prompts with comint-highlight-prompt#794
xenodium merged 1 commit into
xenodium:mainfrom
OSadovy:restored-prompt-face

Conversation

@OSadovy

@OSadovy OSadovy commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for contributing to agent-shell!

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.

The bug

After restoring a session, C-c C-o on a restored interaction silently
shows the previous one in the viewport. No error, nothing in
*Messages*.

Why

agent-shell.el:3011 renders the prompt prefix for a user_message_chunk
replayed during session/load. Its own comment says it means to match the
field/face shape comint emits for a live prompt, but it applies
agent-shell-prompt alone.

That face inherits comint-highlight-prompt, so the prompt looks
correct. But shell-maker--re-search-forward-prompt matches with
(memq 'comint-highlight-prompt (ensure-list ...)), and inheritance
doesn't satisfy memq. The restored interaction never enters
shell-maker--extract-history, so agent-shell-interaction-at-point
returns nil — and agent-shell-viewport-refresh guards its entire body on
that value, so it does nothing at all.

Same applies to session/push, which goes through the same branch.

The fix

Append the face rather than substitute it.

agent-shell-prompt stays first for precedence and remains customizable,
and downstream packages matching on it with memq (there are tsome) keep working.

Verified

Against shell-maker--re-search-forward-prompt on the rendered prompt
text:

agent-shell-prompt                             -> not found
(agent-shell-prompt comint-highlight-prompt)   -> found

No tests added since I think the change is trivial, but happy to add one. The existing suite
passes.

A user_message_chunk replayed during session/load renders a prompt
prefix that, by its own comment, means to match the field/face shape
comint emits for a live prompt. It carried agent-shell-prompt alone.
That face inherits comint-highlight-prompt so it looks right, but
shell-maker--re-search-forward-prompt tests for the symbol with memq,
and inheritance does not satisfy it.

The restored interaction is then missing from
shell-maker--extract-history, so agent-shell-interaction-at-point
returns nil, and agent-shell-viewport-refresh guards its whole body on
that value: C-c C-o silently leaves the previous interaction on screen
rather than showing the one under point. No error, no clue.

Appended rather than substituted, so agent-shell-prompt stays first for
precedence and remains available to customize. Downstream packages that
match on it with memq keep working.

@xenodium xenodium left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix

@xenodium
xenodium merged commit d7e152c into xenodium:main Aug 22, 2026
2 checks passed
@OSadovy
OSadovy deleted the restored-prompt-face branch August 22, 2026 21:38
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.

2 participants