Agent chat: show the agent's answers as Markdown (#1778)

Thanks @Rec0iL.
This commit is contained in:
Rec0iL authored and GitHub committed 2026-10-16 13:26:23 -04:00
1 parent ff7c899840
commit 6496ec86ec
7 files changed
+564 -3

No files matched your search

+19
View File
@@ -756,3 +756,22 @@ done
disconnect(&mut app);
let _ = std::fs::remove_dir_all(&dir);
}
/// An agent's text is Markdown: a code block shows with its Copy button and a link is a button
/// of its own, instead of the raw markers.
#[test]
fn an_agents_markdown_is_drawn_as_blocks() {
let mut h = crate::scenario::Harness::new();
h.call("ui.agent_chat", json!({"open": true}));
h.frames(3);
h.app.agent_chat.items.push(Item::Agent {
thought: false,
text: "# Result\n\n- a **bold** point\n- another\n\n```\nlet x = 1;\n```\n\nSee [the docs](https://example.com/a).".into(),
});
h.frames(3);
assert!(h.widget("Copy").is_some(), "the code block has its Copy button");
assert!(h.widget("↗ example.com").is_some(), "the link is a button that names where it goes");
// A hostile reply draws too (no panic, bounded work).
h.app.agent_chat.items.push(Item::Agent { thought: false, text: "*".repeat(50_000) + &"[".repeat(5_000) + &"`a".repeat(5_000) });
h.frames(3);
}