* claim: #2224 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Agent chat: keep Send in view for a long message, open "View attached" (#2224) The message box sat in a fixed 92-point reserve, so a long message grew it past the panel and took Send, Stop and Attach view with it. The box is now a panel of its own at the bottom: it grows upwards up to a cap, then scrolls, and the conversation takes what is left. The picture sent with a message is kept on it (once the agent starts on the message), and the "View attached" caption opens it in a window. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Agent chat: a message's pictures as thumbnails with a hover preview and a viewer (#2224) Instead of a window on the far side of the screen: the pictures of a message show as small thumbnails under it, hovering one shows it bigger for as long as the pointer stays, and a click opens a viewer over the app with the message's pictures one at a time (previous and next, arrow keys, Esc). A picture carries a note shown with it, so attachments of other kinds can use the same viewer. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * claim: #2286 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Agent chat: Attach selection sends what is selected in the model with the message (#2286) A checkbox beside Attach view. The selection is read when the message is sent (also for a queued one) and described: faces and edges with the names, indices and points the tools take plus their size and place, features by name and kind, bodies by name; at most 64, the rest counted. The agent gets it as text after the message; the conversation shows the message as typed with the things as grouped chips (hover for what the agent was told). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * WIP: the chat's context picker dialog (#2286) * Agent chat: Pick context, a picker for elements, features and bodies (#2286) A button beside Attach selection opens the picker: a dialog with Elements, Features and Bodies inputs, so clicks in the model, the timeline and the browser pick into the active one (clicking again takes one out), with the usual highlight. OK puts the picks as chips with an x above the message box; they go with the next message like an attached selection (text for the agent, chips in the conversation) and the tray is empty again afterwards. Cancel keeps what was picked before. The control channel opens it with pick. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Agent chat: Attach selection counts and describes what was clicked, not the pieces of a rim (#2286) A click on a circular rim or a split surface selects all its pieces for the commands. The checkbox counted them one by one and the agent got one entry per piece (reported on macOS). They are now grouped back into the click they came from: one chip, one entry with the whole size, and the indices of every piece in its detail. Edge details are looked up by position as well as index. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Agent chat: a message's picture is kept on exactly that message (#2224) The turn now carries its message's place in the conversation (also through a queue and a send again after a sign-in), so its picture is kept there, once, and never on an older message that also wanted one (review of #2225). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Agent chat: use the UI kit's checkbox and button and the font tokens (guard tests) Main's UI-kit guard tests reject raw egui checkboxes, buttons and font sizes in the chat panel; Attach selection, Pick context, the chip remove button and the chip fonts now come from ui_kit and Tokens. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
112 lines
5.4 KiB
Rust
112 lines
5.4 KiB
Rust
//! Render the actual Assistant panel with a public-safe transcript, without an agent or GPU.
|
||
#[path = "support/raster.rs"]
|
||
mod raster;
|
||
|
||
use std::collections::HashMap;
|
||
|
||
use egui::{ColorImage, TextureId};
|
||
use serde_json::json;
|
||
use solidcraft_ui_egui::{
|
||
agent_chat::{
|
||
Item,
|
||
backend::{PermissionOption, ToolStatus},
|
||
},
|
||
scenario::{self, Harness},
|
||
theme,
|
||
};
|
||
|
||
#[test]
|
||
fn assistant_transcript_tools_and_approvals_fit_in_both_themes() {
|
||
let previous = theme::is_dark();
|
||
for dark in [false, true] {
|
||
for width in [280.0, 440.0, 760.0] {
|
||
let mut h = Harness::new();
|
||
h.app.home.open = false;
|
||
h.call("ui.resize", json!({"width":1100,"height":1500}));
|
||
h.call("ui.set", json!({"dark":dark}));
|
||
h.call("ui.agent_chat", json!({"features":true,"open":true,"picker":false,"width":width}));
|
||
h.app.agent_chat.items = vec![
|
||
Item::User {
|
||
text: "Make the plate 80 mm wide, soften its edges, and export a STEP file.".into(),
|
||
image: false,
|
||
pictures: vec![],
|
||
context: Default::default(),
|
||
files: vec!["plate-notes.txt".into()],
|
||
},
|
||
Item::Agent { thought: false, text: "I’ll update the width and check the selected edges before exporting.".into() },
|
||
Item::Tool {
|
||
id: "width".into(),
|
||
title: "parameters.set".into(),
|
||
kind: "other".into(),
|
||
status: Some(ToolStatus::Completed),
|
||
output: Some("plate_width = 80 mm".into()),
|
||
},
|
||
Item::Tool {
|
||
id: "fillet".into(),
|
||
title: "solid.fillet".into(),
|
||
kind: "other".into(),
|
||
status: Some(ToolStatus::Failed),
|
||
output: Some("The requested radius is too large. Try a smaller radius.".into()),
|
||
},
|
||
Item::Agent {
|
||
thought: false,
|
||
text: "The width is updated. The fillet needs a smaller radius. May I export the current plate for review?".into(),
|
||
},
|
||
Item::Permission {
|
||
key: 1,
|
||
title: "Export plate.step".into(),
|
||
answer: None,
|
||
options: vec![
|
||
PermissionOption { id: "deny".into(), name: "Deny".into(), kind: "reject_once".into() },
|
||
PermissionOption { id: "always".into(), name: "Always allow".into(), kind: "allow_always".into() },
|
||
PermissionOption { id: "once".into(), name: "Allow once".into(), kind: "allow_once".into() },
|
||
],
|
||
},
|
||
];
|
||
h.ctx = egui::Context::default();
|
||
h.ctx.enable_accesskit();
|
||
solidcraft_ui_egui::fonts::setup_fonts(&h.ctx);
|
||
theme::apply(&h.ctx);
|
||
let mut textures: HashMap<TextureId, ColorImage> = HashMap::new();
|
||
for _ in 0..8 {
|
||
raster::paint(&mut h, &mut textures, vec![]);
|
||
}
|
||
// Expanding the failed call must preserve every approval and composer target.
|
||
let at = scenario::handle_at("agent_chat:tool:3").expect("failed tool target");
|
||
for pressed in [true, false] {
|
||
raster::paint(
|
||
&mut h,
|
||
&mut textures,
|
||
vec![
|
||
egui::Event::PointerMoved(at),
|
||
egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE },
|
||
],
|
||
);
|
||
}
|
||
for _ in 0..8 {
|
||
raster::paint(&mut h, &mut textures, vec![]);
|
||
}
|
||
let output = raster::paint(&mut h, &mut textures, vec![]);
|
||
h.output = output.platform_output.clone();
|
||
let screenshot = raster::raster(&mut h, &textures, output);
|
||
let panel = scenario::rect_of("agent_chat:panel").expect("Assistant panel");
|
||
for name in ["permission:once", "permission:always", "permission:deny", "permissions", "send"] {
|
||
let at = scenario::handle_at(&format!("agent_chat:{name}")).expect("Assistant action retained");
|
||
assert!(panel.contains(at), "{name} outside {width} pt panel: {at:?} {panel:?}");
|
||
}
|
||
assert!(h.widget("The requested radius is too large. Try a smaller radius.").is_some(), "failed tool output expands");
|
||
assert_eq!(h.app.agent_chat.waiting(), 1, "rendering and expanding tools never answer an approval");
|
||
let approval = scenario::rect_of("assistant:approval").expect("approval card");
|
||
assert!(approval.height() < 160.0, "approval stays compact at {width}: {approval:?}");
|
||
if let Ok(dir) = std::env::var("SOLIDCRAFT_ASSISTANT_EVIDENCE") {
|
||
std::fs::create_dir_all(&dir).unwrap();
|
||
image::imageops::crop_imm(&screenshot, panel.left() as u32, panel.top() as u32, panel.width() as u32, panel.height() as u32)
|
||
.to_image()
|
||
.save(std::path::Path::new(&dir).join(format!("assistant-{width:.0}-{}.png", if dark { "dark" } else { "light" })))
|
||
.unwrap();
|
||
}
|
||
}
|
||
}
|
||
theme::set_dark(previous);
|
||
}
|