Connector rerouting no longer unshares the edited slide, the shape group is named Decorative Text Styles, and a socket request is tested as answered in the frame

reroute read the glued connectors through the mutable shape list, so every edit copied the selected slide and its thumbnail was drawn again. The shape-format group said WordArt, which production never displayed. A control request over the real server is answered by the UI frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-27 17:11:05 +00:00
co-authored by Claude Opus 5.5
parent ff4f77f69e
commit 4f338e03ae
4 changed files with 47 additions and 11 deletions
+3 -2
View File
@@ -100,10 +100,11 @@ pub fn endpoints(x: &Xfrm) -> (Point, Point) {
/// Move the ends of connectors glued to shapes on the edited slide to the current site positions.
/// Connections to shapes that no longer exist are dropped.
pub fn reroute(doc: &mut Presentation, sel: &Selection) {
let Some(list) = crate::shapes_mut(doc, sel) else { return };
if !list.iter().any(|s| matches!(s.kind, ShapeKind::Connector { start: Some(_), .. } | ShapeKind::Connector { end: Some(_), .. })) {
// Read first: taking the list mutably would unshare the edited slide even when no connector is glued.
if !crate::shapes_of(doc, sel).iter().any(|s| matches!(s.kind, ShapeKind::Connector { start: Some(_), .. } | ShapeKind::Connector { end: Some(_), .. })) {
return;
}
let Some(list) = crate::shapes_mut(doc, sel) else { return };
let snapshot: Vec<Shape> = list.clone();
let view = doc.clone();
let site = |id: ShapeId, idx: u32| -> Option<Point> {
+11 -8
View File
@@ -288,14 +288,7 @@ impl DocState {
}
/// Shapes of the edited tree (current slide, or the master/layout in Slide Master view).
pub fn shapes(&self) -> &[Shape] {
match self.selection.target {
Target::Slides => self.current_slide().map(|s| s.shapes.as_slice()).unwrap_or(&[]),
Target::Master { master } => self.doc.masters.get(master).map(|m| m.shapes.as_slice()).unwrap_or(&[]),
Target::Handout | Target::NotesMaster => page_master(&self.doc, self.selection.target).map(|m| m.shapes.as_slice()).unwrap_or(&[]),
Target::Layout { master, layout } => {
self.doc.masters.get(master).and_then(|m| m.layouts.get(layout)).map(|l| l.shapes.as_slice()).unwrap_or(&[])
}
}
shapes_of(&self.doc, &self.selection)
}
pub fn shape(&self, id: ShapeId) -> Option<&Shape> {
deckcraft_model::find_shape(self.shapes(), id)
@@ -321,6 +314,16 @@ pub fn master_page(doc: &Presentation, t: Target) -> Option<Presentation> {
Some(p)
}
/// The edited shape tree of a presentation, read without unsharing its slide or master.
pub fn shapes_of<'a>(doc: &'a Presentation, sel: &Selection) -> &'a [Shape] {
match sel.target {
Target::Slides => doc.slides.get(sel.slide).map(|s| s.shapes.as_slice()).unwrap_or(&[]),
Target::Master { master } => doc.masters.get(master).map(|m| m.shapes.as_slice()).unwrap_or(&[]),
Target::Handout | Target::NotesMaster => page_master(doc, sel.target).map(|m| m.shapes.as_slice()).unwrap_or(&[]),
Target::Layout { master, layout } => doc.masters.get(master).and_then(|m| m.layouts.get(layout)).map(|l| l.shapes.as_slice()).unwrap_or(&[]),
}
}
/// Mutable access to the edited shape tree of a presentation.
pub fn shapes_mut<'a>(doc: &'a mut Presentation, sel: &Selection) -> Option<&'a mut Vec<Shape>> {
match sel.target {
+32
View File
@@ -974,4 +974,36 @@ mod tests {
assert!(harness.state().show.is_none(), "an invalid start never launches a show");
Ok(())
}
/// A request from a client's own thread is answered by the UI thread's frame: the connection thread only
/// forwards it and asks for a repaint, so it never touches a running pass's state.
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn a_request_over_the_socket_is_answered_in_the_frame() -> Result<(), Box<dyn Error>> {
use craft::automation::{client::ControlClient, server};
let mut harness = harness_with(
deckcraft_engine::Session::with_new(),
crate::Services::default(),
egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0),
|_| {},
);
let listener = std::net::TcpListener::bind(("127.0.0.1", 0))?;
let (receiver, listening) = server::serve(listener, "token".into(), WindowHost::of(&harness.ctx))?;
harness.state_mut().control = Some(ControlChannel::new(receiver));
let addr = listening.addr;
let notice = "A notice sent over the socket";
let client = std::thread::spawn(move || ControlClient::connect(addr, "token").map_err(|e| format!("{e:?}"))?.call("ui.notify", json!({"text": notice})));
let mut frames = 0;
while !client.is_finished() && frames < 600 {
harness.run_steps(1);
std::thread::sleep(std::time::Duration::from_millis(5));
frames += 1;
}
assert!(client.is_finished(), "the frame answered the request");
client.join().map_err(|_| "the client thread panicked")??;
harness.run_steps(2);
assert!(harness.query_by_label(notice).is_some(), "the request ran in the frame");
Ok(())
}
}
+1 -1
View File
@@ -170,7 +170,7 @@ pub(crate) fn shape_format(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
Menu::new("Shape Effects").opened_by(&response.response, Trigger::Click).show(ui, |ui, cx| effects_menu(app, ui, cx));
});
});
row.group(RibbonGroup::new("shapeFormat.wordArt", "WordArt Styles", Icon::TextEffects.id().into()), |ui| {
row.group(RibbonGroup::new("shapeFormat.wordArt", "Decorative Text Styles", Icon::TextEffects.id().into()), |ui| {
Stack::new().show(ui, |ui, _| {
let response = Button::new("Text Fill")
.icon(Icon::TextFill.id())