From 11362ac715857a6721873ffbff08ad2ba4a2d938 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:13:21 -0500 Subject: [PATCH 1/9] docs: path map for the #1433 module split; drop CLAUDE.md references to the gitignored plan/ directory --- CLAUDE.md | 6 ++-- docs/module-split-map.md | 67 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 docs/module-split-map.md diff --git a/CLAUDE.md b/CLAUDE.md index 67853ff06..334385580 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,7 @@ Read [AGENTS.md](AGENTS.md) first: its rules (asset policy, clean room, never cr win over anything here. ## Start every session -1. Read `plan/STATUS.md`, then the current milestone in `plan/execution-plan.md`. +1. Read `ROADMAP.md` and `docs/roadmap.md`. 2. Read `../../craftrules/AGENTS.md` and the standards it lists for your task. 3. Run `cargo xtask ci` before you change anything, so you know the tree is green. @@ -13,5 +13,5 @@ win over anything here. - Look at UI changes: `deckcraft --sample --control 7990` + `ui.screenshot`, or `deckcraft-cli render`. - Commit after each landed arc (`M.: what`) and push to `origin main`. -- Keep `ROADMAP.md`, the progress docs in `docs/` (AGENTS.md §7) and `plan/STATUS.md` current. -- Don't ask the user questions; record genuinely-theirs decisions in `plan/STATUS.md`. +- Keep `ROADMAP.md` and the progress docs in `docs/` (AGENTS.md §7) current. +- Don't ask the user questions; record genuinely-theirs decisions in `ROADMAP.md`. diff --git a/docs/module-split-map.md b/docs/module-split-map.md new file mode 100644 index 000000000..fc1ba1d38 --- /dev/null +++ b/docs/module-split-map.md @@ -0,0 +1,67 @@ +# Where things moved in #1433 + +[#1433](https://github.com/storytold/deckcraft/pull/1433) (merge `ee875abf`) split the largest +source files into modules. Nothing changed in behaviour, but a branch that edits an old file now +conflicts with it. This note says which new modules received each old file's code, so you can place +your hunks by hand after `git merge origin/main`. Paths are relative to `crates/` unless noted; each +old file stays as the parent module and keeps its re-exports, so import paths are unchanged. + +To find the exact new home of one function: `git grep -n 'fn name' origin/main -- crates` (or +`git log -S'fn name' --oneline origin/main -- crates`). + +## Plain renames (content unchanged) + +| Old | New | +|---|---| +| `engine/src/cmd/mod.rs` | `engine/src/cmd.rs` | +| `opus/src/celt/mod.rs`, `opus/src/silk/mod.rs` | `opus/src/celt.rs`, `opus/src/silk.rs` | +| `pptx/src/read/mod.rs`, `pptx/src/write/mod.rs` | `pptx/src/read.rs`, `pptx/src/write.rs` | +| `ui-egui/src/backstage_tests.rs` | `ui-egui/src/backstage/tests.rs` | +| `ui-egui/src/selpane_tests.rs`, `sorter_tests.rs` | `ui-egui/src/panels/selpane/ui_tests.rs`, `ui-egui/src/sorter/ui_tests.rs` | + +`ui-egui/src` files moved into a folder: `guides_tests`, `preview`, `ruler_tests`, `squiggles` → +`canvas/`; `columns_dialog_tests`, `credits`, `font_dialog_tests`, `paragraph_dialog_tests`, +`photo_album_tests`, `preferences_tests`, `size_position_tests`, `spelling_tests`, +`theme_colors_tests`, `theme_fonts_tests`, `updates_ui` → `dialogs/`; `animtimeline`, +`background_tests`, `fillui`, `notes`, `pattern_fill_tests`, `smartart_tests`, `thesaurus_tests`, +`thumbs` → `panels/`; `align_tests`, `drawtable_tests`, `effects_tests`, `icons_popup_tests`, +`inktoshape_tests`, `master_layout_tests`, `qat` → `ribbon/`. + +## Split files (old file → new modules, all under the old file's folder) + +Each old file now holds only the module list and shared items. + +| Old file | New modules | +|---|---| +| `apps/deckcraft/src/control_server.rs` | `control_server/tests.rs` (its tests) | +| `engine/src/cmd/design.rs` | `design/{colors, master_view, slide_background, slide_setup, browse_theme_tests, tests}.rs` | +| `engine/src/cmd/format.rs` | `format/{font, paragraph, painter, ruler, text_effects}.rs` | +| `engine/src/cmd/insert.rs` | `insert/{album, chart, links, picture, text_fields, icon_and_picture_tests}.rs` | +| `engine/src/cmd/shape.rs` | `shape/{appearance, freeform, picture, size}.rs` | +| `engine/src/cmd/smartart.rs` | `smartart/{diagrams, edit, layout, nodes, paint}.rs` | +| `engine/src/cmd/text.rs` | `text/{autocorrect, caret, editing, formatting, ime, layout}.rs` | +| `engine/src/tools.rs` | `tools/{click, drag, geometry, hit, pointer}.rs` | +| `fonts/src/lib.rs`, `format/src/lib.rs` | `src/tests.rs` (their tests) | +| `geom/src/preset.rs` | `preset/{build, builder, catalog, shapes, tests}.rs` | +| `media/src/player.rs` | `player/tests.rs` | +| `render/src/lib.rs` | `src/{geometry, opts, raster, renderer, slide, stroke, text_draw}.rs` | +| `text/src/lib.rs` | `src/{autonum, breaking, layout, run, shape, symbol}.rs` | +| `ui-egui/src/lib.rs` | `src/{app, state, services, clock, ime_hooks, tests}.rs`; the `SlideApp` impl is in `app.rs` and `app/{clipboard, commands, control, files, frame, ime, input, keys, playback}.rs` | +| `ui-egui/src/panes.rs` (deleted) | `panels.rs` and `panels/{animation, background, comments, designer, format_shape, smartart, thesaurus}.rs` (format-shape pane → `format_shape.rs`, slide background → `background.rs`, animation pane → `animation.rs`, comments and revisions → `comments.rs`) | +| `ui-egui/src/backstage.rs` | `backstage/{files, info, print}.rs` | +| `ui-egui/src/canvas.rs` | `canvas/{context_menu, guides, ime, input, media, overlays, rulers, scroll, tests}.rs` | +| `ui-egui/src/capture.rs` | `capture/tests.rs` | +| `ui-egui/src/dialogs.rs` | `dialogs/{about, alt_text, body, columns, date_time, equation, export, find, font, grid_options, hyperlink, language, paragraph, photo_album, preferences, size_position, slide_size, tabs, theme_colors, theme_fonts, trim, zoom, tests}.rs`; dialogs not listed (for example most bodies) are in `body.rs` | +| `ui-egui/src/icons.rs` | `icons/{draw, geometry}.rs` | +| `ui-egui/src/ribbon.rs` | `ribbon/{animations, arrange, chart, design, draw, galleries, home, insert, masters, picture_format, playback, review, shape_format, slide_show, smartart, table, title_bar, transitions, view}.rs`; one file per ribbon tab, plus `galleries.rs` for the shared gallery popups | +| `ui-egui/src/show.rs` | `show/{keys, media, presenter, render, ui, zoom, tests}.rs` | + +Also touched: `engine/src/file_access.rs` (16 lines), `docs/file-format-parity.md`, `docs/gaps.md` +and `packaging/common.sh` (one line each, path references). + +## Carrying a branch forward + +1. `git merge origin/main` (never rebase) and let git list the conflicting old files. +2. For each conflicting hunk, find the new module above, apply the hunk there by hand, and keep + the old file's side only for module declarations. +3. Run `cargo xtask ci`. From 1da4e33490aefdeae565bbb2ac63fdc0b162d0d9 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Tue, 27 Oct 2026 20:53:24 -0500 Subject: [PATCH 2/9] docs: qualify what the old files keep, list style.rs, say where panes.rs hunks go --- docs/module-split-map.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/module-split-map.md b/docs/module-split-map.md index fc1ba1d38..7ee0f7ce1 100644 --- a/docs/module-split-map.md +++ b/docs/module-split-map.md @@ -29,7 +29,8 @@ To find the exact new home of one function: `git grep -n 'fn name' origin/main - ## Split files (old file → new modules, all under the old file's folder) -Each old file now holds only the module list and shared items. +Each old file keeps its module declarations and any code that was not moved; several rows move +only the tests. | Old file | New modules | |---|---| @@ -45,7 +46,7 @@ Each old file now holds only the module list and shared items. | `geom/src/preset.rs` | `preset/{build, builder, catalog, shapes, tests}.rs` | | `media/src/player.rs` | `player/tests.rs` | | `render/src/lib.rs` | `src/{geometry, opts, raster, renderer, slide, stroke, text_draw}.rs` | -| `text/src/lib.rs` | `src/{autonum, breaking, layout, run, shape, symbol}.rs` | +| `text/src/lib.rs` | `src/{autonum, breaking, layout, run, shape, style, symbol}.rs` | | `ui-egui/src/lib.rs` | `src/{app, state, services, clock, ime_hooks, tests}.rs`; the `SlideApp` impl is in `app.rs` and `app/{clipboard, commands, control, files, frame, ime, input, keys, playback}.rs` | | `ui-egui/src/panes.rs` (deleted) | `panels.rs` and `panels/{animation, background, comments, designer, format_shape, smartart, thesaurus}.rs` (format-shape pane → `format_shape.rs`, slide background → `background.rs`, animation pane → `animation.rs`, comments and revisions → `comments.rs`) | | `ui-egui/src/backstage.rs` | `backstage/{files, info, print}.rs` | @@ -63,5 +64,7 @@ and `packaging/common.sh` (one line each, path references). 1. `git merge origin/main` (never rebase) and let git list the conflicting old files. 2. For each conflicting hunk, find the new module above, apply the hunk there by hand, and keep - the old file's side only for module declarations. + the old file's side only for module declarations. `ui-egui/src/panes.rs` is deleted: do not + restore it, move its hunks into `panels.rs` or the listed `panels/` modules (the crate exposes + `panels` and aliases it as `panes`). 3. Run `cargo xtask ci`. From d403e047cf88200a6abd7424ba2daba30ca61949 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:22:02 -0500 Subject: [PATCH 3/9] docs: preserve optional local session context --- CLAUDE.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 1f8193103..88256c23a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,9 +8,10 @@ New workspace crates must include `[lints] workspace = true` in `Cargo.toml` to before modules or other crate items; crate-level `//!` documentation may precede them. ## Start every session -1. Read `ROADMAP.md` and `docs/roadmap.md`. -2. Read `../../craftrules/AGENTS.md` and the standards it lists for your task. -3. Run `cargo xtask ci` before you change anything, so you know the tree is green. +1. Read `plan/STATUS.md` when it exists. +2. Read `ROADMAP.md` and `docs/roadmap.md`. +3. Read `../../craftrules/AGENTS.md` and the standards it lists for your task. +4. Run `cargo xtask ci` before you change anything, so you know the tree is green. ## Habits - Every user-visible action is a command with tests (`crates/engine/src/cmd/*`). From 5529c695bf04b6149019c0964a2cd72fe1164151 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:32:09 -0500 Subject: [PATCH 4/9] docs: complete module split path mappings --- docs/module-split-map.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/module-split-map.md b/docs/module-split-map.md index 7ee0f7ce1..e56464c52 100644 --- a/docs/module-split-map.md +++ b/docs/module-split-map.md @@ -16,8 +16,9 @@ To find the exact new home of one function: `git grep -n 'fn name' origin/main - | `engine/src/cmd/mod.rs` | `engine/src/cmd.rs` | | `opus/src/celt/mod.rs`, `opus/src/silk/mod.rs` | `opus/src/celt.rs`, `opus/src/silk.rs` | | `pptx/src/read/mod.rs`, `pptx/src/write/mod.rs` | `pptx/src/read.rs`, `pptx/src/write.rs` | +| `ui-egui/src/selpane.rs` | `ui-egui/src/panels/selpane.rs` | | `ui-egui/src/backstage_tests.rs` | `ui-egui/src/backstage/tests.rs` | -| `ui-egui/src/selpane_tests.rs`, `sorter_tests.rs` | `ui-egui/src/panels/selpane/ui_tests.rs`, `ui-egui/src/sorter/ui_tests.rs` | +| `ui-egui/src/selpane_tests.rs`, `ui-egui/src/sorter_tests.rs` | `ui-egui/src/panels/selpane/ui_tests.rs`, `ui-egui/src/sorter/ui_tests.rs` | `ui-egui/src` files moved into a folder: `guides_tests`, `preview`, `ruler_tests`, `squiggles` → `canvas/`; `columns_dialog_tests`, `credits`, `font_dialog_tests`, `paragraph_dialog_tests`, From a1217166292752a75026c0d476038044f293076c Mon Sep 17 00:00:00 2001 From: Zach Berry <1112351+zberry@users.noreply.github.com> Date: Sun, 18 Oct 2026 23:31:04 -0500 Subject: [PATCH 5/9] [CC2] Style commands given none of their optional keys are refused shape.line, shape.effects, picture.adjust, format.paragraph and format.margins answered changed for a call that set nothing. They now say what to pass. shape.fill already refused; the toggles (bold, bullets) and geometry commands keep their meaningful defaults. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd.rs | 15 +++++++++ crates/engine/src/cmd/format.rs | 6 ++-- crates/engine/src/cmd/format/paragraph.rs | 25 ++++++++++++++- crates/engine/src/cmd/shape.rs | 8 ++--- crates/engine/src/cmd/shape/appearance.rs | 12 ++++++- crates/engine/src/cmd/shape/picture.rs | 3 +- crates/engine/src/tests.rs | 38 +++++++++++++++++++++++ 7 files changed, 97 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 6f20c4143..04e63f5bf 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -297,6 +297,16 @@ pub fn parse_params(doc: &str) -> std::result::Result>, String> { /// growing would duplicate ids (#407). pub(crate) const NO_ID_SPACE: &str = "the presentation has used every object id and can hold no more"; +/// A style command whose keys are all optional is refused when it is given none of them, rather +/// than answering `changed` for a call that sets nothing. +pub(crate) fn require_any(p: &Value, cmd: &str, keys: &[&str]) -> Result<()> { + if keys.iter().any(|k| p.get(*k).is_some_and(|v| !v.is_null())) { + return Ok(()); + } + let (last, rest) = keys.split_last().map_or(("", &[][..]), |(l, r)| (*l, r)); + Err(bad(cmd, format!("`{cmd}` was given nothing to set: pass {} or {last}", rest.join(", ")))) +} + pub(crate) fn bad(cmd: &str, msg: impl Into) -> EngineError { EngineError::BadParams { cmd: cmd.into(), msg: msg.into() } } @@ -534,6 +544,10 @@ pub(crate) fn current_names(doc: &deckcraft_model::Presentation, sel: &crate::Se /// A name ending in `?` is optional. Text after `→` is the result, not an input. pub fn needs_arguments(params: &str) -> bool { let input = params.split('→').next().unwrap_or(params); + // Every key optional, but the command refuses a call that gives none of them. + if input.contains("(at least one key)") { + return true; + } let Some(start) = input.find('{') else { return false }; let inside = input.get(start + 1..).unwrap_or(""); let inside = inside.split('}').next().unwrap_or(inside); @@ -657,6 +671,7 @@ mod tests { assert!(needs_arguments("{axis: horizontal|vertical, ids?}")); assert!(needs_arguments("{percent}")); assert!(!needs_arguments("{}")); + assert!(needs_arguments("{left?: pt, top?: pt} (at least one key)")); assert!(!needs_arguments("{on?: bool}")); assert!(!needs_arguments("{theme?: name, size?: [w,h] pt, blank?: bool}")); assert!(!needs_arguments("{uid?: one entry, else all}")); diff --git a/crates/engine/src/cmd/format.rs b/crates/engine/src/cmd/format.rs index 4e273dc1c..d96739a05 100644 --- a/crates/engine/src/cmd/format.rs +++ b/crates/engine/src/cmd/format.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use super::text::{format_body, format_para, format_run, format_run_levels}; use super::{ CommandSpec, always, bad, base64_decode, bool_or, bool_param, cmd, color_param, edit_shapes, f64_or, f64_param, has_doc, has_text, - has_text_or_shapes, ids_param, ok, str_param, + has_text_or_shapes, ids_param, ok, require_any, str_param, }; use crate::{Result, Session}; use deckcraft_model::ShapeId; @@ -199,7 +199,7 @@ pub fn specs() -> Vec { "Paragraph…", ["Format"], None, - "{align?, indentLeft?: pt, indentFirst?: pt (negative = hanging), spaceBefore?: pt, spaceAfter?: pt, lineSpacing?: lines}", + "{align?, indentLeft?: pt, indentFirst?: pt (negative = hanging), spaceBefore?: pt, spaceAfter?: pt, lineSpacing?: lines, lineSpacingPt?: pt} (at least one key)", has_text_or_shapes, paragraph ), @@ -248,7 +248,7 @@ pub fn specs() -> Vec { "Text Box Margins", ["Format Shape", "Text Box"], None, - "{left?: pt, top?: pt, right?: pt, bottom?: pt}", + "{left?: pt, top?: pt, right?: pt, bottom?: pt} (at least one key)", has_text_or_shapes, margins ), diff --git a/crates/engine/src/cmd/format/paragraph.rs b/crates/engine/src/cmd/format/paragraph.rs index f036068f6..c508c3573 100644 --- a/crates/engine/src/cmd/format/paragraph.rs +++ b/crates/engine/src/cmd/format/paragraph.rs @@ -1,6 +1,6 @@ use super::{ Align, Anchor, AutoFit, Bullet, Result, Session, Spacing, TextDir, Value, bad, bool_or, color_param, current_para, f64_or, f64_param, - format_body, format_para, json, ok, on_param, resolve, str_param, + format_body, format_para, json, ok, on_param, require_any, resolve, str_param, }; pub(super) fn align_to(s: &mut Session, a: Align) -> Result { @@ -117,6 +117,28 @@ pub(super) fn line_spacing(s: &mut Session, p: &Value) -> Result { } pub(super) fn paragraph(s: &mut Session, p: &Value) -> Result { + if let Err(e) = + require_any(p, "format.paragraph", &["align", "indentLeft", "indentFirst", "spaceBefore", "spaceAfter", "lineSpacing", "lineSpacingPt"]) + { + // The Paragraph dialog's other fields are format.paragraphDialog's; say so instead of + // calling the call empty. + if let Some(k) = + ["special", "specialBy", "indentRight", "spaceBeforeKind", "spaceAfterKind"].into_iter().find(|k| p.get(*k).is_some_and(|v| !v.is_null())) + { + // The dialog applies a kind or `specialBy` only with the value it qualifies. + let with = match k { + "spaceBeforeKind" => " together with `spaceBefore`", + "spaceAfterKind" => " together with `spaceAfter`", + "specialBy" => " together with `special`", + _ => "", + }; + return Err(bad( + "format.paragraph", + format!("`{k}` is a field of format.paragraphDialog (the whole Paragraph dialog), given{with}; format.paragraph does not read it"), + )); + } + return Err(e); + } let a = str_param(p, "align").map(|a| match a { "center" => Align::Center, "right" => Align::Right, @@ -405,6 +427,7 @@ pub(super) fn wrap(s: &mut Session, p: &Value) -> Result { } pub(super) fn margins(s: &mut Session, p: &Value) -> Result { + require_any(p, "format.margins", &["left", "top", "right", "bottom"])?; let (l, t, r, b) = (f64_param(p, "left"), f64_param(p, "top"), f64_param(p, "right"), f64_param(p, "bottom")); format_body(s, &move |bp| { if l.is_some() { diff --git a/crates/engine/src/cmd/shape.rs b/crates/engine/src/cmd/shape.rs index 9565cdf7b..1d58dd254 100644 --- a/crates/engine/src/cmd/shape.rs +++ b/crates/engine/src/cmd/shape.rs @@ -10,7 +10,7 @@ use serde_json::{Value, json}; use super::{ CommandSpec, NO_ID_SPACE, bad, bool_or, bool_param, cmd, color_param, color_value, edit_geometry, edit_shapes, f64_param, has_selection, - has_slide, id_param, ok, str_param, targets, usize_param, with_param, xfrm_of, + has_slide, id_param, ok, require_any, str_param, targets, usize_param, with_param, xfrm_of, }; use crate::{Result, Session}; @@ -112,7 +112,7 @@ pub fn specs() -> Vec { "Shape Outline", ["Shape Format", "Shape Styles"], None, - "{color?, none?, width?: pt, dash?: solid|dot|dash|lgDash|dashDot|sysDot|sysDash, cap?: flat|round|square, join?: round|bevel|miter, compound?: single|double|thickThin|thinThick|triple, head?: none|triangle|stealth|diamond|oval|arrow, tail?, headSize?: sm|med|lg, tailSize?, reset?, ids?}; a group also formats its members", + "{color?, none?, width?: pt, dash?: solid|dot|dash|lgDash|dashDot|sysDot|sysDash, cap?: flat|round|square, join?: round|bevel|miter, compound?: single|double|thickThin|thinThick|triple, head?: none|triangle|stealth|diamond|oval|arrow, tail?, headSize?: sm|med|lg, tailSize?, reset?, ids?} (at least one key); a group also formats its members", has_selection, line ), @@ -121,7 +121,7 @@ pub fn specs() -> Vec { "Shape Effects", ["Shape Format", "Shape Styles"], None, - "{shadow?: none|outer|inner|perspective|{color, blur, dist, dir}, glow?: none|{color, radius}, softEdges?: pt, reflection?: none|tight|half|full, bevel?: none|circle|…, threeD?: {camera?: preset, rotX?, rotY?, rotZ?: deg, z?: pt, bevelTop?, bevelBottom?: none|circle|…, bevelTopW?, bevelTopH?, bevelBottomW?, bevelBottomH?, depth?, contour?: pt, material?, lighting?, reset?: true}, shadowProps?: {color?, transparency?: 0..1, size?: 0.01..2 (1 = 100%), blur?: pt, dist?: pt, dir?: deg}, glowProps?: {color?, transparency?, radius?: pt}, reflectionProps?: {transparency?, size?: 0..1, dist?: pt, blur?: pt}, reset?, ids?} (the *Props keys adjust the current effect, adding a default one when there is none)", + "{shadow?: none|outer|inner|perspective|{color, blur, dist, dir}, glow?: none|{color, radius}, softEdges?: pt, reflection?: none|tight|half|full, bevel?: none|circle|…, threeD?: {camera?: preset, rotX?, rotY?, rotZ?: deg, z?: pt, bevelTop?, bevelBottom?: none|circle|…, bevelTopW?, bevelTopH?, bevelBottomW?, bevelBottomH?, depth?, contour?: pt, material?, lighting?, reset?: true}, shadowProps?: {color?, transparency?: 0..1, size?: 0.01..2 (1 = 100%), blur?: pt, dist?: pt, dir?: deg}, glowProps?: {color?, transparency?, radius?: pt}, reflectionProps?: {transparency?, size?: 0..1, dist?: pt, blur?: pt}, reset?, ids?} (at least one key) (the *Props keys adjust the current effect, adding a default one when there is none)", has_selection, effects ), @@ -161,7 +161,7 @@ pub fn specs() -> Vec { "Corrections", ["Picture Format", "Adjust"], None, - "{brightness?: -1..1, contrast?: -1..1, saturation?: 0..4, grayscale?: bool, transparency?: 0..1, reset?: bool, ids?}", + "{brightness?: -1..1, contrast?: -1..1, saturation?: 0..4, grayscale?: bool, transparency?: 0..1, reset?: bool, ids?} (at least one key)", has_selection, picture_adjust ), diff --git a/crates/engine/src/cmd/shape/appearance.rs b/crates/engine/src/cmd/shape/appearance.rs index 24bfbabf8..0200ea10c 100644 --- a/crates/engine/src/cmd/shape/appearance.rs +++ b/crates/engine/src/cmd/shape/appearance.rs @@ -1,7 +1,7 @@ use super::{ ColorRef, ColorTransform, Dash, Effects, Fill, Geom, Glow, Gradient, GradientShape, GradientStop, Line, LineEnd, PictureFill, PictureMode, Reflection, Result, Rgba, SchemeSlot, Session, Shadow, ShapeStyle, Value, apply_fill, bad, bool_or, color_param, color_value, edit_geometry, - edit_shapes, f64_param, inherited_fills, json, requested_fill, str_param, targets, usize_param, + edit_shapes, f64_param, inherited_fills, json, requested_fill, require_any, str_param, targets, usize_param, }; pub(super) fn adjust(s: &mut Session, p: &Value) -> Result { @@ -236,6 +236,7 @@ fn line_end(v: &str) -> Option { } pub(super) fn line(s: &mut Session, p: &Value) -> Result { + require_any(p, "shape.line", &["color", "none", "width", "dash", "cap", "join", "compound", "head", "tail", "headSize", "tailSize", "reset"])?; let reset = bool_or(p, "reset", false); let none = bool_or(p, "none", false); let color = color_param(p, "color"); @@ -355,6 +356,15 @@ fn shadow_preset(v: &Value) -> Option> { } pub(super) fn effects(s: &mut Session, p: &Value) -> Result { + // `glow: null` and `softEdges: null` clear those effects (No Glow, No Soft Edges), so a null + // counts as something to set for them. + if !["glow", "softEdges"].iter().any(|k| p.get(*k).is_some()) { + require_any( + p, + "shape.effects", + &["shadow", "glow", "softEdges", "reflection", "bevel", "threeD", "shadowProps", "glowProps", "reflectionProps", "reset"], + )?; + } let reset = bool_or(p, "reset", false); let shadow = p.get("shadow").and_then(shadow_preset); let glow: Option> = p.get("glow").map(|g| match g { diff --git a/crates/engine/src/cmd/shape/picture.rs b/crates/engine/src/cmd/shape/picture.rs index 09cf22ae0..5db75277f 100644 --- a/crates/engine/src/cmd/shape/picture.rs +++ b/crates/engine/src/cmd/shape/picture.rs @@ -1,4 +1,4 @@ -use super::{NO_ID_SPACE, Result, Session, Value, bad, bool_or, bool_param, edit_geometry, edit_shapes, f64_param, json}; +use super::{NO_ID_SPACE, Result, Session, Value, bad, bool_or, bool_param, edit_geometry, edit_shapes, f64_param, json, require_any}; pub(super) fn crop(s: &mut Session, p: &Value) -> Result { let c = [f64_param(p, "left"), f64_param(p, "top"), f64_param(p, "right"), f64_param(p, "bottom")]; @@ -15,6 +15,7 @@ pub(super) fn crop(s: &mut Session, p: &Value) -> Result { } pub(super) fn picture_adjust(s: &mut Session, p: &Value) -> Result { + require_any(p, "picture.adjust", &["brightness", "contrast", "saturation", "grayscale", "transparency", "reset"])?; edit_shapes(s, p, "picture.adjust", |sh| { if let deckcraft_model::ShapeKind::Picture { fill } = &mut sh.kind { let a = &mut fill.adjust; diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index a687de95c..953322922 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -5970,6 +5970,44 @@ fn invalid_slide_index_never_falls_back_to_the_selection_in_export_commands() { let _ = std::fs::remove_dir_all(&dir); } +#[test] +fn style_commands_given_nothing_to_set_are_refused() { + let mut s = session(); + s.execute("insert.textBox", &json!({"text": "Hi", "rect": [50.0, 50.0, 200.0, 100.0]})).unwrap(); + for cmd in ["shape.line", "shape.effects", "picture.adjust", "format.paragraph", "format.margins"] { + let rev = s.doc().unwrap().revision; + let e = s.execute(cmd, &json!({})).unwrap_err().to_string(); + assert!(e.contains("given nothing to set") && e.contains(cmd), "{cmd}: {e}"); + assert_eq!(s.doc().unwrap().revision, rev, "{cmd} changed the deck"); + } + let e = s.execute("shape.line", &json!({})).unwrap_err().to_string(); + assert!(e.contains("pass color, none, width, dash"), "{e}"); + // A key, even one that changes nothing visible, is something to set. + s.execute("shape.line", &json!({"width": 2})).unwrap(); + s.execute("format.margins", &json!({"left": 5})).unwrap(); + // A null glow or soft edge clears it (No Glow, No Soft Edges): that is something to set. + let fx = |s: &Session| s.doc().unwrap().selected_shapes()[0].effects.clone().unwrap_or_default(); + s.execute("shape.effects", &json!({"glow": 8, "softEdges": 5})).unwrap(); + assert!(fx(&s).glow.is_some() && fx(&s).soft_edge.is_some()); + s.execute("shape.effects", &json!({"glow": null})).unwrap(); + assert!(fx(&s).glow.is_none() && fx(&s).soft_edge.is_some()); + s.execute("shape.effects", &json!({"softEdges": null})).unwrap(); + assert!(fx(&s).soft_edge.is_none()); + // The Paragraph dialog's own fields are format.paragraphDialog's, and the refusal says so. + for (k, v) in [("special", json!("hanging")), ("spaceBeforeKind", json!("pct")), ("indentRight", json!(10))] { + let e = s.execute("format.paragraph", &json!({ k: v })).unwrap_err().to_string(); + assert!(e.contains("format.paragraphDialog") && e.contains(k), "{k}: {e}"); + } + let e = s.execute("format.paragraph", &json!({"spaceBeforeKind": "pct"})).unwrap_err().to_string(); + assert!(e.contains("together with `spaceBefore`"), "{e}"); + // The palette lists only commands that run without arguments; these need one key. + for cmd in ["shape.line", "shape.effects", "picture.adjust", "format.paragraph", "format.margins"] { + let spec = crate::command_specs().iter().find(|c| c.id == cmd).unwrap(); + assert!(crate::cmd::needs_arguments(spec.params), "{cmd}: {}", spec.params); + } + s.execute("format.paragraphDialog", &json!({"special": "hanging", "specialBy": 18})).unwrap(); +} + #[test] fn highlight_with_an_invalid_colour_is_rejected_and_keeps_the_highlight() { let mut s = session(); From d542b35bd4bb8be9a6f3239459ba798300cc474d Mon Sep 17 00:00:00 2001 From: Zach Berry <1112351+zberry@users.noreply.github.com> Date: Mon, 2 Nov 2026 17:03:05 -0600 Subject: [PATCH 6/9] Test: picture.adjust and format.paragraph refuse only-null calls and take one key Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/tests.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 953322922..feedb1338 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -6008,6 +6008,43 @@ fn style_commands_given_nothing_to_set_are_refused() { s.execute("format.paragraphDialog", &json!({"special": "hanging", "specialBy": 18})).unwrap(); } +/// A call whose keys are all null sets nothing and is refused like an empty one, changing +/// nothing; one valid key is enough, nulls beside it ignored. +#[test] +fn style_commands_refuse_only_nulls_and_take_one_key() { + let mut png = vec![]; + image::DynamicImage::ImageRgba8(image::RgbaImage::from_pixel(4, 2, image::Rgba([200, 30, 30, 255]))) + .write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png) + .unwrap(); + let mut s = session(); + let pic = + s.execute("insert.picture", &json!({"data": cmd::base64_encode(&png), "name": "a.png", "rect": [100, 100, 40, 20]})).unwrap()["id"].clone(); + let text = s.execute("insert.textBox", &json!({"text": "Hi", "rect": [50, 300, 200, 100]})).unwrap()["id"].clone(); + let nulls = |keys: &[&str]| serde_json::Value::Object(keys.iter().map(|k| ((*k).to_string(), serde_json::Value::Null)).collect()); + for (cmd, id, keys, one) in [ + ( + "picture.adjust", + &pic, + &["brightness", "contrast", "saturation", "grayscale", "transparency", "reset"][..], + json!({"brightness": 0.3, "contrast": null}), + ), + ( + "format.paragraph", + &text, + &["align", "indentLeft", "indentFirst", "spaceBefore", "spaceAfter", "lineSpacing", "lineSpacingPt"][..], + json!({"align": "center", "spaceBefore": null}), + ), + ] { + s.execute("edit.select", &json!({"ids": [id]})).unwrap(); + let rev = s.doc().unwrap().revision; + let e = s.execute(cmd, &nulls(keys)).unwrap_err().to_string(); + assert!(e.contains("given nothing to set") && e.contains(cmd), "{cmd}: {e}"); + assert_eq!(s.doc().unwrap().revision, rev, "{cmd}: only nulls changed the deck"); + s.execute(cmd, &one).unwrap_or_else(|e| panic!("{cmd} {one}: {e}")); + assert_ne!(s.doc().unwrap().revision, rev, "{cmd}: one key set something"); + } +} + #[test] fn highlight_with_an_invalid_colour_is_rejected_and_keeps_the_highlight() { let mut s = session(); From 456cecdc58cf63ab2ff0e08a355db9de8f0385e5 Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Wed, 4 Nov 2026 20:55:50 +0000 Subject: [PATCH 7/9] Apply review fixes - crates/engine/src/cmd/format/paragraph.rs --- crates/engine/src/cmd/format/paragraph.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/format/paragraph.rs b/crates/engine/src/cmd/format/paragraph.rs index c508c3573..d4a1c754d 100644 --- a/crates/engine/src/cmd/format/paragraph.rs +++ b/crates/engine/src/cmd/format/paragraph.rs @@ -134,7 +134,9 @@ pub(super) fn paragraph(s: &mut Session, p: &Value) -> Result { }; return Err(bad( "format.paragraph", - format!("`{k}` is a field of format.paragraphDialog (the whole Paragraph dialog), given{with}; format.paragraph does not read it"), + format!( + "`{k}` is a field of format.paragraphDialog (the whole Paragraph dialog); pass it there{with}. format.paragraph does not read it" + ), )); } return Err(e); From 0bce1064034a9bd1398a17c1e46260f116c93b14 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:55:00 +0100 Subject: [PATCH 8/9] Skip non-integer colour transform values instead of zeroing them Found while testing crates/engine/src/cmd.rs:~425 (color_value) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 59160df14..7b521cb58 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -413,8 +413,12 @@ pub(crate) fn color_value(v: &Value) -> Option { ColorRef::rgb(deckcraft_color::Rgba::from_hex(o.get("rgb").and_then(Value::as_str)?)?) }; for (k, val) in o { - if let Some(t) = deckcraft_color::ColorTransform::from_xml(k, val.as_i64().and_then(|x| i32::try_from(x).ok())) { - c.mods.push(t); + let n = val.as_i64().and_then(|x| i32::try_from(x).ok()); + if let Some(t) = deckcraft_color::ColorTransform::from_xml(k, n) { + // A value-bearing transform without a usable integer is skipped, not zeroed. + if n.is_some() || t.value().is_none() { + c.mods.push(t); + } } } Some(c) @@ -690,6 +694,16 @@ mod tests { } } + #[test] + fn a_non_integer_colour_transform_is_skipped_not_zeroed() { + for bad in [serde_json::json!("75000"), serde_json::json!(75000.0), serde_json::json!(0.75), serde_json::json!(3_000_000_000i64)] { + let c = color_value(&serde_json::json!({"scheme": "accent1", "lumMod": bad})).unwrap(); + assert!(c.mods.is_empty(), "{bad}: {:?}", c.mods); + } + let c = color_value(&serde_json::json!({"scheme": "accent1", "lumMod": 75000})).unwrap(); + assert_eq!(c.mods, vec![deckcraft_color::ColorTransform::LumMod(75000)]); + } + #[test] fn the_palette_skips_a_command_that_needs_a_value() { assert!(needs_arguments("{path}")); From 90e44a619f693df4cd0f99ca717359408223bf37 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Fri, 27 Nov 2026 12:46:37 +0000 Subject: [PATCH 9/9] Apply review fixes - crates/engine/src/cmd/format/paragraph.rs --- crates/engine/src/cmd/format/paragraph.rs | 40 ++++++++++------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/crates/engine/src/cmd/format/paragraph.rs b/crates/engine/src/cmd/format/paragraph.rs index 5394c5754..6142055c3 100644 --- a/crates/engine/src/cmd/format/paragraph.rs +++ b/crates/engine/src/cmd/format/paragraph.rs @@ -120,30 +120,26 @@ pub(super) fn line_spacing(s: &mut Session, p: &Value) -> Result { } pub(super) fn paragraph(s: &mut Session, p: &Value) -> Result { - if let Err(e) = - require_any(p, "format.paragraph", &["align", "indentLeft", "indentFirst", "spaceBefore", "spaceAfter", "lineSpacing", "lineSpacingPt"]) + // The Paragraph dialog's other fields are format.paragraphDialog's; say so instead of + // calling the call empty. + if let Some(k) = + ["special", "specialBy", "indentRight", "spaceBeforeKind", "spaceAfterKind"].into_iter().find(|k| p.get(*k).is_some_and(|v| !v.is_null())) { - // The Paragraph dialog's other fields are format.paragraphDialog's; say so instead of - // calling the call empty. - if let Some(k) = - ["special", "specialBy", "indentRight", "spaceBeforeKind", "spaceAfterKind"].into_iter().find(|k| p.get(*k).is_some_and(|v| !v.is_null())) - { - // The dialog applies a kind or `specialBy` only with the value it qualifies. - let with = match k { - "spaceBeforeKind" => " together with `spaceBefore`", - "spaceAfterKind" => " together with `spaceAfter`", - "specialBy" => " together with `special`", - _ => "", - }; - return Err(bad( - "format.paragraph", - format!( - "`{k}` is a field of format.paragraphDialog (the whole Paragraph dialog); pass it there{with}. format.paragraph does not read it" - ), - )); - } - return Err(e); + // The dialog applies a kind or `specialBy` only with the value it qualifies. + let with = match k { + "spaceBeforeKind" => " together with `spaceBefore`", + "spaceAfterKind" => " together with `spaceAfter`", + "specialBy" => " together with `special`", + _ => "", + }; + return Err(bad( + "format.paragraph", + format!( + "`{k}` is a field of format.paragraphDialog (the whole Paragraph dialog); pass it there{with}. format.paragraph does not read it" + ), + )); } + require_any(p, "format.paragraph", &["align", "indentLeft", "indentFirst", "spaceBefore", "spaceAfter", "lineSpacing", "lineSpacingPt"])?; let a = str_param(p, "align").map(|a| parse_align("format.paragraph", a)).transpose()?; let ml = f64_param(p, "indentLeft"); let ind = f64_param(p, "indentFirst");