Compare commits

...
Author SHA1 Message Date
Martin BallandClaude Opus 5.5 1a9fa89fb2 fix(dialogs): frame the Organizer's Document and Template lists
Part of #7980. v0.19.1 drew a border around both lists; after the port an
empty list has no visible bounds. Uses SurfaceKind::Frame, which List already
takes through its surface prop. Builds on the Organizer layout of #8031.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx
2026-11-28 11:46:01 +00:00
Martin BallandClaude Opus 5.5 8b293b64ad test(dialogs): Cell Margins converts a typed length back to points (#7970)
Cover the typed path CodeRabbit asked about: 1 cm typed in the field reaches the table as about 28.35 pt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx
2026-11-28 09:52:26 +00:00
Martin BallandClaude Opus 5.5 d1c9c8c034 fix(dialogs): Organizer shows both style lists with Copy, Delete and Rename between (#7980)
The lists sat in one row that the first list filled, which pushed the other file's list off the dialog. Three grid columns, as the old dialog had; Rename starts the list's own rename field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx
2026-11-28 03:51:03 +00:00
Martin BallandClaude Opus 5.5 06499e39aa fix(dialogs): Cell Margins shows points in the interface unit, not as cm (#7970)
The fields held points but only labelled them with the unit, so 5.4 pt read 5.4 cm. They now declare points and a length unit, so the field converts as every other length field does. OK without an edit never wrote margins (the dialog compares against the stored values); the test pins that and the shown unit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx
2026-11-28 03:27:12 +00:00
Martin BallandClaude Opus 5.5 5796c665b9 ci(sonar): ignore S8707 path traversal in crates/validate developer scripts (#7994)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 23:38:04 +00:00
FredApps e74e627a38 parity: headless column from the engine registry (RFC-0052) (#7969) 2026-11-28 00:01:17 +01:00
8 changed files with 351 additions and 57 deletions
+1
View File
@@ -74,5 +74,6 @@ WordCraft is a Rust word processor targeting Microsoft Word parity, for macOS, W
- Attribution: `ATTRIBUTION.md`, a row per asset file, checked by `cargo xtask assets`. Icons are our own SVG set in `crates/ui-egui/icons/` (draw new icons there); sample content is in `crates/engine/src/sample.rs` and `cmd/design.rs`.
- Fonts and language data come from other repositories as optional build inputs: craft-fonts through `CRAFT_FONTS_DIR`, and craft-i18n's `language-data/` through `CRAFT_I18N_DIR` (pinned by `craft-i18n.rev`; CI checks it out). Without craft-i18n the app builds with fallback spelling and no pattern hyphenation, so proofing tests need it. Proprietary font requests use installed fonts or the open substitutes in `crates/fonts/src/word.rs`. Layout tests use the fixed fonts in `assets/fonts/` ([docs/testing.md](docs/testing.md)).
- Run: `cargo run --release -p wordcraft -- --sample --control 7981` starts the app with a sample document and the control channel. It takes JSON lines on `127.0.0.1:7981`: authenticate once per connection with the token from `~/.config/wordcraft/control-key.local-7981` (macOS: `~/Library/Application Support/WordCraft/`), `{"id":1,"method":"auth","params":{"token":"…"}}`, then send requests without a token; methods are in `crates/ui-egui/src/control.rs`, docs in `docs/control-protocol.md` (Token). Headless screenshots: `cargo run --release -p wordcraft-ui-egui --example ui_shot -- script.jsonl`. CLI: `wordcraft-cli convert|run|commands|parity`. MCP: `wordcraft-cli mcp --automation-read-root DIR --automation-write-root DIR` (both required; `--connect` is refused until the app confines its control channel, #3695), see `docs/mcp.md`.
- Headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): `cargo xtask parity` marks a catalog feature `headless: yes` only when its command is in the engine registry that `wordcraft-cli` and the MCP server load (never a `ui.*` id). A missing feature takes its `no`/`partial` value and `reach:` (`window`, `os` or `engine-gap`) from `HEADLESS` in `crates/engine/src/catalog.rs`, or reads `unknown`. When a command lands, delete its mark; `headless_marks_are_current` fails on a stale one.
- Notes and progress: `plan/` is an optional gitignored notebook. Committed: `ROADMAP.md` (progress log), `docs/gaps.md`, `docs/roadmap.md`, `docs/target-app-parity.md`, `docs/architecture.md` and the parity checklists.
- Contributor credits: `docs/contributors.md`.
+11
View File
@@ -889,6 +889,17 @@ fn parity_markdown(p: &Value) -> String {
for t in p["tabs"].as_array().cloned().unwrap_or_default() {
s += &format!("| {} | {} | {} |\n", t["tab"].as_str().unwrap_or(""), t["live"], t["total"]);
}
let h = &p["headless"];
s += &format!(
"\n**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): {} yes, {} no (window {}, os {}, engine-gap {}), {} partial, {} unknown.** A feature is `headless: yes` when its command is in the engine registry that `wordcraft-cli` and the MCP server load, so every live feature above is `yes`; the missing ones carry the hand mark from `HEADLESS` in `crates/engine/src/catalog.rs`, or `unknown`.\n",
h["yes"],
h["no"]["window"].as_u64().unwrap_or(0) + h["no"]["os"].as_u64().unwrap_or(0) + h["no"]["engine-gap"].as_u64().unwrap_or(0),
h["no"]["window"],
h["no"]["os"],
h["no"]["engine-gap"],
h["partial"],
h["unknown"]
);
s += "\n## Missing\n\n";
for t in p["tabs"].as_array().cloned().unwrap_or_default() {
let m = t["missing"].as_array().cloned().unwrap_or_default();
+137 -1
View File
@@ -532,6 +532,98 @@ Tools|Templates|Templates and Add-ins|tools.templates
Tools|Views|Full Screen View|view.fullScreenView
";
/// RFC-0052 hand marks for catalog features with no engine command: `id|headless|reach|why`.
///
/// `headless` is `no` or `partial`, `reach` is `window` (needs a desktop window, dialog or
/// pointer), `os` (needs an OS or online service the engine doesn't wrap) or `engine-gap` (could
/// be an engine command, isn't one yet). `yes` is never written here: a feature is `yes` only when
/// its id is in the engine registry that `wordcraft-cli` and the MCP server load, and a mark on such
/// an id is stale (`headless_errors`). A missing feature with no mark is `unknown`.
pub const HEADLESS: &str = "\
tools.dictate|no|os|speech recognition service
insert.onlinePicture|no|os|online image search service
insert.model3d|no|engine-gap|3-D model files could be inserted by a command
insert.screenshot|no|os|screen capture of other windows
addins.get|no|os|add-in store service
insert.video|no|os|online video service
insert.inkEquation|no|window|drawn with a pen or pointer
draw.inkToMath|no|os|handwriting recognition service
review.translate|no|os|online translation service
review.blockAuthors|no|os|co-authoring service
view.readLayout|no|window|Read Mode window layout
";
/// One feature's RFC-0052 `headless:` value and, for `no`/`partial`, its `reach:` and reason.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Headless {
pub value: &'static str,
pub reach: Option<&'static str>,
pub why: &'static str,
}
const REACHES: [&str; 3] = ["window", "os", "engine-gap"];
/// Parsed `HEADLESS`-format marks: (id, value, reach, why). A malformed line is an error.
pub fn headless_marks(src: &'static str) -> Result<Vec<(&'static str, Headless)>, String> {
let mut out = Vec::new();
for line in src.lines().filter(|l| !l.trim().is_empty()) {
let f: Vec<&'static str> = line.splitn(4, '|').collect();
let [id, value, reach, why] = f[..] else {
return Err(format!("headless mark `{line}`: want `id|headless|reach|why`"));
};
if !matches!(value, "no" | "partial") {
return Err(format!("headless mark `{id}`: `{value}` is not `no` or `partial` (`yes` comes from the registry)"));
}
if !REACHES.contains(&reach) {
return Err(format!("headless mark `{id}`: reach `{reach}` is not window, os or engine-gap"));
}
if out.iter().any(|(m, _)| *m == id) {
return Err(format!("headless mark `{id}` is written twice"));
}
out.push((id, Headless { value, reach: Some(reach), why }));
}
Ok(out)
}
/// The `headless:` value of a catalog feature: `yes` when the engine registry has its id, else its
/// hand mark, else `unknown`.
pub fn headless_of(id: &str, live: bool, marks: &[(&'static str, Headless)]) -> Headless {
if live {
return Headless { value: "yes", reach: None, why: "" };
}
marks.iter().find(|(m, _)| *m == id).map(|(_, h)| *h).unwrap_or(Headless { value: "unknown", reach: None, why: "" })
}
/// Problems with the marks against the catalog and the registry's ids: unknown ids, and marks on
/// ids the engine registry has (they would hide a `yes`).
pub fn headless_errors(src: &'static str, catalog: &[(&str, &str, &str, &str)], live: impl Fn(&str) -> bool) -> Vec<String> {
let marks = match headless_marks(src) {
Ok(m) => m,
Err(e) => return vec![e],
};
let mut errs = Vec::new();
for (id, _) in &marks {
if !catalog.iter().any(|e| e.3 == *id) {
errs.push(format!("headless mark `{id}` is not a catalog id"));
} else if live(id) {
errs.push(format!("headless mark `{id}` is stale: the engine registry has it, so it is `yes`"));
}
}
errs
}
/// Headless counts in the RFC-0052 summary shape.
fn headless_summary(values: &[Headless]) -> Value {
let count = |v: &str| values.iter().filter(|h| h.value == v).count();
let no = |r: &str| values.iter().filter(|h| h.value == "no" && h.reach == Some(r)).count();
json!({
"yes": count("yes"),
"no": {"window": no("window"), "os": no("os"), "engine-gap": no("engine-gap")},
"partial": count("partial"),
"unknown": count("unknown"),
})
}
/// Catalog entries: (tab, group, feature, id).
pub fn entries() -> Vec<(&'static str, &'static str, &'static str, &'static str)> {
CATALOG
@@ -546,9 +638,13 @@ pub fn entries() -> Vec<(&'static str, &'static str, &'static str, &'static str)
/// Parity summary: per tab and overall, with the missing features.
pub fn parity(reg: &Registry) -> Value {
let e = entries();
let marks = headless_marks(HEADLESS).unwrap_or_default();
let mut values = Vec::with_capacity(e.len());
let mut tabs: Vec<(&str, usize, usize, Vec<String>)> = Vec::new();
for (tab, group, label, id) in &e {
let have = reg.get(id).is_some();
let h = headless_of(id, have, &marks);
values.push(h);
let t = match tabs.iter_mut().find(|t| t.0 == *tab) {
Some(t) => t,
None => {
@@ -564,7 +660,8 @@ pub fn parity(reg: &Registry) -> Value {
if have {
t.1 += 1;
} else {
t.3.push(format!("{group} › {label} (`{id}`)"));
let reach = h.reach.map(|r| format!(", reach: {r} ({})", h.why)).unwrap_or_default();
t.3.push(format!("{group} › {label} (`{id}`): headless: {}{reach}", h.value));
}
}
let live = tabs.iter().map(|t| t.1).sum::<usize>();
@@ -573,6 +670,7 @@ pub fn parity(reg: &Registry) -> Value {
"live": live,
"total": total,
"percent": if total == 0 { 0.0 } else { (live as f64 * 1000.0 / total as f64).round() / 10.0 },
"headless": headless_summary(&values),
"tabs": tabs.iter().map(|t| json!({"tab": t.0, "live": t.1, "total": t.2, "missing": t.3})).collect::<Vec<_>>(),
})
}
@@ -597,6 +695,44 @@ mod tests {
assert!(pct >= 90.4, "parity {pct}%");
}
#[test]
fn headless_marks_are_current() {
let reg = crate::cmd::registry();
let errs = headless_errors(HEADLESS, &entries(), |id| reg.get(id).is_some());
assert!(errs.is_empty(), "{errs:?}");
}
#[test]
fn headless_yes_comes_only_from_the_registry() {
let marks = headless_marks("a.b|no|window|pointer\n").unwrap();
assert_eq!(headless_of("a.b", true, &marks).value, "yes", "a live id is yes whatever the mark says");
assert_eq!(headless_of("a.b", false, &marks).reach, Some("window"));
assert_eq!(headless_of("c.d", false, &marks).value, "unknown");
assert!(headless_marks("a.b|yes|window|x\n").is_err(), "a hand-written yes is refused");
assert!(headless_marks("a.b|no|desk|x\n").is_err(), "reach must be window, os or engine-gap");
assert!(headless_marks("a.b|no\n").is_err());
assert!(headless_marks("a.b|no|os|x\na.b|partial|os|y\n").is_err(), "one mark per id");
}
#[test]
fn headless_errors_flag_stale_and_unknown_marks() {
let cat = [("T", "G", "F", "a.b"), ("T", "G", "H", "c.d")];
let errs = headless_errors("a.b|no|os|x\nz.z|no|os|y\n", &cat, |id| id == "a.b");
assert!(errs.iter().any(|e| e.contains("`a.b` is stale")), "{errs:?}");
assert!(errs.iter().any(|e| e.contains("`z.z` is not a catalog id")), "{errs:?}");
assert!(headless_errors("bad\n", &cat, |_| false).len() == 1);
}
#[test]
fn parity_counts_every_feature_once_in_the_headless_summary() {
let p = parity(&crate::cmd::registry());
let h = &p["headless"];
let n = |v: &Value| v.as_u64().unwrap_or(0);
let no = n(&h["no"]["window"]) + n(&h["no"]["os"]) + n(&h["no"]["engine-gap"]);
assert_eq!(n(&h["yes"]) + no + n(&h["partial"]) + n(&h["unknown"]), n(&p["total"]));
assert_eq!(n(&h["yes"]), n(&p["live"]), "every live feature is an engine command here");
}
#[test]
fn read_mode_view_menu_is_catalogued() {
let e = entries();
+73 -41
View File
@@ -3,18 +3,21 @@
//! `styles.copyFrom`, `styles.delete`, `styles.rename`), so agents get the same result without
//! the dialogs.
use craft::behavior::{EditEvent, Selection, SelectionChange, item_source::keyed};
use craft::behavior::{ColumnWidth, EditEvent, Selection, SelectionChange, item_source::keyed};
use craft::host::PickRequest;
use craft::ui::choice::Checkbox;
use craft::ui::contract::{Bind, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _};
use craft::ui::contract::{Bind, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, request_rename};
use craft::ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, StackDialog, dialog_id};
use craft::ui::display::Text;
use craft::ui::form::Field;
use craft::ui::layout_components::Row;
use craft::ui::layout::CellAlign;
use craft::ui::layout_components::{Grid, Stack};
use craft::ui::list::{List, ListRow};
use craft::ui::notices::Notice;
use craft::ui::patterns::form_dialogs::{FormCx, PathRow};
use craft::ui::runtime::env::{Env, Label};
use craft::ui::sections::{DialogRole, FooterButton};
use craft::ui::style::SurfaceKind;
use egui::{Context, Ui};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
@@ -24,6 +27,15 @@ use super::styles::{action, label};
use crate::WordApp;
const ORGANIZER_KEY: &str = "organizer";
/// The Organizer's columns: each takes what it holds, and a list holds at least `LIST_WIDTH` (a fill column takes no more
/// than its content in a dialog that sizes to its content, so an empty list was a few pixels wide).
const COLUMNS: [ColumnWidth; 3] = [ColumnWidth::Content; 3];
/// The least width of a list, in points.
const LIST_WIDTH: f32 = 200.0;
/// The rows each list shows before it scrolls.
const LIST_ROWS: u16 = 12;
/// The other file's list has its name above it, so it shows one row fewer to end level with the first.
const OTHER_ROWS: u16 = LIST_ROWS - 1;
/// The Templates and Add-ins dialog's fields.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
@@ -236,50 +248,69 @@ impl OrganizerDialog {
fn body(&mut self, ui: &mut Ui) {
let reason = browse_reason(ui);
Row::new().show(ui, |ui, _| {
let mut selection = Selection::single(self.left.clone());
let mine = &self.mine;
let source = keyed(mine, |st| text_of(st, "id"));
let out = List::new(label(tl!("Document")))
.select(SelectMode::Single)
.selection(Bind::bound(&mut selection))
.rename(true)
.can_rename(|key: &String| {
mine.iter().find(|x| text_of(x, "id") == *key).is_some_and(|x| !x.get("builtIn").and_then(Value::as_bool).unwrap_or(true))
})
.id_salt("mine")
.show_items(ui, &source, &mut |_, icx| {
let Some(st) = mine.get(icx.at) else { return ListRow::spacer() };
ListRow::new(label(text_of(st, "name"))).lead_text(label(glyph(&text_of(st, "type"))), label(""))
});
for event in out.events {
match event {
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
if let Some(key) = keys.last() {
self.left = key.clone();
let mine_id = ui.scope_id().with("organizer_mine");
// Three columns as the old dialog had: this document's styles, Copy / Delete / Rename, the other file's styles.
Grid::new(&COLUMNS).cells(CellAlign::Top).show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
ui.set_min_width(LIST_WIDTH);
let mut selection = Selection::single(self.left.clone());
let mine = &self.mine;
let source = keyed(mine, |st| text_of(st, "id"));
let out = List::new(label(tl!("Document")))
.surface(SurfaceKind::Frame)
.select(SelectMode::Single)
.selection(Bind::bound(&mut selection))
.rename(true)
.can_rename(|key: &String| {
mine.iter().find(|x| text_of(x, "id") == *key).is_some_and(|x| !x.get("builtIn").and_then(Value::as_bool).unwrap_or(true))
})
.id(mine_id)
.min_rows(LIST_ROWS)
.max_rows(LIST_ROWS)
.show_items(ui, &source, &mut |_, icx| {
let Some(st) = mine.get(icx.at) else { return ListRow::spacer() };
ListRow::new(label(text_of(st, "name"))).lead_text(label(glyph(&text_of(st, "type"))), label(""))
});
for event in out.events {
match event {
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
if let Some(key) = keys.last() {
self.left = key.clone();
}
}
CollectionEvent::Rename(EditEvent::Commit { after, .. }) => {
self.requests.push(Request::Rename { style: after.key, name: after.name });
}
_ => {}
}
CollectionEvent::Rename(EditEvent::Commit { after, .. }) => {
self.requests.push(Request::Rename { style: after.key, name: after.name });
}
_ => {}
}
}
if action(ui, "copy", label(tl!("Copy")), !self.right.is_empty(), None) {
self.requests.push(Request::Copy);
}
if action(ui, "delete", label(tl!("Delete")), !self.left_builtin(), None) {
self.requests.push(Request::Delete(self.left.clone()));
}
let name = std::path::Path::new(&self.file).file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "—".into());
Field::new(label(name)).show(ui, |ui, _| {
});
Stack::new().show(ui, |ui, _| {
if action(ui, "copy", label(tl!("Copy")), !self.right.is_empty(), None) {
self.requests.push(Request::Copy);
}
if action(ui, "delete", label(tl!("Delete")), !self.left_builtin(), None) {
self.requests.push(Request::Delete(self.left.clone()));
}
// The list's own rename field takes the name in place.
if action(ui, "rename", label(tl!("Rename…")), !self.left_builtin(), None) {
request_rename(ui.ctx(), mine_id, &self.left);
}
});
Stack::new().show(ui, |ui, _| {
ui.set_min_width(LIST_WIDTH);
let name = std::path::Path::new(&self.file).file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "—".into());
Text::new(label(name)).show(ui);
let mut selection = Selection::single(self.right.clone());
let other = &self.other;
let source = keyed(other, |(n, _)| n.clone());
let out = List::new(label(tl!("Template")))
.surface(SurfaceKind::Frame)
.select(SelectMode::Single)
.selection(Bind::bound(&mut selection))
.id_salt("other")
.min_rows(OTHER_ROWS)
.max_rows(OTHER_ROWS)
.show_items(ui, &source, &mut |_, icx| {
let Some((n, ty)) = other.get(icx.at) else { return ListRow::spacer() };
ListRow::new(label(n)).lead_text(label(glyph(ty)), label(""))
@@ -291,12 +322,13 @@ impl OrganizerDialog {
self.right = key.clone();
}
}
let picked = template_row(label(tl!("Template")), Bind::bound(&mut self.file), reason.clone()).show(ui).picked;
if let Some(path) = picked {
self.requests.push(Request::Load(path));
}
});
});
// The other file's path and Browse stand under both lists, at the dialog's full width.
let picked = template_row(label(tl!("Template")), Bind::bound(&mut self.file), reason.clone()).show(ui).picked;
if let Some(path) = picked {
self.requests.push(Request::Load(path));
}
if !self.message.is_empty() {
Notice::new(craft::theme::variant::Tone::Bad, label(&self.message)).show(ui);
}
+2 -2
View File
@@ -191,11 +191,11 @@ const MARGIN_SIDES: [(&str, &str); 4] = [("top", "Top"), ("left", "Left"), ("bot
fn open_cell_margins(app: &mut WordApp, ctx: &Context, parent: Option<DialogId>) -> Option<DialogId> {
let margins = cell_margins_pt(app)?;
let fields = DialogFields::from_pairs(MARGIN_SIDES.iter().zip(margins).map(|((key, _), v)| (*key, v)));
let kind = crate::options::unit_kind(app.session.units());
let units = crate::options::lengths(app.session.units());
let dialog = HostedParamDialog::new(ctx, "tableCellMargins", fields, move |fields| {
let params: Vec<Param> = MARGIN_SIDES
.iter()
.map(|(key, label)| Param::number(*key, tl!(label).to_string(), 0.0, 1.0, 2).bounds(Some(0.0), Some(144.0)).unit(kind))
.map(|(key, label)| Param::number(*key, tl!(label).to_string(), 0.0, units.shown.step(), 2).bounds(Some(0.0), Some(144.0)).length(units))
.collect();
ParamDialog::command("tableCellMargins", tl!("Cell Margins").to_string(), params).values(Bind::bound(fields)).alt_resets(false)
});
+106
View File
@@ -2283,3 +2283,109 @@ fn modal_dialog_with_open_popup_does_not_shake_on_inside_click_but_shakes_on_out
let key2 = chrome::nudge_id(&h.ctx, id2);
assert!(h.ctx.data(|d| d.get_temp::<f64>(key2)).is_none(), "reopened dialog starts still");
}
/// #7970: Cell Margins shows the table's points in the interface unit (0.19 cm, not 5.4 cm), and OK without
/// an edit leaves the table's margins as they were.
#[test]
fn cell_margins_dialog_shows_points_in_the_interface_unit_and_ok_changes_nothing() {
let mut app = app_with("");
let _ = app.run("insert.table", json!({"rows": 1, "cols": 1}));
app.session.prefs.units = Some(wordcraft_geom::Unit::Centimeters);
let mut h = app_harness(app);
h.run_steps(2);
let (tp, _, _) = h.state().session.sel.focus.path.cell().unwrap();
let margins =
|h: &egui_kittest::Harness<'_, WordApp>| h.state().session.doc.table(h.state().session.sel.focus.story, &tp).unwrap().props.cell_margins;
let before = margins(&h);
let _ = h.state_mut().run("ui.dialog", json!({"name": "tableCellMargins"}));
h.run_steps(3);
let left = h.get_by_role_and_label(egui::accesskit::Role::SpinButton, "Left").value().unwrap_or_default();
let shown: f64 = left.trim_end_matches(|c: char| !c.is_ascii_digit()).replace(',', ".").parse().unwrap_or(f64::NAN);
assert!(shown < 1.0, "5.4 pt is about 0.19 cm, not the point count: {left:?}");
let id = id_of(h.state(), "tableCellMargins");
let ctx = h.ctx.clone();
let _ = h.state_mut().dialog_host.confirm_by_id(&ctx, id);
h.run_steps(4);
assert_eq!(margins(&h), before, "OK without an edit writes no margins");
}
/// #7970: a width typed into Cell Margins in the interface unit reaches the table in points (1 cm is about 28 pt).
#[test]
fn cell_margins_dialog_converts_a_typed_length_back_to_points() {
let mut app = app_with("");
let _ = app.run("insert.table", json!({"rows": 1, "cols": 1}));
app.session.prefs.units = Some(wordcraft_geom::Unit::Centimeters);
let mut h = app_harness(app);
h.run_steps(2);
let (tp, _, _) = h.state().session.sel.focus.path.cell().unwrap();
let _ = h.state_mut().run("ui.dialog", json!({"name": "tableCellMargins"}));
h.run_steps(3);
h.get_by_role_and_label(egui::accesskit::Role::SpinButton, "Left").click();
h.run_steps(3);
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A);
h.event(egui::Event::Paste("1".into()));
h.run_steps(3);
h.key_press(egui::Key::Tab);
h.run_steps(3);
let id = id_of(h.state(), "tableCellMargins");
let ctx = h.ctx.clone();
let _ = h.state_mut().dialog_host.confirm_by_id(&ctx, id);
h.run_steps(4);
let left = h.state().session.doc.table(h.state().session.sel.focus.story, &tp).unwrap().props.cell_margins.map(|m| m[1]);
assert!(left.is_some_and(|l| (l - 28.35).abs() < 0.5), "1 cm is about 28.35 pt: {left:?}");
}
/// #7980: the Organizer shows this document's styles and the other file's side by side, with Copy, Delete and
/// Rename between them, all inside the dialog.
#[test]
fn organizer_shows_both_lists_and_its_buttons() {
use egui::accesskit::Role;
let mut h = app_harness(app_with(""));
h.run_steps(2);
let _ = h.state_mut().run("ui.dialog", json!({"name": "organizer"}));
h.run_steps(4);
let rect = |h: &egui_kittest::Harness<'_, WordApp>, role, name: &str| h.get_by_role_and_label(role, name).rect();
let mine = rect(&h, Role::List, "Document");
let other = rect(&h, Role::List, "Template");
assert!(mine.is_positive() && other.is_positive() && mine.right() <= other.left(), "the lists stand side by side: {mine:?} {other:?}");
// Each list is wider than the button column between them, empty (no other file) or not.
let rename = rect(&h, Role::Button, "Rename…");
assert!(mine.width() > rename.width() && other.width() > rename.width(), "the lists are wider than the buttons: {mine:?} {other:?} {rename:?}");
// The ribbon has its own Copy: the one that counts stands between the lists.
for name in ["Copy", "Delete", "Rename…"] {
let between = h
.query_all(egui_kittest::kittest::By::new().role(Role::Button).label(name))
.any(|b| b.rect().left() >= mine.right() - 1.0 && b.rect().right() <= other.left() + 1.0);
assert!(between, "{name} stands between the lists {mine:?} {other:?}");
}
}
/// Part of #7980: the Organizer's two lists have a visible frame, as before the port; without it an empty list is a
/// blank patch.
#[test]
fn the_organizer_lists_are_framed() {
use egui::accesskit::Role;
fn rects<'a>(shape: &'a egui::Shape, out: &mut Vec<&'a egui::epaint::RectShape>) {
match shape {
egui::Shape::Vec(inner) => inner.iter().for_each(|s| rects(s, out)),
egui::Shape::Rect(r) => out.push(r),
_ => {}
}
}
let mut h = app_harness(app_with(""));
h.run_steps(2);
let _ = h.state_mut().run("ui.dialog", json!({"name": "organizer"}));
h.run_steps(4);
let mut seen = Vec::new();
h.output().shapes.iter().for_each(|c| rects(&c.shape, &mut seen));
for label in ["Document", "Template"] {
let list = h.get_by_role_and_label(Role::List, label).rect();
assert!(
seen.iter().any(|r| r.stroke.width > 0.0
&& r.stroke.color.a() > 0
&& r.rect.contains_rect(list.shrink(2.0))
&& list.expand(2.0).contains_rect(r.rect)),
"the list {label:?} {list:?} has a border"
);
}
}
+14 -12
View File
@@ -32,35 +32,37 @@ Generated by `cargo xtask parity` (`wordcraft-cli parity --markdown`): the word-
| Editing | 41 | 41 |
| Tools | 7 | 7 |
**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 510 yes, 12 no (window 3, os 8, engine-gap 1), 0 partial, 0 unknown.** A feature is `headless: yes` when its command is in the engine registry that `wordcraft-cli` and the MCP server load, so every live feature above is `yes`; the missing ones carry the hand mark from `HEADLESS` in `crates/engine/src/catalog.rs`, or `unknown`.
## Missing
### Home
- Voice › Dictate (`tools.dictate`)
- Voice › Dictate (`tools.dictate`): headless: no, reach: os (speech recognition service)
### Insert
- Illustrations › Online Pictures (`insert.onlinePicture`)
- Illustrations › 3D Models (`insert.model3d`)
- Illustrations › Screenshot (`insert.screenshot`)
- Add-ins › Get Add-ins (`addins.get`)
- Media › Online Video (`insert.video`)
- Symbols › Ink Equation (`insert.inkEquation`)
- Illustrations › Online Pictures (`insert.onlinePicture`): headless: no, reach: os (online image search service)
- Illustrations › 3D Models (`insert.model3d`): headless: no, reach: engine-gap (3-D model files could be inserted by a command)
- Illustrations › Screenshot (`insert.screenshot`): headless: no, reach: os (screen capture of other windows)
- Add-ins › Get Add-ins (`addins.get`): headless: no, reach: os (add-in store service)
- Media › Online Video (`insert.video`): headless: no, reach: os (online video service)
- Symbols › Ink Equation (`insert.inkEquation`): headless: no, reach: window (drawn with a pen or pointer)
### Draw
- Convert › Ink to Math (`draw.inkToMath`)
- Convert › Ink to Math (`draw.inkToMath`): headless: no, reach: os (handwriting recognition service)
### Review
- Language › Translate (`review.translate`)
- Protect › Block Authors (`review.blockAuthors`)
- Language › Translate (`review.translate`): headless: no, reach: os (online translation service)
- Protect › Block Authors (`review.blockAuthors`): headless: no, reach: os (co-authoring service)
### Read Mode
- View › Layout (`view.readLayout`)
- View › Layout (`view.readLayout`): headless: no, reach: window (Read Mode window layout)
### Equation
- Tools › Ink Equation (`insert.inkEquation`)
- Tools › Ink Equation (`insert.inkEquation`): headless: no, reach: window (drawn with a pen or pointer)
+7 -1
View File
@@ -11,7 +11,7 @@ sonar.python.coverage.reportPaths=python-coverage.xml
# S4790 (weak hash): SHA-1 is a start-key and "SHA1/1K" checksum algorithm that ODF package
# encryption (ODF 1.3 Part 2 §4.16) names, and older office suites wrote it. It is needed to open
# those files, not chosen for new security: WordCraft writes a SHA-256 start key and checksum.
sonar.issue.ignore.multicriteria=odt_sha1
sonar.issue.ignore.multicriteria=odt_sha1,validate_py_paths
sonar.issue.ignore.multicriteria.odt_sha1.ruleKey=rust:S4790
sonar.issue.ignore.multicriteria.odt_sha1.resourceKey=crates/formats/src/odt/crypt.rs
@@ -22,3 +22,9 @@ sonar.issue.ignore.multicriteria.odt_sha1.resourceKey=crates/formats/src/odt/cry
# os_window, control-key). process_identity.rs is Windows-only (the taskbar AUMID) and cannot run
# on the Linux runner either.
sonar.coverage.exclusions=packaging/**,apps/wordcraft/src/main.rs,apps/wordcraft-cli/src/main.rs,apps/wordcraft/src/process_identity.rs
# S8707 (path traversal): the crates/validate *.py scripts are developer tools run by hand to
# regenerate checked-in files; reading and writing the paths given on their command line is
# their purpose, and nothing passes them untrusted input.
sonar.issue.ignore.multicriteria.validate_py_paths.ruleKey=pythonsecurity:S8707
sonar.issue.ignore.multicriteria.validate_py_paths.resourceKey=crates/validate/**/*.py