Agent chat: a prompt's bubble is as tall as its message (#11882) (#11883)

* claim: #11882

* Agent chat: a prompt's bubble is as tall as its message (#11882)

The prompt's Copy message row (#10741) was laid out right to left and centred
across its height. egui gives such a row all the height left in the
conversation's view, so a prompt near the top of a conversation stretched
down over the empty view, with Copy message floating in the middle. The row
is top-aligned now.

* Agent chat: keep the test's harness bound (#11882)

---------

Co-authored-by: MateuszSychXpl <151755914+MateuszSychXpl@users.noreply.github.com>
This commit is contained in:
Mateusz Sych
2026-11-04 18:13:19 +00:00
committed by GitHub
parent 8239b914ba
commit 6b6bd26648
2 changed files with 18 additions and 1 deletions
+3 -1
View File
@@ -1745,7 +1745,9 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
context_chips(ui, context, false);
files_line(ui, files.iter().map(String::as_str));
if copyable {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| copy_message_button(ui, n, text));
// Top-aligned: a row centred across its height takes all the height left in
// the conversation's view, which stretched a prompt near the top.
ui.with_layout(Layout::right_to_left(Align::Min), |ui| copy_message_button(ui, n, text));
}
});
if copyable {
+15
View File
@@ -4542,6 +4542,21 @@ fn the_copy_message_button_copies_the_prompt_as_entered() {
assert_eq!(copied_text(&h).as_deref(), Some("make a plate\n\nwith two holes:\n- 6 mm\n- 8 mm"), "the whole prompt, paragraphs and list items");
}
/// A prompt at the top of a short conversation is as tall as its text and its Copy message
/// button: the button sits at the bubble's foot and the reply follows straight after, instead of
/// the bubble stretching over the empty view below it.
#[test]
fn a_prompt_at_the_top_of_the_conversation_is_as_tall_as_its_content() {
// Kept to the end: the published handles and rects are its last frame's.
let _h = chat_with_copiable_messages();
let button = crate::scenario::handle_at("agent_chat:copy:0").expect("the prompt's Copy message button");
let prompt = crate::scenario::rect_of("agent_chat:msg:0").expect("the prompt's message area");
let reply = crate::scenario::rect_of("agent_chat:msg:1").expect("the reply's message area");
let row = crate::theme::Tokens::get().control_height;
assert!(prompt.bottom() - button.y < row, "the bubble ends {} below its button", prompt.bottom() - button.y);
assert!(reply.top() - button.y < 2.0 * row, "the reply starts {} below the prompt's button", reply.top() - button.y);
}
/// The visible button on a reply copies its original Markdown: heading, paragraphs, list and
/// fenced code, not the laid-out text.
#[test]