From 3203480aebc61d55c6ed3718a1e0f163c7651d8f Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 25 Feb 2026 16:32:19 +0000 Subject: [PATCH] story-kit: create 192_bug_code_fences_lose_newlines_when_pasted_from_agent_output --- ..._newlines_when_pasted_from_agent_output.md | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.story_kit/work/1_upcoming/192_bug_code_fences_lose_newlines_when_pasted_from_agent_output.md b/.story_kit/work/1_upcoming/192_bug_code_fences_lose_newlines_when_pasted_from_agent_output.md index ec5cda9..189b243 100644 --- a/.story_kit/work/1_upcoming/192_bug_code_fences_lose_newlines_when_pasted_from_agent_output.md +++ b/.story_kit/work/1_upcoming/192_bug_code_fences_lose_newlines_when_pasted_from_agent_output.md @@ -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. +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