Skip to content

fix(timeline): four correctness bugs in the message body - #281

Merged
tyreseluo merged 3 commits into
mainfrom
fix/timeline-correctness-bugs
Jul 31, 2026
Merged

fix(timeline): four correctness bugs in the message body#281
tyreseluo merged 3 commits into
mainfrom
fix/timeline-correctness-bugs

Conversation

@tyreseluo

Copy link
Copy Markdown

Four defects, all reachable in a normal agent-chat room. Two of them arrived with #274; this is the follow-up that was deliberately kept out of the colour-only PR (#276).

Folding fought the stream

A streaming reply's body grows on every frame, so the moment it crossed the fold threshold it collapsed to three lines and took the typewriter cursor with it. Mid-sentence, the reply read as having stalled.

populate_bot_text_message_content now takes is_streaming and suppresses both the fold and its toggle until the message settles. Regression from #274, which added folding without exempting the streaming call site.

A recycled slot kept the previous bot card

content.bot_message_card / content.message visibility is only ever written by the bot text path — but list.item_with_existed(cx, item_id, id!(Message)) hands the same template to the server-notice and unsupported/redacted paths as well.

So a slot that had held a bot reply kept drawing that reply's card while the new content sat hidden underneath it. A redaction would still show the text it was supposed to remove.

Both paths now call reset_bot_message_card first. The helper's doc comment records why any future branch rendering into content.message has to do the same — the constraint is invisible at the call site otherwise.

The fold toggle turned white when clicked

SmallStateGroupToggleButton defines color / color_hover / color_down but no focus colour, and the toggle overrode only color. Clicking it left the label on an undefined focus value — white on a white card — until an unrelated redraw reset it. Scrolling away and back "fixed" it, which is what made it look intermittent.

All four widgets #274 added — the toggle and the permalink link, in both the Message and CondensedMessage templates — now spell out every state. The permalink link had the identical gap and is fixed here rather than waiting for someone to hover it.

Description truncation panicked on mixed scripts

&description[..(MAX_DESCRIPTION_LENGTH - 3)]

MAX_DESCRIPTION_LENGTH counts bytes, so this cut at a fixed byte offset and panicked whenever byte 177 landed inside a multi-byte character. Pure CJK survives by luck — 177 is divisible by 3, so it always lands on a boundary — but mixed CJK/ASCII does not: of 200 sampled strings, 57% cut mid-character and would have taken the process down as the preview scrolled into view.

Now truncates by characters. Latent rather than live on a homeserver that refuses previews (matrix.palpo.im answers 403 for every URL, so description is never populated), which is why it had not been hit yet.

Testing

cargo test --lib --features agent_chat — 589 pass, including 3 new truncation tests. One asserts the old byte offset was not a char boundary for its input, so that case cannot quietly stop being a regression test.

Exercised against a live agent-chat room: streamed a long reply and confirmed it no longer collapses mid-flight, the toggle keeps its colour through click and hover, and a redaction in a room with bot replies renders the redaction rather than the previous card. Also confirmed from the app log that no RBX_* property fails to resolve — the failure mode that cargo check cannot see.

🤖 Generated with Claude Code

tyreseluo and others added 3 commits July 31, 2026 14:38
`MAX_DESCRIPTION_LENGTH` counts bytes and the slice cut at a fixed byte offset,
so any description longer than the limit panicked whenever byte 177 landed
inside a multi-byte character:

    &description[..(MAX_DESCRIPTION_LENGTH - 3)]

Pure CJK happens to survive — 177 is divisible by 3, so it always lands on a
boundary — but text mixing CJK with ASCII does not: sampling 200 such strings,
57% cut mid-character and would have taken the process down as soon as the
preview scrolled into view.

Truncate by characters instead. Tests cover a mixed-script string (asserting the
old byte offset was *not* a char boundary, so the case cannot silently stop
being a regression test), CJK, emoji, and the short-string passthrough.

Latent rather than live on a homeserver that refuses previews — matrix.palpo.im
answers 403 for every URL, so `description` is never populated there.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n kinds

Three defects in the message body, all reachable in a normal agent-chat room.

**Folding fought the stream.** A streaming reply's body grows every frame, so
the moment it crossed the fold threshold it collapsed to three lines and took
the typewriter cursor with it — the reply read as having stalled, mid-sentence.
`populate_bot_text_message_content` now takes `is_streaming` and suppresses both
the fold and its toggle until the message settles. (Regression from #274, which
added folding without exempting the streaming call site.)

**A recycled slot kept the previous bot card.** Those two visibilities are only
written by the bot text path, but the PortalList hands the same `Message`
template to the server-notice and unsupported/redacted paths too. A slot that
had held a bot reply therefore kept drawing that reply's card while the new
content sat hidden underneath — a redaction would still show the text it was
meant to remove. Both paths now call `reset_bot_message_card` first; the helper
says why any future branch rendering into `content.message` must do the same.

**The fold toggle turned white when clicked.** `SmallStateGroupToggleButton`
defines color/hover/down but no focus colour, and the toggle only overrode
`color`, so clicking it left the label on an undefined focus value until an
unrelated redraw reset it. All four widgets added in #274 — the toggle and the
permalink link, in both the Message and CondensedMessage templates — now spell
out every state. The permalink link had the same gap and is fixed alongside,
rather than waiting for someone to hover it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Caught by the `typos` CI gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tyreseluo
tyreseluo merged commit 45b3498 into main Jul 31, 2026
12 checks passed
@tyreseluo
tyreseluo deleted the fix/timeline-correctness-bugs branch July 31, 2026 07:13
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