From 58892b8380623dd855807e924b509077b978e608 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 27 Nov 2026 18:57:54 +0000 Subject: [PATCH 1/2] WIP red-app-r4-3: edits before the fixer was stopped (its job scope was capped at 4 GB); not built Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/backstage/tests.rs | 14 +++++++---- crates/ui-egui/src/ribbon/draw.rs | 34 +++++++++++++++++---------- crates/ui-egui/src/ribbon/states.rs | 8 ++++++- crates/ui-egui/src/ribbon/table.rs | 16 +++++++++---- 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/src/backstage/tests.rs b/crates/ui-egui/src/backstage/tests.rs index e4c13a73e..3c40e40ce 100644 --- a/crates/ui-egui/src/backstage/tests.rs +++ b/crates/ui-egui/src/backstage/tests.rs @@ -88,6 +88,12 @@ fn saved_path(files: &ScriptedFiles, extension: &str) -> PathBuf { request.directory.unwrap_or_default().join(request.file_name.unwrap()) } +/// Whether the closing guard's unsaved-changes question is open; the typed prompt carries no command key. +fn close_prompt_open(h: &Harness<'_, SlideApp>) -> bool { + craft::ui::shell::WindowDialogs::of(&h.ctx, &craft::ui::runtime::env::WindowKey::main()) + .with(|host| host.get::().is_some()) +} + fn wait_for_open(h: &mut Harness<'_, SlideApp>) { for _ in 0..500 { h.run_steps(1); @@ -258,7 +264,7 @@ fn close_closes_and_asks_about_unsaved_changes() { h.run_steps(3); navigation(&h).get_by_role_and_label(Role::Button, "Close").click(); h.run_steps(3); - assert!(crate::dialogs::open_keys(&h.ctx).iter().any(|key| key == "close")); + assert!(close_prompt_open(&h)); h.get_by_role_and_label(Role::Button, "Cancel").click(); h.run_steps(3); assert_eq!(h.state().session.documents().len(), 1); @@ -281,13 +287,13 @@ fn host_close_prompt_keeps_the_presentation_when_the_save_fails() { h.run_steps(2); h.key_press_modifiers(Modifiers::COMMAND, Key::W); h.run_steps(3); - assert!(crate::dialogs::open_keys(&h.ctx).iter().any(|key| key == "close")); + assert!(close_prompt_open(&h)); h.get_by_role_and_label(Role::Button, "Save").click(); h.run_steps(4); if fail { assert_eq!(h.state().session.documents().len(), 1); assert!(h.state().session.active().unwrap().is_dirty()); - assert!(crate::dialogs::open_keys(&h.ctx).iter().any(|key| key == "close")); + assert!(close_prompt_open(&h)); assert!(h.query_by_label_contains(reason).is_some()); } else { assert!(h.state().session.documents().is_empty()); @@ -473,7 +479,7 @@ fn start_screen_ignores_document_shortcuts() { h.run_steps(2); h.key_press_modifiers(Modifiers::COMMAND, Key::W); h.run_steps(3); - assert!(crate::dialogs::open_keys(&h.ctx).iter().any(|key| key == "close")); + assert!(close_prompt_open(&h)); } #[test] diff --git a/crates/ui-egui/src/ribbon/draw.rs b/crates/ui-egui/src/ribbon/draw.rs index 6fb5d9651..448ca4d3e 100644 --- a/crates/ui-egui/src/ribbon/draw.rs +++ b/crates/ui-egui/src/ribbon/draw.rs @@ -5,25 +5,35 @@ use craft::ui::contract::{Props as _, Show as _, TooltipSpec}; use deckcraft_engine::ToolKind; use serde_json::json; +/// The Tools group's toggles. +pub(super) fn tools() -> [(Icon, &'static str, ToolKind); 2] { + [ + (Icon::LassoSelect, "Select", ToolKind::Select), + (Icon::Eraser, "Eraser", ToolKind::Ink { mode: "eraser".into(), color: deckcraft_color::Rgba::BLACK, width: 2.0 }), + ] +} + +/// The Pens group's toggles. +pub(super) fn pens() -> [(Icon, &'static str, ToolKind); 5] { + [ + (Icon::Pen, "Black Pen", "pen", deckcraft_color::Rgba::rgb(20, 20, 20), 1.5), + (Icon::Pen, "Red Pen", "pen", deckcraft_color::Rgba::rgb(0xD8, 0x3F, 0x3F), 1.5), + (Icon::Pen, "Blue Pen", "pen", deckcraft_color::Rgba::rgb(0x2E, 0x6F, 0xD8), 1.5), + (Icon::Pencil, "Pencil", "pen", deckcraft_color::Rgba::rgb(90, 90, 90), 1.0), + (Icon::HighlighterPen, "Highlighter", "highlighter", deckcraft_color::Rgba::rgb(255, 230, 0), 10.0), + ] + .map(|(icon, label, mode, color, width)| (icon, label, ToolKind::Ink { mode: mode.into(), color, width })) +} + /// Opens the drawing tools and ink conversion groups. pub(crate) fn draw(app: &mut SlideApp, row: &mut RibbonRow<'_>) { row.group(RibbonGroup::new("tools", "Tools", Icon::LassoSelect.id().into()), |ui| { - for (icon, label, kind) in [ - (Icon::LassoSelect, "Select", ToolKind::Select), - (Icon::Eraser, "Eraser", ToolKind::Ink { mode: "eraser".into(), color: deckcraft_color::Rgba::BLACK, width: 2.0 }), - ] { + for (icon, label, kind) in tools() { ToggleButton::command(states::tool_ref(&kind, false)).label(label).icon(icon.id()).arrangement(Arrangement::Stacked).show(ui); } }); row.group(RibbonGroup::new("pens", "Pens", Icon::Pen.id().into()), |ui| { - for (icon, label, mode, color, width) in [ - (Icon::Pen, "Black Pen", "pen", deckcraft_color::Rgba::rgb(20, 20, 20), 1.5), - (Icon::Pen, "Red Pen", "pen", deckcraft_color::Rgba::rgb(0xD8, 0x3F, 0x3F), 1.5), - (Icon::Pen, "Blue Pen", "pen", deckcraft_color::Rgba::rgb(0x2E, 0x6F, 0xD8), 1.5), - (Icon::Pencil, "Pencil", "pen", deckcraft_color::Rgba::rgb(90, 90, 90), 1.0), - (Icon::HighlighterPen, "Highlighter", "highlighter", deckcraft_color::Rgba::rgb(255, 230, 0), 10.0), - ] { - let kind = ToolKind::Ink { mode: mode.into(), color, width }; + for (icon, label, kind) in pens() { ToggleButton::command(states::tool_ref(&kind, false)).label(label).icon(icon.id()).arrangement(Arrangement::Stacked).show(ui); } }); diff --git a/crates/ui-egui/src/ribbon/states.rs b/crates/ui-egui/src/ribbon/states.rs index 8df131932..73795c533 100644 --- a/crates/ui-egui/src/ribbon/states.rs +++ b/crates/ui-egui/src/ribbon/states.rs @@ -27,8 +27,14 @@ pub(crate) fn publish(app: &mut SlideApp, states: &mut CommandStates) { checked(states, id.into(), format["align"].as_str() == Some(align)); } + // Every tool toggle the ribbon shows states whether it is the current tool, not only the current one. + let current = &app.session.tool.kind; + let draw = super::draw::tools().into_iter().chain(super::draw::pens()).map(|(_, _, kind)| (kind, false)); + for (kind, toggle) in draw.chain(super::table::draw_borders().map(|(_, _, kind)| (kind, true))) { + checked(states, tool_ref(&kind, toggle), &kind == current); + } for toggle in [false, true] { - checked(states, tool_ref(&app.session.tool.kind, toggle), true); + checked(states, tool_ref(current, toggle), true); } for (id, mode) in [ ("view.normal", ViewMode::Normal), diff --git a/crates/ui-egui/src/ribbon/table.rs b/crates/ui-egui/src/ribbon/table.rs index efe3c4611..c62355dcd 100644 --- a/crates/ui-egui/src/ribbon/table.rs +++ b/crates/ui-egui/src/ribbon/table.rs @@ -177,10 +177,8 @@ pub(crate) fn table_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) { }); }); row.group(RibbonGroup::new("table.draw", "Draw Borders", Icon::Pencil.id().into()), |ui| { - use deckcraft_engine::ToolKind; - use deckcraft_engine::tools::{DRAW_TABLE, TABLE_ERASER}; - for (icon, label, preset) in [(Icon::Pencil, "Draw Table", DRAW_TABLE), (Icon::Eraser, "Table Eraser", TABLE_ERASER)] { - ToggleButton::command(states::tool_ref(&ToolKind::Shape { preset: preset.into() }, true)) + for (icon, label, kind) in draw_borders() { + ToggleButton::command(states::tool_ref(&kind, true)) .icon(icon.id()) .label(label) .arrangement(Arrangement::Stacked) @@ -189,6 +187,16 @@ pub(crate) fn table_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) { }); } +/// The Draw Borders group's toggles. +pub(super) fn draw_borders() -> [(Icon, &'static str, deckcraft_engine::ToolKind); 2] { + use deckcraft_engine::ToolKind; + use deckcraft_engine::tools::{DRAW_TABLE, TABLE_ERASER}; + [ + (Icon::Pencil, "Draw Table", ToolKind::Shape { preset: DRAW_TABLE.into() }), + (Icon::Eraser, "Table Eraser", ToolKind::Shape { preset: TABLE_ERASER.into() }), + ] +} + fn apply_shading(app: &mut SlideApp, pick: Option) { let params = pick.map_or_else(|| json!({"none": true}), |color| json!({"color": cref_param(&color)})); let _ = app.run("table.cellFill", params); From 54e7dc9b5819cf6f30210418713afebc5a166d22 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 27 Nov 2026 19:26:17 +0000 Subject: [PATCH 2/2] Every ribbon tool toggle publishes its checked state; the canvas editor yields to the opening overlay; backstage, IME and field-frame tests drive the port's own signals; DIAG prints for the remaining red tests Ribbon: the Draw and Draw Borders toggles state whether their tool is the current one, so an unselected toggle reads unchecked instead of having no state. Canvas text editor: blocked while a presentation is opening, so it takes focus back when the overlay closes. Tests: the close prompt is found as the typed UnsavedChangesDialog (it carries no command key); host Save As lets a frame pass after the host open; Find and Replace opens through app.find; the Japanese conversion waits for the IME to be on before composing. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/backstage/tests.rs | 2 ++ crates/ui-egui/src/canvas/picture.rs | 7 +++++++ crates/ui-egui/src/canvas/ruler_tests.rs | 5 +++++ crates/ui-egui/src/canvas/text_host.rs | 4 ++-- crates/ui-egui/src/dialogs/photo_album.rs | 12 ++++++++++-- crates/ui-egui/src/dialogs/preferences.rs | 5 ++++- crates/ui-egui/src/eyedropper.rs | 7 +++++++ crates/ui-egui/src/field_frame_tests.rs | 2 +- crates/ui-egui/src/ime_tests.rs | 4 +++- crates/ui-egui/src/panels/pattern_fill_tests.rs | 5 +++++ 10 files changed, 46 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/backstage/tests.rs b/crates/ui-egui/src/backstage/tests.rs index 3c40e40ce..b789a12f0 100644 --- a/crates/ui-egui/src/backstage/tests.rs +++ b/crates/ui-egui/src/backstage/tests.rs @@ -312,6 +312,8 @@ fn host_save_as_under_the_same_name_returns_to_the_slide() { h.state_mut().start_for_host().unwrap(); let deck = deckcraft_engine::cmd::file::save_bytes(&Session::with_new().doc().unwrap().doc, "pptx").unwrap(); h.state_mut().open_from_host(Some("deck.pptx"), &deck); + // The page's file arrives between frames: the start screen gives way before File opens again. + h.run_steps(1); h.state_mut().run("app.backstage", json!({"page": "saveAs"})).unwrap(); h.run_steps(3); let original = h.state().backstage.as_ref().unwrap().instance.clone(); diff --git a/crates/ui-egui/src/canvas/picture.rs b/crates/ui-egui/src/canvas/picture.rs index d02697e37..4d55d4e15 100644 --- a/crates/ui-egui/src/canvas/picture.rs +++ b/crates/ui-egui/src/canvas/picture.rs @@ -180,6 +180,13 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpace) { }; let (mut image, mut drawn) = render(region); picture.canvas_renders += 1; + eprintln!( + "DIAG the_picture_renders_again_only_when_its_revision_changes: render {} pass {} size {size:?} scale {scale} region {region:?} anim {} edit {editing_text:?} gifs {}", + picture.canvas_renders, + ui.ctx().current_pass_index(), + anim_key(anim), + crate::media::gif_key(&gifs) + ); // Text can spill beyond its box. Store the expanded region's revision so the next // pass reuses it, rather than repeating the first, too-small render. let expanded = region_for(source.estimate.union(source.drawn).union(drawn)); diff --git a/crates/ui-egui/src/canvas/ruler_tests.rs b/crates/ui-egui/src/canvas/ruler_tests.rs index 53f258ef1..718618061 100644 --- a/crates/ui-egui/src/canvas/ruler_tests.rs +++ b/crates/ui-egui/src/canvas/ruler_tests.rs @@ -18,14 +18,19 @@ fn drag_with_modifiers(h: &mut Harness<'_, SlideApp>, a: Pos2, b: Pos2, modifier h.event(egui::Event::ModifiersChanged(modifiers)); h.hover_at(a); h.run_steps(1); + let editing = |h: &Harness<'_, SlideApp>| h.state().session.active().unwrap().selection.text.is_some(); + eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: before press at {a:?} editing {}", editing(h)); h.event(egui::Event::PointerButton { pos: a, button: PointerButton::Primary, pressed: true, modifiers }); h.run_steps(1); + eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: after press editing {} status {:?}", editing(h), h.state().status); for i in 1..=8 { h.event(egui::Event::PointerMoved(a + (b - a) * (i as f32 / 8.0))); h.run_steps(1); } + eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: after moves editing {}", editing(h)); h.event(egui::Event::PointerButton { pos: b, button: PointerButton::Primary, pressed: false, modifiers }); h.run_steps(2); + eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: after release editing {} status {:?}", editing(h), h.state().status); h.event(egui::Event::ModifiersChanged(Modifiers::NONE)); } diff --git a/crates/ui-egui/src/canvas/text_host.rs b/crates/ui-egui/src/canvas/text_host.rs index 0da89c65c..267bf70fe 100644 --- a/crates/ui-egui/src/canvas/text_host.rs +++ b/crates/ui-egui/src/canvas/text_host.rs @@ -310,12 +310,12 @@ fn document_bounds(points: [deckcraft_geom::Point; 4], transform: Affine) -> Rec })) } -/// Hosts the edited shape or cell while no dialog, palette, File view or other text field owns input. +/// Hosts the edited shape or cell while no dialog, palette, File view, opening overlay or other text field owns input. /// The editor takes keyboard focus in the first pass it is shown, and again after a pass without it. pub(crate) fn show_editor(app: &mut crate::SlideApp, ui: &mut Ui, space: &CanvasSpace) -> Option { let shown = egui::Id::new("slide-text-editor-shown"); let hosted = ui.data(|data| data.get_temp::(shown)); - let blocked = crate::dialogs::modal_open(ui.ctx()) || app.palette_open || app.backstage_open(); + let blocked = crate::dialogs::modal_open(ui.ctx()) || app.palette_open || app.backstage_open() || app.opening.is_some(); let target = app.session.active().and_then(|state| { let target = state.selection.text.as_ref().filter(|target| !target.notes)?; Some((state.uid, target.clone())) diff --git a/crates/ui-egui/src/dialogs/photo_album.rs b/crates/ui-egui/src/dialogs/photo_album.rs index f6a44e098..2d95b2e76 100644 --- a/crates/ui-egui/src/dialogs/photo_album.rs +++ b/crates/ui-egui/src/dialogs/photo_album.rs @@ -147,7 +147,13 @@ pub(crate) fn open(app: &SlideApp, ctx: &egui::Context, params: &Value) -> Hoste let mut text = fields.text("boxText").unwrap_or("Text Box").to_string(); Row::new().show(ui, |ui, _| { let can_pick = Host::of(ui).files().can_pick(); - if clicked(&Button::new("Add Pictures…").enabled(can_pick).tooltip("Pass pictures to insert.photoAlbum").show(ui)) { + let add = Button::new("Add Pictures…").enabled(can_pick).tooltip("Pass pictures to insert.photoAlbum").show(ui); + eprintln!( + "DIAG create_inserts_the_album_in_one_step: pass {} can_pick {can_pick} clicked {}", + ui.ctx().current_pass_index(), + clicked(&add) + ); + if clicked(&add) { context.request_action("addPictures"); } let draft = album_check_item_count(list.len().saturating_add(1)).and_then(|()| album_check_text(&text).map(str::to_string)); @@ -309,7 +315,9 @@ fn append_picture(dialog: &mut HostedParamDialog, name: &str, bytes: &[u8], tota /// Consumes each action and file answer once, so a second pass has no input to replay. pub(crate) fn each_pass(app: &mut SlideApp, _ctx: &egui::Context, dialog: &mut HostedParamDialog) { let files = app.host.files(); - for action in dialog.take_actions() { + let actions = dialog.take_actions(); + eprintln!("DIAG create_inserts_the_album_in_one_step: each_pass actions {actions:?} pick {:?}", app.dialogs.album_pick.is_some()); + for action in actions { if action == "addPictures" && app.dialogs.album_pick.is_none() { if files.can_pick() { app.dialogs.album_pick = Some(files.pick(PickRequest::open_many("picture"))); diff --git a/crates/ui-egui/src/dialogs/preferences.rs b/crates/ui-egui/src/dialogs/preferences.rs index 3f3a5a6b0..235223e82 100644 --- a/crates/ui-egui/src/dialogs/preferences.rs +++ b/crates/ui-egui/src/dialogs/preferences.rs @@ -147,7 +147,9 @@ impl AutoCorrectForm { Row::new().show(ui, |ui, _| { TextField::new(Word::plain("Replace"), Bind::bound(&mut *from)).show(ui); TextField::new(Word::plain("With"), Bind::bound(&mut *to)).show(ui); - if Button::new(Word::plain("Add")).enabled(!from.trim().is_empty()).show(ui).clicks > 0 { + let add = Button::new(Word::plain("Add")).enabled(!from.trim().is_empty()).show(ui).clicks; + eprintln!("DIAG autocorrect_list_edits_survive_nested_and_preferences_cancel: from {from:?} add clicks {add}"); + if add > 0 { actions.push(json!({ "add": [from.trim(), to] })); from.clear(); to.clear(); @@ -414,6 +416,7 @@ pub(crate) fn open_autocorrect(app: &mut SlideApp, ctx: &Context, host: &mut Dia /// Applies live settings and restores opening values for every external or window Cancel path. pub(crate) fn pump(app: &mut SlideApp, _ctx: &Context, host: &mut DialogHost) { for action in host.take_actions(dialog_id("preferences")) { + eprintln!("DIAG autocorrect_list_edits_survive_nested_and_preferences_cancel: action {action}"); match app.run("text.autocorrect", action) { Ok(reply) => { if let Some(form) = host.get_mut::().and_then(|dialog| dialog.autocorrect.as_mut()) { diff --git a/crates/ui-egui/src/eyedropper.rs b/crates/ui-egui/src/eyedropper.rs index 30fe94a71..14beee1f6 100644 --- a/crates/ui-egui/src/eyedropper.rs +++ b/crates/ui-egui/src/eyedropper.rs @@ -34,6 +34,7 @@ pub enum Target { /// Arms one pick-mode tool over a snapshot of the active slide. pub fn arm(app: &mut SlideApp, target: Target) { let Some(d) = app.session.active() else { return }; + eprintln!("DIAG set_transparent_color_takes_the_colour_clicked_in_the_picture: arm target {:?}", d.selection.target); if d.selection.target != deckcraft_engine::Target::Slides { app.set_status("The Eyedropper takes colours from a slide"); return; @@ -68,6 +69,12 @@ pub fn after_pass(app: &mut SlideApp, ctx: &Context, mut tool: DropperTool<'stat // A press outside the canvas disarms, as production did. let outside = !armed.fresh && ctx.input(|i| i.pointer.primary_pressed() && i.pointer.hover_pos().is_some_and(|pos| !canvas_rect.contains(pos))); + eprintln!( + "DIAG set_transparent_color_takes_the_colour_clicked_in_the_picture: after_pass pass {} fresh {} outside {outside} ended {}", + ctx.current_pass_index(), + armed.fresh, + tool.ended() + ); armed.fresh = false; if outside { ctx.request_repaint(); diff --git a/crates/ui-egui/src/field_frame_tests.rs b/crates/ui-egui/src/field_frame_tests.rs index 0d67f4c59..d7b289d5a 100644 --- a/crates/ui-egui/src/field_frame_tests.rs +++ b/crates/ui-egui/src/field_frame_tests.rs @@ -96,7 +96,7 @@ fn only_a_painted_fill_or_outline_stands_apart() { #[test] fn light_text_fields_show_in_dialogs_panes_and_the_ribbon() { let mut h = harness(); - h.state_mut().open_dialog("find-replace", json!({})); + h.state_mut().run("app.find", json!({})).unwrap(); h.run_steps(3); let tokens = craft::ui::runtime::env::Env::of_root(&h.ctx).tokens.clone(); let raised = color(tokens.color.surface.raised); diff --git a/crates/ui-egui/src/ime_tests.rs b/crates/ui-egui/src/ime_tests.rs index 025b539de..91632235e 100644 --- a/crates/ui-egui/src/ime_tests.rs +++ b/crates/ui-egui/src/ime_tests.rs @@ -66,7 +66,9 @@ fn japanese_conversion_shows_the_active_part() { let mut h = harness(Session::with_new()); let title = h.state().session.active().unwrap().doc.slides[0].shapes[0].id.0; h.state_mut().run("text.edit", json!({"id": title})).unwrap(); - h.run_steps(1); + // The platform composes only after a frame's output turned the input method on. + h.run_steps(2); + assert!(h.output().platform_output.ime.is_some()); let undo = undo_len(h.state()); let converted = "日本ご"; h.event(Event::Ime(ImeEvent::Preedit { text: converted.into(), active_range_chars: Some(2..3) })); diff --git a/crates/ui-egui/src/panels/pattern_fill_tests.rs b/crates/ui-egui/src/panels/pattern_fill_tests.rs index cc8970c97..e0cd92906 100644 --- a/crates/ui-egui/src/panels/pattern_fill_tests.rs +++ b/crates/ui-egui/src/panels/pattern_fill_tests.rs @@ -55,6 +55,11 @@ fn pick_hex(h: &mut Harness<'_, SlideApp>, button: &str, hex: &str) { h.run_steps(2); } h.run_steps(2); + eprintln!( + "DIAG shape_pattern_fill_keeps_preset_and_system_colors: opener {button} at {opener:?} hex fields {} openers {}", + h.query_all_by_label("More Colors…").count(), + h.query_all_by_role_and_label(Role::Button, button).count() + ); h.get_by_role_and_label(Role::TextInput, "More Colors…").click(); h.run_steps(1); for pressed in [true, false] {