Skip to content

Fix chat prompt jumping and indentation - #802

Open
nhojb wants to merge 2 commits into
xenodium:mainfrom
nhojb:fix/chat-prompt-alignment
Open

Fix chat prompt jumping and indentation#802
nhojb wants to merge 2 commits into
xenodium:mainfrom
nhojb:fix/chat-prompt-alignment

Conversation

@nhojb

@nhojb nhojb commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Fixes a couple of issues with the shell prompt:

  1. Text on the first line jumps to column 0 every time a new character is entered (see screen recording)
  2. Text on the second-line was not indented to match the first line (column 0, not column 2)
  3. First line indent was not correct in the submitted prompt (column 0, not column 2)

Note: Running the latest agent-shell in emacs 31.1

First line jumping

Screen.Recording.2026-08-25.at.10.25.15.mov

Indentation (fixed)

Screenshot 2026-08-25 at 12 42 31 Screenshot 2026-08-25 at 12 42 41

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.

nhojb and others added 2 commits August 25, 2026 11:21
The live prompt's marker was carried as a `line-prefix' on the overlay
hiding the comint prompt.  A `line-prefix' is resolved once, at the
position a display row starts from, and that row starts on a prompt
whose every character is replaced by a `display' of "".  Redisplay
paths that resolve it a position later -- at the first character of the
input, past the overlay -- find nothing and paint the row flush left,
which shows as the input jumping sideways for a frame on each keystroke.

Render the marker as the `display' replacing the prompt text instead, so
it is part of the row and there is no prefix left to lose.  This also
settles the prompts that were rendering flush left for good: one after a
code block panel, or at the start of a fresh shell, has no newline above
for the `Me' label to ride, so the label falls back to a `before-string'
whose trailing newlines moved the row start into the string itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both the live prompt and a submitted turn indented the lines under the
first but not the first itself, so a multi-line prompt read as ragged
either way.

While composing, only the first line was indented, by the marker: the
overlay carrying it covers the prompt text alone, so no later row's
start ever sees it, and a typed newline began a row outside it.  Carry
the body indent on a rear-advancing overlay over the draft itself, which
is in place before anything is typed and takes in what follows, since no
relabel runs per keystroke.  A draft ending in a newline has no
character at all on its last row (that row starts at end of buffer, past
the overlay) for a `line-prefix' to hang off, so the caret sat flush
left until the next character: an `after-string' stands in there
meanwhile, kept in step by the draft's own modification hooks.

Once submitted, the turn kept the indent on those same lines but not on
its first, whose row starts on the hidden prompt.  Display the body
indent in place of that prompt's text, as the live prompt displays the
marker, so the whole turn lines up with the response below it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nhojb
nhojb force-pushed the fix/chat-prompt-alignment branch from b36cd83 to 17a696b Compare August 25, 2026 11:44
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