Skip to content

fix(cli, md): Unshade separator between reasoning and message blocks#702

Merged
JeanMertz merged 1 commit into
mainfrom
prr265
May 29, 2026
Merged

fix(cli, md): Unshade separator between reasoning and message blocks#702
JeanMertz merged 1 commit into
mainfrom
prr265

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

When a reasoning block has a background colour configured, the blank line separating it from the following message was incorrectly rendered with the reasoning background, visually extending the shaded region one line too far.

The root cause was that inter-block separators were emitted as part of the block that preceded them, so the separator after a reasoning block always inherited its background, regardless of what came next.

The fix defers that separator: print_block now suppresses the trailing separator for reasoning blocks (via the new
suppress_trailing_separator field on TerminalOptions) and sets a reasoning_separator_pending flag instead. When the next event arrives the flag is consumed and the separator is emitted with the correct background — shaded when more reasoning follows (the gap stays inside the reasoning region), unstyled when reasoning gives way to a message, tool call, or end of stream. flush also drains the pending separator without shading, covering role-header transitions and end-of-stream cases.

Two regression tests pin the behaviour: one checks that a single reasoning block followed by a message produces no shaded separator, and another checks that multi-paragraph reasoning keeps exactly one shaded inter-paragraph separator while the gap to the message remains unstyled.

When a reasoning block has a background colour configured, the blank
line separating it from the following message was incorrectly rendered
with the reasoning background, visually extending the shaded region one
line too far.

The root cause was that inter-block separators were emitted as part of
the block that preceded them, so the separator after a reasoning block
always inherited its background, regardless of what came next.

The fix defers that separator: `print_block` now suppresses the trailing
separator for reasoning blocks (via the new
`suppress_trailing_separator` field on `TerminalOptions`) and sets a
`reasoning_separator_pending` flag instead. When the next event arrives
the flag is consumed and the separator is emitted with the correct
background — shaded when more reasoning follows (the gap stays inside
the reasoning region), unstyled when reasoning gives way to a message,
tool call, or end of stream. `flush` also drains the pending separator
without shading, covering role-header transitions and end-of-stream
cases.

Two regression tests pin the behaviour: one checks that a single
reasoning block followed by a message produces no shaded separator, and
another checks that multi-paragraph reasoning keeps exactly one shaded
inter-paragraph separator while the gap to the message remains unstyled.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit 265937c into main May 29, 2026
16 checks passed
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