From 3131c02ebe10ecfd92cef399c72886d28ab184af Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:26:18 +0100 Subject: [PATCH 01/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20the=20tests=20?= =?UTF-8?q?read=20every=20sentence=20of=20words.rs=20against=20the=20voice?= =?UTF-8?q?=20guide?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each sentence's comment (Shows, When, At most, Placeholders), the same placeholders in French and in English and those its comment names, no straight apostrophe, a list's label at 18 characters and any sentence at its comment's limit, none of the lexicon's refused words. What each rule finds today is counted in STILL_WRONG: the rewrite, one pull request an area, lowers it, and a sentence that breaks a rule raises it, which fails. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/tests/words.rs | 406 +++++++++++++++++++++++++++++++++++ 1 file changed, 406 insertions(+) diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index 36f8cedd..2f29bd14 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1221,6 +1221,412 @@ fn every_french_sentence_has_its_spaces_before_the_tall_signs() { ); } +// The voice guide (`docs/voice.md`, D94): what every sentence holds, read from `src/words.rs`. + +/// What the rewrite (D94, one pull request an area) still has to put right: how many sentences +/// each rule of the guide finds wrong today. A number only goes down: a sentence put right lowers +/// it in the same pull request, and a new sentence that breaks a rule raises it, which fails. +const STILL_WRONG: [(&str, usize); 5] = [ + ("without their comment", 604), + ("with other placeholders in French and in English, or than their comment names", 1), + ("with a straight apostrophe", 12), + ("longer than their limit", 5), + ("with a word the lexicon refuses", 95), +]; + +/// A sentence of `src/words.rs`, as the file arranges it. +#[derive(Debug)] +struct Sentence { + /// The function that says it. + function: String, + /// In `window` and `menu`, the field it fills and its place there: an array holds several. + field: Option<(String, usize)>, + /// Said in French, in English, or before either is named. + french: Option, + text: String, + /// The comment that covers it, when it gives the guide's four words: its field's, or the last + /// one above it in its function. Numbered, so that what one comment covers is read together. + comment: Option<(usize, String)>, +} + +impl Sentence { + fn name(&self) -> String { + match &self.field { + Some((field, place)) => format!("{}.{field}[{place}] {:?}", self.function, self.text), + None => format!("{} {:?}", self.function, self.text), + } + } +} + +/// Functions whose literals are no sentence: a language's code, a model's name made fit to show, +/// what a program said made fit to show. +const NOT_SAID: [&str; 9] = [ + "named", + "code", + "detail", + "quantised", + "dated", + "without_tail", + "js_space", + "model_said", + "shown_detail", +]; + +/// A comment that gives the guide's four words, in their order. +fn context(comment: &str) -> bool { + let at: Vec<_> = ["Shows:", "When:", "At most:", "Placeholders:"] + .iter() + .map(|word| comment.find(word)) + .collect(); + at.iter().all(Option::is_some) && at.windows(2).all(|pair| pair[0] < pair[1]) +} + +/// Every sentence of `src/words.rs`: each string literal of a function, its escapes read as the +/// compiler reads them, with the comment that covers it. +fn sentences() -> Vec { + let path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/words.rs"); + let source: Vec = std::fs::read_to_string(path).unwrap().chars().collect(); + let mut found = Vec::new(); + let mut fields = std::collections::HashMap::new(); + let (mut function, mut structure, mut keyword, mut word_before) = (String::new(), String::new(), String::new(), String::new()); + let mut french = None; + let (mut block, mut doc) = (String::new(), None::); + let (mut comment, mut comments) = (None::<(usize, String)>, 0); + let (mut field, mut place) = (String::new(), 0); + let mut at = 0; + while at < source.len() { + let c = source[at]; + if c == '/' && source.get(at + 1) == Some(&'/') { + let end = source[at..].iter().position(|&d| d == '\n').map_or(source.len(), |n| at + n); + block.extend(&source[at..end]); + block.push('\n'); + at = end; + continue; + } + if c.is_whitespace() { + at += 1; + continue; + } + // A token: the comment above it ends here. + if !block.is_empty() { + let closed = std::mem::take(&mut block); + if keyword == "fn" && context(&closed) { + comments += 1; + comment = Some((comments, closed.clone())); + } + doc = Some(closed); + } + if c.is_alphanumeric() || c == '_' { + let start = at; + while at < source.len() && (source[at].is_alphanumeric() || source[at] == '_') { + at += 1; + } + let word: String = source[start..at].iter().collect(); + match word_before.as_str() { + "fn" => { + (function, keyword, french, comment) = (word.clone(), "fn".into(), None, None); + } + "struct" => (structure, keyword) = (word.clone(), "struct".into()), + _ => {} + } + match word.as_str() { + "French" => french = Some(true), + "English" => french = Some(false), + _ => {} + } + let next = source[at..] + .iter() + .position(|d| !d.is_whitespace()) + .map_or(source.len(), |n| at + n); + let named = source.get(next) == Some(&':') && source.get(next + 1) != Some(&':'); + if named + && keyword == "struct" + && word_before == "pub" + && let Some(doc) = doc.take() + { + fields.insert((structure.clone(), word.clone()), doc); + } + if named && keyword == "fn" { + (field, place) = (word.clone(), 0); + } + if word != "pub" { + doc = None; + } + word_before = word; + continue; + } + doc = None; + if c == '\'' { + // A character, escaped or not, or a lifetime. + at = match (source.get(at + 1), source.get(at + 2)) { + (Some('\\'), _) => at + 3 + source[at + 3..].iter().position(|&d| d == '\'').unwrap() + 1, + (_, Some('\'')) => at + 3, + _ => at + 1, + }; + continue; + } + if c != '"' { + at += 1; + continue; + } + let mut text = String::new(); + at += 1; + while at < source.len() { + let d = source[at]; + at += 1; + match d { + '\\' => { + let escaped = source[at]; + at += 1; + match escaped { + 'u' => { + let close = at + source[at..].iter().position(|&e| e == '}').unwrap(); + let code: String = source[at + 1..close].iter().collect(); + text.push(char::from_u32(u32::from_str_radix(&code, 16).unwrap()).unwrap()); + at = close + 1; + } + 'n' => text.push('\n'), + other => text.push(other), + } + } + '"' => break, + other => text.push(other), + } + } + let shown = matches!(function.as_str(), "window" | "menu"); + let said = keyword == "fn" + && !NOT_SAID.contains(&function.as_str()) + && word_before != "expect" + && !(shown && field == "locale") + && strip_placeholders(&text).chars().any(char::is_alphabetic); + if said { + let owner = if function == "window" { "Window" } else { "Menu" }; + let own = fields.get(&(owner.to_string(), field.clone())).filter(|doc| context(doc)); + found.push(Sentence { + function: function.clone(), + field: shown.then(|| (field.clone(), place)), + french, + text, + comment: if shown { own.map(|doc| (0, doc.clone())) } else { comment.clone() }, + }); + place += 1; + } + } + found +} + +/// The placeholders of a sentence, `{}` or `{name}`, a format's options left out: `{minutes:02}` +/// is `{minutes}`. `{{` is no placeholder. +fn placeholders(text: &str) -> Vec { + let mut found = Vec::new(); + let mut rest = text; + while let Some(open) = rest.find('{') { + let after = &rest[open + 1..]; + if let Some(escaped) = after.strip_prefix('{') { + rest = escaped; + continue; + } + let Some(close) = after.find('}') else { break }; + let name = after[..close].split(':').next().unwrap(); + if name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') { + found.push(format!("{{{name}}}")); + } + rest = &after[close + 1..]; + } + found +} + +fn strip_placeholders(text: &str) -> String { + placeholders(text) + .iter() + .fold(text.to_string(), |text, placeholder| text.replacen(placeholder.as_str(), "", 1)) +} + +/// A sentence's length as the guide counts it: each placeholder as 6 characters, the size or the +/// time that usually fills it. +fn measured(text: &str) -> usize { + strip_placeholders(text).chars().count() + 6 * placeholders(text).len() +} + +/// The limit a comment gives, in characters: none when it says `no limit`. +fn limit(comment: &str) -> Option { + let after = &comment[comment.find("At most:")? + "At most:".len()..]; + after.trim_start().split(|c: char| !c.is_ascii_digit()).next()?.parse().ok() +} + +/// What `rule` finds today, against what `STILL_WRONG` says is left of it. +fn still_wrong(rule: usize, found: Vec) { + let (what, left) = STILL_WRONG[rule]; + assert!( + found.len() == left, + "{} sentences {what}, STILL_WRONG says {left}: {}\n{}", + found.len(), + if found.len() < left { + "lower it" + } else { + "a sentence was written that breaks the guide" + }, + found.join("\n") + ); +} + +#[test] +fn the_sentences_are_read_as_the_file_arranges_them() { + let sentences = sentences(); + let (french, english): (Vec<_>, Vec<_>) = sentences.iter().partition(|sentence| sentence.french == Some(true)); + assert!(french.len() > 300 && english.len() > 300, "{} {}", french.len(), english.len()); + fn strings(value: &serde_json::Value, found: &mut Vec) { + match value { + serde_json::Value::String(text) => found.push(text.clone()), + serde_json::Value::Array(values) => values.iter().for_each(|value| strings(value, found)), + serde_json::Value::Object(fields) => fields.values().for_each(|value| strings(value, found)), + _ => {} + } + } + let shown = |language: Language| { + let mut texts = Vec::new(); + strings(&serde_json::to_value(words::window(language)).unwrap(), &mut texts); + texts.retain(|text| text != words::window(language).locale && strip_placeholders(text).chars().any(char::is_alphabetic)); + texts.sort(); + texts + }; + for (language, french) in [(Language::English, false), (Language::French, true)] { + let mut read: Vec<_> = sentences + .iter() + .filter(|sentence| sentence.function == "window" && sentence.french == Some(french)) + .map(|sentence| sentence.text.clone()) + .collect(); + read.sort(); + assert_eq!(read, shown(language), "{language:?}: the window's sentences, each read once"); + } +} + +/// Each sentence carries a comment that says where it shows, when, its limit and its placeholders: +/// one for both its languages, so counted on its English. +#[test] +fn every_sentence_carries_its_comment() { + let without = sentences() + .into_iter() + .filter(|sentence| sentence.french != Some(true) && sentence.comment.is_none()) + .map(|s| s.name()) + .collect(); + still_wrong(0, without); +} + +/// The same placeholders in French and in English — a field's, or those one comment covers —, and +/// those its comment names. +#[test] +fn a_sentence_has_the_same_placeholders_in_both_languages_and_its_comment_names_them() { + use std::collections::BTreeMap; + let mut groups: BTreeMap; 2]> = BTreeMap::new(); + let mut named: BTreeMap = BTreeMap::new(); + for sentence in sentences() { + let Some(french) = sentence.french else { continue }; + let group = match (&sentence.field, &sentence.comment) { + (Some((field, place)), _) => format!("{}.{field}[{place}]", sentence.function), + (None, Some((number, _))) => format!("{} comment {number}", sentence.function), + (None, None) => sentence.function.clone(), + }; + groups.entry(group.clone()).or_default()[french as usize].extend(placeholders(&sentence.text)); + if let Some((_, comment)) = &sentence.comment { + named.insert(group, comment[comment.find("Placeholders:").unwrap()..].to_string()); + } + } + let mut wrong = Vec::new(); + for (group, [mut english, mut french]) in groups { + english.sort(); + french.sort(); + if english != french { + wrong.push(format!("{group}: {english:?} in English, {french:?} in French")); + } + if let Some(named) = named.get(&group) { + let said: std::collections::BTreeSet<_> = english.iter().chain(&french).cloned().collect(); + let listed: std::collections::BTreeSet<_> = placeholders(named).into_iter().collect(); + if said != listed { + wrong.push(format!("{group}: says {said:?}, its comment names {listed:?}")); + } + } + } + still_wrong(1, wrong); +} + +#[test] +fn no_sentence_has_a_straight_apostrophe() { + let wrong = sentences() + .into_iter() + .filter(|sentence| sentence.text.contains('\'')) + .map(|s| s.name()) + .collect(); + still_wrong(2, wrong); +} + +/// A list's label at most 18 characters, whatever its comment says, and every sentence at most what +/// its comment says. A notification's title is read whole below. +#[test] +fn a_sentence_fits_its_limit_and_a_list_label_holds_18_characters() { + let script = std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/ui/window.js")).unwrap(); + // A list's labels: what the window puts in a chip, by name or by the `chip_` they all begin with. + let mut labels = std::collections::BTreeSet::new(); + for (opening, _) in script.match_indices("words.") { + let name: String = script[opening + 6..] + .chars() + .take_while(|c| c.is_alphanumeric() || *c == '_') + .collect(); + if name.starts_with("chip_") || script[..opening].ends_with("chip(") { + labels.insert(name); + } + } + assert!(labels.contains("chip_making") && labels.contains("recording"), "{labels:?}"); + let mut wrong = Vec::new(); + for sentence in sentences() { + let comment = sentence.comment.as_ref().map(|(_, comment)| comment.as_str()).unwrap_or_default(); + let label = sentence + .field + .as_ref() + .is_some_and(|(field, _)| sentence.function == "window" && labels.contains(field)) + || comment.contains("list label"); + let at_most = match limit(comment) { + Some(at_most) if label => Some(at_most.min(18)), + None if label => Some(18), + at_most => at_most, + }; + if at_most.is_some_and(|at_most| measured(&sentence.text) > at_most) { + wrong.push(format!("{} {} > {}", sentence.name(), measured(&sentence.text), at_most.unwrap())); + } + } + still_wrong(3, wrong); +} + +/// The lexicon's refused words that a test can tell apart: « fournisseur », « segment », « tu »; +/// "provider", "keyring", and "minutes" — the summary's, not a length's: after a number or a +/// placeholder, it is a length. +#[test] +fn no_sentence_says_a_word_the_lexicon_refuses() { + let mut wrong = Vec::new(); + for sentence in sentences() { + let refused: &[&str] = match sentence.french { + Some(true) => &["fournisseur", "fournisseurs", "segment", "segments", "tu"], + Some(false) => &["provider", "providers", "keyring", "minutes"], + None => continue, + }; + let words: Vec = sentence + .text + .split(|c: char| !(c.is_alphanumeric() || c == '{' || c == '}' || c == '_')) + .filter(|word| !word.is_empty()) + .map(str::to_lowercase) + .collect(); + let length = |at: usize| at > 0 && (words[at - 1].starts_with('{') || words[at - 1].chars().all(|c| c.is_ascii_digit())); + if let Some(at) = words + .iter() + .enumerate() + .position(|(at, word)| refused.contains(&word.as_str()) && !(word == "minutes" && length(at))) + { + wrong.push(format!("{} « {} »", sentence.name(), words[at])); + } + } + still_wrong(4, wrong); +} + #[test] fn a_list_waiting_on_its_key_says_so_and_what_stays_offered() { let (english, french) = (words::window(Language::English), words::window(Language::French)); From 6535ebbe4d04dcc8c8a69136285e76f7de4768a8 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:30:18 +0100 Subject: [PATCH 02/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20the=20voice=20?= =?UTF-8?q?guide's=20ratchet=20keyed=20by=20sentence,=20not=20counted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/words_still_wrong.txt lists, sorted, each sentence that still breaks a rule: a sentence not listed fails, one listed and put right fails until removed, so a sentence put right never covers another written wrong. The comments alone stay counted, 604 keys being three review budgets. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/tests/words.rs | 93 ++++++++++++------ modules/shell/tests/words_still_wrong.txt | 113 ++++++++++++++++++++++ 2 files changed, 175 insertions(+), 31 deletions(-) create mode 100644 modules/shell/tests/words_still_wrong.txt diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index 2f29bd14..2efa4b8b 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1223,16 +1223,15 @@ fn every_french_sentence_has_its_spaces_before_the_tall_signs() { // The voice guide (`docs/voice.md`, D94): what every sentence holds, read from `src/words.rs`. -/// What the rewrite (D94, one pull request an area) still has to put right: how many sentences -/// each rule of the guide finds wrong today. A number only goes down: a sentence put right lowers -/// it in the same pull request, and a new sentence that breaks a rule raises it, which fails. -const STILL_WRONG: [(&str, usize); 5] = [ - ("without their comment", 604), - ("with other placeholders in French and in English, or than their comment names", 1), - ("with a straight apostrophe", 12), - ("longer than their limit", 5), - ("with a word the lexicon refuses", 95), -]; +/// What the rewrite (D94, one pull request an area) still has to put right, sentence by sentence: +/// `tests/words_still_wrong.txt`, one `rule key` a line, sorted. A sentence that breaks a rule and +/// is not listed fails; one listed that no longer breaks it fails too, until it is removed — the +/// list only shrinks, and a sentence put right never covers another written wrong. +const STILL_WRONG: &str = include_str!("words_still_wrong.txt"); + +/// The sentences still without their comment, counted: 604 keys would be three review budgets. +/// The number only goes down, as the list does. +const WITHOUT_COMMENT: usize = 604; /// A sentence of `src/words.rs`, as the file arranges it. #[derive(Debug)] @@ -1454,19 +1453,41 @@ fn limit(comment: &str) -> Option { after.trim_start().split(|c: char| !c.is_ascii_digit()).next()?.parse().ok() } -/// What `rule` finds today, against what `STILL_WRONG` says is left of it. -fn still_wrong(rule: usize, found: Vec) { - let (what, left) = STILL_WRONG[rule]; +/// What `rule` finds today, against what `STILL_WRONG` lists of it, key by key. +fn still_wrong(rule: &str, found: Vec) { + let lines: Vec<_> = STILL_WRONG.lines().filter(|line| !line.is_empty()).collect(); + assert!(lines.is_sorted(), "tests/words_still_wrong.txt: keep it sorted"); + let mut listed: Vec<_> = lines + .iter() + .filter_map(|line| line.strip_prefix(&format!("{rule} "))) + .map(str::to_string) + .collect(); + let mut found = found; + listed.sort(); + found.sort(); + let new: Vec<_> = found + .iter() + .filter(|key| !listed.contains(key)) + .map(|key| format!("{rule} {key}")) + .collect(); + let gone: Vec<_> = listed + .iter() + .filter(|key| !found.contains(key)) + .map(|key| format!("{rule} {key}")) + .collect(); assert!( - found.len() == left, - "{} sentences {what}, STILL_WRONG says {left}: {}\n{}", - found.len(), - if found.len() < left { - "lower it" - } else { - "a sentence was written that breaks the guide" - }, - found.join("\n") + new.is_empty(), + "written against the guide (`{rule}`), put it right:\n{}", + new.join("\n") + ); + assert!( + gone.is_empty(), + "put right (`{rule}`): remove it from the list:\n{}", + gone.join("\n") + ); + assert_eq!( + found, listed, + "`{rule}`: a key listed once more or once less than it breaks the rule" ); } @@ -1505,12 +1526,22 @@ fn the_sentences_are_read_as_the_file_arranges_them() { /// one for both its languages, so counted on its English. #[test] fn every_sentence_carries_its_comment() { - let without = sentences() + let without: Vec<_> = sentences() .into_iter() .filter(|sentence| sentence.french != Some(true) && sentence.comment.is_none()) .map(|s| s.name()) .collect(); - still_wrong(0, without); + assert!( + without.len() == WITHOUT_COMMENT, + "{} sentences without their comment, WITHOUT_COMMENT says {WITHOUT_COMMENT}: {}\n{}", + without.len(), + if without.len() < WITHOUT_COMMENT { + "lower it" + } else { + "a sentence was written without its comment" + }, + without.join("\n") + ); } /// The same placeholders in French and in English — a field's, or those one comment covers —, and @@ -1537,17 +1568,17 @@ fn a_sentence_has_the_same_placeholders_in_both_languages_and_its_comment_names_ english.sort(); french.sort(); if english != french { - wrong.push(format!("{group}: {english:?} in English, {french:?} in French")); + wrong.push(format!("{group}: in both languages")); } if let Some(named) = named.get(&group) { let said: std::collections::BTreeSet<_> = english.iter().chain(&french).cloned().collect(); let listed: std::collections::BTreeSet<_> = placeholders(named).into_iter().collect(); if said != listed { - wrong.push(format!("{group}: says {said:?}, its comment names {listed:?}")); + wrong.push(format!("{group}: in its comment")); } } } - still_wrong(1, wrong); + still_wrong("placeholders", wrong); } #[test] @@ -1557,7 +1588,7 @@ fn no_sentence_has_a_straight_apostrophe() { .filter(|sentence| sentence.text.contains('\'')) .map(|s| s.name()) .collect(); - still_wrong(2, wrong); + still_wrong("apostrophe", wrong); } /// A list's label at most 18 characters, whatever its comment says, and every sentence at most what @@ -1591,10 +1622,10 @@ fn a_sentence_fits_its_limit_and_a_list_label_holds_18_characters() { at_most => at_most, }; if at_most.is_some_and(|at_most| measured(&sentence.text) > at_most) { - wrong.push(format!("{} {} > {}", sentence.name(), measured(&sentence.text), at_most.unwrap())); + wrong.push(sentence.name()); } } - still_wrong(3, wrong); + still_wrong("limit", wrong); } /// The lexicon's refused words that a test can tell apart: « fournisseur », « segment », « tu »; @@ -1624,7 +1655,7 @@ fn no_sentence_says_a_word_the_lexicon_refuses() { wrong.push(format!("{} « {} »", sentence.name(), words[at])); } } - still_wrong(4, wrong); + still_wrong("lexicon", wrong); } #[test] diff --git a/modules/shell/tests/words_still_wrong.txt b/modules/shell/tests/words_still_wrong.txt new file mode 100644 index 00000000..00d33a0e --- /dev/null +++ b/modules/shell/tests/words_still_wrong.txt @@ -0,0 +1,113 @@ +apostrophe audio_trashed "The system's trash did not take it." +apostrophe window.key_kept[0] "A key is kept in the system's keyring; a new one replaces it." +apostrophe window.key_not_kept[0] "The choice is saved, but the key was not kept in the system's keyring: {}" +apostrophe window.sessions_folder[1] "New meetings are written here. Those already recorded stay where they were: the window and the audio's keeping follow this folder." +apostrophe window.shortcut_where[0] "The desktop grants it: it changes in the desktop's keyboard settings." +apostrophe window.speech_failed[0] "Apple's model was not downloaded. Try again later; Whisper still hears." +apostrophe window.speech_fetch[0] "Download Apple's model (macOS fetches it from Apple)" +apostrophe window.speech_fetching[0] "macOS is downloading Apple's model…" +apostrophe window.speech_missing[0] "Apple's model is not on this Mac yet" +apostrophe window.speech_option[0] "Apple's SpeechAnalyzer, on this Mac" +apostrophe window.test_sends[0] "Test sends {} one sentence of Kitokey's, nothing of a meeting." +apostrophe window.where_online[0] "Online — the transcript's text is sent" +lexicon announcement "I’m recording this meeting to write up its minutes. Tell me if you’d rather I didn’t." « minutes » +lexicon audio_trashed "The audio of 1 meeting kept more than {} is in the trash; its transcript and minutes stay." « minutes » +lexicon audio_trashed "The audio of {meetings} meetings kept more than {} is in the trash; their transcripts and minutes stay." « minutes » +lexicon cause "Ce modèle ne donne pas les temps de ce qu’il entend\u{a0}: choisissez-en un qui donne ceux de chaque segment dans les réglages de Kitokey." « segment » +lexicon cause "Le fournisseur a refusé faute de crédit\u{a0}: ajoutez du crédit chez lui, puis réessayez." « fournisseur » +lexicon cause "Le fournisseur a refusé la clé\u{a0}: saisissez-la de nouveau dans les réglages de Kitokey." « fournisseur » +lexicon cause "Le fournisseur ne connaît pas ce modèle ou cette adresse\u{a0}: choisissez-les de nouveau dans les réglages de Kitokey." « fournisseur » +lexicon cause "Le fournisseur n’a pas pu être joint\u{a0}: vérifiez qu’il tourne, ou le réseau, puis réessayez." « fournisseur » +lexicon cause "Le fournisseur n’a pas répondu à temps\u{a0}: réessayez plus tard, ou choisissez un modèle plus rapide dans les réglages de Kitokey." « fournisseur » +lexicon cause "Le fournisseur n’a pas su répondre\u{a0}: réessayez plus tard." « fournisseur » +lexicon cause "Le fournisseur refuse pour trop de demandes, ou un quota épuisé\u{a0}: patientez, ou vérifiez votre forfait chez lui." « fournisseur » +lexicon cause "Le fournisseur renvoie la demande vers une autre adresse\u{a0}: vérifiez l’adresse dans les réglages de Kitokey." « fournisseur » +lexicon cause "Le fournisseur répond qu’il est en panne\u{a0}: réessayez plus tard. Sur cet ordinateur, ce modèle est peut-être trop gros pour la mémoire\u{a0}: choisissez-en un plus petit." « fournisseur » +lexicon cause "L’adresse, le modèle ou la clé du fournisseur ne peuvent pas être utilisés tels quels\u{a0}: corrigez-les dans les réglages de Kitokey." « fournisseur » +lexicon cause "The minutes could not be written in the meeting’s folder: free space, or check the folder." « minutes » +lexicon cause "The model did not write minutes: try again, or choose another model in Kitokey’s settings." « minutes » +lexicon cause "The provider answers that it is failing: try again later. On this computer, this model may be too large for the memory: choose a smaller one." « provider » +lexicon cause "The provider could not be reached: check that it runs, or the network, then try again." « provider » +lexicon cause "The provider did not answer in time: try again later, or choose a faster model in Kitokey’s settings." « provider » +lexicon cause "The provider does not know this model or this address: choose them again in Kitokey’s settings." « provider » +lexicon cause "The provider failed to answer: try again later." « provider » +lexicon cause "The provider refused for lack of credit: add credit with it, then try again." « provider » +lexicon cause "The provider refused the key: give it again in Kitokey’s settings." « provider » +lexicon cause "The provider refuses for too many requests, or a quota used up: wait, or check your plan with it." « provider » +lexicon cause "The provider sends the request to another address: check the address in Kitokey’s settings." « provider » +lexicon cause "The provider’s address, model or key cannot be used as given: correct them in Kitokey’s settings." « provider » +lexicon cause "The transcript holds no speech: there is nothing to write minutes of. Check the recording." « minutes » +lexicon cause_own "Le fournisseur ne connaît pas {}, choisi pour cette réunion\u{a0}: choisissez-en un autre dans Refaire…\u{a0}› Avancé." « fournisseur » +lexicon cause_own "Le fournisseur répond qu’il est en panne\u{a0}: réessayez plus tard. Sur cet ordinateur, {}, choisi pour cette réunion, est peut-être trop gros pour la mémoire\u{a0}: choisissez-en un plus petit dans Refaire…\u{a0}› Avancé." « fournisseur » +lexicon cause_own "The provider answers that it is failing: try again later. On this computer, {}, chosen for this meeting, may be too large for the memory: choose a smaller one in Redo…\u{a0}› Advanced." « provider » +lexicon cause_own "The provider does not know {}, chosen for this meeting: choose another in Redo…\u{a0}› Advanced." « provider » +lexicon cause_own "{}, chosen for this meeting, did not write minutes: try again, or choose another model in Redo…\u{a0}› Advanced." « minutes » +lexicon failure "the system’s keyring does not answer: unlock it, then try again." « keyring » +lexicon failure "who writes the minutes has changed: look at this page again." « minutes » +lexicon menu.minutes[0] "Write the minutes of the last recording" « minutes » +lexicon menu.minuting[0] "Writing the minutes…" « minutes » +lexicon minutes "Minutes ready" « minutes » +lexicon minutes "Minutes ready" « minutes » +lexicon minutes "No minutes without a transcript" « minutes » +lexicon minutes "No one is chosen to write the minutes" « minutes » +lexicon minutes "The minutes wait for Ollama" « minutes » +lexicon minutes "The minutes wait for Ollama" « minutes » +lexicon minutes "The minutes wait for your agreement" « minutes » +lexicon minutes "The minutes were not made again" « minutes » +lexicon minutes "The minutes were not made again" « minutes » +lexicon minutes "The minutes were not written" « minutes » +lexicon minutes "The minutes were not written" « minutes » +lexicon minutes "The minutes were not written" « minutes » +lexicon minutes "The minutes were not written" « minutes » +lexicon minutes "«\u{a0}{address}\u{a0}» n’est pas l’adresse d’un fournisseur\u{a0}: choisissez qui écrit le compte rendu dans les réglages de Kitokey." « fournisseur » +lexicon minutes "“{address}” is not a provider’s address: choose who writes the minutes in Kitokey’s settings." « provider » +lexicon pulled "{model} is in Ollama: it is offered first for the minutes." « minutes » +lexicon window.after_minutes[0] "Write the transcript, then the minutes" « minutes » +lexicon window.after_minutes[1] "Each follows the other; a notification says when the minutes are ready." « minutes » +lexicon window.agree_eyebrow[0] "Before the first minutes online" « minutes » +lexicon window.agree_lead[0] "To write the minutes, Kitokey sends the transcript to the service you chose. Here is exactly what leaves." « minutes » +lexicon window.agree_local[0] "Write the minutes on this computer instead" « minutes » +lexicon window.chip_failed[0] "Minutes not written" « minutes » +lexicon window.chip_making[0] "Minutes…" « minutes » +lexicon window.confidential_ollama_empty[0] "Ollama holds no model on this computer: the minutes wait for it." « minutes » +lexicon window.context_changed[1] "The transcript and the minutes were made with another context." « minutes » +lexicon window.context_making[0] "The context cannot change while the transcript or the minutes are being made." « minutes » +lexicon window.context_why[0] "The transcription hears it as the first words said: names are spelt as here. The minutes use it to give each action to the right person." « minutes » +lexicon window.copy_minutes[0] "Copy the minutes" « minutes » +lexicon window.corrected_since[0] "The transcript was corrected after these minutes were written." « minutes » +lexicon window.free_audio[1] "The minutes and the transcript still read. The audio is nearly all the weight." « minutes » +lexicon window.free_busy[0] "being recorded, transcribed or its minutes written" « minutes » +lexicon window.free_whole[1] "The audio, the transcript and the minutes: nothing of the meeting is left." « minutes » +lexicon window.keep_audio[1] "After that, the audio goes to the trash; the transcript and minutes stay." « minutes » +lexicon window.key_kept[0] "A key is kept in the system's keyring; a new one replaces it." « keyring » +lexicon window.key_not_kept[0] "The choice is saved, but the key was not kept in the system's keyring: {}" « keyring » +lexicon window.make_minutes[0] "Write the minutes" « minutes » +lexicon window.minutes[0] "Minutes" « minutes » +lexicon window.minutes_making[0] "Writing the minutes" « minutes » +lexicon window.minutes_not_copied[0] "The minutes could not be copied." « minutes » +lexicon window.minutes_not_made[0] "The minutes were not written. The transcript is untouched." « minutes » +lexicon window.minutes_step[0] "Minutes" « minutes » +lexicon window.minutes_title[0] "Minutes" « minutes » +lexicon window.minutes_unsaved[0] "Not saved yet — the minutes are still written by {}." « minutes » +lexicon window.minutes_unsaved_none[0] "Not saved yet — no minutes are written until it is." « minutes » +lexicon window.models_gone_minutes[0] "The minutes model chosen for this meeting goes through a service Settings do not name: Settings’ stands in." « minutes » +lexicon window.models_minutes[0] "Minutes model" « minutes » +lexicon window.models_note[0] "The models “on this computer” are those Kitokey finds installed. A key is kept in your system’s keyring, never in a file. Nothing leaves this computer without your agreement: a transcription service you name receives your meetings’ sound and their context, a service that writes the minutes their text and context only." « keyring » +lexicon window.no_minutes[0] "No minutes yet." « minutes » +lexicon window.no_player[0] "Its audio was freed: the meeting can no longer be listened to. Its transcript and minutes stay." « minutes » +lexicon window.offered_ollama_good[0] "For the minutes, on this computer, through Ollama" « minutes » +lexicon window.redo_note[0] "The current minutes stay in place until the new ones are ready, then go to the trash." « minutes » +lexicon window.redo_title[0] "Write the minutes again" « minutes » +lexicon window.service_tested[0] "Il entend, avec les temps de chaque segment\u{a0}: un son propre à Kitokey a été transcrit." « segment » +lexicon window.weight_described[0] "The audio takes {}; the transcripts and minutes, {}." « minutes » +lexicon window.welcome_connected[1] "The minutes are written by an online service; the transcription stays on this computer." « minutes » +lexicon window.welcome_ollama_lacks[0] "Ollama does not hold {} yet: the minutes wait for it. Settings fetch it in one click." « minutes » +lexicon window.welcome_ollama_silent[0] "Ollama does not answer on this computer: the minutes wait for it. It is free, at ollama.com." « minutes » +lexicon window.welcome_rows[1] "Minutes" « minutes » +lexicon window.welcome_writer[0] "Who writes the minutes?" « minutes » +limit window.chip_failed[0] "Compte rendu non fait" +limit window.chip_failed[0] "Minutes not written" +limit window.chip_transcript_failed[0] "Transcript not written" +limit window.chip_transcript_failed[0] "Transcription non faite" +limit window.recording[0] "Enregistrement en cours" +placeholders of: in both languages From c18adb6667f5e8d25ea240d16ae243c52a4ff3d2 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:35:08 +0100 Subject: [PATCH 03/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20a=20sentence?= =?UTF-8?q?=20of=20no=20named=20language=20held=20to=20both=20lexicons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reader cannot place a helper's sentences, such as french_days', in either language: they escaped the lexicon. They are now held to both; none of today's is refused (the verifier's mutant, french_days saying « fournisseur », now fails). Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/tests/words.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index 2efa4b8b..e8a832d8 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1635,10 +1635,15 @@ fn a_sentence_fits_its_limit_and_a_list_label_holds_18_characters() { fn no_sentence_says_a_word_the_lexicon_refuses() { let mut wrong = Vec::new(); for sentence in sentences() { + const FRENCH: [&str; 5] = ["fournisseur", "fournisseurs", "segment", "segments", "tu"]; + const ENGLISH: [&str; 4] = ["provider", "providers", "keyring", "minutes"]; + // A sentence the reader cannot place in either language — a helper such as `french_days` — + // is held to both lexicons. + let both = [FRENCH.as_slice(), ENGLISH.as_slice()].concat(); let refused: &[&str] = match sentence.french { - Some(true) => &["fournisseur", "fournisseurs", "segment", "segments", "tu"], - Some(false) => &["provider", "providers", "keyring", "minutes"], - None => continue, + Some(true) => &FRENCH, + Some(false) => &ENGLISH, + None => &both, }; let words: Vec = sentence .text From 0d0a34c1658e41c71f8e3a8e4b0bbfdfcad778b7 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:41:28 +0100 Subject: [PATCH 04/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20a=20settings?= =?UTF-8?q?=20file=20refused=20says=20which=20setting=20and=20what=20to=20?= =?UTF-8?q?do,=20in=20the=20user's=20language?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit settings::read gives each refusal its kind beside its sentence: a file that cannot be opened, a line that is no setting or a value not of its kind, a path that is not whole, keep_audio out of its range — with the line and, when it is one of Kitokey's own, the key. words::refused says it in French and in English; the notification at a start, the sentence under a refused command and the one on Settings end with it. The sentence of settings.rs goes to the log (shell.settings_unread at a start, shell.command_failed under a command) and behind developer mode, never to the user (#783). Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/MANIFEST.yaml | 5 ++ modules/shell/scripts/e2e_window.py | 13 +++- modules/shell/src/autostart.rs | 2 +- modules/shell/src/main.rs | 31 ++++++--- modules/shell/src/settings.rs | 97 ++++++++++++++++++++++---- modules/shell/src/words.rs | 89 ++++++++++++++++++++---- modules/shell/tests/log.rs | 10 ++- modules/shell/tests/settings.rs | 68 +++++++++++++++++- modules/shell/tests/words.rs | 104 +++++++++++++++++++++++++--- 9 files changed, 364 insertions(+), 55 deletions(-) diff --git a/modules/shell/MANIFEST.yaml b/modules/shell/MANIFEST.yaml index 479e096f..f67e5e90 100644 --- a/modules/shell/MANIFEST.yaml +++ b/modules/shell/MANIFEST.yaml @@ -358,6 +358,11 @@ evidence: - pattern: '"message":"shell\.command_failed"' level: warning scenario: AB + # The window's run starts once on a settings file broken by hand: settings.rs's sentence goes to + # the log, the user is told which setting and what to do (#783). + - pattern: '"message":"shell\.settings_unread"' + level: warning + scenario: window # A failure of the page's own, thrown then rejected; any other kind of the page's is not provoked. - pattern: '^(?=.*"message":"shell\.page_failed")(?=.*"kind":"ScenarioI")' level: error diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index ae4f594e..e71f8a5d 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -7448,8 +7448,11 @@ def folder_field(): held = window.file.read_text() lines = [line for line in held.splitlines() if not line.startswith("keep_audio")] + ["keep_audio = 0"] broken = "\n".join(lines) + "\n" - refused = "Le réglage n’a pas été enregistré\u00a0: le fichier des réglages ne peut pas être lu\u00a0: corrigez-le, puis réessayez.".replace("\xa0", " ") # WebDriver's `.text` reads U+00A0 as a space - locked_said = "Le fichier des réglages ne peut pas être lu\u00a0: Kitokey ne l’écrit pas tant qu’il n’est pas corrigé.".replace("\xa0", " ") # WebDriver's `.text` reads U+00A0 as a space + # Which setting, on which line, and what to do (#783) — never settings.rs's own sentence. + # WebDriver's `.text` reads U+00A0 as a space. + which = lambda line: f"Ligne {line} : « keep_audio » vaut « always » ou un nombre de jours, de 1 à 36\u202f500. Corrigez-le." # noqa: E731 + refused = f"Le réglage n’a pas été enregistré : le fichier des réglages ne peut pas être lu. {which(len(lines))}" + locked_said = f"Le fichier des réglages ne peut pas être lu : Kitokey ne l’écrit pas tant qu’il n’est pas corrigé. {which(len(lines))}" unreadable = lambda: browser.find_element(By.ID, "settings-unreadable").text # noqa: E731 window.file.write_text(broken) changed(lambda: browser.find_element(By.ID, "reminder").click()) @@ -7465,6 +7468,9 @@ def folder_field(): lines = [line for line in held.splitlines() if not line.startswith("keep_audio")] + ["keep_audio = 0"] window.file.write_text("\n".join(lines) + "\n") raw = f'settings.toml, line {len(lines)}: keep_audio is "always" or a number of days' + # The file's line has moved with developer mode written: the sentences name the new one. + refused = f"Le réglage n’a pas été enregistré : le fichier des réglages ne peut pas être lu. {which(len(lines))}" + locked_said = f"Le fichier des réglages ne peut pas être lu : Kitokey ne l’écrit pas tant qu’il n’est pas corrigé. {which(len(lines))}" changed(lambda: browser.find_element(By.ID, "reminder").click()) said = not_saved() check("developer mode on, the raw text is under the sentence of the command that failed, without its path", said == f"{refused}\n{raw}", said) @@ -7624,7 +7630,8 @@ def log_message(self, *_): wait_for(browser, lambda b: b.find_elements(By.CSS_SELECTOR, "#settings .warn")) warned = browser.find_element(By.CSS_SELECTOR, "#settings .warn").text locked = browser.execute_script("return [...document.querySelectorAll('#settings input, #settings select')].every(e => e.disabled)") - check("a settings file that cannot be read is said so, and nothing can be changed", warned == "Le fichier des réglages ne peut pas être lu : Kitokey ne l’écrit pas tant qu’il n’est pas corrigé." and locked, warned) + which = "Ligne 3 : « keep_audio » vaut « always » ou un nombre de jours, de 1 à 36\u202f500. Corrigez-le." # U+00A0 read as a space + check("a settings file that cannot be read is said so, which setting and what to do, and nothing can be changed", warned == f"Le fichier des réglages ne peut pas être lu : Kitokey ne l’écrit pas tant qu’il n’est pas corrigé. {which}" and locked, warned) check("it is left as it was", window.file.read_text() == f'sessions = "{broken}"\nwelcomed = true\nkeep_audio = 0\n') # The shell itself refuses, not only the page. refused = browser.execute_async_script( diff --git a/modules/shell/src/autostart.rs b/modules/shell/src/autostart.rs index ad67b2de..554aab24 100644 --- a/modules/shell/src/autostart.rs +++ b/modules/shell/src/autostart.rs @@ -104,7 +104,7 @@ pub fn carry_over(before: &Path, entry: &Path) -> io::Result { /// At a start: the entry written when the settings say it never was, and that it was, kept in /// them. True when it was written now. A settings file that cannot be read writes nothing. pub fn first(entry: &Path, settings_file: &Path) -> io::Result { - let mut settings = settings::read(settings_file).map_err(|why| io::Error::new(io::ErrorKind::InvalidData, why))?; + let mut settings = settings::read(settings_file).map_err(|why| io::Error::new(io::ErrorKind::InvalidData, why.detail))?; if settings.autostart.is_some() { return Ok(false); } diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index dd5d0db2..31d121eb 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -200,10 +200,15 @@ impl Shell { /// Reads the settings file again — the user may have changed it by hand — and holds what it /// says; a file that cannot be read is said, by its name and not its path, and what was held /// stays. - fn reread(&self) -> Result { + fn reread(&self) -> Result { let read = settings::file().map_or_else( || Ok(Settings::default()), - |file| settings::read(&file).map_err(|why| settings::unnamed(&why, &file)), + |file| { + settings::read(&file).map_err(|why| settings::Unread { + detail: settings::unnamed(&why.detail, &file), + ..why + }) + }, ); if let Ok(settings) = &read { *self.settings.lock().unwrap() = settings.clone(); @@ -251,7 +256,7 @@ impl Shell { /// The settings read again for a command. fn read_or_told(&self) -> Result { - self.reread().map_err(|why| self.told(Failure::SettingsUnread, why)) + self.reread().map_err(|why| self.told(Failure::SettingsUnread(why.refused), why)) } /// The settings written for a command. @@ -562,7 +567,11 @@ fn main() { let refused = licence::refused(&licence, &sessions, seconds_now()); tracing::info!(licence = %answer, refused, "shell.licence_read"); if let Err(why) = read { - tell(app.handle(), &words::trouble(&Trouble::Settings(why), language)); + // The sentence of `settings.rs` to the log, by the file's name; the user is told which + // setting and what to do (#783). + let detail = settings::file().map_or_else(|| why.detail.clone(), |file| settings::unnamed(&why.detail, &file)); + tracing::warn!(%detail, "shell.settings_unread"); + tell(app.handle(), &words::trouble(&Trouble::Settings(why.refused), language)); } shortcut(app.handle()); offers(app.handle()); @@ -647,7 +656,7 @@ fn offer_recording(app: &AppHandle, application: String) { tracing::info!("shell.offer_off"); let shell = app.state::(); let _saving = shell.saving.lock().unwrap(); - let saved = shell.reread().and_then(|mut settings| { + let saved = shell.reread().map_err(|why| why.detail).and_then(|mut settings| { settings.offer = false; let file = settings::file().ok_or("this system names no folder for settings")?; settings::write(&file, &settings).map_err(|error| error.to_string())?; @@ -707,7 +716,7 @@ fn show_welcome(app: &AppHandle) { let shell = app.state::(); { let _saving = shell.saving.lock().unwrap(); - let written = shell.reread().and_then(|mut settings| { + let written = shell.reread().map_err(|why| why.detail).and_then(|mut settings| { settings.welcomed = true; let file = settings::file().ok_or("this system names no folder for settings")?; settings::write(&file, &settings).map_err(|error| error.to_string())?; @@ -1593,7 +1602,7 @@ fn models_offered(shell: State<'_, Shell>, name: Option) -> Result (settings, None), - Err(why) => (shell.settings(), Some(shell.told(Failure::SettingsLocked, why))), + Err(why) => (shell.settings(), Some(shell.told(Failure::SettingsLocked(why.refused), why))), }; let (mut chosen, gone, confidential) = match &name { Some(name) => { @@ -2247,7 +2256,7 @@ async fn settings_shown(app: AppHandle, shell: State<'_, Shell>) -> Result (settings, None), - Err(why) => (shell.settings(), Some(shell.told(Failure::SettingsLocked, why))), + Err(why) => (shell.settings(), Some(shell.told(Failure::SettingsLocked(why.refused), why))), }; let models = settings::whisper_models(&models_folder(), &settings) .into_iter() @@ -3077,8 +3086,8 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> let settings = match shell.reread() { Ok(settings) => settings, Err(why) => { - refused(why.clone()); - return tell(app, &words::trouble(&Trouble::Settings(why), shell.language())); + refused(why.detail); + return tell(app, &words::trouble(&Trouble::Settings(why.refused), shell.language())); } }; let named = settings.minutes_provider.clone().zip(settings.minutes_model.clone()); @@ -3639,7 +3648,7 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (F return Ok(()); } shell.transcripts_tried.lock().unwrap().insert(folder.clone(), Some(again.clone())); - let read = shell.reread().map_err(|why| (Failure::SettingsUnread, why))?; + let read = shell.reread().map_err(|why| (Failure::SettingsUnread(why.refused), why.detail))?; // The models this computer lists, as Settings name theirs: a Refaire… may pick Settings' own. let listed = settings::whisper_models(&models_folder(), &read); let settings = own(&read, &folder); diff --git a/modules/shell/src/settings.rs b/modules/shell/src/settings.rs index 64c4fbdb..7cf58b6b 100644 --- a/modules/shell/src/settings.rs +++ b/modules/shell/src/settings.rs @@ -249,31 +249,104 @@ struct Written { microphone_description: Option, } +/// What in a settings file Kitokey refuses, as the user is told it (#783): which setting, on which +/// line. A key is one of the file's own (`KEYS`), never what the user typed in its place. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Refused { + /// The file is there and cannot be opened: its permissions, a folder in its place. + Unopened, + /// A line that is not a setting as TOML writes one, or a setting whose value is not of its kind. + Unparsed { line: usize, key: Option<&'static str> }, + /// `sessions` or `model`: not a whole path. + NotWhole { key: &'static str, line: usize }, + /// `keep_audio`: neither "always" nor a number of days from 1 to 36,500. + KeepAudio { line: usize }, +} + +/// A settings file refused: what the user is told, and the sentence the log and developer mode +/// hold — which names the file by its whole path until `unnamed` is given it. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Unread { + pub refused: Refused, + pub detail: String, +} + +impl std::fmt::Display for Unread { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.detail) + } +} + +/// The keys a settings file may hold: those a refusal names. +const KEYS: [&str; 25] = [ + "reminder", + "sessions", + "transcript", + "after", + "model", + "engine", + "transcription_provider", + "transcription_model", + "transcription_agreed", + "minutes_provider", + "minutes_model", + "meeting_language", + "minutes_agreed", + "keep_audio", + "developer", + "offer", + "autostart", + "window", + "log", + "welcomed", + "folded", + "bar_at", + "language", + "microphone", + "microphone_description", +]; + /// Reads the settings. No file is no choice made: the defaults. A file that cannot be read as /// settings is said in one sentence — which file, which line, and what in it — and nothing of /// it is used. -pub fn read(path: &Path) -> Result { +pub fn read(path: &Path) -> Result { + let unread = |refused, detail| Unread { refused, detail }; let text = match fs::read_to_string(path) { Ok(text) => text, Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(Settings::default()), - Err(error) => return Err(format!("{} cannot be read ({error})", path.display())), + Err(error) => return Err(unread(Refused::Unopened, format!("{} cannot be read ({error})", path.display()))), }; // The line a place of the file is on: one more than the line ends before it. let line = |at: usize| text[..at.min(text.len())].matches('\n').count() + 1; + // The key a line sets, when it is one of the file's own. + let key = |at: usize| { + let start = text[..at.min(text.len())].rfind('\n').map_or(0, |end| end + 1); + let (named, _) = text[start..].split_once('=')?; + KEYS.into_iter().find(|key| *key == named.trim()) + }; let written: Written = toml::from_str(&text).map_err(|error| match error.span() { - Some(span) => format!("{}, line {}: {}", path.display(), line(span.start), error.message()), - None => format!("{}: {}", path.display(), error.message()), + Some(span) => unread( + Refused::Unparsed { + line: line(span.start), + key: key(span.start), + }, + format!("{}, line {}: {}", path.display(), line(span.start), error.message()), + ), + None => unread( + Refused::Unparsed { line: 1, key: None }, + format!("{}: {}", path.display(), error.message()), + ), })?; // A path written as people write it: from their home, with a tilde — or from the root. - let whole = |key: &str, what: &str, written: toml::Spanned| { + let whole = |key: &'static str, what: &str, written: toml::Spanned| { let at = line(written.span().start); let named = from_home(written.into_inner()); if named.is_absolute() { Ok(named) } else { - Err(format!( - "{}, line {at}: {key} is {what} whole path, from the root or from ~", - path.display() + Err(unread( + Refused::NotWhole { key, line: at }, + format!("{}, line {at}: {key} is {what} whole path, from the root or from ~", path.display()), )) } }; @@ -310,9 +383,9 @@ pub fn read(path: &Path) -> Result { toml::Value::String(always) if always == "always" => KeepAudio::Always, toml::Value::Integer(days) if (1..=36_500).contains(days) => KeepAudio::Days(*days as u32), _ => { - return Err(format!( - "{}, line {at}: keep_audio is \"always\" or a number of days", - path.display() + return Err(unread( + Refused::KeepAudio { line: at }, + format!("{}, line {at}: keep_audio is \"always\" or a number of days", path.display()), )); } }; @@ -345,7 +418,7 @@ pub fn write(path: &Path, settings: &Settings) -> io::Result<()> { let refused = |why: String| io::Error::new(io::ErrorKind::InvalidData, why); // Through a link, the file it points to. let path = &fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf()); - let before = read(path).map_err(refused)?; + let before = read(path).map_err(|why| refused(why.detail))?; let mut document = match fs::read_to_string(path) { Ok(text) => text.parse::().map_err(|error| refused(error.to_string()))?, Err(error) if error.kind() == io::ErrorKind::NotFound => DocumentMut::new(), diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index d7ee4afa..9c4bb071 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -4,6 +4,7 @@ use crate::{ recording::{Said, Source}, registry::Good, + settings::Refused, summarising::Cause, transcription::Made, trial::Left, @@ -1643,8 +1644,8 @@ pub fn window(language: Language) -> Window { pub enum Trouble { /// The program that records could not be started: what the system said of it. NoRecorder(String), - /// The settings file was not read: the sentence that says which file, and what in it. - Settings(String), + /// The settings file was not read: which setting, on which line (#783). + Settings(Refused), /// The desktop did not bind the global shortcut: what it said of it. Shortcut(String), /// The model a transcript is heard with is not on the machine: where it was looked for. @@ -1686,8 +1687,10 @@ pub enum Failure { FolderNotWhole, FolderUnmade, Autostart, - SettingsUnread, - SettingsLocked, + /// The settings file refused, which setting and where (#783): under the command it stopped, + /// and, `SettingsLocked`, alone on Settings. + SettingsUnread(Refused), + SettingsLocked(Refused), SettingsUnwritten, FolderNotOpened, KeyboardSettings, @@ -1742,11 +1745,25 @@ pub fn failure(failure: Failure, language: Language) -> String { (Failure::Autostart, French) => { "le démarrage à l’ouverture de session n’a pas pu être changé\u{a0}: vérifiez que votre dossier personnel peut être écrit." } - (Failure::SettingsUnread, English) => "the settings file cannot be read: correct it, then try again.", - (Failure::SettingsUnread, French) => "le fichier des réglages ne peut pas être lu\u{a0}: corrigez-le, puis réessayez.", - (Failure::SettingsLocked, English) => "The settings file cannot be read: Kitokey does not write over it until it is corrected.", - (Failure::SettingsLocked, French) => { - "Le fichier des réglages ne peut pas être lu\u{a0}: Kitokey ne l’écrit pas tant qu’il n’est pas corrigé." + // Shows: under a command the window refused, after « not saved: », then the refusal. + // When: the settings file cannot be read as settings. At most: no limit. Placeholders: {} the refusal. + (Failure::SettingsUnread(why), English) => return format!("the settings file cannot be read. {}", refused(&why, language)), + (Failure::SettingsUnread(why), French) => { + return format!("le fichier des réglages ne peut pas être lu. {}", refused(&why, language)); + } + // Shows: alone on Settings, then the refusal. When: the settings file cannot be read. + // At most: no limit. Placeholders: {} the refusal. + (Failure::SettingsLocked(why), English) => { + return format!( + "The settings file cannot be read: Kitokey does not write over it until it is corrected. {}", + refused(&why, language) + ); + } + (Failure::SettingsLocked(why), French) => { + return format!( + "Le fichier des réglages ne peut pas être lu\u{a0}: Kitokey ne l’écrit pas tant qu’il n’est pas corrigé. {}", + refused(&why, language) + ); } (Failure::SettingsUnwritten, English) => "the settings file could not be written: check that the disk has room, then try again.", (Failure::SettingsUnwritten, French) => { @@ -2025,6 +2042,49 @@ pub fn cause(cause: Cause, language: Language) -> &'static str { } } +/// What the user is told of a settings file refused (#783): which setting, on which line, and the +/// gesture — never `settings.rs`'s own sentence, which stays for the log and developer mode. +// Shows: after the sentence of a notification or a page that says the file was not read. +// When: `settings::read` refuses the file. At most: no limit. Placeholders: {line} the line, {key} +// the setting's name as the file writes it — one of Kitokey's own, never what the user typed. +pub fn refused(refused: &Refused, language: Language) -> String { + use Language::{English, French}; + match (*refused, language) { + (Refused::Unopened, English) => "Kitokey cannot open its settings file: check that you may read it.".into(), + (Refused::Unopened, French) => "Kitokey ne peut pas ouvrir son fichier de réglages\u{a0}: vérifiez que vous pouvez le lire.".into(), + (Refused::Unparsed { line, key: Some(key) }, English) => { + format!("Line {line}: Kitokey does not understand the value of “{key}”. Correct it, or remove the line.") + } + (Refused::Unparsed { line, key: Some(key) }, French) => { + format!("Ligne {line}\u{a0}: Kitokey ne comprend pas la valeur de «\u{a0}{key}\u{a0}». Corrigez-la, ou supprimez la ligne.") + } + (Refused::Unparsed { line, key: None }, English) => { + format!("Line {line} is not written as a setting. Correct it, or remove it.") + } + (Refused::Unparsed { line, key: None }, French) => { + format!("La ligne {line} n’est pas écrite comme un réglage. Corrigez-la, ou supprimez-la.") + } + (Refused::NotWhole { key: "model", line }, English) => { + format!("Line {line}: “model” gives a file’s whole path, from / or from ~. Correct it.") + } + (Refused::NotWhole { key: "model", line }, French) => { + format!("Ligne {line}\u{a0}: «\u{a0}model\u{a0}» donne le chemin complet d’un fichier, depuis / ou depuis ~. Corrigez-le.") + } + (Refused::NotWhole { key, line }, English) => { + format!("Line {line}: “{key}” gives a folder’s whole path, from / or from ~. Correct it.") + } + (Refused::NotWhole { key, line }, French) => { + format!("Ligne {line}\u{a0}: «\u{a0}{key}\u{a0}» donne le chemin complet d’un dossier, depuis / ou depuis ~. Corrigez-le.") + } + (Refused::KeepAudio { line }, English) => { + format!("Line {line}: “keep_audio” is “always” or a number of days, from 1 to 36,500. Correct it.") + } + (Refused::KeepAudio { line }, French) => format!( + "Ligne {line}\u{a0}: «\u{a0}keep_audio\u{a0}» vaut «\u{a0}always\u{a0}» ou un nombre de jours, de 1 à 36\u{202f}500. Corrigez-le." + ), + } +} + /// What the user is told of a trouble: what it is, and what still works. Where the user has /// something to put right — the settings file's line, the place the model goes —, it says where; /// never what a program or the system said (D29). @@ -2040,18 +2100,23 @@ pub fn trouble(trouble: &Trouble, language: Language) -> Notice { "Kitokey ne peut pas enregistrer", "Son programme d’enregistrement n’a pas pu démarrer. Réinstaller Kitokey le remet en place.", ), + // Shows: a notification at a start, its body then the refusal. When: the settings file cannot + // be read. At most: no limit. Placeholders: {} the refusal. (Trouble::Settings(why), English) => { return said( "Your settings were not read", - format!("Kitokey runs with its defaults until the file is corrected: {}.", detail(why)), + format!( + "Kitokey runs with its defaults until the file is corrected. {}", + refused(why, language) + ), ); } (Trouble::Settings(why), French) => { return said( "Vos réglages n’ont pas été lus", format!( - "Kitokey fonctionne avec ses réglages par défaut tant que le fichier n’est pas corrigé\u{a0}: {}.", - detail(why) + "Kitokey fonctionne avec ses réglages par défaut tant que le fichier n’est pas corrigé. {}", + refused(why, language) ), ); } diff --git a/modules/shell/tests/log.rs b/modules/shell/tests/log.rs index 304a6fda..1e6d309c 100644 --- a/modules/shell/tests/log.rs +++ b/modules/shell/tests/log.rs @@ -122,10 +122,14 @@ exit 1"#, // A command refused by a settings file broken by hand: `settings::read` names its whole path. let broken = folder.path().join("settings.toml"); fs::write(&broken, "keep_audio = 0\n").unwrap(); - let raw = settings::read(&broken).unwrap_err(); + let refused = settings::read(&broken).unwrap_err(); + let raw = refused.detail.clone(); assert!(raw.contains(&*folder.path().to_string_lossy()), "{raw}"); let unread = "settings.toml, line 1: keep_audio is \"always\" or a number of days"; - assert_eq!(log::command_failed(&Failure::SettingsUnread, &raw, Some(&broken)), unread); + assert_eq!( + log::command_failed(&Failure::SettingsUnread(refused.refused), &raw, Some(&broken)), + unread + ); let text = String::from_utf8(kept.0.lock().unwrap().clone()).unwrap(); let lines: Vec = text.lines().map(|line| serde_json::from_str(line).unwrap()).collect(); @@ -148,7 +152,7 @@ exit 1"#, let refused = lines.iter().find(|line| line["message"] == "shell.command_failed").unwrap(); assert_eq!( (&refused["failure"], &refused["detail"]), - (&"SettingsUnread".into(), &unread.into()), + (&"SettingsUnread(KeepAudio { line: 1 })".into(), &unread.into()), "{text}" ); let recorded = fs::read_to_string(folder.path().join("recording.trace")).unwrap(); diff --git a/modules/shell/tests/settings.rs b/modules/shell/tests/settings.rs index f8a9aef2..f4aff409 100644 --- a/modules/shell/tests/settings.rs +++ b/modules/shell/tests/settings.rs @@ -11,7 +11,7 @@ fn written(text: &str) -> Result { let folder = tempfile::tempdir().unwrap(); let path = folder.path().join("settings.toml"); fs::write(&path, text).unwrap(); - read(&path).map_err(|said| said.replace(&path.display().to_string(), "")) + read(&path).map_err(|unread| unread.detail.replace(&path.display().to_string(), "")) } #[test] @@ -74,7 +74,69 @@ fn a_file_that_is_not_settings_is_said_in_one_sentence_and_not_used() { } // A file that is there and cannot be read is said too, not taken for no file. let folder = tempfile::tempdir().unwrap(); - assert!(read(folder.path()).unwrap_err().contains("cannot be read")); + assert!(read(folder.path()).unwrap_err().detail.contains("cannot be read")); +} + +/// What the user is told of a file refused (#783) is which setting, on which line: the sentence +/// above stays for the log and developer mode. A key is named only when it is one of Kitokey's — +/// never what the user typed in its place. +#[test] +fn a_file_refused_names_the_setting_and_its_line() { + use kitokey_shell::settings::Refused; + let refused = |text: &str| { + let folder = tempfile::tempdir().unwrap(); + let path = folder.path().join("settings.toml"); + fs::write(&path, text).unwrap(); + read(&path).unwrap_err().refused + }; + for (text, expected) in [ + ("keep_audio = 0\n", Refused::KeepAudio { line: 1 }), + ("reminder = false\nkeep_audio = \"never\"\n", Refused::KeepAudio { line: 2 }), + ( + "reminder = false\nsessions = \"Kitokey\"\n", + Refused::NotWhole { key: "sessions", line: 2 }, + ), + ("model = \"ggml.bin\"\n", Refused::NotWhole { key: "model", line: 1 }), + ( + "# mine\ndeveloper = \"yes\"\n", + Refused::Unparsed { + line: 2, + key: Some("developer"), + }, + ), + ( + "after = \"sometimes\"\n", + Refused::Unparsed { + line: 1, + key: Some("after"), + }, + ), + ( + " bar_at = [1]\n", + Refused::Unparsed { + line: 1, + key: Some("bar_at"), + }, + ), + ( + "reminder = false\nreminder = true\n", + Refused::Unparsed { + line: 2, + key: Some("reminder"), + }, + ), + ("this is not TOML\n", Refused::Unparsed { line: 1, key: None }), + ("reminder = true\n= 3\n", Refused::Unparsed { line: 2, key: None }), + ( + "# é\r\nreminder = true\r\n\r\n[sessions]\r\nx = 1\r\n", + Refused::Unparsed { line: 4, key: None }, + ), + ("my secret = 3\n", Refused::Unparsed { line: 1, key: None }), + ] { + assert_eq!(refused(text), expected, "{text:?}"); + } + let folder = tempfile::tempdir().unwrap(); + assert_eq!(read(folder.path()).unwrap_err().refused, Refused::Unopened); } #[test] @@ -617,7 +679,7 @@ fn a_failure_of_the_settings_file_names_it_without_its_path_even_through_a_link( let folder = tempfile::tempdir().unwrap(); let file = folder.path().join("settings.toml"); fs::write(&file, "keep_audio = 0\n").unwrap(); - let said = read(&file).unwrap_err(); + let said = read(&file).unwrap_err().detail; assert_eq!( unnamed(&said, &file), "settings.toml, line 1: keep_audio is \"always\" or a number of days" diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index 36f8cedd..e6a0150f 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -4,6 +4,7 @@ use std::path::PathBuf; use kitokey_shell::{ recording::{Said, Source}, + settings::Refused, words::{self, Failure, Language, Notice, Refusal}, }; @@ -308,7 +309,10 @@ fn the_menu_and_the_shells_own_troubles_are_said_in_both_languages() { for language in BOTH { for trouble in [ Trouble::NoRecorder(String::new()), - Trouble::Settings("settings.toml, line 3: invalid boolean".into()), + Trouble::Settings(Refused::Unparsed { + line: 3, + key: Some("reminder"), + }), Trouble::Shortcut(String::new()), Trouble::NoModel("/kitokey/models/ggml.bin".into()), Trouble::NoTranscriber(String::new()), @@ -319,8 +323,12 @@ fn the_menu_and_the_shells_own_troubles_are_said_in_both_languages() { "{title} — {body}" ); } - let settings = words::trouble(&Trouble::Settings("settings.toml, line 3: invalid boolean".into()), language).body; - assert!(settings.contains("settings.toml, line 3: invalid boolean"), "{settings}"); + let unparsed = Refused::Unparsed { + line: 3, + key: Some("reminder"), + }; + let settings = words::trouble(&Trouble::Settings(unparsed), language).body; + assert!(settings.ends_with(&words::refused(&unparsed, language)), "{settings}"); let model = words::trouble(&Trouble::NoModel("/kitokey/models/ggml.bin".into()), language).body; assert!(model.contains("/kitokey/models/ggml.bin"), "{model}"); } @@ -328,10 +336,8 @@ fn the_menu_and_the_shells_own_troubles_are_said_in_both_languages() { let body = |trouble, language| words::trouble(&trouble, language).body; assert!(body(Trouble::NoRecorder(String::new()), Language::English).ends_with("Installing Kitokey again puts it back.")); assert!(body(Trouble::NoRecorder(String::new()), Language::French).ends_with("Réinstaller Kitokey le remet en place.")); - assert!(body(Trouble::Settings(String::new()), Language::English).contains("runs with its defaults")); + assert!(body(Trouble::Settings(Refused::Unopened), Language::English).contains("runs with its defaults")); assert!(body(Trouble::Shortcut(String::new()), Language::French).contains("permet toujours de démarrer")); - // What the settings file holds wrong comes out on one line. - assert!(body(Trouble::Settings("line one\n\tline two".into()), Language::English).contains("line one line two")); } #[test] @@ -1533,18 +1539,25 @@ fn the_settings_files_path_stays_out_of_what_a_command_keeps_of_a_failure() { #[test] fn a_settings_file_that_cannot_be_read_is_said_whole_its_raw_text_under_it_only_in_developer_mode() { let raw = "settings.toml, line 1: keep_audio is \"always\" or a number of days"; - let page = |language, developer| serde_json::to_value(words::told(Failure::SettingsLocked, raw, language, developer)).unwrap(); + let locked = Failure::SettingsLocked(Refused::KeepAudio { line: 1 }); + let page = |language, developer| serde_json::to_value(words::told(locked, raw, language, developer)).unwrap(); assert_eq!( page(Language::French, false), - "Le fichier des réglages ne peut pas être lu\u{a0}: Kitokey ne l’écrit pas tant qu’il n’est pas corrigé." + "Le fichier des réglages ne peut pas être lu\u{a0}: Kitokey ne l’écrit pas tant qu’il n’est pas corrigé. \ + Ligne 1\u{a0}: «\u{a0}keep_audio\u{a0}» vaut «\u{a0}always\u{a0}» ou un nombre de jours, de 1 à 36\u{202f}500. Corrigez-le." ); assert_eq!( page(Language::English, false), - "The settings file cannot be read: Kitokey does not write over it until it is corrected." + "The settings file cannot be read: Kitokey does not write over it until it is corrected. \ + Line 1: “keep_audio” is “always” or a number of days, from 1 to 36,500. Correct it." ); assert_eq!( page(Language::English, true), - format!("The settings file cannot be read: Kitokey does not write over it until it is corrected.\n{raw}").as_str() + format!( + "The settings file cannot be read: Kitokey does not write over it until it is corrected. \ + Line 1: “keep_audio” is “always” or a number of days, from 1 to 36,500. Correct it.\n{raw}" + ) + .as_str() ); } @@ -1741,3 +1754,74 @@ fn a_notice_of_minutes_failed_by_the_meetings_own_model_says_what_its_page_says( } } } + +/// A settings file refused is said in the user's language: which setting, on which line, and what +/// to do — never `settings.rs`'s own sentence, which stays for the log and behind « Développeur » +/// (#783, D94). The window says it under each command it refuses, and the notification at a start. +#[test] +fn a_settings_file_refused_says_which_setting_and_what_to_do_in_both_languages() { + use words::Trouble; + let said = [ + ( + Refused::Unopened, + "Kitokey cannot open its settings file: check that you may read it.", + "Kitokey ne peut pas ouvrir son fichier de réglages\u{a0}: vérifiez que vous pouvez le lire.", + ), + ( + Refused::Unparsed { + line: 4, + key: Some("after"), + }, + "Line 4: Kitokey does not understand the value of “after”. Correct it, or remove the line.", + "Ligne 4\u{a0}: Kitokey ne comprend pas la valeur de «\u{a0}after\u{a0}». Corrigez-la, ou supprimez la ligne.", + ), + ( + Refused::Unparsed { line: 4, key: None }, + "Line 4 is not written as a setting. Correct it, or remove it.", + "La ligne 4 n’est pas écrite comme un réglage. Corrigez-la, ou supprimez-la.", + ), + ( + Refused::NotWhole { key: "sessions", line: 4 }, + "Line 4: “sessions” gives a folder’s whole path, from / or from ~. Correct it.", + "Ligne 4\u{a0}: «\u{a0}sessions\u{a0}» donne le chemin complet d’un dossier, depuis / ou depuis ~. Corrigez-le.", + ), + ( + Refused::NotWhole { key: "model", line: 4 }, + "Line 4: “model” gives a file’s whole path, from / or from ~. Correct it.", + "Ligne 4\u{a0}: «\u{a0}model\u{a0}» donne le chemin complet d’un fichier, depuis / ou depuis ~. Corrigez-le.", + ), + ( + Refused::KeepAudio { line: 4 }, + "Line 4: “keep_audio” is “always” or a number of days, from 1 to 36,500. Correct it.", + "Ligne 4\u{a0}: «\u{a0}keep_audio\u{a0}» vaut «\u{a0}always\u{a0}» ou un nombre de jours, de 1 à 36\u{202f}500. Corrigez-le.", + ), + ]; + // Each refusal `settings.rs` makes is said: one added fails to compile here until it is named. + for (refused, ..) in &said { + match refused { + Refused::Unopened | Refused::Unparsed { .. } | Refused::NotWhole { .. } | Refused::KeepAudio { .. } => {} + } + } + let raw = "settings.toml, line 4: keep_audio is \"always\" or a number of days"; + for (refused, english, french) in said { + for (language, sentence) in [(Language::English, english), (Language::French, french)] { + assert_eq!(words::refused(&refused, language), sentence); + // The notification at a start: what still works, then the setting and the gesture. + let Notice { title, body } = words::trouble(&Trouble::Settings(refused), language); + assert!(title.chars().count() <= 50 && body.ends_with(sentence), "{title} — {body}"); + assert!( + body.starts_with(["Kitokey runs with its defaults", "Kitokey fonctionne avec ses réglages par défaut"][language as usize]), + "{body}" + ); + // Under a command the window refused: its sentence, the refusal after it, the raw text + // only in developer mode. + for failure in [Failure::SettingsUnread(refused), Failure::SettingsLocked(refused)] { + let shown = |developer| serde_json::to_value(words::told(failure, raw, language, developer)).unwrap(); + let shown = (shown(false), shown(true)); + assert!(shown.0.as_str().unwrap().ends_with(sentence), "{shown:?}"); + assert!(!shown.0.as_str().unwrap().contains(raw), "{shown:?}"); + assert_eq!(shown.1.as_str().unwrap(), format!("{}\n{raw}", shown.0.as_str().unwrap())); + } + } + } +} From 46786e688e9703cfc39af5bb91a96d0fb33e446f Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:43:09 +0100 Subject: [PATCH 05/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20the=20settings?= =?UTF-8?q?'=20log=20line=20declared=20under=20the=20window's=20K?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The window's block that starts on a settings file broken by hand is K; the manifest names its scenarios by the e2e's letters. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/MANIFEST.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/shell/MANIFEST.yaml b/modules/shell/MANIFEST.yaml index f67e5e90..d45920c2 100644 --- a/modules/shell/MANIFEST.yaml +++ b/modules/shell/MANIFEST.yaml @@ -358,11 +358,11 @@ evidence: - pattern: '"message":"shell\.command_failed"' level: warning scenario: AB - # The window's run starts once on a settings file broken by hand: settings.rs's sentence goes to + # The window's K starts once on a settings file broken by hand: settings.rs's sentence goes to # the log, the user is told which setting and what to do (#783). - pattern: '"message":"shell\.settings_unread"' level: warning - scenario: window + scenario: K # A failure of the page's own, thrown then rejected; any other kind of the page's is not provoked. - pattern: '^(?=.*"message":"shell\.page_failed")(?=.*"kind":"ScenarioI")' level: error From 2ceff1c82a1ff23a8360dbe8c5f58de7a810cb89 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:49:03 +0100 Subject: [PATCH 06/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20a=20comment's?= =?UTF-8?q?=20placeholders=20read=20against=20all=20it=20covers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A field's comment covers every place of its array: its placeholders are read against all of them, not against each place, which refused agree_context's « {} » found only in its second sentence. Each place is still compared in both languages. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/tests/words.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index e8a832d8..e2ea4003 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1550,7 +1550,9 @@ fn every_sentence_carries_its_comment() { fn a_sentence_has_the_same_placeholders_in_both_languages_and_its_comment_names_them() { use std::collections::BTreeMap; let mut groups: BTreeMap; 2]> = BTreeMap::new(); - let mut named: BTreeMap = BTreeMap::new(); + // What one comment covers — a whole field, each place of an array, or the arms after it — and + // the placeholders it says, against those its sentences hold. + let mut covered: BTreeMap, String)> = BTreeMap::new(); for sentence in sentences() { let Some(french) = sentence.french else { continue }; let group = match (&sentence.field, &sentence.comment) { @@ -1558,9 +1560,15 @@ fn a_sentence_has_the_same_placeholders_in_both_languages_and_its_comment_names_ (None, Some((number, _))) => format!("{} comment {number}", sentence.function), (None, None) => sentence.function.clone(), }; - groups.entry(group.clone()).or_default()[french as usize].extend(placeholders(&sentence.text)); - if let Some((_, comment)) = &sentence.comment { - named.insert(group, comment[comment.find("Placeholders:").unwrap()..].to_string()); + groups.entry(group).or_default()[french as usize].extend(placeholders(&sentence.text)); + if let Some((number, comment)) = &sentence.comment { + let key = match &sentence.field { + Some((field, _)) => format!("{}.{field}", sentence.function), + None => format!("{} comment {number}", sentence.function), + }; + let entry = covered.entry(key).or_default(); + entry.0.extend(placeholders(&sentence.text)); + entry.1 = comment[comment.find("Placeholders:").unwrap()..].to_string(); } } let mut wrong = Vec::new(); @@ -1570,12 +1578,11 @@ fn a_sentence_has_the_same_placeholders_in_both_languages_and_its_comment_names_ if english != french { wrong.push(format!("{group}: in both languages")); } - if let Some(named) = named.get(&group) { - let said: std::collections::BTreeSet<_> = english.iter().chain(&french).cloned().collect(); - let listed: std::collections::BTreeSet<_> = placeholders(named).into_iter().collect(); - if said != listed { - wrong.push(format!("{group}: in its comment")); - } + } + for (key, (said, named)) in covered { + let listed: std::collections::BTreeSet<_> = placeholders(&named).into_iter().collect(); + if said != listed { + wrong.push(format!("{key}: in its comment")); } } still_wrong("placeholders", wrong); From 31a3f0ed9b95cb36978847cd24f01c177e776510 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:51:03 +0100 Subject: [PATCH 07/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20a=20locale=20c?= =?UTF-8?q?ompared=20and=20a=20target=20named=20are=20no=20sentence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reader counted Language::of's "fr" and cfg!'s "linux" as sentences waiting for their comment: literals after eq_ignore_ascii_case and target_os are the code's, as an expect's are. WITHOUT_COMMENT: 602. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/tests/words.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index e2ea4003..d707dde4 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1229,9 +1229,9 @@ fn every_french_sentence_has_its_spaces_before_the_tall_signs() { /// list only shrinks, and a sentence put right never covers another written wrong. const STILL_WRONG: &str = include_str!("words_still_wrong.txt"); -/// The sentences still without their comment, counted: 604 keys would be three review budgets. +/// The sentences still without their comment, counted: 602 keys would be three review budgets. /// The number only goes down, as the list does. -const WITHOUT_COMMENT: usize = 604; +const WITHOUT_COMMENT: usize = 602; /// A sentence of `src/words.rs`, as the file arranges it. #[derive(Debug)] @@ -1395,7 +1395,8 @@ fn sentences() -> Vec { let shown = matches!(function.as_str(), "window" | "menu"); let said = keyword == "fn" && !NOT_SAID.contains(&function.as_str()) - && word_before != "expect" + // An `expect`'s words, a locale compared, a target named: for the code, no sentence. + && !matches!(word_before.as_str(), "expect" | "eq_ignore_ascii_case" | "target_os") && !(shown && field == "locale") && strip_placeholders(&text).chars().any(char::is_alphabetic); if said { From 129f6372a84592caf9ce534618483e1c262a7c7a Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:54:23 +0100 Subject: [PATCH 08/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20only=20the=20l?= =?UTF-8?q?iteral=20right=20after=20a=20word=20of=20the=20code=20is=20the?= =?UTF-8?q?=20code's?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reader kept expect, eq_ignore_ascii_case or target_os as the word before every literal up to the next identifier: a sentence after the code's literal — cfg!(target_os = "linux") { "Can't open it" } — escaped every rule (the verifier's probes). It is now forgotten after each literal; the probes are tests of the reader. words.rs had no such sentence: WITHOUT_COMMENT and the list do not move. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/tests/words.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index d707dde4..0da6eb07 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1283,8 +1283,12 @@ fn context(comment: &str) -> bool { /// Every sentence of `src/words.rs`: each string literal of a function, its escapes read as the /// compiler reads them, with the comment that covers it. fn sentences() -> Vec { - let path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/words.rs"); - let source: Vec = std::fs::read_to_string(path).unwrap().chars().collect(); + sentences_in(&std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/src/words.rs")).unwrap()) +} + +/// The sentences of a source written as `words.rs` is. +fn sentences_in(source: &str) -> Vec { + let source: Vec = source.chars().collect(); let mut found = Vec::new(); let mut fields = std::collections::HashMap::new(); let (mut function, mut structure, mut keyword, mut word_before) = (String::new(), String::new(), String::new(), String::new()); @@ -1411,6 +1415,8 @@ fn sentences() -> Vec { }); place += 1; } + // Only the literal right after a word of the code is the code's: the next one is read. + word_before.clear(); } found } @@ -1492,6 +1498,27 @@ fn still_wrong(rule: &str, found: Vec) { ); } +/// Only the literal right after `expect`, `eq_ignore_ascii_case` or `target_os` is the code's: a +/// sentence after it is still read (the verifier's probes on #812). +#[test] +fn a_literal_of_the_code_leaves_the_sentence_after_it_read() { + let read = |source: &str| sentences_in(source).into_iter().map(|sentence| sentence.text).collect::>(); + assert_eq!( + read("fn opened() -> &'static str {\n if cfg!(target_os = \"linux\") { \"Can't open it on Linux\" } else { \"Open it\" }\n}\n"), + ["Can't open it on Linux", "Open it"] + ); + assert_eq!( + read( + "fn said(code: &str) -> &'static str {\n if code.eq_ignore_ascii_case(\"fr\") { \"Le fournisseur\" } else { \"The provider\" }\n}\n" + ), + ["Le fournisseur", "The provider"] + ); + assert_eq!( + read("fn told(x: Option) -> &'static str {\n x.expect(\"always there\");\n \"A sentence\"\n}\n"), + ["A sentence"] + ); +} + #[test] fn the_sentences_are_read_as_the_file_arranges_them() { let sentences = sentences(); From 301716f9aa26517218875b012ddde64645eea143 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:59:20 +0100 Subject: [PATCH 09/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20#783's=20sente?= =?UTF-8?q?nces=20held=20by=20the=20voice=20guide's=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With #812 merged in: words::refused's comment is inside its body, where a comment covers what follows it; trouble() and failure() carry a comment after their settings' arms, so that it covers the arms it says. The folder and the model not whole are two refusals, each with its own gesture — a folder's whole path, a file's —, no longer one with a key; French says « chemin entier » as FolderNotWhole already does. WITHOUT_COMMENT: 582. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/settings.rs | 14 ++++++++------ modules/shell/src/words.rs | 29 ++++++++++++++++++----------- modules/shell/tests/settings.rs | 7 ++----- modules/shell/tests/words.rs | 16 ++++++++++------ 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/modules/shell/src/settings.rs b/modules/shell/src/settings.rs index 7cf58b6b..f3d26ec3 100644 --- a/modules/shell/src/settings.rs +++ b/modules/shell/src/settings.rs @@ -257,8 +257,10 @@ pub enum Refused { Unopened, /// A line that is not a setting as TOML writes one, or a setting whose value is not of its kind. Unparsed { line: usize, key: Option<&'static str> }, - /// `sessions` or `model`: not a whole path. - NotWhole { key: &'static str, line: usize }, + /// `sessions`: not a folder's whole path. + SessionsNotWhole { line: usize }, + /// `model`: not a file's whole path. + ModelNotWhole { line: usize }, /// `keep_audio`: neither "always" nor a number of days from 1 to 36,500. KeepAudio { line: usize }, } @@ -338,14 +340,14 @@ pub fn read(path: &Path) -> Result { ), })?; // A path written as people write it: from their home, with a tilde — or from the root. - let whole = |key: &'static str, what: &str, written: toml::Spanned| { + let whole = |key: &str, what: &str, refused: fn(usize) -> Refused, written: toml::Spanned| { let at = line(written.span().start); let named = from_home(written.into_inner()); if named.is_absolute() { Ok(named) } else { Err(unread( - Refused::NotWhole { key, line: at }, + refused(at), format!("{}, line {at}: {key} is {what} whole path, from the root or from ~", path.display()), )) } @@ -391,10 +393,10 @@ pub fn read(path: &Path) -> Result { }; } if let Some(sessions) = written.sessions { - settings.sessions = whole("sessions", "the folder's", sessions)?; + settings.sessions = whole("sessions", "the folder's", |line| Refused::SessionsNotWhole { line }, sessions)?; } if let Some(model) = written.model { - settings.model = whole("model", "the file's", model)?; + settings.model = whole("model", "the file's", |line| Refused::ModelNotWhole { line }, model)?; } Ok(settings) } diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 9c4bb071..103d5b70 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -1765,6 +1765,9 @@ pub fn failure(failure: Failure, language: Language) -> String { refused(&why, language) ); } + // Shows: under a command the window refused, after « not saved: », or alone where the page + // shows it (the folder, the keyboard settings). When: the command named by its arm fails. + // At most: no limit. Placeholders: none. (Failure::SettingsUnwritten, English) => "the settings file could not be written: check that the disk has room, then try again.", (Failure::SettingsUnwritten, French) => { "le fichier des réglages n’a pas pu être écrit\u{a0}: vérifiez qu’il reste de la place, puis réessayez." @@ -2044,11 +2047,11 @@ pub fn cause(cause: Cause, language: Language) -> &'static str { /// What the user is told of a settings file refused (#783): which setting, on which line, and the /// gesture — never `settings.rs`'s own sentence, which stays for the log and developer mode. -// Shows: after the sentence of a notification or a page that says the file was not read. -// When: `settings::read` refuses the file. At most: no limit. Placeholders: {line} the line, {key} -// the setting's name as the file writes it — one of Kitokey's own, never what the user typed. pub fn refused(refused: &Refused, language: Language) -> String { use Language::{English, French}; + // Shows: after the sentence of a notification or a page that says the file was not read. + // When: `settings::read` refuses the file. At most: no limit. Placeholders: {line} the line, + // {key} the setting's name as the file writes it — one of Kitokey's own, never what the user typed. match (*refused, language) { (Refused::Unopened, English) => "Kitokey cannot open its settings file: check that you may read it.".into(), (Refused::Unopened, French) => "Kitokey ne peut pas ouvrir son fichier de réglages\u{a0}: vérifiez que vous pouvez le lire.".into(), @@ -2064,17 +2067,17 @@ pub fn refused(refused: &Refused, language: Language) -> String { (Refused::Unparsed { line, key: None }, French) => { format!("La ligne {line} n’est pas écrite comme un réglage. Corrigez-la, ou supprimez-la.") } - (Refused::NotWhole { key: "model", line }, English) => { - format!("Line {line}: “model” gives a file’s whole path, from / or from ~. Correct it.") + (Refused::SessionsNotWhole { line }, English) => { + format!("Line {line}: “sessions” gives a folder’s whole path, from / or from ~. Correct it.") } - (Refused::NotWhole { key: "model", line }, French) => { - format!("Ligne {line}\u{a0}: «\u{a0}model\u{a0}» donne le chemin complet d’un fichier, depuis / ou depuis ~. Corrigez-le.") + (Refused::SessionsNotWhole { line }, French) => { + format!("Ligne {line}\u{a0}: «\u{a0}sessions\u{a0}» donne le chemin entier d’un dossier, depuis / ou depuis ~. Corrigez-le.") } - (Refused::NotWhole { key, line }, English) => { - format!("Line {line}: “{key}” gives a folder’s whole path, from / or from ~. Correct it.") + (Refused::ModelNotWhole { line }, English) => { + format!("Line {line}: “model” gives a file’s whole path, from / or from ~. Correct it.") } - (Refused::NotWhole { key, line }, French) => { - format!("Ligne {line}\u{a0}: «\u{a0}{key}\u{a0}» donne le chemin complet d’un dossier, depuis / ou depuis ~. Corrigez-le.") + (Refused::ModelNotWhole { line }, French) => { + format!("Ligne {line}\u{a0}: «\u{a0}model\u{a0}» donne le chemin entier d’un fichier, depuis / ou depuis ~. Corrigez-le.") } (Refused::KeepAudio { line }, English) => { format!("Line {line}: “keep_audio” is “always” or a number of days, from 1 to 36,500. Correct it.") @@ -2120,6 +2123,10 @@ pub fn trouble(trouble: &Trouble, language: Language) -> Notice { ), ); } + // Shows: a notification, its title then its body. When: the shortcut is not bound, the model or + // the program that hears is missing, the meetings' folder cannot be written, or no recording is + // there to transcribe. At most: the title, 50 characters; the body, no limit. Placeholders: + // {at} where the model is looked for, or the folder. (Trouble::Shortcut(_), English) => ( "The keyboard shortcut is not set", "The menu of Kitokey’s icon still starts and stops a recording.", diff --git a/modules/shell/tests/settings.rs b/modules/shell/tests/settings.rs index f4aff409..6e4e8a5d 100644 --- a/modules/shell/tests/settings.rs +++ b/modules/shell/tests/settings.rs @@ -92,11 +92,8 @@ fn a_file_refused_names_the_setting_and_its_line() { for (text, expected) in [ ("keep_audio = 0\n", Refused::KeepAudio { line: 1 }), ("reminder = false\nkeep_audio = \"never\"\n", Refused::KeepAudio { line: 2 }), - ( - "reminder = false\nsessions = \"Kitokey\"\n", - Refused::NotWhole { key: "sessions", line: 2 }, - ), - ("model = \"ggml.bin\"\n", Refused::NotWhole { key: "model", line: 1 }), + ("reminder = false\nsessions = \"Kitokey\"\n", Refused::SessionsNotWhole { line: 2 }), + ("model = \"ggml.bin\"\n", Refused::ModelNotWhole { line: 1 }), ( "# mine\ndeveloper = \"yes\"\n", Refused::Unparsed { diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index df08c61f..c84cd56a 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1237,7 +1237,7 @@ const STILL_WRONG: &str = include_str!("words_still_wrong.txt"); /// The sentences still without their comment, counted: 602 keys would be three review budgets. /// The number only goes down, as the list does. -const WITHOUT_COMMENT: usize = 602; +const WITHOUT_COMMENT: usize = 582; /// A sentence of `src/words.rs`, as the file arranges it. #[derive(Debug)] @@ -2258,14 +2258,14 @@ fn a_settings_file_refused_says_which_setting_and_what_to_do_in_both_languages() "La ligne 4 n’est pas écrite comme un réglage. Corrigez-la, ou supprimez-la.", ), ( - Refused::NotWhole { key: "sessions", line: 4 }, + Refused::SessionsNotWhole { line: 4 }, "Line 4: “sessions” gives a folder’s whole path, from / or from ~. Correct it.", - "Ligne 4\u{a0}: «\u{a0}sessions\u{a0}» donne le chemin complet d’un dossier, depuis / ou depuis ~. Corrigez-le.", + "Ligne 4\u{a0}: «\u{a0}sessions\u{a0}» donne le chemin entier d’un dossier, depuis / ou depuis ~. Corrigez-le.", ), ( - Refused::NotWhole { key: "model", line: 4 }, + Refused::ModelNotWhole { line: 4 }, "Line 4: “model” gives a file’s whole path, from / or from ~. Correct it.", - "Ligne 4\u{a0}: «\u{a0}model\u{a0}» donne le chemin complet d’un fichier, depuis / ou depuis ~. Corrigez-le.", + "Ligne 4\u{a0}: «\u{a0}model\u{a0}» donne le chemin entier d’un fichier, depuis / ou depuis ~. Corrigez-le.", ), ( Refused::KeepAudio { line: 4 }, @@ -2276,7 +2276,11 @@ fn a_settings_file_refused_says_which_setting_and_what_to_do_in_both_languages() // Each refusal `settings.rs` makes is said: one added fails to compile here until it is named. for (refused, ..) in &said { match refused { - Refused::Unopened | Refused::Unparsed { .. } | Refused::NotWhole { .. } | Refused::KeepAudio { .. } => {} + Refused::Unopened + | Refused::Unparsed { .. } + | Refused::SessionsNotWhole { .. } + | Refused::ModelNotWhole { .. } + | Refused::KeepAudio { .. } => {} } } let raw = "settings.toml, line 4: keep_audio is \"always\" or a number of days"; From fc3b37e36e14fab6c6670ab741aa6e6833b80885 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:41:55 +0100 Subject: [PATCH 10/12] =?UTF-8?q?D94=20=E2=80=94=20shell:=20Settings'=20?= =?UTF-8?q?=C2=AB=20G=C3=A9n=C3=A9ral=20=C2=BB=20heading=20carries=20its?= =?UTF-8?q?=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #808 added general_title without the voice guide's comment; merged with main, every_sentence_carries_its_comment counted 603 for 602. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/words.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index bdf10d17..7bbe5315 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -472,6 +472,7 @@ pub struct Window { pub autostart_held: [&'static str; 2], pub keep_audio: [&'static str; 2], /// The settings' last group: Kitokey itself, as GNOME's preferences name it (D95). + /// Shows: Settings, as a heading. When: always. At most: no limit. Placeholders: none. pub general_title: &'static str, /// Folded at the bottom of « Général », and its one switch: what a program said of a failure, /// shown on the page under the sentence (D29). From bcb8e8f654a3b870997f6b035bde9fb2bd193b93 Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:41:37 +0100 Subject: [PATCH 11/12] =?UTF-8?q?shell:=20#807's=20five=20sentences=20carr?= =?UTF-8?q?y=20the=20guide's=20comment;=20=C2=AB=20Minutes=20stopped=20?= =?UTF-8?q?=C2=BB=20kept=20on=20the=20list=20still=20wrong=20(D94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merged with main, #807's settings banners, « Annuler », and the stopped transcript and minutes had no comment (607 against 602), and window.minutes_stopped says « minutes », which the lexicon refuses. The comments are given; the sentence is listed by key, its rewording being criterion 3's. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/words.rs | 10 ++++++++++ modules/shell/tests/words_still_wrong.txt | 1 + 2 files changed, 11 insertions(+) diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index feb15d0a..503a0e75 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -337,7 +337,11 @@ pub struct Window { pub list_unread_do: &'static str, /// The settings file cannot be read: said above every page but Settings (#770) — never read since /// Kitokey started, then read before and its last settings held. + /// Shows: a banner above every page but Settings. When: the settings file cannot be read and was + /// never read since Kitokey started. At most: no limit. Placeholders: none. pub settings_banner: &'static str, + /// Shows: a banner above every page but Settings. When: the settings file cannot be read, read + /// before, its last settings held. At most: no limit. Placeholders: none. pub settings_banner_kept: &'static str, pub again_refused: &'static str, pub hearing_models_refused: &'static str, @@ -645,13 +649,19 @@ pub struct Window { pub transcript_model_needed: &'static str, pub transcript_model_coming: &'static str, /// The button that ends what is being made of a meeting, or takes it out of the line (D92). + /// Shows: a button on a meeting's page, beside what is being made. When: its transcript or minutes + /// are being made, or waiting in line. At most: no limit. Placeholders: none. pub making_cancel: &'static str, /// « Annuler » refused — its meeting gone meanwhile (D92). Shows: a meeting's page, beside the /// making's line, until the next gesture on it. When: the shell refused to end or take out the /// making. At most: no limit. Placeholders: {} why it was refused. pub making_cancel_failed: &'static str, /// Said on its page once the user cancelled its transcript, or its minutes: what was there stays. + /// Shows: a meeting's page, where its transcript is. When: the user cancelled its transcript. + /// At most: no limit. Placeholders: none. pub transcript_stopped: &'static str, + /// Shows: a meeting's page, where its minutes are. When: the user cancelled its minutes. + /// At most: no limit. Placeholders: none. pub minutes_stopped: &'static str, pub ran_online: &'static str, /// The header's button, at rest and while a recording runs. diff --git a/modules/shell/tests/words_still_wrong.txt b/modules/shell/tests/words_still_wrong.txt index 00d33a0e..6969f674 100644 --- a/modules/shell/tests/words_still_wrong.txt +++ b/modules/shell/tests/words_still_wrong.txt @@ -87,6 +87,7 @@ lexicon window.minutes_making[0] "Writing the minutes" « minutes » lexicon window.minutes_not_copied[0] "The minutes could not be copied." « minutes » lexicon window.minutes_not_made[0] "The minutes were not written. The transcript is untouched." « minutes » lexicon window.minutes_step[0] "Minutes" « minutes » +lexicon window.minutes_stopped[0] "Minutes stopped. You can start them again, with another model if you like." « minutes » lexicon window.minutes_title[0] "Minutes" « minutes » lexicon window.minutes_unsaved[0] "Not saved yet — the minutes are still written by {}." « minutes » lexicon window.minutes_unsaved_none[0] "Not saved yet — no minutes are written until it is." « minutes » From 334eba5951fad12a57541de73dcb5f4772287a7c Mon Sep 17 00:00:00 2001 From: "kitokey-sam[bot]" <356216031+kitokey-sam[bot]@users.noreply.github.com> Date: Sun, 15 Nov 2026 02:05:22 +0100 Subject: [PATCH 12/12] shell: the keys a settings refusal names are held to the file's fields, and a key in quotes is named (#783) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit marc's survivor at 5612d21: microphone_description taken out of KEYS left every test green, nothing tying KEYS to Written. A unit test now lists Written's fields in an exhaustive pattern — a field added or taken out fails to compile — and compares their names with KEYS. A key written in quotes ("after" or 'after'), as TOML allows, is now named as the bare one. Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/settings.rs | 56 ++++++++++++++++++++++++++++++++- modules/shell/tests/settings.rs | 15 +++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/modules/shell/src/settings.rs b/modules/shell/src/settings.rs index f3d26ec3..5ab6bac6 100644 --- a/modules/shell/src/settings.rs +++ b/modules/shell/src/settings.rs @@ -324,7 +324,9 @@ pub fn read(path: &Path) -> Result { let key = |at: usize| { let start = text[..at.min(text.len())].rfind('\n').map_or(0, |end| end + 1); let (named, _) = text[start..].split_once('=')?; - KEYS.into_iter().find(|key| *key == named.trim()) + // A key written in quotes, as TOML allows, is the same key. + let named = named.trim().trim_matches(|c| c == '"' || c == '\''); + KEYS.into_iter().find(|key| *key == named) }; let written: Written = toml::from_str(&text).map_err(|error| match error.span() { Some(span) => unread( @@ -546,3 +548,55 @@ pub fn write(path: &Path, settings: &Settings) -> io::Result<()> { let _ = fs::remove_file(&draft); }) } + +#[cfg(test)] +mod tests { + use super::*; + + /// `KEYS` names each of `Written`'s fields, and nothing else (#813): a setting added to the file + /// is named by a refusal. The pattern lists every field — one added or taken out fails to compile + /// here — and the names compared are the pattern's own. + #[test] + fn the_keys_a_refusal_names_are_the_files_fields() { + macro_rules! fields { + ($($field:ident),* $(,)?) => {{ + #[allow(dead_code)] + fn every(written: Written) { + let Written { $($field: _),* } = written; + } + [$(stringify!($field)),*] + }}; + } + let mut fields = fields!( + reminder, + sessions, + transcript, + after, + model, + engine, + transcription_provider, + transcription_model, + transcription_agreed, + minutes_provider, + minutes_model, + meeting_language, + minutes_agreed, + keep_audio, + developer, + offer, + autostart, + window, + log, + welcomed, + folded, + bar_at, + language, + microphone, + microphone_description, + ); + let mut keys = KEYS; + fields.sort_unstable(); + keys.sort_unstable(); + assert_eq!(keys, fields); + } +} diff --git a/modules/shell/tests/settings.rs b/modules/shell/tests/settings.rs index 6e4e8a5d..79c66dec 100644 --- a/modules/shell/tests/settings.rs +++ b/modules/shell/tests/settings.rs @@ -122,6 +122,21 @@ fn a_file_refused_names_the_setting_and_its_line() { key: Some("reminder"), }, ), + // A key in quotes, as TOML allows, is named the same (#813). + ( + "\"after\" = \"sometimes\"\n", + Refused::Unparsed { + line: 1, + key: Some("after"), + }, + ), + ( + "'after' = \"sometimes\"\n", + Refused::Unparsed { + line: 1, + key: Some("after"), + }, + ), ("this is not TOML\n", Refused::Unparsed { line: 1, key: None }), ("reminder = true\n= 3\n", Refused::Unparsed { line: 2, key: None }), (