story-kit: queue 192_bug_code_fences_lose_newlines_when_pasted_from_agent_output for merge

This commit is contained in:
Dave
2026-02-25 16:42:27 +00:00
parent a3a065a323
commit c441a002c0

View File

@@ -1,66 +0,0 @@
---
name: "Code fences lose newlines when pasted from agent output"
---
# Bug 192: Code fences lose newlines when pasted from agent output
## Description
When the assistant pastes a multi-line Rust function using a fenced code block, the second half of the code loses its line breaks and renders as a single long line. This has been reproduced twice in the Matrix chat interface.
Here is the function that the Matrix claude instance was asked to format in chat:
```rust
pub fn mentions_bot(body: &str, bot_user_id: &OwnedUserId) -> bool {
let full_id = bot_user_id.as_str();
if body.contains(full_id) {
return true;
}
let short = format!("@{}", bot_user_id.localpart());
let mut start = 0;
while let Some(rel) = body[start..].find(short.as_str()) {
let abs = start + rel;
let after = abs + short.len();
let next = body[after..].chars().next();
let is_word_end =
next.is_none_or(|c| !c.is_alphanumeric() && c != '-' && c != '_');
if is_word_end {
return true;
}
start = abs + 1;
}
false
}
```
This part rendered fine:
```rust
pub fn mentions_bot(body: &str, bot_user_id: &OwnedUserId) -> bool {
let full_id = bot_user_id.as_str();
if body.contains(full_id) {
return true;
}
```
however everything after that (starting with the newline) came out non-formatted and garbled.
## How to Reproduce
1. Ask the assistant to paste a multi-line Rust function in a fenced code block
2. The function `mentions_bot()` from the matrix bot module was used as the test case
3. Observe the rendered output in Matrix
## Actual Result
The first portion of the code block renders with proper newlines, but partway through (around the `let short = format!(...)` line), all remaining lines collapse into a single line with no line breaks.
## Expected Result
The entire code block should render with proper newlines preserved, matching the original source formatting.
## Acceptance Criteria
- [ ] Code fences with multi-line content preserve all newlines when sent through the Matrix bot interface
- [ ] Verify the issue is not a Matrix client rendering bug vs. a message sending bug (inspect the raw message content)