An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.
Rust
fix(cli): preserve trailing block separators in streamed markdown (#3312)
Bellman171a07b68c78
diff --git a/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json b/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.jsonnew file mode 100644index 00000000..06a232b5--- /dev/null+++ b/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json@@ -0,0 +1 @@+{"schema_version":1,"session_id":"5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299","state":"running","ready_for_input":false,"updated_at":"2026-10-12T22:09:30.659Z","current_turn_id":null,"last_turn_id":null,"live":true,"reason":null,"source":"agent_session_event","event":"turn_start","cwd":"/home/bellman/Data/Workspace/gc-task-cc-issue-3257-lane","workdir":"/home/bellman/Data/Workspace/gc-task-cc-issue-3257-lane","branch":null,"session_file":"/home/bellman/.gajaeway/broker/agent/sessions/v2-6fji37qf7ld523ivvoiohlcpmz3nu45m2apxyrkusn5nxczjmouq/2026-10-12T22-04-33-362Z_5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.jsonl","activity":{"seq":115,"last_activity_at":"2026-10-12T22:09:34.144Z","tool":"bash","phase":"started","outcome":null,"elapsed_ms":null,"active_tool_count":1,"active_tools":[{"tool":"bash","started_at":"2026-10-12T22:09:34.144Z"}],"in_flight":[{"digest":"e603a70efb03b6b2b78c94b704197d26fc8a35113543291a21f68b3b08ca11a9","tool":"bash","started_at":"2026-10-12T22:09:34.144Z"}]}}diff --git a/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json.lock b/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json.locknew file mode 100644index 00000000..04859899--- /dev/null+++ b/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json.lock@@ -0,0 +1 @@+{"pid":1,"start_time":"unknown","token":"1a2e8a33-76f2-4175-ac23-1521458f12a2","owner_host_id":"7af2fb0e8e37bd543e3d0bda6f205b56f30077b5a9b77e83208e94ae441315ac","released":true}\ No newline at end of filediff --git a/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json.lock.transition.owner b/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json.lock.transition.ownernew file mode 100644index 00000000..cba444ee--- /dev/null+++ b/.gjc/_session-5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299/runtime/runtime-state.json.lock.transition.owner@@ -0,0 +1 @@+{"pid":1,"start_time":"unknown","token":"a1342032-af80-4a49-a783-291bf73bf027","owner_host_id":"7af2fb0e8e37bd543e3d0bda6f205b56f30077b5a9b77e83208e94ae441315ac","released":true}\ No newline at end of filediff --git a/.gjc/state/sdk/.gjc-exact-replace-destination-e14c8f-76fc0 b/.gjc/state/sdk/.gjc-exact-replace-destination-e14c8f-76fc0new file mode 100644index 00000000..e69de29bdiff --git a/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.json b/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.jsonnew file mode 100644index 00000000..81f32d27--- /dev/null+++ b/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.json@@ -0,0 +1,12 @@+{+ "version": 1,+ "sessionId": "5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299",+ "pid": 487360,+ "host": "127.0.0.1",+ "port": 37541,+ "url": "ws://127.0.0.1:37541",+ "token": "LlIfu_aHH57jfys2Ii0ORMrnu56NLAa1",+ "startedAt": 1791842673967,+ "updatedAt": 1791842673967,+ "stale": false+}\ No newline at end of filediff --git a/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.lifecycle.json b/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.lifecycle.jsonnew file mode 100644index 00000000..1d45a043--- /dev/null+++ b/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.lifecycle.json@@ -0,0 +1 @@+{"effectMarker":"f441857a-f591-474b-b34a-6d89b2bf9feb","incarnation":"linux:159099652","pid":487360}\ No newline at end of filediff --git a/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.lifecycle.ready.json b/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.lifecycle.ready.jsonnew file mode 100644index 00000000..1d45a043--- /dev/null+++ b/.gjc/state/sdk/5e2dd1e8-ea4b-4af1-b56b-89ab7cca4299.lifecycle.ready.json@@ -0,0 +1 @@+{"effectMarker":"f441857a-f591-474b-b34a-6d89b2bf9feb","incarnation":"linux:159099652","pid":487360}\ No newline at end of filediff --git a/rust/crates/rusty-claude-cli/src/render.rs b/rust/crates/rusty-claude-cli/src/render.rsindex 24b77d09..bf0337e1 100644--- a/rust/crates/rusty-claude-cli/src/render.rs+++ b/rust/crates/rusty-claude-cli/src/render.rs@@ -249,6 +249,16 @@ impl TerminalRenderer {#[must_use]pub fn render_markdown(&self, markdown: &str) -> String {+ self.render_markdown_raw(markdown).trim_end().to_string()+ }++ /// Render markdown to ANSI without trimming trailing whitespace.+ ///+ /// Block-level events (paragraphs, headings, lists, code blocks) emit their+ /// trailing newline separators here. `render_markdown` trims them for+ /// one-shot output, while streaming keeps them so that successive chunks+ /// stay on their own lines instead of running together.+ fn render_markdown_raw(&self, markdown: &str) -> String {let normalized = normalize_nested_fences(markdown);let mut output = String::new();let mut state = RenderState::default();@@ -267,7 +277,7 @@ impl TerminalRenderer {);}- output.trim_end().to_string()+ output}#[must_use]@@ -275,6 +285,18 @@ impl TerminalRenderer {self.render_markdown(markdown)}+ /// Stream-friendly variant of `markdown_to_ansi` that preserves trailing+ /// block separators (such as a paragraph's closing newlines).+ ///+ /// `MarkdownStreamState::push` writes each rendered chunk directly to the+ /// terminal with no separator of its own, so the trailing newlines must+ /// survive here to keep a paragraph from sticking to the block that follows+ /// it. The final `flush` still uses `markdown_to_ansi` to trim the tail.+ #[must_use]+ pub fn markdown_to_ansi_stream(&self, markdown: &str) -> String {+ self.render_markdown_raw(markdown)+ }+#[allow(clippy::too_many_lines)]fn render_event(&self,@@ -609,7 +631,7 @@ impl MarkdownStreamState {let split = find_stream_safe_boundary(&self.pending)?;let ready = self.pending[..split].to_string();self.pending.drain(..split);- Some(renderer.markdown_to_ansi(&ready))+ Some(renderer.markdown_to_ansi_stream(&ready))}#[must_use]@@ -1052,6 +1074,34 @@ mod tests {assert!(plain_text.contains("fn nested()"));}+ #[test]+ fn stream_rendering_preserves_block_separators() {+ let renderer = TerminalRenderer::new();++ // The stream variant keeps the paragraph-ending newlines that the+ // one-shot variant trims, so consecutive streamed chunks do not run+ // into each other when written back-to-back to the terminal.+ let streamed = renderer.markdown_to_ansi_stream("Intro paragraph.\n\n");+ assert!(streamed.ends_with('\n'));+ assert!(!renderer+ .markdown_to_ansi("Intro paragraph.\n\n")+ .ends_with('\n'));++ let mut state = MarkdownStreamState::default();+ let first = state+ .push(&renderer, "Intro paragraph.\n\n")+ .expect("blank line closes the paragraph block");+ let second = state+ .push(&renderer, "1. first item\n\n")+ .expect("blank line closes the list block");++ let combined = strip_ansi(&format!("{first}{second}"));+ assert!(combined.contains("Intro paragraph."));+ assert!(combined.contains("1. first item"));+ // The two blocks stay on separate lines instead of sticking together.+ assert!(!combined.contains("Intro paragraph.1."));+ }+#[test]fn spinner_advances_frames() {let terminal_renderer = TerminalRenderer::new();