story-kit: create 192_bug_code_fences_lose_newlines_when_pasted_from_agent_output

This commit is contained in:
Dave
2026-02-25 16:32:19 +00:00
parent f09f6a86a2
commit 3203480aeb

View File

@@ -8,6 +8,44 @@ name: "Code fences lose newlines when pasted from agent output"
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. 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 ## How to Reproduce
1. Ask the assistant to paste a multi-line Rust function in a fenced code block 1. Ask the assistant to paste a multi-line Rust function in a fenced code block