Compare commits

...
Author SHA1 Message Date
Martin BallandClaude Opus 5.5 ea23b769a1 fix(options): Read Aloud slider, one Agents heading, hints, Apply/Clear on folders (#7987)
Part of #7987. Fixed: the Read Aloud speed is a slider again; the Agents
page no longer repeats its heading; the Display and Save hints sit under
the rows they explain (they were page footnotes), and the Privacy hint
is back; User templates and Dictionaries folder have v0.19.1's Apply and
Clear and the placeholder again (typing saves nothing until Apply or
Enter; Clear returns to the default).

Still open: the General > Initials placeholder (RowKind::Text has no
placeholder, needs craft-libs); the speed slider's accessible value text
does not carry the x unit. Reset Section at the bottom of Advanced is
not a defect: the page scrolls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx
2026-11-28 07:58:37 +00:00
Martin BallandClaude Opus 5.5 0b324da562 fix(layout): Read Mode fits a wide table to its column (#7988)
In the reading view a table with its own width is scaled to the column,
less its start offset (indent plus half border), mirrored tables too.

Not addressed here: Read Mode laying out 2 wider columns where v0.19.1
laid out 4, and the pager moving from bottom right to bottom left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCWNarDG3QfXK2YMzdx
2026-11-28 05:02:30 +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 <noreply@anthropic.com>
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
9 changed files with 371 additions and 41 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();
+15 -1
View File
@@ -10,7 +10,7 @@ use wordcraft_geom::Rect;
use crate::boxes::BoxContext;
use crate::para::{CellText, ClKind, ParaLayout};
use crate::{BoxInput, BoxLayout, Ctx, Placed, layout_box};
use crate::{BoxInput, BoxLayout, Ctx, Placed, ViewMode, layout_box};
/// Largest preferred table width, as a share of the text column, that a file can ask for.
const MAX_WIDTH_SHARE: f32 = 10.0;
@@ -431,6 +431,12 @@ fn table_frame(ctx: &mut Ctx, t: &Table, avail: f32, depth: usize, style: Option
grid.iter_mut().for_each(|w| *w *= k);
total = avail;
}
// The reading view reflows to its column, so even a table with its own width fits it (#7988).
if ctx.opts.view == ViewMode::Read && total > avail && avail > 0.0 {
let k = avail / total;
grid.iter_mut().for_each(|w| *w *= k);
total = avail;
}
if !t.props.fixed {
// Measuring lays paragraphs out once more; it mustn't count their equations twice.
let eq_count = ctx.eq_count;
@@ -477,6 +483,14 @@ fn table_frame(ctx: &mut Ctx, t: &Table, avail: f32, depth: usize, style: Option
} else {
indent - first_cell_left_margin_in(t, margins_def)
};
// The reading view fits the table into what the start offset leaves of the column, mirrored or not (#7988).
let room = (avail - start_offset.max(0.0)).max(1.0);
if ctx.opts.view == ViewMode::Read && acc > room && !matches!(t.props.align, Some(Align::Center | Align::Right)) {
let k = room / acc;
colx.iter_mut().for_each(|c| *c *= k);
acc = room;
total = room;
}
let x = match (t.props.align, rtl) {
(Some(Align::Center), _) => (avail - total) / 2.0,
// End alignment: the right margin, or the left one in a right-to-left table.
+25
View File
@@ -660,6 +660,31 @@ fn reading_layout_reflows_into_viewport_height_pages_without_changing_print_layo
assert!(invalid.pages.iter().all(|p| p.w.is_finite() && p.h.is_finite()));
}
#[test]
fn reading_layout_fits_a_wide_table_to_the_column() {
crate::test_fonts();
// #7988: a 468 pt table is wider than a reading column but must not run past its edge, however it is indented or mirrored.
let cases = [(0.0, false, None), (36.0, false, None), (36.0, true, None)];
let aligned = [None, Some(Align::Left), Some(Align::Center), Some(Align::Right)].map(|a| (36.0, false, a));
let aligned_rtl = [Some(Align::Left), Some(Align::Right)].map(|a| (36.0, true, a));
for (indent, rtl, align) in cases.into_iter().chain(aligned).chain(aligned_rtl) {
let mut d = Document::from_text("Before.");
let mut t = Table::new(2, 4, 468.0);
t.props.indent = Some(indent);
t.props.bidi_visual = rtl;
t.props.align = align;
d.insert_block(StoryRef::Body, &Path::top(1), wordcraft_doc::Block::Table(t)).unwrap();
let opts = LayoutOptions { view: ViewMode::Read, web_width: 360.0, read_height: 600.0, ..Default::default() };
let l = layout(&d, &mut LayoutCache::new(), &opts);
let p = &l.pages[0];
let cells: Vec<_> = p.items.iter().filter_map(|i| if let Placed::Cell { rect, .. } = i { Some(*rect) } else { None }).collect();
let (left, right) = cells.iter().fold((f32::MAX, 0.0f32), |(l, r), c| (l.min(c.x), r.max(c.x + c.w)));
assert!(right > left, "cells placed");
assert!(right <= p.body.x + p.body.w + 0.5, "indent {indent} rtl {rtl} {align:?}: right {right} vs column {}", p.body.x + p.body.w);
assert!(left >= p.body.x - 0.5, "indent {indent} rtl {rtl} {align:?}: left {left} vs column {}", p.body.x);
}
}
#[test]
fn hit_and_caret_agree() {
crate::test_fonts();
+76 -26
View File
@@ -9,6 +9,7 @@ use craft::behavior::{EditEvent, MotionMode, keyed};
use craft::ui::buttons::Button;
use craft::ui::contract::{Bind, Entry, Props as _, Show, ShowCollection, ShowContainer};
use craft::ui::display::{Elide, Shade, Text};
use craft::ui::form::{SliderField, SliderFieldLayout};
use craft::ui::layout_components::Row;
use craft::ui::list::{List, ListRow};
use craft::ui::patterns::preferences::{GroupSpec, PageSpec, PrefValue, PreferencesModel, PreferencesPage, RowKind, RowSpec};
@@ -302,7 +303,6 @@ impl PreferencesModel for OptionsModel<'_> {
use crate::StatusCount;
use crate::scroll::ScrollSpeed;
use crate::theme::{Animations, Appearance};
use wordcraft_engine::speech::{MAX_RATE, MIN_RATE};
let app = &*self.app;
let s = &self.strings;
let prefs = &app.session.prefs;
@@ -375,7 +375,8 @@ impl PreferencesModel for OptionsModel<'_> {
b("display.spaces", tl!("Spaces"), marks.spaces),
b("display.paragraphs", tl!("Paragraph marks"), marks.paragraphs),
b("display.hidden", tl!("Hidden text"), marks.hidden),
b("display.allMarks", tl!("Show all formatting marks"), app.session.view.marks),
b("display.allMarks", tl!("Show all formatting marks"), app.session.view.marks)
.help(tl!("These marks show even when Show/Hide ¶ is off.")),
],
),
GroupSpec::new(
@@ -404,8 +405,7 @@ impl PreferencesModel for OptionsModel<'_> {
],
),
],
)
.footnote(tl!("These marks show even when Show/Hide ¶ is off."));
);
let proofing = page_of(
"proofing",
@@ -445,7 +445,11 @@ impl PreferencesModel for OptionsModel<'_> {
GroupSpec::new(Some(tl!("Save documents")), {
// The browser can't write to the user's files, so AutoSave can't be turned on there (#176).
let row = b("save.autosave", tl!("AutoSave documents you have saved in WordCraft"), app.autosave && !browser).enabled(!browser);
vec![if browser { row.help(&s.autosave_reason) } else { row }]
vec![row.help(if browser {
&s.autosave_reason
} else {
tl!("AutoSave writes your changes to the file a moment after you stop typing.")
})]
}),
// The open document's `file.privacyOptions` (#1062): saved with it, honoured when it is saved.
GroupSpec::new(
@@ -460,12 +464,12 @@ impl PreferencesModel for OptionsModel<'_> {
"save.removeDateTime",
tl!("Leave out the date and time of comments and tracked changes when saving"),
settings.remove_date_time,
),
)
.help(tl!("The document you are editing keeps the names and dates; only the saved file leaves them out.")),
],
),
],
)
.footnote(tl!("AutoSave writes your changes to the file a moment after you stop typing."));
);
let language = page_of(
"language",
@@ -486,11 +490,7 @@ impl PreferencesModel for OptionsModel<'_> {
GroupSpec::new(
Some(tl!("Dictionaries")),
vec![
RowSpec::new(
"language.dictionariesFolder",
tl!("Dictionaries folder:"),
RowKind::Text(prefs.dictionaries_folder.as_deref().unwrap_or("")),
)
RowSpec::new("language.dictionariesFolder", tl!("Dictionaries folder:"), RowKind::Custom)
.help(tl!("Hunspell .aff and .dic files here (pl_PL, pt_BR, it_IT, hr_HR, tr_TR) are used before the system's.\nAn installed Language pack is used after this folder.")),
custom("language.dictionaryFiles", tl!("Dictionary files")),
],
@@ -523,12 +523,7 @@ impl PreferencesModel for OptionsModel<'_> {
GroupSpec::new(
Some(tl!("Read Aloud")),
vec![
RowSpec::new(
"accessibility.readAloudSpeed",
tl!("Speed"),
RowKind::float(app.session.read_aloud.rate() as f64, (MIN_RATE as f64)..=(MAX_RATE as f64), 2),
)
.step(0.05),
RowSpec::new("accessibility.readAloudSpeed", tl!("Speed"), RowKind::Custom),
b("accessibility.skipCitations", tl!("Skip citations & bibliography"), app.session.read_aloud.skip_citations),
],
),
@@ -586,12 +581,8 @@ impl PreferencesModel for OptionsModel<'_> {
groups.push(GroupSpec::new(
Some(tl!("File locations")),
vec![
RowSpec::new(
"advanced.templatesFolder",
tl!("User templates:"),
RowKind::Text(prefs.user_templates_folder.as_deref().unwrap_or("")),
)
.help(tl!("File › New lists the .dotx and .dotm templates here under Personal; Save as Word Template starts here.")),
RowSpec::new("advanced.templatesFolder", tl!("User templates:"), RowKind::Custom)
.help(tl!("File › New lists the .dotx and .dotm templates here under Personal; Save as Word Template starts here.")),
],
));
}
@@ -710,6 +701,15 @@ impl PreferencesModel for OptionsModel<'_> {
"general.defaultApp" => default_app_row(self.app, ui),
"proofing.autoCorrect" => self.command_button(ui, tl!("AutoCorrect Options"), "tools.autocorrect"),
"proofing.customDictionaryFile" => self.custom_dictionary_file(ui),
"language.dictionariesFolder" => {
let saved = self.app.session.prefs.dictionaries_folder.clone().unwrap_or_default();
self.folder_row(ui, key, tl!("Dictionaries folder:"), saved, tl!("Not set: the system's usual places").to_string())
}
"advanced.templatesFolder" => {
let saved = self.app.session.prefs.user_templates_folder.clone().unwrap_or_default();
let default = self.app.services.templates_dir.as_ref().map(|d| d.to_string_lossy().into_owned());
self.folder_row(ui, key, tl!("User templates:"), saved, default.unwrap_or_else(|| tl!("Not set").to_string()))
}
"proofing.customDictionary" => self.custom_dictionary(ui),
"language.proofingLanguage" => {
Text::new(self.strings.proofing_language.clone()).role(TypeRole::Caption).shade(Shade::Faint).show(ui);
@@ -724,6 +724,7 @@ impl PreferencesModel for OptionsModel<'_> {
dictionary_files(ui);
false
}
"accessibility.readAloudSpeed" => self.read_aloud_speed(ui),
"advanced.customizeKeyboard" => self.command_button(ui, tl!("Customize…"), "tools.customizeKeyboard"),
"advanced.customizeRibbon" => self.command_button(ui, tl!("Customize…"), "tools.customizeRibbon"),
_ => false,
@@ -732,7 +733,6 @@ impl PreferencesModel for OptionsModel<'_> {
fn custom_page(&mut self, ui: &mut Ui, page: &str) -> bool {
if page == "agents" {
Text::new(tl!("Agents")).role(TypeRole::Heading).show(ui);
Text::new(tl!("Every command is available to scripts and AI agents: run `wordcraft-cli mcp` for an MCP server, or start the app with `--control <port>` for the JSON control channel."))
.show(ui);
}
@@ -769,6 +769,56 @@ impl OptionsModel<'_> {
clicked
}
/// The Read Aloud speed: a slider with its number, as the player's.
fn read_aloud_speed(&mut self, ui: &mut Ui) -> bool {
use wordcraft_engine::speech::{MAX_RATE, MIN_RATE};
let rate = f64::from(self.app.session.read_aloud.rate());
let out = SliderField::new(tl!("Speed"), Bind::given(rate), f64::from(MIN_RATE)..=f64::from(MAX_RATE))
.step(0.05)
.layout(SliderFieldLayout::Inline)
.short(true)
.unit(tl!("×"))
.show(ui);
// Committed, not live, so a drag doesn't restart the sentence on every frame.
let committed = out.edit.events.committed().copied();
if let Some(v) = committed {
self.set("accessibility.readAloudSpeed", PrefValue::Float(v));
}
committed.is_some()
}
/// A folder setting (v0.19.1's): the saved path or a placeholder, Apply (or Enter) saves the typed path,
/// Clear returns to the default. The draft follows the saved path whenever that changes.
fn folder_row(&mut self, ui: &mut Ui, key: &str, label: &'static str, saved: String, placeholder: String) -> bool {
#[derive(Clone, Default)]
struct Draft {
text: String,
seen: Option<String>,
}
let mut changed = false;
Row::new().id_salt(key).show(ui, |ui, cx| {
let draft = &mut cx.keep::<Draft>();
if draft.seen.as_deref() != Some(saved.as_str()) {
draft.text = saved.clone();
draft.seen = Some(saved.clone());
}
let out = TextField::new(label, Bind::bound(&mut draft.text)).limit(None).placeholder(placeholder.clone()).submits().show(ui);
let typed = draft.text.trim().to_string();
let differs = typed != saved;
let apply = Button::new(tl!("Apply")).enabled(differs).show(ui).clicked() || (out.submitted && differs);
let clear = Button::new(tl!("Clear")).enabled(!saved.is_empty()).show(ui).clicked();
if apply {
self.set(key, PrefValue::Text(typed));
changed = true;
} else if clear {
self.set(key, PrefValue::Text(String::new()));
draft.text.clear();
changed = true;
}
});
changed
}
fn custom_dictionary_file(&mut self, ui: &mut Ui) -> bool {
let saved = self.app.session.prefs.custom_dictionary.clone().unwrap_or_default();
let out = TextField::new(tl!("Dictionary file:"), Bind::given(saved)).limit(None).show(ui);
+85
View File
@@ -454,3 +454,88 @@ fn escape_does_not_commit_the_custom_dictionary_path() {
assert_eq!(dictionary_field_text(&h), "", "the field shows the saved (empty) path");
let _ = std::fs::remove_dir_all(&dir);
}
/// #7987: the Read Aloud speed is a slider, not only a number box.
#[test]
fn read_aloud_speed_is_a_slider() {
use egui_kittest::kittest::Queryable;
let h = options_harness(app(), system_reducing_motion(false));
let _ = h.get_by_role_and_label(egui::accesskit::Role::Slider, "Speed");
}
/// #7987: the Agents page names itself once.
#[test]
fn agents_page_has_one_heading() {
use egui_kittest::kittest::Queryable;
let mut a = app();
a.run("ui.backstage", json!({"value": true, "page": "options", "pane": "agents"})).unwrap();
let mut h = crate::test_harness::builder().build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
options_frames(&mut h, 3);
use egui_kittest::kittest::NodeT;
// The nav entry is a list item; every other node that carries the name is a title.
let titles = h.query_all_by_label("Agents").filter(|n| n.accesskit_node().role() != egui::accesskit::Role::ListItem).count();
assert_eq!(titles, 2, "the page's group and its title, no second heading");
}
/// #7987: a hint sits under the setting it explains, not in a page footnote at the bottom.
#[test]
fn display_and_save_hints_sit_under_their_rows() {
let mut a = app();
let (display, save, privacy) = with_model(&mut a, true, |m| {
let pages = m.pages();
let help_of = |page: &str, key: &str| {
let p = pages.iter().find(|p| p.id == page).expect("page");
let r = p.groups.iter().flat_map(|g| g.rows.iter()).find(|r| r.key == key).expect("row");
(p.footnote.is_none(), r.help.is_some())
};
(help_of("display", "display.allMarks"), help_of("save", "save.autosave"), help_of("save", "save.removeDateTime"))
});
assert_eq!(display, (true, true));
assert_eq!(save, (true, true));
assert_eq!(privacy, (true, true), "the Privacy hint under its row");
}
/// #7987: a folder setting has Apply and Clear. Typing alone saves nothing, Apply saves the typed path, and Clear
/// returns to the default.
#[test]
fn folder_settings_have_apply_and_clear() {
use egui_kittest::kittest::Queryable;
let dir = std::env::temp_dir().join(format!("wc-ui-folder-row-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let path = dir.to_string_lossy().into_owned();
for (pane, label, saved) in [
("advanced", "User templates:", (|a: &WordApp| a.session.prefs.user_templates_folder.clone()) as fn(&WordApp) -> Option<String>),
("language", "Dictionaries folder:", |a: &WordApp| a.session.prefs.dictionaries_folder.clone()),
] {
let mut a = app();
a.run("ui.backstage", json!({"value": true, "page": "options", "pane": pane})).unwrap();
let mut h = crate::test_harness::builder().build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
options_frames(&mut h, 3);
h.get_by_role_and_label(egui::accesskit::Role::TextInput, label).focus();
options_frames(&mut h, 2);
h.get_by_role_and_label(egui::accesskit::Role::TextInput, label).type_text(&path);
options_frames(&mut h, 3);
assert_eq!(saved(h.state()), None, "{label} typing alone saved");
h.get_by_label("Apply").click();
options_frames(&mut h, 3);
assert_eq!(saved(h.state()).as_deref(), Some(path.as_str()), "{label} Apply");
h.get_by_label("Clear").click();
options_frames(&mut h, 3);
assert_eq!(saved(h.state()), None, "{label} Clear");
}
let _ = std::fs::remove_dir_all(&dir);
}
+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