An sse-swap element must never contain another
An agent reply rendered nothing from its first tool call onwards. An ordinary
chat was fine, and that difference is the whole diagnosis: `#steps-{id}` is
itself an `sse-swap` target, so its innerHTML is replaced every time a round
closes -- and I had put the live `reasoning` and `render` containers *inside*
it. Every round boundary tore out the two elements the next frames were aimed
at, in the same pass that aimed them. An ordinary chat closes no steps, so the
swap never happened and nothing was ever torn out.
The tail moves back out to `_message.html`, as siblings of the steps container.
That removes the trick where the `steps` frame re-emitted the tail empty in
order to clear it, and replaces it with something simpler: `reasoning` and
`render` are now sent on every pass including empty, which is what clears them
when a round closes. Safe here and not before -- they carry the open tail only,
so an empty one means the tail is empty, where the version that carried the
whole reply would have wiped the answer. `steps` is the frame that must never
blank now.
`tests/test_chat.py` walks every template and refuses any `sse-swap` element
inside another; checked against the bug before being kept.
Two things I had left undone and should not have. `.msg__steps` had no styling
at all, so the sequence ran together with nothing separating a paragraph from
the command it led to. And `.msg__body--live:not(:empty) + .msg__waiting .dots`
stopped matching when those two stopped being siblings, so the dots pulsed
beside a finished answer for ever; it is a `:has()` on the bubble now.
The version bump is not cosmetic either: the service worker keys its cache on
it, so without one every browser kept serving the previous release's CSS and JS
against the new markup.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,16 +95,34 @@
|
||||
{% endif %}
|
||||
|
||||
{% if streaming %}
|
||||
{# The reply as a sequence of steps, in the order they happened. The
|
||||
closed ones are re-sent only when a round ends; the two live containers
|
||||
come with them, inside `_steps.html`, which is how the tail blanks
|
||||
itself. See services/steps.py. #}
|
||||
{# The reply as a sequence of steps, in the order they happened. Closed
|
||||
steps only, re-sent when a round ends. See services/steps.py. #}
|
||||
<div class="msg__steps" id="steps-{{ message.id }}" data-steps
|
||||
sse-swap="steps" hx-swap="innerHTML">
|
||||
{% with steps = [], live = true %}
|
||||
{% include "chat/_steps.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
sse-swap="steps" hx-swap="innerHTML"></div>
|
||||
|
||||
{# The step still being written. SIBLINGS of the container above, never
|
||||
inside it: that one is swapped whole every time a round closes, and an
|
||||
`sse-swap` element nested in another is torn out and rebuilt at each
|
||||
boundary with the frames aimed at it arriving in the same pass. That is
|
||||
what made an agent reply render nothing from its first tool call on.
|
||||
|
||||
Both frames are sent on every version bump *including empty*, which is
|
||||
how the tail clears when a round closes and its contents move into a
|
||||
step above. That is safe here and was not before: these carry the open
|
||||
tail only, so an empty one means the tail is genuinely empty, whereas
|
||||
the version that carried the whole reply would have wiped it. `steps`
|
||||
is the one that must never blank now. #}
|
||||
<details class="reasoning reasoning--live" id="reasoning-{{ message.id }}">
|
||||
<summary class="reasoning__summary">
|
||||
{{ icon("sparkle", "icon--sm reasoning__icon") }}
|
||||
<span class="reasoning__label">Thinking…</span>
|
||||
{{ icon("chevron-down", "icon--sm reasoning__chevron") }}
|
||||
</summary>
|
||||
<div class="reasoning__body" sse-swap="reasoning" hx-swap="innerHTML"></div>
|
||||
</details>
|
||||
|
||||
<div class="msg__body msg__body--live" id="stream-{{ message.id }}"
|
||||
sse-swap="render" hx-swap="innerHTML"></div>
|
||||
|
||||
{# Where a question from the model, or a command waiting to be allowed,
|
||||
lands. Unlike the blocks above it this frame is sent on every version
|
||||
|
||||
Reference in New Issue
Block a user