From 75557733ff33cda5cf1451af81b2619a74557b4e Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 22:55:23 +0100 Subject: [PATCH 01/16] =?UTF-8?q?Start=20D92=20=E2=80=94=20After=20the=20s?= =?UTF-8?q?top,=20the=20bar=20names=20the=20meeting=20and=20its=20stage,?= =?UTF-8?q?=20the=20page=20gives=20an=20estimate=20and=20Cancel,=20and=20o?= =?UTF-8?q?ne=20notification=20says=20it=20is=20ready?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 From b067e949fad2b3affe63edc89bc9813faa464318 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 22:58:07 +0100 Subject: [PATCH 02/16] =?UTF-8?q?shell:=20D92's=20=C2=AB=20Annuler=20?= =?UTF-8?q?=C2=BB=20held=20by=20the=20window's=20e2e=20before=20it=20is=20?= =?UTF-8?q?built=20(BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scenario BE, criterion 4 of D92: a transcript and minutes made again with a first model, held by the played programs — each with a child deaf to TERM —, « Annuler » on the meeting's page: both processes gone and the shell idle within two seconds, the version already whole kept byte for byte with nothing beside it, the page saying what was stopped, no notification; then a second model started at once, the version shown naming it. A first transcript cancelled leaves nothing to be taken up; the next model makes it whole. Fails today: no « Annuler » on the page. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 122 ++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 68cadb1a..c67a95c0 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -59,6 +59,11 @@ provider=local case "$3" in http://127.0.0.1*|http://localhost*) ;; *) provider=$(python3 -c "$HOST" "$3"); [ -n "$STANDIN" ] && python3 -c "$SEND" "$STANDIN/write";; esac [ -e "$here/slow-minutes" ] && sleep 3 + # Held, as a model answering slowly (D92): its number and its child's — deaf to TERM — noted, then waits. + if [ -e "$here/hold-minutes" ]; then + echo '{"event": "sending", "host": "h", "model": "m", "characters": 1}' + echo $$ > "$here/held-minutes"; ( trap '' TERM; exec sleep 60 ) & echo $! > "$here/held-minutes-child"; sleep 60; exit 0 + fi [ -e "$here/fail-minutes" ] && { echo '{"event": "failed", "code": "answer.not_minutes"}'; echo "kitokey-summary: the provider's answer is not minutes" >&2; exit 1; } [ -e "$here/fail-plainly" ] && { echo "kitokey-summary: a failure no code names" >&2; exit 1; } context=$(python3 -c "$CONTEXT" "$1") @@ -97,6 +102,11 @@ [ -n "$STANDIN" ] && python3 -c "$SEND" "$STANDIN/hear" fi [ -e "$(dirname "$0")/slow-hearing" ] && sleep 3 +# Held, as a long meeting heard (D92): a transcript begun, its number and its child's — deaf to TERM — noted, then waits. +if [ -e "$(dirname "$0")/hold-hearing" ]; then + printf '{"type":"header","contract":"transcript/v1","engine":"%s","model":"%s","language":null,"context":null}\n' "$engine" "$model" > "$1/transcript.jsonl" + echo $$ > "$(dirname "$0")/held-hearing"; ( trap '' TERM; exec sleep 60 ) & echo $! > "$(dirname "$0")/held-hearing-child"; sleep 60; exit 0 +fi context=$(python3 -c "$CONTEXT" "$1") printf '{"type":"header","contract":"transcript/v1","engine":"%s","model":"%s","language":null,"context":%s}\\n{"type":"segment","speaker":"me","track":"local","start":0.0,"end":1.0,"text":"Refait avec %s."}\\n{"type":"complete","duration":1.0}\\n' "$engine" "$model" "$context" "$model" > "$1/transcript.jsonl" """ @@ -2112,6 +2122,117 @@ def own_models(now: dt.datetime) -> None: check("none chosen: models.json removed", removed) +def gone(pid: int) -> bool: + """A process ended: none by that number, or one ended and not yet waited for.""" + try: + return Path(f"/proc/{pid}/stat").read_text().rsplit(")", 1)[1].split()[0] == "Z" + except (FileNotFoundError, ProcessLookupError, IndexError): + return True + + +def cancelled_at_once(now: dt.datetime) -> None: + """BE. « Annuler » on a making the page started (D92, criterion 4, the decider's word of + 2026-11-13): ended within two seconds — its program and what it started, one deaf to TERM —, + the version already whole shown as it was, byte for byte, nothing said by a notification; + then another model chosen and started at once, the version shown saying it made it.""" + print("BE. Annuler: a making ended within 2 s, child and all; the whole version kept byte for byte; no notification; another model at once (D92)") + meetings = WORK / "cancelled" + meeting = meetings / "2026-11-13_17-31" + session(meeting, now - dt.timedelta(hours=1), 1, {"local.wav": 1000}) + whole = ('{"type":"header","contract":"transcript/v1","engine":"whisper.cpp","model":"ggml-tiny-first","language":null,"context":null}\n' + '{"type":"segment","speaker":"me","track":"local","start":0.0,"end":1.0,"text":"La version entière."}\n' + '{"type":"complete","duration":1.0}\n') + (meeting / "transcript.jsonl").write_text(whole) + (meeting / "minutes.md").write_text("---\ncontract: minutes/v2\nmade: 2026-11-13T17:40:00+01:00\nprovider: local\nmodel: writer-first\n" + "context: null\n---\n\n## A\n\nLa version entière.\n\n## B\n\n## C\n") + data = WORK / "data-cancelled" + folder = data / "kitokey" / "models" + folder.mkdir(parents=True) + a, b = folder / "ggml-tiny-a.bin", folder / "ggml-tiny-b.bin" + for model in (a, b): + model.write_bytes(b"\0" * 16) + local = "http://localhost:11434/v1" + window = Window(meetings, "fr_FR.UTF-8", f'reminder = false\nmodel = "{a}"\nminutes_provider = "{local}"\nminutes_model = "writer-a"\n') + window.env.update(XDG_DATA_HOME=str(data)) + sha = lambda path: hashlib.sha256(path.read_bytes()).hexdigest() if path.exists() else None + idle = "return window.__TAURI__.core.invoke('makings').then(m => m.transcript === null && m.minutes === null && m.transcripts_waiting.length === 0 && m.minutes_waiting.length === 0)" + makers = lambda b: " | ".join(b.execute_script("return [...document.querySelectorAll('.maker')].map(m => m.textContent)")).lower() + steps = ( + ("the transcript", meeting / "transcript.jsonl", "hearing", + lambda b, model: b.execute_script("return window.__TAURI__.core.invoke('transcript_redo', {name: arguments[0], model: arguments[1]})", meeting.name, str(model)), + (a, b), "tiny b"), + ("the minutes", meeting / "minutes.md", "minutes", + lambda b, model: b.execute_script("return window.__TAURI__.core.invoke('minutes_redo', {name: arguments[0], provider: arguments[1], model: arguments[2]})", meeting.name, local, model), + ("writer-a", "writer-b"), "writer b"), + ) + with window as browser: + browser.execute_script(f"location.hash = '#/meeting/{meeting.name}'") + for what, file, step, start, (first, second), said_after in steps: + before, listed = sha(file), sorted(p.name for p in meeting.iterdir()) + held, child = WORK / f"held-{step}", WORK / f"held-{step}-child" + held.unlink(missing_ok=True) + child.unlink(missing_ok=True) + (WORK / f"hold-{step}").touch() + notified = WORK / f"notified-cancelled-{step}" + monitor = subprocess.Popen(["dbus-monitor", "--session", "interface='org.freedesktop.Notifications',member='Notify'"], + stdout=open(notified, "w"), stderr=subprocess.DEVNULL) + try: + time.sleep(0.5) + start(browser, first) + running = wait_for(browser, lambda b: held.exists() and child.exists() and child.read_text().strip() != "", 15) + check(f"{what}: made again with the first model, held running", running) + if not running: + continue + pids = int(held.read_text()), int(child.read_text()) + offered = wait_for(browser, lambda b: b.execute_script("const c = document.getElementById('making-cancel'); return !!c && c.getClientRects().length > 0"), 10) + check(f"{what}: « Annuler » on its page while it is made", offered) + if not offered: + continue + pressed = time.monotonic() + press(browser, "making-cancel") + ended = wait_for(browser, lambda b: all(gone(pid) for pid in pids) and b.execute_script(idle), 2) + took = time.monotonic() - pressed + check(f"{what}: ended within two seconds, its program and the child deaf to TERM ({took:.2f} s)", + ended and took <= 2, [(pid, gone(pid)) for pid in pids]) + check(f"{what}: the version already whole kept, byte for byte, nothing left beside it", + wait_for(browser, lambda b: sha(file) == before and sorted(p.name for p in meeting.iterdir()) == listed, 3), + sorted(p.name for p in meeting.iterdir())) + stopped = browser.execute_script("const s = document.getElementById('making-stopped'); return s ? s.textContent : ''") + check(f"{what}: the page says what was stopped", "arrêté" in stopped.lower(), stopped) + time.sleep(2) + check(f"{what}: no notification for a cancel", "member=Notify" not in notified.read_text(), notified.read_text()[-300:]) + finally: + monitor.terminate() + (WORK / f"hold-{step}").unlink(missing_ok=True) + start(browser, second) + made = wait_for(browser, lambda b: sha(file) != before and b.execute_script(idle), 15) + check(f"{what}: another model started at once, without restarting Kitokey — the version shown says it made it", + made and wait_for(browser, lambda b: said_after in makers(b), 10), makers(browser)) + # A first transcript, none whole before it: cancelled, nothing of it is left to be taken up by + # another model's making — the page offers to make it, and the next model makes it whole. + fresh = meetings / "2026-11-13_18-02" + session(fresh, now - dt.timedelta(minutes=30), 1, {"local.wav": 1000}) + held = WORK / "held-hearing" + held.unlink(missing_ok=True) + (WORK / "hold-hearing").touch() + try: + browser.execute_script("window.__TAURI__.core.invoke('transcript_asked', {name: arguments[0]})", fresh.name) + running = wait_for(browser, lambda b: held.exists(), 15) + browser.execute_script(f"location.hash = '#/meeting/{fresh.name}'") + offered = running and wait_for(browser, lambda b: b.execute_script("const c = document.getElementById('making-cancel'); return !!c && c.getClientRects().length > 0"), 10) + check("a first transcript: « Annuler » on its page while it is made", offered) + if offered: + press(browser, "making-cancel") + ended = wait_for(browser, lambda b: b.execute_script(idle), 2) + check("a first transcript cancelled: ended within two seconds, nothing of it left in the meeting's folder", + ended and sorted(p.name for p in fresh.iterdir()) == ["local.wav", "session.json"], sorted(p.name for p in fresh.iterdir())) + finally: + (WORK / "hold-hearing").unlink(missing_ok=True) + browser.execute_script("return window.__TAURI__.core.invoke('transcript_redo', {name: arguments[0], model: arguments[1]})", fresh.name, str(b)) + made = wait_for(browser, lambda b: (fresh / "transcript.jsonl").exists() and b.execute_script(idle), 15) + check("then another model makes it whole at once", made and '"model":"ggml-tiny-b"' in (fresh / "transcript.jsonl").read_text()) + + LONG = "hf.co/unsloth/Mistral-Small-3.2-24B-Instruct-2506-GGUF:UD-Q4_K_XL-very-long-name" LONG_SAID = "Mistral Small 3.2 24B Instruct 2506 GGUF UD Q4 K XL Very Long Name" # A list's chosen entry: whether it fits the list as drawn, and what is said whole under it, if anything — @@ -8527,6 +8648,7 @@ def aside(folder): bar_opened(now) context_before_start(now) own_models(now) + cancelled_at_once(now) models_advanced(now) meeting_named(now) word_after_a_gap(now) From 6dac43848a334ec253cb681e6d8138ec6f970e5e Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:05:11 +0100 Subject: [PATCH 03/16] =?UTF-8?q?shell:=20=C2=AB=20Annuler=20=C2=BB=20ends?= =?UTF-8?q?=20a=20meeting's=20making=20within=20two=20seconds,=20the=20who?= =?UTF-8?q?le=20version=20kept=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The meeting's page offers « Annuler » while its transcript or its minutes are made, or wait their turn. The program is stopped as a group: TERM, a second's grace, then KILL to what is left — the summary's program now leads a group of its own, as the transcript's did. A cancelled making is no failure: nothing told, no notification, nothing made after it; the page says it stopped, and its button to make it again is offered. A redo's earlier transcript is put back, the minutes there were never replaced; a first transcript cancelled leaves nothing to be taken up by another model. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/main.rs | 124 ++++++++++++++++++++++++--- modules/shell/src/summarising.rs | 10 +++ modules/shell/src/transcription.rs | 44 ++++++++++ modules/shell/src/words.rs | 11 +++ modules/shell/tests/summarising.rs | 40 +++++++++ modules/shell/tests/transcription.rs | 33 +++++++ modules/shell/ui/window.js | 47 +++++++--- 7 files changed, 288 insertions(+), 21 deletions(-) diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index dd5d0db2..5aee594a 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -167,6 +167,12 @@ struct Shell { /// made again here, their end is no failure to tell (D60). heard_here: Mutex>, written_here: Mutex>, + /// Makings the user cancelled (« Annuler », D92), until their program is said ended: no + /// failure then, nothing told, nothing made after them. + cancelling: Mutex>, + /// What was last cancelled of a meeting — its transcript or its minutes —, said on its page + /// until a making of it starts again. + stopped: Mutex>, /// What had left before a meeting was said confidential, and to which host: said on its page /// while it stays so, until Kitokey quits (D60). left: Mutex>>, @@ -365,6 +371,7 @@ fn main() { busy_meetings, freed, minutes_redo, + making_cancelled, context_shown, context_saved, context_redo, @@ -536,6 +543,8 @@ fn main() { minutes_host: Mutex::new(None), heard_here: Mutex::default(), written_here: Mutex::default(), + cancelling: Mutex::default(), + stopped: Mutex::default(), left: Mutex::default(), ollama_waiting: Mutex::default(), fetching: Mutex::new(false), @@ -1074,6 +1083,33 @@ fn minutes_redo( Ok(()) } +/// « Annuler » on a meeting's page (D92, the decider's word of 2026-11-13): what is being made of +/// it — its transcript, its minutes — ends within two seconds, and what waits its turn leaves the +/// line. The version already whole stays; the user may at once start another making. +#[tauri::command] +fn making_cancelled(shell: State<'_, Shell>, name: String) -> Result<(), Told> { + let folder = session_folder(&shell, &name)?; + // Out of the lines first: nothing of it starts in its place meanwhile. + shell.waiting.lock().unwrap().retain(|(queued, _)| *queued != folder); + shell.minutes_waiting.lock().unwrap().retain(|queued| queued.folder != folder); + // Marked before its program is stopped: its end, whenever it comes, finds it. + let running = shell.transcription.lock().unwrap(); + if let (Some(transcription), true) = (running.as_ref(), shell.hearing.lock().unwrap().as_deref() == Some(folder.as_path())) { + shell.cancelling.lock().unwrap().insert(folder.clone()); + transcription.cancel(); + } + drop(running); + if shell.writing_minutes.lock().unwrap().as_deref() == Some(folder.as_path()) { + shell.cancelling.lock().unwrap().insert(folder.clone()); + // Not started yet — the keyring asked first —: its start finds it marked, and ends it. + if let Some(making) = shell.minuting.lock().unwrap().as_ref() { + making.cancel(); + } + } + tracing::info!(session = %name, "shell.making_cancelled"); + Ok(()) +} + /// A line of a meeting's transcript corrected on the user's word (D62, ADR-0014): once complete, /// never while it is made or waits to be made again. The making's lock held while it is written: /// one writer at a time. @@ -2846,6 +2882,16 @@ fn minutes_ended_here(app: &AppHandle, folder: &Path) { minutes_next(app); } +/// Minutes the user cancelled (D92): said stopped on their page, the ones there kept, nothing +/// told; the next ones asked meanwhile started. +fn minutes_cancelled(app: &AppHandle, folder: &Path) { + let shell = app.state::(); + shell.minutes_by.lock().unwrap().take(); + shell.minutes_host.lock().unwrap().take(); + shell.stopped.lock().unwrap().insert(folder.to_path_buf(), "minutes"); + minutes_next(app); +} + /// What is being made in the background, for the pages (D25): the minutes being written, by /// what and for how long, those waiting their turn, the transcript being made and those waiting, /// and why a meeting's last minutes were not written. @@ -2875,6 +2921,8 @@ struct Makings { /// Confidential meetings whose minutes wait for Ollama, and why (D60); the model it would fetch. ollama_waiting: HashMap, ollama_recommended: &'static str, + /// What the user last cancelled of a meeting, by its name: `transcript` or `minutes` (D92). + stopped: HashMap, } #[derive(serde::Serialize)] @@ -3003,6 +3051,13 @@ fn makings(shell: State<'_, Shell>) -> Makings { .map(|(folder, wait)| (named(folder), *wait)) .collect(), ollama_recommended: providers::RECOMMENDED, + stopped: shell + .stopped + .lock() + .unwrap() + .iter() + .map(|(folder, what)| (named(folder), *what)) + .collect(), } } @@ -3175,6 +3230,9 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> .then(|| model.clone()); *shell.minutes_host.lock().unwrap() = (!providers::local(&provider)).then(|| host.clone()); shell.minutes_failed.lock().unwrap().remove(&folder); + // Begun again: no longer said stopped, and a cancel left from a making that never began ends none. + shell.stopped.lock().unwrap().remove(&folder); + shell.cancelling.lock().unwrap().remove(&folder); minuting(app, true); let app = app.clone(); // The keyring may ask the user first: never on the window's and the tray's thread. @@ -3215,6 +3273,9 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> // Said confidential as it started: ended at once. if here() { making.end(); + } else if shell.cancelling.lock().unwrap().contains(&folder) { + // Cancelled before its program started — the keyring asked first —: ended at once. + making.cancel(); } *shell.minuting.lock().unwrap() = Some(making); events @@ -3241,7 +3302,9 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> }) .unwrap_or(summarising::Made::Failed(String::new(), None)); shell.minuting.lock().unwrap().take(); - let ended_here = matches!(made, summarising::Made::Failed(..)) && here(); + // Cancelled by the user (D92), and not written meanwhile: no failure, nothing told. + let cancelled = shell.cancelling.lock().unwrap().remove(&folder) && matches!(made, summarising::Made::Failed(..)); + let ended_here = matches!(made, summarising::Made::Failed(..)) && !cancelled && here(); // Replaced, the earlier minutes go to the trash — refused, they stay beside, and it is said. let mut kept_beside = None; if let Some(previous) = previous { @@ -3255,6 +3318,9 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> } } } + if cancelled { + return minutes_cancelled(&app, &folder); + } if ended_here { return minutes_ended_here(&app, &folder); } @@ -3559,18 +3625,35 @@ fn hearing(shell: &Shell, folder: &Path, hearer: &Hearer) { _ => None, }; shell.transcripts_failed.lock().unwrap().remove(folder); + shell.stopped.lock().unwrap().remove(folder); } -/// A transcript ended: counted when written, its reason kept when not — said on its page. Whether -/// it was ended because its meeting was said confidential, to be made again here: no failure then. -fn heard(shell: &Shell, folder: &Path, made: &Made) -> bool { +/// How a transcript's making ended, for what follows it. +#[derive(PartialEq)] +enum Heard { + /// Written, or failed: told, and what follows it made. + Ended, + /// Ended because its meeting was said confidential, to be made again here: no failure (D60). + Here, + /// Cancelled by the user (D92): no failure, nothing told, nothing made after it. + Cancelled, +} + +/// A transcript ended: counted when written, its reason kept when not — said on its page —, or +/// said stopped when the user cancelled it. +fn heard(shell: &Shell, folder: &Path, made: &Made) -> Heard { shell.hearing.lock().unwrap().take(); shell.hearing_by.lock().unwrap().take(); shell.hearing_host.lock().unwrap().take(); let here = shell.heard_here.lock().unwrap().remove(folder); + // Written all the same, as it was cancelled: written it is. + let cancelled = shell.cancelling.lock().unwrap().remove(folder) && !matches!(made, Made::Written(_)); + if cancelled { + shell.stopped.lock().unwrap().insert(folder.to_path_buf(), "transcript"); + } match made { Made::Written(_) => *shell.transcripts_made.lock().unwrap().entry(folder.to_path_buf()).or_default() += 1, - Made::Failed(_) if here => {} + Made::Failed(_) if here || cancelled => {} Made::Failed(why) => { let why = if why.trim().is_empty() { "kitokey-transcription stopped without saying why" @@ -3584,7 +3667,11 @@ fn heard(shell: &Shell, folder: &Path, made: &Made) -> bool { .insert(folder.to_path_buf(), why.to_string()); } } - here + match (cancelled, here) { + (true, _) => Heard::Cancelled, + (false, true) => Heard::Here, + (false, false) => Heard::Ended, + } } /// The next transcript in line, once one ends: made, or made again with the model a Refaire… @@ -3717,7 +3804,13 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (F // Replaced, the earlier transcript goes to the trash — refused, it stays beside, and it is // said; not replaced, it is put back — failing that, it is said where it is. let mut kept_beside = None; - if let Some((current, previous)) = shell.redoing.lock().unwrap().take() { + let redoing = shell.redoing.lock().unwrap().take(); + // Cancelled with none whole before it: what it began is no version, nor taken up by the + // next model's making (D92). + if here == Heard::Cancelled && redoing.is_none() { + let _ = std::fs::remove_file(folder.join("transcript.jsonl")); + } + if let Some((current, previous)) = redoing { let name = previous.file_name().map(|name| name.to_string_lossy().into_owned()); let written = matches!(made, Made::Written(_)); if let Some(not_put_back) = sessions::settle(¤t, &previous, written, |previous| { @@ -3729,8 +3822,12 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (F if *shell.leaving.lock().unwrap() { return; } - // Ended for its meeting said confidential: made again here, first in line. - if here { + // Ended for its meeting said confidential: made again here, first in line. Cancelled: + // nothing told — the earlier one not put back excepted —, nothing made after it. + if here != Heard::Ended { + if let (Heard::Cancelled, Some((name, not_put_back))) = (&here, kept_beside) { + tell(&app, &words::transcript_kept_beside(shell.language(), &name, not_put_back)); + } return transcribe_next(&app); } // Made again and ready, its click opens the meeting as after a stop (D44). @@ -3867,12 +3964,17 @@ fn transcribe(app: &AppHandle, folder: PathBuf) { let here = heard(&shell, &heard_folder, &made); drop(running); transcribing(&app, false); + // Cancelled: what it began is no version, nor taken up by the next model's making (D92). + if here == Heard::Cancelled { + let _ = std::fs::remove_file(heard_folder.join("transcript.jsonl")); + } // Ended by Kitokey as it quits: nothing to tell, it goes on next time. if *shell.leaving.lock().unwrap() { return; } - // Ended for its meeting said confidential: made again here, first in line. - if here { + // Ended for its meeting said confidential: made again here, first in line; cancelled, + // nothing told, nothing made after it. + if here != Heard::Ended { return transcribe_next(&app); } let notice = words::made(&made, shell.language()); diff --git a/modules/shell/src/summarising.rs b/modules/shell/src/summarising.rs index e9c0df52..ab1a1403 100644 --- a/modules/shell/src/summarising.rs +++ b/modules/shell/src/summarising.rs @@ -104,6 +104,9 @@ impl Summarising { if let Some(key) = key { command.env("KITOKEY_PROVIDER_KEY", key); } + // A group of its own, as the transcript's: cancelled, whatever it started ends with it (D92). + #[cfg(unix)] + std::os::unix::process::CommandExt::process_group(&mut command, 0); let mut child = command .stdin(Stdio::null()) .stdout(Stdio::piped()) @@ -185,6 +188,13 @@ impl Summarising { let _ = child.kill(); } } + + /// Stops the program on the user's word, « Annuler » (D92), as a transcript's: within two + /// seconds, without waiting here; the minutes there stay. + pub fn cancel(&self) { + let program = Arc::clone(&self.program); + thread::spawn(move || crate::transcription::cancel(&program)); + } } /// The event a line of the contract names; none for a line that is not one. diff --git a/modules/shell/src/transcription.rs b/modules/shell/src/transcription.rs index e52bf017..dabda99b 100644 --- a/modules/shell/src/transcription.rs +++ b/modules/shell/src/transcription.rs @@ -234,6 +234,50 @@ impl Transcription { let _ = child.kill(); } } + + /// Stops the program on the user's word, « Annuler » (D92): within two seconds, without + /// waiting here. What it had written is the shell's to settle once it is said ended. + pub fn cancel(&self) { + let program = Arc::clone(&self.program); + thread::spawn(move || cancel(&program)); + } +} + +/// How long a program told to stop is given before it is killed, with what it started: the two +/// seconds « Annuler » promises hold it, the shell's waiting a tenth of a second at a time (D92). +const GRACE: Duration = Duration::from_secs(1); + +/// Stops a program that leads a group of its own, and whatever it started: TERM to the group, a +/// second's grace, then KILL to what is left of it. The group is taken while its leader runs, its +/// number its own then; within the grace, no other process can have been given it. +#[cfg(unix)] +pub(crate) fn cancel(program: &Mutex) { + let running = |child: &mut Child| matches!(child.try_wait(), Ok(None)); + let Some(group) = program + .lock() + .ok() + .and_then(|mut child| running(&mut child).then(|| i32::try_from(child.id()).ok()).flatten()) + else { + return; + }; + // SAFETY: signals sent to the group this program leads, which it was started in. + unsafe { libc::kill(-group, libc::SIGTERM) }; + let until = std::time::Instant::now() + GRACE; + // SAFETY: signal 0 sends nothing: it asks whether the group still holds a process. + while std::time::Instant::now() < until && unsafe { libc::kill(-group, 0) } == 0 { + thread::sleep(Duration::from_millis(50)); + } + // SAFETY: as above; none left, it reaches no one. + unsafe { libc::kill(-group, libc::SIGKILL) }; +} + +/// Elsewhere, the program alone: no step starts one of its own there — the one program a step +/// starts, SpeechAnalyzer's helper, is macOS's alone. +#[cfg(not(unix))] +pub(crate) fn cancel(program: &Mutex) { + if let Ok(mut child) = program.lock() { + let _ = child.kill(); + } } /// A file's or a folder's own name, never its path: the path says whose meetings and where. diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index d7ee4afa..70bae690 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -637,6 +637,11 @@ pub struct Window { /// A transcript waiting for the default Whisper model: offered in the menu, or coming. 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). + pub making_cancel: &'static str, + /// Said on its page once the user cancelled its transcript, or its minutes: what was there stays. + pub transcript_stopped: &'static str, + pub minutes_stopped: &'static str, pub ran_online: &'static str, /// The header's button, at rest and while a recording runs. pub record_start: &'static str, @@ -1066,6 +1071,9 @@ pub fn window(language: Language) -> Window { minutes_unsaved_none: "Not saved yet — no minutes are written until it is.", transcript_model_needed: "Waiting for the Whisper model.", transcript_model_coming: "Waiting for the Whisper model, being downloaded.", + making_cancel: "Cancel", + transcript_stopped: "Transcription stopped. You can start it again, with another model if you like.", + minutes_stopped: "Minutes stopped. You can start them again, with another model if you like.", ran_online: "online", record_start: "Start a recording", record_stop: "Stop the recording", @@ -1489,6 +1497,9 @@ pub fn window(language: Language) -> Window { minutes_unsaved_none: "Pas encore enregistré — aucun compte rendu n’est fait tant que ce n’est pas le cas.", transcript_model_needed: "En attente du modèle Whisper.", transcript_model_coming: "En attente du modèle Whisper, en cours de téléchargement.", + making_cancel: "Annuler", + transcript_stopped: "Transcription arrêtée. Vous pouvez la relancer, avec un autre modèle si besoin.", + minutes_stopped: "Compte rendu arrêté. Vous pouvez le relancer, avec un autre modèle si besoin.", ran_online: "en ligne", record_start: "Démarrer un enregistrement", record_stop: "Arrêter l’enregistrement", diff --git a/modules/shell/tests/summarising.rs b/modules/shell/tests/summarising.rs index 2b3a0163..a283f5a5 100644 --- a/modules/shell/tests/summarising.rs +++ b/modules/shell/tests/summarising.rs @@ -212,3 +212,43 @@ fn a_test_is_read_from_its_last_lines() { "a-program stopped without saying why (exit status: 3)" ); } + +#[test] +fn cancelled_minutes_end_within_two_seconds_with_what_they_started_the_minutes_there_kept() { + let _held = ONE_AT_A_TIME.lock().unwrap_or_else(|poisoned| poisoned.into_inner()); + let folder = session(); + let minutes = folder.path().join("session/minutes.md"); + fs::write(&minutes, "the minutes before").unwrap(); + let path = folder.path().join("kitokey-summary"); + fs::write( + &path, + "#!/bin/sh\necho '{\"event\": \"sending\", \"host\": \"h\", \"model\": \"m\", \"characters\": 1}'\n( trap '' TERM; exec sleep 60 ) & echo $! > \"$1/child\"\nsleep 60\n", + ) + .unwrap(); + fs::set_permissions(&path, fs::Permissions::from_mode(0o755)).unwrap(); + let (making, events) = Summarising::start(&path, &folder.path().join("session"), "http://localhost:11434/v1", "m", None).unwrap(); + let child = folder.path().join("session/child"); + for _ in 0..50 { + if fs::read_to_string(&child).is_ok_and(|pid| !pid.trim().is_empty()) { + break; + } + std::thread::sleep(Duration::from_millis(100)); + } + let child = fs::read_to_string(&child).expect("the program never started its child"); + let until = std::time::Instant::now() + Duration::from_secs(2); + making.cancel(); + let ended = loop { + match events.recv_timeout(until.saturating_duration_since(std::time::Instant::now())) { + Ok(Event::Ended(made)) => break made, + Ok(_) => {} + Err(_) => panic!("not ended within two seconds"), + } + }; + assert!(matches!(ended, Made::Failed(..)), "{ended:?}"); + let stat = fs::read_to_string(format!("/proc/{}/stat", child.trim())).unwrap_or_default(); + assert!( + stat.is_empty() || stat.rsplit_once(')').is_some_and(|(_, rest)| rest.trim_start().starts_with('Z')), + "its child still runs" + ); + assert_eq!(fs::read_to_string(&minutes).unwrap(), "the minutes before"); +} diff --git a/modules/shell/tests/transcription.rs b/modules/shell/tests/transcription.rs index cf1bd0ce..63e7c653 100644 --- a/modules/shell/tests/transcription.rs +++ b/modules/shell/tests/transcription.rs @@ -312,3 +312,36 @@ fn the_meetings_language_is_told_to_each_engine_speechanalyzer_only_in_the_two_i assert!(args().ends_with(wanted), "{hearer:?} {spoken:?}: {}", args()); } } + +/// Whether a process has ended: none by that number, or one ended and not yet waited for. +fn gone(pid: &str) -> bool { + fs::read_to_string(format!("/proc/{}/stat", pid.trim())).map_or(true, |stat| { + stat.rsplit_once(')').and_then(|(_, rest)| rest.split_whitespace().next()) == Some("Z") + }) +} + +#[test] +fn cancelled_it_ends_within_two_seconds_with_what_it_started_even_deaf_to_term() { + let folder = tempfile::tempdir().unwrap(); + fs::create_dir(folder.path().join("session")).unwrap(); + let (transcription, said) = made( + folder.path(), + r#"echo '{"type":"header"}' > "$1/transcript.jsonl" +( trap '' TERM; exec sleep 60 ) & echo $! > "$1/child" +sleep 60"#, + ); + let child = folder.path().join("session/child"); + for _ in 0..50 { + if fs::read_to_string(&child).is_ok_and(|pid| !pid.trim().is_empty()) { + break; + } + std::thread::sleep(Duration::from_millis(100)); + } + let child = fs::read_to_string(&child).expect("the program never started its child"); + let pressed = std::time::Instant::now(); + transcription.cancel(); + let ended = said.recv_timeout(Duration::from_secs(2)).expect("not ended within two seconds"); + assert!(matches!(ended, Made::Failed(_)), "{ended:?}"); + assert!(gone(&child), "its child, deaf to TERM, still runs"); + assert!(pressed.elapsed() <= Duration::from_secs(2)); +} diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index 93c7b18e..fa77a2b8 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -385,6 +385,8 @@ function minutesState(name) { return { kind: "ollama", silent: makings.ollama_waiting[name] === "silent", busy: makings.model_fetching !== null }; } if (makings.failed[name] !== undefined) return { kind: "failed", why: makings.failed[name], said: makings.failed_said[name] }; + // Cancelled by the user (D92): said, until it is made again. + if (makings.stopped[name] === "minutes") return { kind: "stopped" }; return null; } @@ -398,17 +400,35 @@ function transcriptState(name) { } if (waiting >= 0) return { kind: "waiting", before: waiting + 1 }; if (makings.transcripts_failed[name] !== undefined) return { kind: "failed", why: makings.transcripts_failed[name] }; + if (makings.stopped[name] === "transcript") return { kind: "stopped" }; return null; } +// The card whose « Annuler » was pressed: once it says stopped, the focus goes to what makes it again. +let cancelledFrom = null; + +// « Annuler » (D92): what is made of the meeting ends within two seconds, or leaves the line. +function cancelButton(said, id) { + const cancel = element("button", "open", words.making_cancel); + cancel.type = "button"; + if (id) cancel.id = id; + cancel.addEventListener("click", async () => { + cancel.disabled = true; + cancelledFrom = said.id; + await window.__TAURI__.core.invoke("making_cancelled", { name: said.dataset.name }).catch(() => {}); + readMakings(); + }); + return cancel; +} + // One card's state, said where its content is: what makes it and for how long, its place in // line, the word it waits for, or why it was not made, with Try again (D25). function paintState(said, shown, of) { said.hidden = shown === null; said.className = `making-state ${shown?.kind ?? ""}`; - // Being made, waiting, or failed with Try again: not offered a second time. + // Being made, waiting, or failed with Try again: not offered a second time. Stopped, it is. const offered = document.getElementById(of.offer); - if (offered) offered.hidden = shown !== null; + if (offered) offered.hidden = shown !== null && shown.kind !== "stopped"; // Drawn again only when it says something else — a link or a button under the pointer or the // keyboard's focus stays the same one —; while it is made, only its time moves. const { seconds, ...same } = shown ?? {}; @@ -423,9 +443,15 @@ function paintState(said, shown, of) { said.dataset.key = key; if (shown === null) return said.replaceChildren(); if (shown.kind === "making") { - said.replaceChildren(element("span", "what", of.making), element("span", "by", `${by} · ${minutes}`), element("span", "making-bar")); + said.replaceChildren(element("span", "what", of.making), element("span", "by", `${by} · ${minutes}`), element("span", "making-bar"), cancelButton(said, "making-cancel")); } else if (shown.kind === "waiting") { - said.replaceChildren(element("span", "what", fill(words.minutes_waiting, shown.before))); + said.replaceChildren(element("span", "what", fill(words.minutes_waiting, shown.before)), cancelButton(said)); + } else if (shown.kind === "stopped") { + const stopped = element("span", "what", of.stopped); + stopped.id = "making-stopped"; + said.replaceChildren(stopped); + if (cancelledFrom === said.id && offered && !offered.hidden) offered.focus(); + cancelledFrom = null; } else if (shown.kind === "model") { if (shown.coming) said.replaceChildren(element("span", "what", words.transcript_model_coming)); else said.replaceChildren(element("span", "what", words.transcript_model_needed), modelFetch(shown.busy)); @@ -541,9 +567,10 @@ function paintMakings() { paintModel(); paintOffered(); for (const chip_ of document.querySelectorAll(".chip.making")) { - // The minutes' state first; else the transcript's, which comes before them. - const minutes = minutesState(chip_.dataset.name); - const transcript = transcriptState(chip_.dataset.name); + // The minutes' state first; else the transcript's, which comes before them. Stopped: no chip. + const chipped = (state) => (state?.kind === "stopped" ? null : state); + const minutes = chipped(minutesState(chip_.dataset.name)); + const transcript = chipped(transcriptState(chip_.dataset.name)); const state = minutes ?? transcript; chip_.hidden = state === null; if (state === null) continue; @@ -556,7 +583,7 @@ function paintMakings() { const minutes = document.getElementById("minutes-state"); if (minutes) { paintState(minutes, minutesState(minutes.dataset.name), { - offer: "make-minutes", again: "minutes-again", ask: "minutes_again", making: words.minutes_making, not_made: words.minutes_not_made, + offer: "make-minutes", again: "minutes-again", ask: "minutes_again", making: words.minutes_making, not_made: words.minutes_not_made, stopped: words.minutes_stopped, }); } // No line corrected while the transcript is made or waits to be (D62): its pencils hidden. @@ -564,12 +591,12 @@ function paintMakings() { if (pencil.parentElement.querySelector(".correcting")) continue; const kind = transcriptState(pencil.dataset.name)?.kind; // Nor while its minutes are written: they read the transcript before (#528's verification). - pencil.hidden = (kind !== undefined && kind !== "failed") || minutesState(pencil.dataset.name)?.kind === "making"; + pencil.hidden = (kind !== undefined && kind !== "failed" && kind !== "stopped") || minutesState(pencil.dataset.name)?.kind === "making"; } const transcript = document.getElementById("transcript-state"); if (transcript) { paintState(transcript, transcriptState(transcript.dataset.name), { - offer: "make-transcript", again: "transcript-again", ask: "transcript_again", making: words.transcript_making, not_made: words.transcript_not_made, + offer: "make-transcript", again: "transcript-again", ask: "transcript_again", making: words.transcript_making, not_made: words.transcript_not_made, stopped: words.transcript_stopped, }); } paintContext(); From f6ef3fc70c9abb54e2348d329c3ecee6e36a46c6 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:15:15 +0100 Subject: [PATCH 04/16] =?UTF-8?q?shell:=20=C2=AB=20Annuler=20=C2=BB=20neit?= =?UTF-8?q?her=20lost=20nor=20left=20behind;=20the=20TERM=20grace=20held?= =?UTF-8?q?=20by=20a=20test=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The verifier's review of 6dac438. A mark is now by meeting and kind, set by « Annuler » only under its kind's lock while that making runs for the meeting, and taken under the same lock as it ends or begins: a cancel between the start's two steps is no longer erased, and one pressed after the end no longer marks a later making — of the other kind least of all, a first transcript's failure taken for a cancel and its file removed. A meeting taken from a line and not yet begun is said taken; « Annuler » withdraws it there and its start begins nothing. A test holds the group told TERM first, a child ending by it within the grace. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/main.rs | 126 +++++++++++++++++++++++---- modules/shell/tests/transcription.rs | 31 +++++++ 2 files changed, 139 insertions(+), 18 deletions(-) diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index 5aee594a..15231b7a 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -167,9 +167,15 @@ struct Shell { /// made again here, their end is no failure to tell (D60). heard_here: Mutex>, written_here: Mutex>, - /// Makings the user cancelled (« Annuler », D92), until their program is said ended: no - /// failure then, nothing told, nothing made after them. - cancelling: Mutex>, + /// Makings the user cancelled (« Annuler », D92), by meeting and kind, until their program is + /// said ended: no failure then, nothing told, nothing made after them. A mark is set only under + /// its kind's lock — `transcription`, `writing_minutes` — while that making runs for the meeting, + /// and taken under it as the making ends or begins: never left to a later one. + cancelling: Mutex>, + /// The meeting taken from each line and not yet begun, and whether « Annuler » withdrew it + /// meanwhile: its start, under its kind's lock, then begins nothing (D92). + promoted_transcript: Mutex>, + promoted_minutes: Mutex>, /// What was last cancelled of a meeting — its transcript or its minutes —, said on its page /// until a making of it starts again. stopped: Mutex>, @@ -544,6 +550,8 @@ fn main() { heard_here: Mutex::default(), written_here: Mutex::default(), cancelling: Mutex::default(), + promoted_transcript: Mutex::default(), + promoted_minutes: Mutex::default(), stopped: Mutex::default(), left: Mutex::default(), ollama_waiting: Mutex::default(), @@ -1089,27 +1097,72 @@ fn minutes_redo( #[tauri::command] fn making_cancelled(shell: State<'_, Shell>, name: String) -> Result<(), Told> { let folder = session_folder(&shell, &name)?; - // Out of the lines first: nothing of it starts in its place meanwhile. - shell.waiting.lock().unwrap().retain(|(queued, _)| *queued != folder); - shell.minutes_waiting.lock().unwrap().retain(|queued| queued.folder != folder); - // Marked before its program is stopped: its end, whenever it comes, finds it. + // Out of the lines; taken from one and not yet begun, withdrawn: its start begins nothing. + let withdraw = |slot: &Mutex>| { + if let Some((taken, withdrawn)) = slot.lock().unwrap().as_mut() + && *taken == folder + { + *withdrawn = true; + } + }; + { + let mut waiting = shell.waiting.lock().unwrap(); + waiting.retain(|(queued, _)| *queued != folder); + withdraw(&shell.promoted_transcript); + } + { + let mut waiting = shell.minutes_waiting.lock().unwrap(); + waiting.retain(|queued| queued.folder != folder); + withdraw(&shell.promoted_minutes); + } + // Being made: marked under its kind's lock — a start in progress is waited for, an end already + // taken leaves nothing to mark —, then stopped; its end finds the mark. let running = shell.transcription.lock().unwrap(); if let (Some(transcription), true) = (running.as_ref(), shell.hearing.lock().unwrap().as_deref() == Some(folder.as_path())) { - shell.cancelling.lock().unwrap().insert(folder.clone()); + shell.cancelling.lock().unwrap().insert((folder.clone(), Kind::Transcript)); transcription.cancel(); } drop(running); - if shell.writing_minutes.lock().unwrap().as_deref() == Some(folder.as_path()) { - shell.cancelling.lock().unwrap().insert(folder.clone()); + let writing = shell.writing_minutes.lock().unwrap(); + if writing.as_deref() == Some(folder.as_path()) { + shell.cancelling.lock().unwrap().insert((folder.clone(), Kind::Minutes)); // Not started yet — the keyring asked first —: its start finds it marked, and ends it. if let Some(making) = shell.minuting.lock().unwrap().as_ref() { making.cancel(); } } + drop(writing); tracing::info!(session = %name, "shell.making_cancelled"); Ok(()) } +/// What a making makes, for the marks « Annuler » leaves (D92). +#[derive(Clone, Copy, Hash, PartialEq, Eq)] +enum Kind { + Transcript, + Minutes, +} + +/// The slot of a meeting taken from a line freed once its start has been tried — begun, or not —, +/// unless it already holds the next one taken. +fn free(slot: &Mutex>, folder: &Path) { + let mut slot = slot.lock().unwrap(); + if slot.as_ref().is_some_and(|(taken, _)| taken == folder) { + *slot = None; + } +} + +/// Whether the meeting taken from a line was withdrawn by « Annuler » before it began: then +/// nothing begins, and the slot is freed (D92). +fn withdrawn(slot: &Mutex>, folder: &Path) -> bool { + let mut slot = slot.lock().unwrap(); + let withdrawn = slot.as_ref().is_some_and(|(taken, withdrawn)| *withdrawn && taken == folder); + if withdrawn { + *slot = None; + } + withdrawn +} + /// A line of a meeting's transcript corrected on the user's word (D62, ADR-0014): once complete, /// never while it is made or waits to be made again. The making's lock held while it is written: /// one writer at a time. @@ -2848,16 +2901,31 @@ fn minutes_ended(app: &AppHandle, folder: &Path, failed: Option<(String, Option< fn minutes_next(app: &AppHandle) { let shell = app.state::(); minuting(app, false); - *shell.writing_minutes.lock().unwrap() = None; + { + // Freed with any mark an « Annuler » pressed after its end left: none ends a later making. + let mut writing = shell.writing_minutes.lock().unwrap(); + if let Some(ended) = writing.take() { + shell.cancelling.lock().unwrap().remove(&(ended, Kind::Minutes)); + } + } if *shell.leaving.lock().unwrap() { return; } loop { - let Some(next) = shell.minutes_waiting.lock().unwrap().pop_front() else { + // Taken from the line under its lock, and said taken: « Annuler » meanwhile withdraws it. + let next = { + let mut waiting = shell.minutes_waiting.lock().unwrap(); + let next = waiting.pop_front(); + *shell.promoted_minutes.lock().unwrap() = next.as_ref().map(|next| (next.folder.clone(), false)); + next + }; + let Some(next) = next else { return; }; // Started, or set aside (an agreement to give, a reason it cannot): the next one then. + let taken = next.folder.clone(); write_minutes_from(app, next.folder, next.agreed.as_deref(), next.chosen, true); + free(&shell.promoted_minutes, &taken); if shell.writing_minutes.lock().unwrap().is_some() { return; } @@ -3217,7 +3285,13 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> drop(writing); return write_minutes_from(app, folder, agreed_now, again.then_some((provider, model)), from_line); } + // Taken from the line and withdrawn by « Annuler » since: nothing begins (D92). + if withdrawn(&shell.promoted_minutes, &folder) { + return; + } + // Begun, under the lock « Annuler » marks under: a mark left from before ends nothing of it. *writing = Some(folder.clone()); + shell.cancelling.lock().unwrap().remove(&(folder.clone(), Kind::Minutes)); drop(writing); // Started: out of the line, its agreement given, its last failure gone. shell.minutes_waiting.lock().unwrap().retain(|queued| queued.folder != folder); @@ -3230,9 +3304,7 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> .then(|| model.clone()); *shell.minutes_host.lock().unwrap() = (!providers::local(&provider)).then(|| host.clone()); shell.minutes_failed.lock().unwrap().remove(&folder); - // Begun again: no longer said stopped, and a cancel left from a making that never began ends none. shell.stopped.lock().unwrap().remove(&folder); - shell.cancelling.lock().unwrap().remove(&folder); minuting(app, true); let app = app.clone(); // The keyring may ask the user first: never on the window's and the tray's thread. @@ -3273,7 +3345,7 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> // Said confidential as it started: ended at once. if here() { making.end(); - } else if shell.cancelling.lock().unwrap().contains(&folder) { + } else if shell.cancelling.lock().unwrap().contains(&(folder.clone(), Kind::Minutes)) { // Cancelled before its program started — the keyring asked first —: ended at once. making.cancel(); } @@ -3303,7 +3375,8 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> .unwrap_or(summarising::Made::Failed(String::new(), None)); shell.minuting.lock().unwrap().take(); // Cancelled by the user (D92), and not written meanwhile: no failure, nothing told. - let cancelled = shell.cancelling.lock().unwrap().remove(&folder) && matches!(made, summarising::Made::Failed(..)); + let cancelled = + shell.cancelling.lock().unwrap().remove(&(folder.clone(), Kind::Minutes)) && matches!(made, summarising::Made::Failed(..)); let ended_here = matches!(made, summarising::Made::Failed(..)) && !cancelled && here(); // Replaced, the earlier minutes go to the trash — refused, they stay beside, and it is said. let mut kept_beside = None; @@ -3626,6 +3699,8 @@ fn hearing(shell: &Shell, folder: &Path, hearer: &Hearer) { }; shell.transcripts_failed.lock().unwrap().remove(folder); shell.stopped.lock().unwrap().remove(folder); + // Begun, under the lock « Annuler » marks under: a mark left from before ends nothing of it. + shell.cancelling.lock().unwrap().remove(&(folder.to_path_buf(), Kind::Transcript)); } /// How a transcript's making ended, for what follows it. @@ -3647,7 +3722,7 @@ fn heard(shell: &Shell, folder: &Path, made: &Made) -> Heard { shell.hearing_host.lock().unwrap().take(); let here = shell.heard_here.lock().unwrap().remove(folder); // Written all the same, as it was cancelled: written it is. - let cancelled = shell.cancelling.lock().unwrap().remove(folder) && !matches!(made, Made::Written(_)); + let cancelled = shell.cancelling.lock().unwrap().remove(&(folder.to_path_buf(), Kind::Transcript)) && !matches!(made, Made::Written(_)); if cancelled { shell.stopped.lock().unwrap().insert(folder.to_path_buf(), "transcript"); } @@ -3691,13 +3766,20 @@ fn transcribe_next(app: &AppHandle) { let at = waiting.iter().position(|(folder, again)| { matches!(again, Some(Again::Model(_))) || !default_model_missing_for(&own(&settings, folder), folder) }); - at.and_then(|at| waiting.remove(at)) + let next = at.and_then(|at| waiting.remove(at)); + // Said taken: « Annuler » meanwhile withdraws it (D92). + *shell.promoted_transcript.lock().unwrap() = next.as_ref().map(|(folder, _)| (folder.clone(), false)); + next }; + let taken = next.as_ref().map(|(folder, _)| folder.clone()); match next { None => return, Some((folder, None)) => transcribe(app, folder), Some((folder, Some(again))) => retranscribe_or_say(app, folder, again), } + if let Some(taken) = taken { + free(&shell.promoted_transcript, &taken); + } if shell.transcription.lock().unwrap().is_some() { return; } @@ -3719,6 +3801,10 @@ fn retranscribe_or_say(app: &AppHandle, folder: PathBuf, again: Again) { fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (Failure, String)> { let shell = app.state::(); let mut running = shell.transcription.lock().unwrap(); + // Taken from the line and withdrawn by « Annuler » since: nothing begins (D92). + if withdrawn(&shell.promoted_transcript, &folder) { + return Ok(()); + } if running.is_some() { // One at a time: it waits its turn, said on its page — the one being made too. drop(running); @@ -3905,6 +3991,10 @@ fn hearer_now(shell: &Shell, settings: &Settings, folder: &Path) -> (Hearer, Opt fn transcribe(app: &AppHandle, folder: PathBuf) { let shell = app.state::(); let mut running = shell.transcription.lock().unwrap(); + // Taken from the line and withdrawn by « Annuler » since: nothing begins (D92). + if withdrawn(&shell.promoted_transcript, &folder) { + return; + } if running.is_some() { wait(&shell, folder, None); return; diff --git a/modules/shell/tests/transcription.rs b/modules/shell/tests/transcription.rs index 63e7c653..3ba3de6d 100644 --- a/modules/shell/tests/transcription.rs +++ b/modules/shell/tests/transcription.rs @@ -345,3 +345,34 @@ sleep 60"#, assert!(gone(&child), "its child, deaf to TERM, still runs"); assert!(pressed.elapsed() <= Duration::from_secs(2)); } + +#[test] +fn cancelled_its_group_is_told_term_first_and_given_the_grace_to_end_by_it() { + let folder = tempfile::tempdir().unwrap(); + fs::create_dir(folder.path().join("session")).unwrap(); + // A child of the program, in its group, that ends on TERM saying so: TERM sent to the leader + // alone, or KILL at once, and it never says it. + let (transcription, said) = made( + folder.path(), + r#"( trap 'echo TERM > "$1/told"; exit 0' TERM; echo $$ > "$1/child"; sleep 60 & wait ) & +sleep 60"#, + ); + let child = folder.path().join("session/child"); + for _ in 0..50 { + if fs::read_to_string(&child).is_ok_and(|pid| !pid.trim().is_empty()) { + break; + } + std::thread::sleep(Duration::from_millis(100)); + } + assert!(child.exists(), "the program never started its child"); + transcription.cancel(); + said.recv_timeout(Duration::from_secs(2)).expect("not ended within two seconds"); + assert_eq!( + fs::read_to_string(folder.path().join("session/told")) + .ok() + .as_deref() + .map(str::trim), + Some("TERM"), + "its child was not told TERM within the grace" + ); +} From 3e518c7332dfaaf17aef6a7de1a427621ce26915 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:22:50 +0100 Subject: [PATCH 05/16] =?UTF-8?q?shell:=20=C2=AB=20Annuler=20=C2=BB=20by?= =?UTF-8?q?=20a=20cancellation=20token=20per=20making,=20its=20orders=20te?= =?UTF-8?q?sted=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The verifier's second review of the same piece found a third window between two locks: marks set by « Annuler » and read by a making's start and end could still be lost or left. The field's convention replaces them — Go's context, tokio's CancellationToken, .NET's: each making owns one token from the line to its end, cancelled, or holding its running program, under one lock. « Annuler » cancels the meeting's tokens — in a line, taken from it, being made —; a start begins nothing once cancelled, and holds its program, stopped at once if cancelled since; an end is « cancelled » by its own token alone. No mark, no set by meeting. tests/cancel.rs holds the token's three orders and a cancel racing the hold. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/cancel.rs | 54 ++++++ modules/shell/src/lib.rs | 1 + modules/shell/src/main.rs | 269 +++++++++++++++-------------- modules/shell/src/summarising.rs | 9 +- modules/shell/src/transcription.rs | 9 +- modules/shell/tests/cancel.rs | 71 ++++++++ 6 files changed, 286 insertions(+), 127 deletions(-) create mode 100644 modules/shell/src/cancel.rs create mode 100644 modules/shell/tests/cancel.rs diff --git a/modules/shell/src/cancel.rs b/modules/shell/src/cancel.rs new file mode 100644 index 00000000..da49f148 --- /dev/null +++ b/modules/shell/src/cancel.rs @@ -0,0 +1,54 @@ +//! « Annuler » (D92): one token for each making, from the moment it is asked to its end — as +//! Go's `context`, tokio's `CancellationToken` and .NET's own. Cancelled, or holding its running +//! program, under one lock: whichever comes first, the other sees it, and the program is stopped +//! once, whatever the order. + +use std::sync::{Arc, Mutex}; + +/// A making's own token: cloned to whoever may cancel it and to whoever runs it. +#[derive(Clone, Default)] +pub struct Cancel(Arc>); + +#[derive(Default)] +struct State { + cancelled: bool, + /// How to stop its program, once one runs and until it is stopped. + stop: Option>, +} + +impl Cancel { + /// Cancels the making: its program, if one is held, is stopped now; one held later is stopped + /// as it is held; one not started yet is never started by whoever asks [`Cancel::cancelled`]. + pub fn cancel(&self) { + let stop = { + let mut state = self.0.lock().unwrap_or_else(|poisoned| poisoned.into_inner()); + state.cancelled = true; + state.stop.take() + }; + if let Some(stop) = stop { + stop(); + } + } + + /// Whether it was cancelled: then nothing of it starts, and its end is said cancelled. + pub fn cancelled(&self) -> bool { + self.0.lock().unwrap_or_else(|poisoned| poisoned.into_inner()).cancelled + } + + /// Its program, just started: kept to be stopped on a cancel — or stopped at once, cancelled + /// already between its start and now. + pub fn hold(&self, stop: impl FnOnce() + Send + 'static) { + let mut state = self.0.lock().unwrap_or_else(|poisoned| poisoned.into_inner()); + if state.cancelled { + drop(state); + stop(); + } else { + state.stop = Some(Box::new(stop)); + } + } + + /// Whether two tokens are the one making's. + pub fn same(&self, other: &Cancel) -> bool { + Arc::ptr_eq(&self.0, &other.0) + } +} diff --git a/modules/shell/src/lib.rs b/modules/shell/src/lib.rs index f3e17766..6542264f 100644 --- a/modules/shell/src/lib.rs +++ b/modules/shell/src/lib.rs @@ -3,6 +3,7 @@ //! the shortcut and the window are built on this, and hold none of it. pub mod autostart; +pub mod cancel; pub mod confidential; pub mod context; pub mod correction; diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index 15231b7a..e501af1f 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -24,6 +24,7 @@ use tauri::{ }; use tauri_plugin_notification::NotificationExt; // A call starting is seen only on Linux, by PipeWire (D30). +use kitokey_shell::cancel::Cancel; #[cfg(target_os = "linux")] use kitokey_shell::microphone; use kitokey_shell::{ @@ -141,7 +142,7 @@ struct Shell { minutes_tried: Mutex>>, /// The sessions whose transcripts wait for the one being made, or for the model — in /// the order they were asked, each once; made again as a *Refaire…* asked (D25, D59). - waiting: Mutex)>>, + waiting: Mutex, Cancel)>>, /// The model making the transcript, and since when: said on the meeting's page (D25). hearing_by: Mutex>, /// Why a meeting's last transcript was not made, until one is begun (D25). @@ -167,15 +168,14 @@ struct Shell { /// made again here, their end is no failure to tell (D60). heard_here: Mutex>, written_here: Mutex>, - /// Makings the user cancelled (« Annuler », D92), by meeting and kind, until their program is - /// said ended: no failure then, nothing told, nothing made after them. A mark is set only under - /// its kind's lock — `transcription`, `writing_minutes` — while that making runs for the meeting, - /// and taken under it as the making ends or begins: never left to a later one. - cancelling: Mutex>, - /// The meeting taken from each line and not yet begun, and whether « Annuler » withdrew it - /// meanwhile: its start, under its kind's lock, then begins nothing (D92). - promoted_transcript: Mutex>, - promoted_minutes: Mutex>, + /// The token of the transcript being made, set and taken under `transcription`'s lock, and + /// of the minutes being written, under `writing_minutes`' (« Annuler », D92). + transcript_token: Mutex>, + minutes_token: Mutex>, + /// The making taken from each line and not yet begun, with its token: « Annuler » meanwhile + /// cancels it, and its start then begins nothing (D92). + promoted_transcript: Mutex>, + promoted_minutes: Mutex>, /// What was last cancelled of a meeting — its transcript or its minutes —, said on its page /// until a making of it starts again. stopped: Mutex>, @@ -480,7 +480,7 @@ fn main() { return; } match transcription::latest(&shell.settings().sessions) { - Some(last) => transcribe(app, last), + Some(last) => transcribe(app, last, Cancel::default()), None => tell(app, &words::trouble(&Trouble::NoSession, shell.language())), } } @@ -549,7 +549,8 @@ fn main() { minutes_host: Mutex::new(None), heard_here: Mutex::default(), written_here: Mutex::default(), - cancelling: Mutex::default(), + transcript_token: Mutex::default(), + minutes_token: Mutex::default(), promoted_transcript: Mutex::default(), promoted_minutes: Mutex::default(), stopped: Mutex::default(), @@ -1097,72 +1098,67 @@ fn minutes_redo( #[tauri::command] fn making_cancelled(shell: State<'_, Shell>, name: String) -> Result<(), Told> { let folder = session_folder(&shell, &name)?; - // Out of the lines; taken from one and not yet begun, withdrawn: its start begins nothing. - let withdraw = |slot: &Mutex>| { - if let Some((taken, withdrawn)) = slot.lock().unwrap().as_mut() + // Each making of it cancelled by its own token: waiting in a line — taken out —, taken from one + // and not yet begun, or being made, read under its kind's lock. Its start and its end read the + // same token: whichever comes first, the other sees it. + let taken = |slot: &Mutex>| { + if let Some((taken, token)) = slot.lock().unwrap().as_ref() && *taken == folder { - *withdrawn = true; + token.cancel(); } }; { let mut waiting = shell.waiting.lock().unwrap(); - waiting.retain(|(queued, _)| *queued != folder); - withdraw(&shell.promoted_transcript); + waiting.retain(|(queued, _, token)| { + let ours = *queued == folder; + if ours { + token.cancel(); + } + !ours + }); + taken(&shell.promoted_transcript); } { let mut waiting = shell.minutes_waiting.lock().unwrap(); - waiting.retain(|queued| queued.folder != folder); - withdraw(&shell.promoted_minutes); + waiting.retain(|queued| { + let ours = queued.folder == folder; + if ours { + queued.cancel.cancel(); + } + !ours + }); + taken(&shell.promoted_minutes); } - // Being made: marked under its kind's lock — a start in progress is waited for, an end already - // taken leaves nothing to mark —, then stopped; its end finds the mark. - let running = shell.transcription.lock().unwrap(); - if let (Some(transcription), true) = (running.as_ref(), shell.hearing.lock().unwrap().as_deref() == Some(folder.as_path())) { - shell.cancelling.lock().unwrap().insert((folder.clone(), Kind::Transcript)); - transcription.cancel(); + { + let _running = shell.transcription.lock().unwrap(); + if shell.hearing.lock().unwrap().as_deref() == Some(folder.as_path()) + && let Some(token) = shell.transcript_token.lock().unwrap().as_ref() + { + token.cancel(); + } } - drop(running); - let writing = shell.writing_minutes.lock().unwrap(); - if writing.as_deref() == Some(folder.as_path()) { - shell.cancelling.lock().unwrap().insert((folder.clone(), Kind::Minutes)); - // Not started yet — the keyring asked first —: its start finds it marked, and ends it. - if let Some(making) = shell.minuting.lock().unwrap().as_ref() { - making.cancel(); + { + let writing = shell.writing_minutes.lock().unwrap(); + if writing.as_deref() == Some(folder.as_path()) + && let Some(token) = shell.minutes_token.lock().unwrap().as_ref() + { + token.cancel(); } } - drop(writing); tracing::info!(session = %name, "shell.making_cancelled"); Ok(()) } -/// What a making makes, for the marks « Annuler » leaves (D92). -#[derive(Clone, Copy, Hash, PartialEq, Eq)] -enum Kind { - Transcript, - Minutes, -} - -/// The slot of a meeting taken from a line freed once its start has been tried — begun, or not —, +/// The slot of a making taken from a line freed once its start has been tried — begun, or not —, /// unless it already holds the next one taken. -fn free(slot: &Mutex>, folder: &Path) { +fn free(slot: &Mutex>, token: &Cancel) { let mut slot = slot.lock().unwrap(); - if slot.as_ref().is_some_and(|(taken, _)| taken == folder) { + if slot.as_ref().is_some_and(|(_, taken)| taken.same(token)) { *slot = None; } } -/// Whether the meeting taken from a line was withdrawn by « Annuler » before it began: then -/// nothing begins, and the slot is freed (D92). -fn withdrawn(slot: &Mutex>, folder: &Path) -> bool { - let mut slot = slot.lock().unwrap(); - let withdrawn = slot.as_ref().is_some_and(|(taken, withdrawn)| *withdrawn && taken == folder); - if withdrawn { - *slot = None; - } - withdrawn -} - /// A line of a meeting's transcript corrected on the user's word (D62, ADR-0014): once complete, /// never while it is made or waits to be made again. The making's lock held while it is written: /// one writer at a time. @@ -1171,7 +1167,7 @@ fn transcript_corrected(shell: State<'_, Shell>, name: String, track: String, st let folder = session_folder(&shell, &name)?; let running = shell.transcription.lock().unwrap(); let hearing = shell.hearing.lock().unwrap().as_deref() == Some(folder.as_path()); - let waits = shell.waiting.lock().unwrap().iter().any(|(queued, _)| *queued == folder); + let waits = shell.waiting.lock().unwrap().iter().any(|(queued, ..)| *queued == folder); if (running.is_some() && hearing) || waits { return Err(shell.told(Failure::Busy, format!("the transcript of {name} is being made"))); } @@ -1196,7 +1192,7 @@ fn transcript_corrected(shell: State<'_, Shell>, name: String, track: String, st #[tauri::command] fn transcript_redo(app: AppHandle, shell: State<'_, Shell>, name: String, model: PathBuf) -> Result<(), Told> { let folder = session_folder(&shell, &name)?; - retranscribe(&app, folder, Again::Model(model)).map_err(|(failure, detail)| shell.told(failure, detail)) + retranscribe(&app, folder, Again::Model(model), Cancel::default()).map_err(|(failure, detail)| shell.told(failure, detail)) } /// *Refaire…* on a transcript (D91): made again by whoever the meeting's own models name — chosen @@ -1204,7 +1200,7 @@ fn transcript_redo(app: AppHandle, shell: State<'_, Shell>, name: String, model: #[tauri::command] fn transcript_redo_own(app: AppHandle, shell: State<'_, Shell>, name: String) -> Result<(), Told> { let folder = session_folder(&shell, &name)?; - retranscribe(&app, folder, Again::Own).map_err(|(failure, detail)| shell.told(failure, detail)) + retranscribe(&app, folder, Again::Own, Cancel::default()).map_err(|(failure, detail)| shell.told(failure, detail)) } /// *Try again*, on a meeting whose transcript was not made: as it was last asked — made again @@ -1215,8 +1211,8 @@ fn transcript_again(app: AppHandle, shell: State<'_, Shell>, name: String) -> Re // Read, and the lock let go, before it is asked again: retranscribe takes it too. let tried = shell.transcripts_tried.lock().unwrap().get(&folder).cloned().flatten(); match tried { - Some(again) => retranscribe_or_say(&app, folder, again), - None => transcribe(&app, folder), + Some(again) => retranscribe_or_say(&app, folder, again, Cancel::default()), + None => transcribe(&app, folder, Cancel::default()), } Ok(()) } @@ -1228,7 +1224,7 @@ fn transcript_asked(app: AppHandle, shell: State<'_, Shell>, name: String) -> Re if shell.recording.lock().unwrap().is_some() && shell.recorded.lock().unwrap().as_deref() == Some(folder.as_path()) { return Err(shell.told(Failure::Busy, format!("{name} is being recorded"))); } - transcribe(&app, folder); + transcribe(&app, folder, Cancel::default()); Ok(()) } @@ -1872,8 +1868,8 @@ fn confidential_set(app: AppHandle, shell: State<'_, Shell>, name: String, on: b confidential::add(&mut left, What::Sound, &host); shell.heard_here.lock().unwrap().insert(folder.clone()); let mut waiting = shell.waiting.lock().unwrap(); - waiting.retain(|(queued, _)| *queued != folder); - waiting.push_front((folder.clone(), Some(Again::Settings))); + waiting.retain(|(queued, ..)| *queued != folder); + waiting.push_front((folder.clone(), Some(Again::Settings), Cancel::default())); drop(waiting); tracing::info!(host = %host, "shell.confidential_ended"); transcription.end(); @@ -1910,7 +1906,7 @@ fn confidential_set(app: AppHandle, shell: State<'_, Shell>, name: String, on: b shell.asked_again.lock().unwrap().remove(&folder); } if !writing && !queued && (awaiting || by_service) { - write_minutes_from(&app, folder.clone(), None, None, true); + write_minutes_from(&app, folder.clone(), None, None, true, Cancel::default()); } Ok(confidential_of(&shell, &folder)) } @@ -2010,7 +2006,7 @@ fn context_redo(app: AppHandle, shell: State<'_, Shell>, name: String) -> Result return Err(shell.told(closed.failure(), format!("{name} cannot be made again now: {closed:?}"))); } // One that cannot begin — no model, the program missing — says why on its page. - retranscribe_or_say(&app, folder, Again::Settings); + retranscribe_or_say(&app, folder, Again::Settings, Cancel::default()); Ok(()) } @@ -2870,6 +2866,8 @@ struct Queued { folder: PathBuf, agreed: Option, chosen: Option<(String, String)>, + /// Its own token, from the line to its end (D92). + cancel: Cancel, } /// A making of minutes is over: its meeting free, its failure kept for its page, and the next @@ -2902,11 +2900,10 @@ fn minutes_next(app: &AppHandle) { let shell = app.state::(); minuting(app, false); { - // Freed with any mark an « Annuler » pressed after its end left: none ends a later making. + // Freed with its token, under the one lock: « Annuler » after this finds none. let mut writing = shell.writing_minutes.lock().unwrap(); - if let Some(ended) = writing.take() { - shell.cancelling.lock().unwrap().remove(&(ended, Kind::Minutes)); - } + writing.take(); + shell.minutes_token.lock().unwrap().take(); } if *shell.leaving.lock().unwrap() { return; @@ -2916,16 +2913,16 @@ fn minutes_next(app: &AppHandle) { let next = { let mut waiting = shell.minutes_waiting.lock().unwrap(); let next = waiting.pop_front(); - *shell.promoted_minutes.lock().unwrap() = next.as_ref().map(|next| (next.folder.clone(), false)); + *shell.promoted_minutes.lock().unwrap() = next.as_ref().map(|next| (next.folder.clone(), next.cancel.clone())); next }; let Some(next) = next else { return; }; // Started, or set aside (an agreement to give, a reason it cannot): the next one then. - let taken = next.folder.clone(); - write_minutes_from(app, next.folder, next.agreed.as_deref(), next.chosen, true); - free(&shell.promoted_minutes, &taken); + let token = next.cancel.clone(); + write_minutes_from(app, next.folder, next.agreed.as_deref(), next.chosen, true, next.cancel); + free(&shell.promoted_minutes, &token); if shell.writing_minutes.lock().unwrap().is_some() { return; } @@ -2943,6 +2940,7 @@ fn minutes_ended_here(app: &AppHandle, folder: &Path) { folder: folder.to_path_buf(), agreed: None, chosen: None, + cancel: Cancel::default(), }); drop(waiting); shell.minutes_by.lock().unwrap().take(); @@ -3045,8 +3043,8 @@ fn makings(shell: State<'_, Shell>) -> Makings { let settings = shell.settings(); let (transcripts_waiting, model_needed) = { let waiting = shell.waiting.lock().unwrap(); - let names = waiting.iter().map(|(folder, _)| named(folder)).collect(); - let needed = default_model_missing(&settings) || waiting.iter().any(|(folder, _)| default_model_missing_for(&settings, folder)); + let names = waiting.iter().map(|(folder, ..)| named(folder)).collect(); + let needed = default_model_missing(&settings) || waiting.iter().any(|(folder, ..)| default_model_missing_for(&settings, folder)); (names, needed) }; Makings { @@ -3152,19 +3150,26 @@ fn look_again(app: &AppHandle) { .remove(&folder) .filter(|asked| asked.named == named) .map(|asked| asked.choice); - write_minutes_from(app, folder, None, chosen, true); + write_minutes_from(app, folder, None, chosen, true, Cancel::default()); } } /// The same, `agreed_now` naming the host the user just agreed to send this meeting to, once: /// the gate is passed only if that is still the host the settings name as it is read here. fn write_minutes(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str>, chosen: Option<(String, String)>) { - write_minutes_from(app, folder, agreed_now, chosen, false); + write_minutes_from(app, folder, agreed_now, chosen, false, Cancel::default()); } /// `from_line`: taken from the line, where nobody asked just now — an agreement it needs is set /// aside and said on its page, never a window opened over what the user is doing. -fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str>, chosen: Option<(String, String)>, from_line: bool) { +fn write_minutes_from( + app: &AppHandle, + folder: PathBuf, + agreed_now: Option<&str>, + chosen: Option<(String, String)>, + from_line: bool, + cancel: Cancel, +) { let shell = app.state::(); let writing = shell.writing_minutes.lock().unwrap(); if let Some(being) = writing.as_ref() { @@ -3184,6 +3189,7 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> folder, agreed: agreed_now.map(str::to_string), chosen, + cancel, }); } return; @@ -3283,15 +3289,15 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> if writing.is_some() { // Another started meanwhile, between the reading and now: this one waits its turn. drop(writing); - return write_minutes_from(app, folder, agreed_now, again.then_some((provider, model)), from_line); + return write_minutes_from(app, folder, agreed_now, again.then_some((provider, model)), from_line, cancel); } - // Taken from the line and withdrawn by « Annuler » since: nothing begins (D92). - if withdrawn(&shell.promoted_minutes, &folder) { + // Cancelled before it began: nothing begins (D92). + if cancel.cancelled() { return; } - // Begun, under the lock « Annuler » marks under: a mark left from before ends nothing of it. + // Begun, its token with it under the lock « Annuler » reads it under. *writing = Some(folder.clone()); - shell.cancelling.lock().unwrap().remove(&(folder.clone(), Kind::Minutes)); + *shell.minutes_token.lock().unwrap() = Some(cancel.clone()); drop(writing); // Started: out of the line, its agreement given, its last failure gone. shell.minutes_waiting.lock().unwrap().retain(|queued| queued.folder != folder); @@ -3331,6 +3337,9 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> || !providers::local(&provider) && (confidential::marked(&folder) || shell.written_here.lock().unwrap().contains(&folder)); let started = if here() { Err(std::io::Error::other("the meeting was said confidential")) + } else if cancel.cancelled() { + // Cancelled while the keyring was asked: never started (D92). + Err(std::io::Error::other("cancelled")) } else { Summarising::start( &program("kitokey-summary", "KITOKEY_SUMMARY"), @@ -3345,13 +3354,18 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> // Said confidential as it started: ended at once. if here() { making.end(); - } else if shell.cancelling.lock().unwrap().contains(&(folder.clone(), Kind::Minutes)) { - // Cancelled before its program started — the keyring asked first —: ended at once. - making.cancel(); } + // Held by its token: cancelled meanwhile, it is stopped at once (D92). + cancel.hold(making.stopper()); *shell.minuting.lock().unwrap() = Some(making); events } + Err(_) if cancel.cancelled() => { + if let Some(previous) = &previous { + let _ = std::fs::remove_file(previous); + } + return minutes_cancelled(&app, &folder); + } Err(_) if here() => { if let Some(previous) = &previous { let _ = std::fs::remove_file(previous); @@ -3375,8 +3389,7 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> .unwrap_or(summarising::Made::Failed(String::new(), None)); shell.minuting.lock().unwrap().take(); // Cancelled by the user (D92), and not written meanwhile: no failure, nothing told. - let cancelled = - shell.cancelling.lock().unwrap().remove(&(folder.clone(), Kind::Minutes)) && matches!(made, summarising::Made::Failed(..)); + let cancelled = cancel.cancelled() && matches!(made, summarising::Made::Failed(..)); let ended_here = matches!(made, summarising::Made::Failed(..)) && !cancelled && here(); // Replaced, the earlier minutes go to the trash — refused, they stay beside, and it is said. let mut kept_beside = None; @@ -3403,6 +3416,7 @@ fn write_minutes_from(app: &AppHandle, folder: PathBuf, agreed_now: Option<&str> folder: folder.clone(), agreed: None, chosen: None, + cancel: Cancel::default(), }); } minutes_ended( @@ -3673,18 +3687,18 @@ fn listen(app: &AppHandle, said: &Receiver, trial: Option<&Path>) { } // Quitting, the stop's transcript is not begun: it is made from the menu next time. if let Some(folder) = stopped.filter(|_| !*shell.leaving.lock().unwrap()) { - transcribe(app, folder); + transcribe(app, folder, Cancel::default()); } } /// Puts a session in line for its transcript, once — made again as a *Refaire…* asked, the /// newer ask kept when it is asked again. -fn wait(shell: &Shell, folder: PathBuf, again: Option) { +fn wait(shell: &Shell, folder: PathBuf, again: Option, cancel: Cancel) { let mut waiting = shell.waiting.lock().unwrap(); - match waiting.iter_mut().find(|(queued, _)| *queued == folder) { - Some((_, chosen)) if again.is_some() => *chosen = again, + match waiting.iter_mut().find(|(queued, ..)| *queued == folder) { + Some((_, chosen, _)) if again.is_some() => *chosen = again, Some(_) => {} - None => waiting.push_back((folder, again)), + None => waiting.push_back((folder, again, cancel)), } } @@ -3699,8 +3713,6 @@ fn hearing(shell: &Shell, folder: &Path, hearer: &Hearer) { }; shell.transcripts_failed.lock().unwrap().remove(folder); shell.stopped.lock().unwrap().remove(folder); - // Begun, under the lock « Annuler » marks under: a mark left from before ends nothing of it. - shell.cancelling.lock().unwrap().remove(&(folder.to_path_buf(), Kind::Transcript)); } /// How a transcript's making ended, for what follows it. @@ -3715,14 +3727,14 @@ enum Heard { } /// A transcript ended: counted when written, its reason kept when not — said on its page —, or -/// said stopped when the user cancelled it. -fn heard(shell: &Shell, folder: &Path, made: &Made) -> Heard { +/// said stopped when its own token was cancelled. +fn heard(shell: &Shell, folder: &Path, made: &Made, cancelled: bool) -> Heard { shell.hearing.lock().unwrap().take(); shell.hearing_by.lock().unwrap().take(); shell.hearing_host.lock().unwrap().take(); let here = shell.heard_here.lock().unwrap().remove(folder); - // Written all the same, as it was cancelled: written it is. - let cancelled = shell.cancelling.lock().unwrap().remove(&(folder.to_path_buf(), Kind::Transcript)) && !matches!(made, Made::Written(_)); + // Written all the same, as it was cancelled: written it is — never a whole one thrown away. + let cancelled = cancelled && !matches!(made, Made::Written(_)); if cancelled { shell.stopped.lock().unwrap().insert(folder.to_path_buf(), "transcript"); } @@ -3763,23 +3775,22 @@ fn transcribe_next(app: &AppHandle) { let settings = shell.settings(); let next = { let mut waiting = shell.waiting.lock().unwrap(); - let at = waiting.iter().position(|(folder, again)| { + let at = waiting.iter().position(|(folder, again, _)| { matches!(again, Some(Again::Model(_))) || !default_model_missing_for(&own(&settings, folder), folder) }); let next = at.and_then(|at| waiting.remove(at)); - // Said taken: « Annuler » meanwhile withdraws it (D92). - *shell.promoted_transcript.lock().unwrap() = next.as_ref().map(|(folder, _)| (folder.clone(), false)); + // Said taken, with its token: « Annuler » meanwhile cancels it (D92). + *shell.promoted_transcript.lock().unwrap() = next.as_ref().map(|(folder, _, token)| (folder.clone(), token.clone())); next }; - let taken = next.as_ref().map(|(folder, _)| folder.clone()); - match next { - None => return, - Some((folder, None)) => transcribe(app, folder), - Some((folder, Some(again))) => retranscribe_or_say(app, folder, again), - } - if let Some(taken) = taken { - free(&shell.promoted_transcript, &taken); + let Some((folder, again, token)) = next else { + return; + }; + match again { + None => transcribe(app, folder, token.clone()), + Some(again) => retranscribe_or_say(app, folder, again, token.clone()), } + free(&shell.promoted_transcript, &token); if shell.transcription.lock().unwrap().is_some() { return; } @@ -3787,8 +3798,8 @@ fn transcribe_next(app: &AppHandle) { } /// Made again as a Refaire… asked; one that cannot begin says why on its page. -fn retranscribe_or_say(app: &AppHandle, folder: PathBuf, again: Again) { - if let Err((_, why)) = retranscribe(app, folder.clone(), again) { +fn retranscribe_or_say(app: &AppHandle, folder: PathBuf, again: Again, cancel: Cancel) { + if let Err((_, why)) = retranscribe(app, folder.clone(), again, cancel) { app.state::().transcripts_failed.lock().unwrap().insert(folder, why); } } @@ -3798,17 +3809,17 @@ fn retranscribe_or_say(app: &AppHandle, folder: PathBuf, again: Again) { /// transcript there stays in place until the new one is whole — set aside for the run, since the /// program goes on from a transcript it finds —, then goes to the system's trash; a run that /// fails, or that Kitokey ends as it quits, puts it back. -fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (Failure, String)> { +fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again, cancel: Cancel) -> Result<(), (Failure, String)> { let shell = app.state::(); let mut running = shell.transcription.lock().unwrap(); - // Taken from the line and withdrawn by « Annuler » since: nothing begins (D92). - if withdrawn(&shell.promoted_transcript, &folder) { + // Cancelled before it began: nothing begins (D92). + if cancel.cancelled() { return Ok(()); } if running.is_some() { // One at a time: it waits its turn, said on its page — the one being made too. drop(running); - wait(&shell, folder, Some(again)); + wait(&shell, folder, Some(again), cancel); return Ok(()); } shell.transcripts_tried.lock().unwrap().insert(folder.clone(), Some(again.clone())); @@ -3830,7 +3841,7 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (F // model is offered, as for a first transcript. if matches!(again, Again::Settings | Again::Own) && *model == Settings::default().model { drop(running); - wait(&shell, folder, Some(again)); + wait(&shell, folder, Some(again), cancel); if !*shell.fetching.lock().unwrap() { offer(app); } @@ -3870,7 +3881,10 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (F return Err((Failure::ProgramNotStarted, error.to_string())); } }; + // Held by its token: cancelled meanwhile, it is stopped at once (D92). + cancel.hold(transcription.stopper()); *running = Some(transcription); + *shell.transcript_token.lock().unwrap() = Some(cancel.clone()); // Who puts the earlier transcript back, or trashes it: this run's end, or Kitokey quitting — // whichever comes first takes it, the other finds nothing. *shell.redoing.lock().unwrap() = previous.clone().map(|previous| (current.clone(), previous)); @@ -3884,7 +3898,8 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again) -> Result<(), (F // Ended and said so at once: none begun in between loses what it says of itself. let mut running = shell.transcription.lock().unwrap(); running.take(); - let here = heard(&shell, &folder, &made); + shell.transcript_token.lock().unwrap().take(); + let here = heard(&shell, &folder, &made, cancel.cancelled()); drop(running); transcribing(&app, false); // Replaced, the earlier transcript goes to the trash — refused, it stays beside, and it is @@ -3988,15 +4003,15 @@ fn hearer_now(shell: &Shell, settings: &Settings, folder: &Path) -> (Hearer, Opt /// Makes the transcript of a session — after the one being made, if there is one. What is /// missing — the model, the program — is said in one sentence, and on its page; the recording is /// never touched. Whether it began. -fn transcribe(app: &AppHandle, folder: PathBuf) { +fn transcribe(app: &AppHandle, folder: PathBuf, cancel: Cancel) { let shell = app.state::(); let mut running = shell.transcription.lock().unwrap(); - // Taken from the line and withdrawn by « Annuler » since: nothing begins (D92). - if withdrawn(&shell.promoted_transcript, &folder) { + // Cancelled before it began: nothing begins (D92). + if cancel.cancelled() { return; } if running.is_some() { - wait(&shell, folder, None); + wait(&shell, folder, None, cancel); return; } shell.transcripts_tried.lock().unwrap().insert(folder.clone(), None); @@ -4007,7 +4022,7 @@ fn transcribe(app: &AppHandle, folder: PathBuf) { if matches!(hearer, Hearer::Model(_)) && !model.is_file() { // The default model is offered, its size and host shown; one the user named is theirs. if *model == Settings::default().model { - wait(&shell, folder, None); + wait(&shell, folder, None, cancel); // Already coming: the session waits for it, and nothing is offered twice. if !*shell.fetching.lock().unwrap() { offer(app); @@ -4041,7 +4056,10 @@ fn transcribe(app: &AppHandle, folder: PathBuf) { return; } }; + // Held by its token: cancelled meanwhile, it is stopped at once (D92). + cancel.hold(transcription.stopper()); *running = Some(transcription); + *shell.transcript_token.lock().unwrap() = Some(cancel.clone()); hearing(&shell, &folder, &hearer); transcribing(app, true); let heard_folder = folder; @@ -4051,7 +4069,8 @@ fn transcribe(app: &AppHandle, folder: PathBuf) { let shell = app.state::(); let mut running = shell.transcription.lock().unwrap(); running.take(); - let here = heard(&shell, &heard_folder, &made); + shell.transcript_token.lock().unwrap().take(); + let here = heard(&shell, &heard_folder, &made, cancel.cancelled()); drop(running); transcribing(&app, false); // Cancelled: what it began is no version, nor taken up by the next model's making (D92). @@ -4244,7 +4263,7 @@ fn pull(app: &AppHandle) { if outcome.is_ok() { let waited: Vec = shell.ollama_waiting.lock().unwrap().keys().cloned().collect(); for folder in waited { - write_minutes_from(&app, folder, None, None, true); + write_minutes_from(&app, folder, None, None, true, Cancel::default()); } } }); diff --git a/modules/shell/src/summarising.rs b/modules/shell/src/summarising.rs index ab1a1403..ced6e00a 100644 --- a/modules/shell/src/summarising.rs +++ b/modules/shell/src/summarising.rs @@ -192,8 +192,15 @@ impl Summarising { /// Stops the program on the user's word, « Annuler » (D92), as a transcript's: within two /// seconds, without waiting here; the minutes there stay. pub fn cancel(&self) { + (self.stopper())(); + } + + /// The same, to be held by the making's token (`crate::cancel::Cancel::hold`). + pub fn stopper(&self) -> impl FnOnce() + Send + 'static { let program = Arc::clone(&self.program); - thread::spawn(move || crate::transcription::cancel(&program)); + move || { + thread::spawn(move || crate::transcription::cancel(&program)); + } } } diff --git a/modules/shell/src/transcription.rs b/modules/shell/src/transcription.rs index dabda99b..739eebb4 100644 --- a/modules/shell/src/transcription.rs +++ b/modules/shell/src/transcription.rs @@ -238,8 +238,15 @@ impl Transcription { /// Stops the program on the user's word, « Annuler » (D92): within two seconds, without /// waiting here. What it had written is the shell's to settle once it is said ended. pub fn cancel(&self) { + (self.stopper())(); + } + + /// The same, to be held by the making's token (`crate::cancel::Cancel::hold`). + pub fn stopper(&self) -> impl FnOnce() + Send + 'static { let program = Arc::clone(&self.program); - thread::spawn(move || cancel(&program)); + move || { + thread::spawn(move || cancel(&program)); + } } } diff --git a/modules/shell/tests/cancel.rs b/modules/shell/tests/cancel.rs new file mode 100644 index 00000000..023fe6b6 --- /dev/null +++ b/modules/shell/tests/cancel.rs @@ -0,0 +1,71 @@ +//! « Annuler »'s token (D92) in its three orders, a played program counting its stops: cancelled +//! before the program starts, between its start and its hold, and once held. + +use std::sync::{ + Arc, + atomic::{AtomicUsize, Ordering}, +}; + +use kitokey_shell::cancel::Cancel; + +/// A played program's stop, counted. +fn program() -> (Arc, impl FnOnce() + Send + 'static) { + let stops = Arc::new(AtomicUsize::new(0)); + let counted = Arc::clone(&stops); + (stops, move || { + counted.fetch_add(1, Ordering::SeqCst); + }) +} + +#[test] +fn cancelled_before_its_program_starts_it_says_so_and_none_is_started() { + let token = Cancel::default(); + assert!(!token.cancelled()); + token.cancel(); + assert!(token.cancelled(), "whoever would start it must see it cancelled"); +} + +#[test] +fn cancelled_between_its_programs_start_and_its_hold_the_program_is_stopped_as_it_is_held() { + let token = Cancel::default(); + let (stops, stop) = program(); + // Started; « Annuler » now; then held. + token.cancel(); + assert_eq!(stops.load(Ordering::SeqCst), 0); + token.hold(stop); + assert_eq!(stops.load(Ordering::SeqCst), 1, "held after a cancel, it is stopped at once"); + token.cancel(); + assert_eq!(stops.load(Ordering::SeqCst), 1, "stopped once"); +} + +#[test] +fn cancelled_once_held_the_program_is_stopped_once() { + let token = Cancel::default(); + let (stops, stop) = program(); + token.hold(stop); + assert_eq!(stops.load(Ordering::SeqCst), 0, "held, it runs"); + token.cancel(); + token.cancel(); + assert_eq!(stops.load(Ordering::SeqCst), 1); + assert!(token.cancelled()); +} + +#[test] +fn a_cancel_racing_the_hold_stops_the_program_exactly_once_whichever_comes_first() { + for _ in 0..2000 { + let token = Cancel::default(); + let (stops, stop) = program(); + let cancelling = token.clone(); + let cancel = std::thread::spawn(move || cancelling.cancel()); + token.hold(stop); + cancel.join().unwrap(); + assert_eq!(stops.load(Ordering::SeqCst), 1); + } +} + +#[test] +fn a_making_is_told_from_another_by_its_token() { + let one = Cancel::default(); + assert!(one.same(&one.clone())); + assert!(!one.same(&Cancel::default())); +} From 306147553af5815508dd002801489fb86516d2c3 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:26:32 +0100 Subject: [PATCH 06/16] =?UTF-8?q?shell:=20a=20transcript=20written=20after?= =?UTF-8?q?=20=C2=AB=20Annuler=20=C2=BB=20is=20kept,=20and=20nothing=20fol?= =?UTF-8?q?lows=20it=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The decider's case, as the coordinator settled it: Annuler is pressed to change the model. A transcript its program wrote all the same is whole and kept, shown as written — never said stopped —, but no notification is sent and no minutes are made after it with the model being changed, whatever `after` says. The same for minutes written after a cancel: kept, nothing told. BE holds it: the played program finishing on TERM, the settings chaining the minutes, none made and nothing notified. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 39 ++++++++++++++++++++++++++++- modules/shell/src/main.rs | 13 +++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index c67a95c0..8e44a004 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -105,6 +105,8 @@ # Held, as a long meeting heard (D92): a transcript begun, its number and its child's — deaf to TERM — noted, then waits. if [ -e "$(dirname "$0")/hold-hearing" ]; then printf '{"type":"header","contract":"transcript/v1","engine":"%s","model":"%s","language":null,"context":null}\n' "$engine" "$model" > "$1/transcript.jsonl" + # Told to stop, it finishes all the same when the scenario says so: a transcript written after « Annuler ». + [ -e "$(dirname "$0")/hold-hearing-finish" ] && trap 'printf '"'"'{"type":"complete","duration":1.0}\n'"'"' >> "$1/transcript.jsonl"; exit 0' TERM echo $$ > "$(dirname "$0")/held-hearing"; ( trap '' TERM; exec sleep 60 ) & echo $! > "$(dirname "$0")/held-hearing-child"; sleep 60; exit 0 fi context=$(python3 -c "$CONTEXT" "$1") @@ -2152,7 +2154,8 @@ def cancelled_at_once(now: dt.datetime) -> None: for model in (a, b): model.write_bytes(b"\0" * 16) local = "http://localhost:11434/v1" - window = Window(meetings, "fr_FR.UTF-8", f'reminder = false\nmodel = "{a}"\nminutes_provider = "{local}"\nminutes_model = "writer-a"\n') + # The minutes follow a transcript (`after`): none must follow one written after « Annuler ». + window = Window(meetings, "fr_FR.UTF-8", f'reminder = false\nafter = "minutes"\nmodel = "{a}"\nminutes_provider = "{local}"\nminutes_model = "writer-a"\n') window.env.update(XDG_DATA_HOME=str(data)) sha = lambda path: hashlib.sha256(path.read_bytes()).hexdigest() if path.exists() else None idle = "return window.__TAURI__.core.invoke('makings').then(m => m.transcript === null && m.minutes === null && m.transcripts_waiting.length === 0 && m.minutes_waiting.length === 0)" @@ -2231,6 +2234,40 @@ def cancelled_at_once(now: dt.datetime) -> None: browser.execute_script("return window.__TAURI__.core.invoke('transcript_redo', {name: arguments[0], model: arguments[1]})", fresh.name, str(b)) made = wait_for(browser, lambda b: (fresh / "transcript.jsonl").exists() and b.execute_script(idle), 15) check("then another model makes it whole at once", made and '"model":"ggml-tiny-b"' in (fresh / "transcript.jsonl").read_text()) + # Written all the same after « Annuler » (the decider's decision, 2026-11-13): kept, being + # whole, shown as written — never said stopped —, and nothing follows it: no notification, + # no minutes made with the model the user was changing, though the settings chain them. + finished = meetings / "2026-11-13_18-30" + session(finished, now - dt.timedelta(minutes=20), 1, {"local.wav": 1000}) + held.unlink(missing_ok=True) + (WORK / "summary-args").unlink(missing_ok=True) + (WORK / "hold-hearing").touch() + (WORK / "hold-hearing-finish").touch() + notified = WORK / "notified-cancelled-finished" + monitor = subprocess.Popen(["dbus-monitor", "--session", "interface='org.freedesktop.Notifications',member='Notify'"], + stdout=open(notified, "w"), stderr=subprocess.DEVNULL) + try: + time.sleep(0.5) + browser.execute_script("window.__TAURI__.core.invoke('transcript_asked', {name: arguments[0]})", finished.name) + running = wait_for(browser, lambda b: held.exists(), 15) + browser.execute_script(f"location.hash = '#/meeting/{finished.name}'") + offered = running and wait_for(browser, lambda b: b.execute_script("const c = document.getElementById('making-cancel'); return !!c && c.getClientRects().length > 0"), 10) + check("finishing all the same: « Annuler » on its page", offered) + if offered: + press(browser, "making-cancel") + ended = wait_for(browser, lambda b: b.execute_script(idle), 3) + whole = (finished / "transcript.jsonl").read_text() if (finished / "transcript.jsonl").exists() else "" + check("written all the same after « Annuler »: kept whole", ended and '"type":"complete"' in whole, whole) + time.sleep(3) + stopped = browser.execute_script("const s = document.getElementById('making-stopped'); return s ? s.textContent : ''") + check("written all the same: not said stopped on its page", stopped == "", stopped) + check("written all the same: no minutes made after it, though the settings chain them", + not (WORK / "summary-args").exists() and not (finished / "minutes.md").exists()) + check("written all the same: no notification", "member=Notify" not in notified.read_text(), notified.read_text()[-300:]) + finally: + monitor.terminate() + (WORK / "hold-hearing").unlink(missing_ok=True) + (WORK / "hold-hearing-finish").unlink(missing_ok=True) LONG = "hf.co/unsloth/Mistral-Small-3.2-24B-Instruct-2506-GGUF:UD-Q4_K_XL-very-long-name" diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index e501af1f..861e5fc9 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -3428,7 +3428,8 @@ fn write_minutes_from( }, own_model.as_deref(), ); - if *shell.leaving.lock().unwrap() { + // Written all the same after « Annuler »: kept, being whole, and nothing told (D92). + if *shell.leaving.lock().unwrap() || cancel.cancelled() { return; } let written = matches!(made, summarising::Made::Written(_)); @@ -3931,6 +3932,11 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again, cancel: Cancel) } return transcribe_next(&app); } + // Written all the same after « Annuler »: kept, being whole, but nothing follows it — no + // notification, no minutes made with a model the user was changing (D92). + if cancel.cancelled() { + return transcribe_next(&app); + } // Made again and ready, its click opens the meeting as after a stop (D44). match &made { Made::Written(_) => tell_opening(&app, &words::made(&made, shell.language()), folder.clone()), @@ -4086,6 +4092,11 @@ fn transcribe(app: &AppHandle, folder: PathBuf, cancel: Cancel) { if here != Heard::Ended { return transcribe_next(&app); } + // Written all the same after « Annuler »: kept, being whole, but nothing follows it — no + // notification, no minutes made with a model the user was changing (D92). + if cancel.cancelled() { + return transcribe_next(&app); + } let notice = words::made(&made, shell.language()); match made { Made::Written(folder) => { From 3934563d9afb008d8ef43b1cd352eb85e255b3b1 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:47:30 +0100 Subject: [PATCH 07/16] shell: D92's one notification held by the window's e2e before it is built (AL) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AL now asks, of a meeting made after a stop: nothing told while a window of Kitokey has the focus; with another application's window in front, one notification naming the meeting — the minutes', or the failure's —, never « Transcription prête » on its own before them; its click opens the page. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 78 +++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 8e44a004..e3ca685a 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -4760,9 +4760,21 @@ def actions_rows(now: dt.datetime) -> None: shot(browser, "d46-actions-rows") +# Another application, as the user's: a window of its own the desktop gives the focus to, as it +# gives it any window shown (headless.sh's extension) — Kitokey's own window still seen beside it. +ELSEWHERE = """ +import gi +gi.require_version("Gtk", "4.0") +from gi.repository import Gio, Gtk +app = Gtk.Application(application_id="org.example.Elsewhere", flags=Gio.ApplicationFlags.NON_UNIQUE) +app.connect("activate", lambda a: Gtk.ApplicationWindow(application=a, title="Elsewhere").present()) +app.run([]) +""" + + def meeting_told_once(now: dt.datetime) -> None: - """AL. A meeting's notifications are fewer, and a click on one opens the meeting (D44).""" - print("AL. a window seen: no stop told, the transcript not told before its minutes; their notification's click opens the meeting (D44)") + """AL. A meeting made after a stop is told once, naming it, and only where no window of Kitokey has the focus (D44, D92).""" + print("AL. the last step's end: none told while a window of Kitokey has the focus; else one notification, naming the meeting, its click opening it (D92)") meetings = WORK / "telling" meetings.mkdir() model = WORK / "telling-model.bin" @@ -4775,20 +4787,41 @@ def meeting_told_once(now: dt.datetime) -> None: for rule, out in (("interface='org.freedesktop.Notifications',member='Notify'", notified), ("type='method_return',sender='org.freedesktop.Notifications'", answered))] live = lambda b: "live" in (b.find_element(By.ID, "record").get_attribute("class") or "") + focused = lambda b: b.execute_script("return document.hasFocus()") + idle = lambda b: b.execute_script("return window.__TAURI__.core.invoke('makings').then(m => m.transcript === null" + " && m.transcripts_waiting.length === 0 && m.minutes === null && m.minutes_waiting.length === 0)") + told = lambda mark: notified.read_text()[mark:] + # The meeting as the notification names it: no title of its own, so its day and hour. + names = lambda text: "18 oct." in text and "12:00" in text + other = None try: time.sleep(0.5) with Window(meetings, "fr_FR.UTF-8", settings) as browser: + # The window has the focus: made after a stop, transcript then minutes, nothing told. + check("the window has the focus, as the desktop gives it", wait_for(browser, focused, 5)) browser.find_element(By.ID, "record").click() wait_for(browser, lambda b: (meeting / "session.json").exists() and live(b), 10) # The button says it at the click now (D68); a press within half a second is the same press. time.sleep(0.6) browser.find_element(By.ID, "record").click() - made = wait_for(browser, lambda b: "Compte rendu prêt" in notified.read_text(), 20) - told = notified.read_text() - check("a window seen: the stop is not told, nor the transcript before its minutes — their notification alone", - made and "Enregistrement arrêté" not in told and "Transcription prête" not in told, told[-600:]) - check("its words say the click opens it", "Cliquez pour l’ouvrir." in told, told[-400:]) - # Away from the meeting, then the notification clicked as the desktop clicks it. + made = wait_for(browser, lambda b: (meeting / "minutes.md").exists() and idle(b), 20) + time.sleep(2) + check("a window of Kitokey has the focus: the stop, the transcript and its minutes made, nothing told", + made and focused(browser) and told(0).count("member=Notify") == 0, told(0)[-600:]) + + # Another application has the focus, Kitokey's window seen beside it: made again — the + # transcript, then its minutes —, one notification, the minutes', naming the meeting. + other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + check("another application has the focus, Kitokey's window still seen", + wait_for(browser, lambda b: not focused(b), 10) and browser.find_element(By.ID, "meeting").is_displayed()) + mark = len(notified.read_text()) + browser.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", meeting.name) + ready = wait_for(browser, lambda b: "Compte rendu prêt" in told(mark) and idle(b), 20) + time.sleep(2) + check("the focus elsewhere: one notification, the minutes', naming the meeting — the transcript not told on its own", + ready and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) + and names(told(mark)) and "Cliquez pour l’ouvrir." in told(mark), told(mark)[-600:]) + # Clicked as the desktop clicks it: the full window opens on that meeting's page. browser.execute_script("location.hash = '#/settings'") wait_for(browser, lambda b: b.find_element(By.ID, "settings").is_displayed(), 5) number = re.findall(r"^ +uint32 (\d+)", answered.read_text(), re.M)[-1] @@ -4798,21 +4831,24 @@ def meeting_told_once(now: dt.datetime) -> None: and b.find_element(By.ID, "meeting").is_displayed(), 10) check("clicked: the full window opens on that meeting's page, never the file manager", opened, browser.execute_script("return location.hash")) - # Its transcript made again (Refaire…): ready, its click opens the meeting too. - (meeting / "local.wav").write_bytes(b"\0" * 1000) + + # Failed, its last step: one notification still — the failure's, naming the meeting. + other.terminate(); other.wait(timeout=10) + other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + wait_for(browser, lambda b: not focused(b), 10) + (WORK / "fail-minutes").touch() mark = len(notified.read_text()) - browser.execute_script("window.__TAURI__.core.invoke('transcript_redo', {name: arguments[0], model: arguments[1]})", - meeting.name, str(model)) - again = wait_for(browser, lambda b: "Transcription prête" in notified.read_text()[mark:], 15) - browser.execute_script("location.hash = '#/settings'") - wait_for(browser, lambda b: b.find_element(By.ID, "settings").is_displayed(), 5) - number = re.findall(r"^ +uint32 (\d+)", answered.read_text(), re.M)[-1] - subprocess.run(["gdbus", "emit", "--session", "--object-path", "/org/freedesktop/Notifications", "--signal", - "org.freedesktop.Notifications.ActionInvoked", f"uint32 {number}", "'default'"], capture_output=True) - reopened = wait_for(browser, lambda b: b.execute_script("return location.hash") == f"#/meeting/{meeting.name}", 10) - check("a transcript made again says the click opens it, and the click does", - again and "Cliquez pour l’ouvrir." in notified.read_text()[mark:] and reopened, browser.execute_script("return location.hash")) + browser.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", meeting.name) + failed = wait_for(browser, lambda b: told(mark).count("member=Notify") >= 1 and idle(b), 20) + time.sleep(2) + check("its minutes failed: one notification, the failure's, naming the meeting — the transcript not told on its own", + failed and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) + and "Compte rendu prêt" not in told(mark) and names(told(mark)), told(mark)[-600:]) finally: + (WORK / "fail-minutes").unlink(missing_ok=True) + if other is not None: + other.terminate() + other.wait(timeout=10) for monitor in monitors: monitor.terminate() monitor.wait(timeout=10) From d53c80c1bcc177e76c21827b8202909fd18d9be5 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:52:55 +0100 Subject: [PATCH 08/16] shell: a meeting made is told once, naming it, and only where no window of Kitokey has the focus (D92) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The end of a meeting's making — the transcript when no minutes follow, else the minutes, written or failed — is told by one notification, its meeting named first: its title, else its hour that day, else its day and hour, by one formatter in words.rs (CLDR's abbreviated months, as the window's Intl). A window of Kitokey with the focus: nothing told, its page says it. A transcript made again with its minutes after: theirs alone. AL's precondition met in app_language too: its notifications awaited with another application in front. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 42 +++++++++------ modules/shell/src/main.rs | 52 +++++++++++++----- modules/shell/src/words.rs | 69 ++++++++++++++++++++++++ modules/shell/tests/words.rs | 81 +++++++++++++++++++++++++++++ 4 files changed, 216 insertions(+), 28 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index e3ca685a..a1fd0868 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -1802,6 +1802,18 @@ def meeting_language(now: dt.datetime) -> None: (heard / "language").unlink() +# Another application, as the user's: a window of its own the desktop gives the focus to, as it +# gives it any window shown (headless.sh's extension) — Kitokey's own window still seen beside it. +ELSEWHERE = """ +import gi +gi.require_version("Gtk", "4.0") +from gi.repository import Gio, Gtk +app = Gtk.Application(application_id="org.example.Elsewhere", flags=Gio.ApplicationFlags.NON_UNIQUE) +app.connect("activate", lambda a: Gtk.ApplicationWindow(application=a, title="Elsewhere").present()) +app.run([]) +""" + + def app_language(now: dt.datetime) -> None: """AF. The language Kitokey speaks, chosen in Settings, the system's by default (D64).""" print("AF. the app's language chosen in Settings: spoken at once and after a restart, never the meetings' (D64)") @@ -1827,12 +1839,23 @@ def app_language(now: dt.datetime) -> None: sections = lambda b: b.execute_script("return [document.getElementById('settings-link').getAttribute('aria-label'), document.documentElement.lang]") redo = lambda b: b.execute_script("window.__TAURI__.core.invoke('transcript_redo', {name: arguments[0], model: arguments[1]})", heard.name, str(model)) + def away(b, made) -> None: + """A making's end awaited with another application in front: told only then (D92).""" + other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + try: + wait_for(b, lambda b: not b.execute_script("return document.hasFocus()"), 10) + made() + finally: + other.terminate() + other.wait(timeout=10) + wait_for(b, lambda b: b.execute_script("return document.hasFocus()"), 5) + def by_settings(b, ready: str) -> str: """The transcript made again by whoever the settings name to hear (D59): what it was told.""" args.unlink(missing_ok=True) count = notified.read_text().count(ready) - b.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", heard.name) - wait_for(b, lambda b: told() != "" and notified.read_text().count(ready) > count, 15) + away(b, lambda: (b.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", heard.name), + wait_for(b, lambda b: told() != "" and notified.read_text().count(ready) > count, 15))) return told() notified = WORK / "notified-language" @@ -1851,8 +1874,7 @@ def by_settings(b, ready: str) -> str: [o.text for o in pick.options] == ["Langue du système", "Français", "English"] and pick.first_selected_option.get_attribute("value") == "" and label == "Langue de Kitokey", ([o.text for o in pick.options], label)) - redo(browser) - wait_for(browser, lambda b: "Transcription prête" in notified.read_text(), 15) + away(browser, lambda: (redo(browser), wait_for(browser, lambda b: "Transcription prête" in notified.read_text(), 15))) before = by_settings(browser, "Transcription prête") spoke = len(asked.read_text()) choose(browser, "app-language", "en") @@ -4760,18 +4782,6 @@ def actions_rows(now: dt.datetime) -> None: shot(browser, "d46-actions-rows") -# Another application, as the user's: a window of its own the desktop gives the focus to, as it -# gives it any window shown (headless.sh's extension) — Kitokey's own window still seen beside it. -ELSEWHERE = """ -import gi -gi.require_version("Gtk", "4.0") -from gi.repository import Gio, Gtk -app = Gtk.Application(application_id="org.example.Elsewhere", flags=Gio.ApplicationFlags.NON_UNIQUE) -app.connect("activate", lambda a: Gtk.ApplicationWindow(application=a, title="Elsewhere").present()) -app.run([]) -""" - - def meeting_told_once(now: dt.datetime) -> None: """AL. A meeting made after a stop is told once, naming it, and only where no window of Kitokey has the focus (D44, D92).""" print("AL. the last step's end: none told while a window of Kitokey has the focus; else one notification, naming the meeting, its click opening it (D92)") diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index 861e5fc9..d75af746 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -3438,12 +3438,9 @@ fn write_minutes_from( summarising::Made::Written(_) => words::Minutes::Ready, summarising::Made::Failed(_, cause) => words::Minutes::failed_by(cause, again, own_model.as_deref(), shell.language()), }; - // Ready, a click opens the meeting (D44); a failure is said as ever. - if written { - tell_opening(&app, &words::minutes(&said, shell.language()), folder.clone()); - } else { - tell(&app, &words::minutes(&said, shell.language())); - } + // Ready, a click opens the meeting (D44); failed, it is said — once, naming the meeting, + // where no window of Kitokey has the focus (D92). + tell_made(&app, &words::minutes(&said, shell.language()), &folder, written); }); } @@ -3937,10 +3934,12 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again, cancel: Cancel) if cancel.cancelled() { return transcribe_next(&app); } - // Made again and ready, its click opens the meeting as after a stop (D44). + // Made again and ready, its click opens the meeting as after a stop (D44); the minutes + // made after it, theirs alone says it (D92). match &made { - Made::Written(_) => tell_opening(&app, &words::made(&made, shell.language()), folder.clone()), - Made::Failed(_) => tell(&app, &words::made(&made, shell.language())), + Made::Written(_) if minutes_after => {} + Made::Written(_) => tell_made(&app, &words::made(&made, shell.language()), &folder, true), + Made::Failed(_) => tell_made(&app, &words::made(&made, shell.language()), &folder, false), } if let Some((name, not_put_back)) = kept_beside { tell(&app, &words::transcript_kept_beside(shell.language(), &name, not_put_back)); @@ -4101,14 +4100,14 @@ fn transcribe(app: &AppHandle, folder: PathBuf, cancel: Cancel) { match made { Made::Written(folder) => { // The minutes follow, when the settings say so — as they are now; then their - // notification alone says the meeting is made (D44). + // notification alone says the meeting is made (D44, D92). if shell.reread().is_ok_and(|settings| settings.after == settings::After::Minutes) { make_minutes(&app, folder); } else { - tell_opening(&app, ¬ice, folder.clone()); + tell_made(&app, ¬ice, &folder, true); } } - Made::Failed(_) => tell(&app, ¬ice), + Made::Failed(_) => tell_made(&app, ¬ice, &heard_folder, false), } transcribe_next(&app); }); @@ -4467,6 +4466,35 @@ fn window_seen(app: &AppHandle) -> bool { .any(|window| window.is_visible().unwrap_or(false) && !window.is_minimized().unwrap_or(false)) } +/// Whether a window of Kitokey has the focus, as the toolkit says: the user is in Kitokey (D92). +fn window_focused(app: &AppHandle) -> bool { + ["main", "small"] + .iter() + .filter_map(|label| app.get_webview_window(label)) + .any(|window| window.is_focused().unwrap_or(false)) +} + +/// The notification that ends a meeting's making — its last step written or failed (D92): told +/// once, naming the meeting, and only when no window of Kitokey has the focus, the page saying it +/// there. `opening`: its click opens the meeting (D44). +fn tell_made(app: &AppHandle, notice: &Notice, folder: &Path, opening: bool) { + if window_focused(app) { + tracing::info!("shell.made_not_told"); + return; + } + let language = app.state::().language(); + let name = folder.file_name().unwrap_or_default().to_string_lossy(); + let title = named::read(folder).or_else(|| minutes::title(folder)); + let started = chrono::NaiveDateTime::parse_from_str(&name, "%Y-%m-%d_%H-%M").ok(); + let meeting = words::meeting(title.as_deref(), started, chrono::Local::now().date_naive(), language); + let notice = words::for_meeting(notice.clone(), &meeting, language); + if opening { + tell_opening(app, ¬ice, folder.to_path_buf()); + } else { + tell(app, ¬ice); + } +} + /// Quits Kitokey. A recording in progress is stopped first, as the user would stop it: its /// files are whole before Kitokey is gone. Asked a second time, Kitokey leaves at once: a /// recorder that does not end is not a reason to keep the user. diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 70bae690..e3233c09 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -63,6 +63,75 @@ pub struct Notice { pub body: String, } +/// A day as the window's `Intl` says it, with CLDR's abbreviated months: « 18 oct. », "Oct 18". +/// One formatter for every day Kitokey says beside a meeting (D92, D93). +pub fn day(day: chrono::NaiveDate, language: Language) -> String { + use chrono::Datelike; + // CLDR's abbreviated months, as `Intl.DateTimeFormat` gives them with `month: "short"`. + let month = day.month0() as usize; + match language { + Language::English => { + let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + format!("{} {}", months[month], day.day()) + } + Language::French => { + let months = [ + "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc.", + ]; + format!("{} {}", day.day(), months[month]) + } + } +} + +/// An hour as the window's `Intl` says it, two digits: « 09:42 », "09:42 AM". +pub fn hour(time: chrono::NaiveTime, language: Language) -> String { + match language { + Language::English => time.format("%I:%M %p").to_string(), + // `%R`: the hour and minutes on 24 hours, as `%H:%M`. + Language::French => time.format("%R").to_string(), + } +} + +/// A meeting named in a sentence (D92): the title it was given, else when it was recorded — its +/// hour on the day it is said, its day and hour after. Used where a sentence names the meeting it +/// is about; the window names it in its list and page itself. +pub fn meeting(title: Option<&str>, started: Option, today: chrono::NaiveDate, language: Language) -> String { + use Language::{English, French}; + match (title.map(str::trim).filter(|title| !title.is_empty()), started, language) { + (Some(title), _, French) => format!("«\u{a0}{title}\u{a0}»"), + (Some(title), _, English) => format!("“{title}”"), + (None, Some(started), French) if started.date() == today => format!("la réunion de {}", hour(started.time(), French)), + (None, Some(started), English) if started.date() == today => format!("the {} meeting", hour(started.time(), English)), + (None, Some(started), French) => { + format!("la réunion du {} à {}", day(started.date(), French), hour(started.time(), French)) + } + (None, Some(started), English) => { + format!( + "the meeting of {} at {}", + day(started.date(), English), + hour(started.time(), English) + ) + } + (None, None, French) => "la réunion".into(), + (None, None, English) => "the meeting".into(), + } +} + +/// The notification that ends a meeting's making, its meeting named first (D92). Shows: a +/// notification's body, before the sentences it had. When: the meeting's last step ended — written +/// or failed —, no window of Kitokey having the focus. At most: no limit. Placeholders: {} the +/// meeting, as `meeting` names it. +pub fn for_meeting(notice: Notice, meeting: &str, language: Language) -> Notice { + let named = match language { + Language::French => format!("Pour {meeting}."), + Language::English => format!("For {meeting}."), + }; + Notice { + body: format!("{named} {}", notice.body), + ..notice + } +} + /// A length as a person says it: seconds under a minute, then minutes, then hours — each /// to the nearest, so that a minute and fifty-nine seconds is two minutes. pub fn length(seconds: f64) -> String { diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index 36f8cedd..4f6cc8e7 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1741,3 +1741,84 @@ fn a_notice_of_minutes_failed_by_the_meetings_own_model_says_what_its_page_says( } } } + +/// A meeting's day and hour, as the window's `Intl` says them (CLDR's abbreviated months). +fn at(day: &str, time: &str) -> chrono::NaiveDateTime { + chrono::NaiveDateTime::parse_from_str(&format!("{day} {time}"), "%Y-%m-%d %H:%M").unwrap() +} + +#[test] +fn a_day_and_an_hour_are_said_as_the_window_says_them() { + let french = [ + "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc.", + ]; + let english = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + for (month, (fr, en)) in french.iter().zip(english).enumerate() { + let day = chrono::NaiveDate::from_ymd_opt(2026, month as u32 + 1, 18).unwrap(); + assert_eq!(words::day(day, Language::French), format!("18 {fr}")); + assert_eq!(words::day(day, Language::English), format!("{en} 18")); + } + let first = chrono::NaiveDate::from_ymd_opt(2026, 11, 1).unwrap(); + assert_eq!( + (words::day(first, Language::French), words::day(first, Language::English)), + ("1 nov.".into(), "Nov 1".into()) + ); + for (time, fr, en) in [ + ("12:00", "12:00", "12:00 PM"), + ("09:42", "09:42", "09:42 AM"), + ("00:05", "00:05", "12:05 AM"), + ("17:31", "17:31", "05:31 PM"), + ] { + let when = at("2026-11-13", time); + assert_eq!(words::hour(when.time(), Language::French), fr); + assert_eq!(words::hour(when.time(), Language::English), en); + } +} + +#[test] +fn a_meeting_is_named_by_its_title_else_its_hour_that_day_else_its_day_and_hour() { + let started = Some(at("2026-10-18", "12:00")); + let (that_day, later) = (at("2026-10-18", "23:59").date(), at("2026-11-14", "01:00").date()); + let named = |title, when, today, language| words::meeting(title, when, today, language); + assert_eq!( + named(Some("Point hebdo"), started, later, Language::French), + "«\u{a0}Point hebdo\u{a0}»" + ); + assert_eq!(named(Some("Weekly sync"), started, later, Language::English), "“Weekly sync”"); + assert_eq!(named(None, started, that_day, Language::French), "la réunion de 12:00"); + assert_eq!(named(None, started, that_day, Language::English), "the 12:00 PM meeting"); + assert_eq!(named(None, started, later, Language::French), "la réunion du 18 oct. à 12:00"); + assert_eq!(named(None, started, later, Language::English), "the meeting of Oct 18 at 12:00 PM"); + // A title of blanks is none; a meeting whose start cannot be read is the meeting. + assert_eq!( + named(Some(" \t"), started, later, Language::French), + "la réunion du 18 oct. à 12:00" + ); + assert_eq!(named(None, None, later, Language::French), "la réunion"); + assert_eq!(named(None, None, later, Language::English), "the meeting"); +} + +#[test] +fn the_notification_that_ends_a_meeting_names_it_first_and_keeps_its_title() { + for language in BOTH { + let notice = words::minutes(&words::Minutes::Ready, language); + let meeting = words::meeting(None, Some(at("2026-10-18", "12:00")), at("2026-11-14", "01:00").date(), language); + let told = words::for_meeting(notice.clone(), &meeting, language); + assert_eq!(told.title, notice.title); + assert!(told.body.ends_with(¬ice.body), "{told:?}"); + assert!(told.body.contains(&meeting), "{told:?}"); + assert!(told.title.chars().count() <= 50, "{told:?}"); + } + let told = words::for_meeting( + words::minutes(&words::Minutes::Ready, Language::French), + "«\u{a0}Point hebdo\u{a0}»", + Language::French, + ); + assert!(told.body.starts_with("Pour «\u{a0}Point hebdo\u{a0}». "), "{told:?}"); + let told = words::for_meeting( + words::minutes(&words::Minutes::Ready, Language::English), + "the 12:00 PM meeting", + Language::English, + ); + assert!(told.body.starts_with("For the 12:00 PM meeting. "), "{told:?}"); +} From 3a9bda865e7e8658f0619e334b224fad331ca96f Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:54:29 +0100 Subject: [PATCH 09/16] =?UTF-8?q?shell:=20=C2=AB=20Annuler=20=C2=BB=20refu?= =?UTF-8?q?sed=20is=20said=20in=20its=20making's=20line,=20as=20the=20page?= =?UTF-8?q?'s=20other=20gestures=20say=20theirs=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/silence.rs refused a command that fails without a word: the cancel's failure — its meeting gone meanwhile — now says it where its making is said, and the button is given back. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/ui/window.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index fa77a2b8..ec05ae08 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -415,7 +415,10 @@ function cancelButton(said, id) { cancel.addEventListener("click", async () => { cancel.disabled = true; cancelledFrom = said.id; - await window.__TAURI__.core.invoke("making_cancelled", { name: said.dataset.name }).catch(() => {}); + await window.__TAURI__.core.invoke("making_cancelled", { name: said.dataset.name }).catch((why) => { + said.textContent = fill(words.not_saved, why); + cancel.disabled = false; + }); readMakings(); }); return cancel; From 51e52f3ea89cd2f8b2cd7255434a0b1d0b9af07b Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:57:45 +0100 Subject: [PATCH 10/16] =?UTF-8?q?shell:=20minutes=20not=20started=20name?= =?UTF-8?q?=20their=20meeting=20=E2=80=94=20the=20one=20notification=20of?= =?UTF-8?q?=20a=20meeting=20made=20after=20a=20stop=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A transcript written with its minutes to follow is not told: when they cannot start — nobody named, no provider, an agreement asked, no whole transcript —, D25's notice is the one notification, and now names the meeting. Told as D25 says, the focus aside. AL's fourth step holds it. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 18 +++++++++++++++- modules/shell/src/main.rs | 33 +++++++++++++++++------------ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index a1fd0868..812aa8b3 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -4806,7 +4806,8 @@ def meeting_told_once(now: dt.datetime) -> None: other = None try: time.sleep(0.5) - with Window(meetings, "fr_FR.UTF-8", settings) as browser: + window = Window(meetings, "fr_FR.UTF-8", settings) + with window as browser: # The window has the focus: made after a stop, transcript then minutes, nothing told. check("the window has the focus, as the desktop gives it", wait_for(browser, focused, 5)) browser.find_element(By.ID, "record").click() @@ -4854,6 +4855,21 @@ def meeting_told_once(now: dt.datetime) -> None: check("its minutes failed: one notification, the failure's, naming the meeting — the transcript not told on its own", failed and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) and "Compte rendu prêt" not in told(mark) and names(told(mark)), told(mark)[-600:]) + + # Its minutes not started — nobody named to write them: the transcript's end is the last + # step's, one notification still, D25's, naming the meeting (D25, D92). + (WORK / "fail-minutes").unlink(missing_ok=True) + window.file.write_text(f'after = "minutes"\nreminder = false\nmodel = "{model}"\n') + other.terminate(); other.wait(timeout=10) + other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + wait_for(browser, lambda b: not focused(b), 10) + mark = len(notified.read_text()) + browser.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", meeting.name) + unchosen = wait_for(browser, lambda b: told(mark).count("member=Notify") >= 1 and idle(b), 20) + time.sleep(2) + check("its minutes not started: one notification, what to do for them, naming the meeting — the transcript not told on its own", + unchosen and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) + and names(told(mark)), told(mark)[-600:]) finally: (WORK / "fail-minutes").unlink(missing_ok=True) if other is not None: diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index d75af746..28eab887 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -3198,7 +3198,9 @@ fn write_minutes_from( let asked_again = chosen.clone(); drop(writing); shell.minutes_tried.lock().unwrap().insert(folder.clone(), chosen.clone()); - // Not started: said on the meeting's page as well as in a notification (D25). + // Not started: said on the meeting's page as well as in a notification (D25) — the one that + // ends a meeting made after a stop, then, its transcript's own not told: its meeting named (D92). + let told = |notice: Notice| tell(app, &of_meeting(app, ¬ice, &folder)); let refused = |why: String| { shell.awaiting.lock().unwrap().retain(|(aside, _)| *aside != folder); shell.minutes_failed.lock().unwrap().insert(folder.clone(), (why, None, None)); @@ -3207,7 +3209,7 @@ fn write_minutes_from( Ok(settings) => settings, Err(why) => { refused(why.clone()); - return tell(app, &words::trouble(&Trouble::Settings(why), shell.language())); + return told(words::trouble(&Trouble::Settings(why), shell.language())); } }; let named = settings.minutes_provider.clone().zip(settings.minutes_model.clone()); @@ -3236,7 +3238,7 @@ fn write_minutes_from( let said = words::Minutes::OllamaWaits { silent: wait == Wait::Silent, }; - return tell(app, &words::minutes(&said, shell.language())); + return told(words::minutes(&said, shell.language())); } } } else { @@ -3249,19 +3251,19 @@ fn write_minutes_from( if from_line { return; } - tell(app, &words::minutes(&words::Minutes::Unchosen, shell.language())); + told(words::minutes(&words::Minutes::Unchosen, shell.language())); return open_window_at(app, "#/settings"); } }; if !matches!(meeting::transcript(&folder), meeting::Read::Present(transcript) if transcript.complete) { refused("this meeting has no whole transcript".into()); - return tell(app, &words::minutes(&words::Minutes::NoTranscript, shell.language())); + return told(words::minutes(&words::Minutes::NoTranscript, shell.language())); } let Some(host) = providers::host(&provider) else { let why = format!("{provider} is no provider's address"); tracing::warn!(detail = %why, "shell.minutes_refused"); refused(why); - return tell(app, &words::minutes(&words::Minutes::NoProvider(provider), shell.language())); + return told(words::minutes(&words::Minutes::NoProvider(provider), shell.language())); }; if agreed_now != Some(host.as_str()) && !providers::local(&provider) && settings.minutes_agreed.as_deref() != Some(host.as_str()) { let mut awaiting = shell.awaiting.lock().unwrap(); @@ -3278,7 +3280,7 @@ fn write_minutes_from( if from_line { return; } - tell(app, &words::minutes(&words::Minutes::Waiting(host), shell.language())); + told(words::minutes(&words::Minutes::Waiting(host), shell.language())); let name = folder .file_name() .map(|name| name.to_string_lossy().into_owned()) @@ -4474,6 +4476,16 @@ fn window_focused(app: &AppHandle) -> bool { .any(|window| window.is_focused().unwrap_or(false)) } +/// A notice about a meeting, its meeting named first: its title, else when it was recorded (D92). +fn of_meeting(app: &AppHandle, notice: &Notice, folder: &Path) -> Notice { + let language = app.state::().language(); + let name = folder.file_name().unwrap_or_default().to_string_lossy(); + let title = named::read(folder).or_else(|| minutes::title(folder)); + let started = chrono::NaiveDateTime::parse_from_str(&name, "%Y-%m-%d_%H-%M").ok(); + let meeting = words::meeting(title.as_deref(), started, chrono::Local::now().date_naive(), language); + words::for_meeting(notice.clone(), &meeting, language) +} + /// The notification that ends a meeting's making — its last step written or failed (D92): told /// once, naming the meeting, and only when no window of Kitokey has the focus, the page saying it /// there. `opening`: its click opens the meeting (D44). @@ -4482,12 +4494,7 @@ fn tell_made(app: &AppHandle, notice: &Notice, folder: &Path, opening: bool) { tracing::info!("shell.made_not_told"); return; } - let language = app.state::().language(); - let name = folder.file_name().unwrap_or_default().to_string_lossy(); - let title = named::read(folder).or_else(|| minutes::title(folder)); - let started = chrono::NaiveDateTime::parse_from_str(&name, "%Y-%m-%d_%H-%M").ok(); - let meeting = words::meeting(title.as_deref(), started, chrono::Local::now().date_naive(), language); - let notice = words::for_meeting(notice.clone(), &meeting, language); + let notice = of_meeting(app, notice, folder); if opening { tell_opening(app, ¬ice, folder.to_path_buf()); } else { From 0a5dd006929ef1beca48747189647271e67e7bb0 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 08:58:29 +0100 Subject: [PATCH 11/16] =?UTF-8?q?shell:=20e2e=20AL=20says=20each=20notific?= =?UTF-8?q?ation=20seen=20when=20a=20check=20fails=20=E2=80=94=20its=20sen?= =?UTF-8?q?der,=20relayed=20or=20not,=20title=20and=20body=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At 397a654 the three checks failed with a text that names the meeting: the tail of the monitor's text did not say whether the count or a transcript's notification failed them. Each Notify seen is now listed. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 812aa8b3..3ed5b012 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -4801,6 +4801,10 @@ def meeting_told_once(now: dt.datetime) -> None: idle = lambda b: b.execute_script("return window.__TAURI__.core.invoke('makings').then(m => m.transcript === null" " && m.transcripts_waiting.length === 0 && m.minutes === null && m.minutes_waiting.length === 0)") told = lambda mark: notified.read_text()[mark:] + # What each Notify seen was, for a check that fails: its sender, whether the desktop relayed it + # (`x-shell-sender`), its title and body — a count alone does not say which. + seen = lambda mark: [(m.split(' ', 1)[0], 'x-shell-sender' in m, re.findall(r'^ string "(.*)"$', m, re.M)[2:4]) + for m in told(mark).split('sender=')[1:] if 'member=Notify' in m.split('\n', 1)[0]] # The meeting as the notification names it: no title of its own, so its day and hour. names = lambda text: "18 oct." in text and "12:00" in text other = None @@ -4818,7 +4822,7 @@ def meeting_told_once(now: dt.datetime) -> None: made = wait_for(browser, lambda b: (meeting / "minutes.md").exists() and idle(b), 20) time.sleep(2) check("a window of Kitokey has the focus: the stop, the transcript and its minutes made, nothing told", - made and focused(browser) and told(0).count("member=Notify") == 0, told(0)[-600:]) + made and focused(browser) and told(0).count("member=Notify") == 0, seen(0)) # Another application has the focus, Kitokey's window seen beside it: made again — the # transcript, then its minutes —, one notification, the minutes', naming the meeting. @@ -4831,7 +4835,7 @@ def meeting_told_once(now: dt.datetime) -> None: time.sleep(2) check("the focus elsewhere: one notification, the minutes', naming the meeting — the transcript not told on its own", ready and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) - and names(told(mark)) and "Cliquez pour l’ouvrir." in told(mark), told(mark)[-600:]) + and names(told(mark)) and "Cliquez pour l’ouvrir." in told(mark), seen(mark)) # Clicked as the desktop clicks it: the full window opens on that meeting's page. browser.execute_script("location.hash = '#/settings'") wait_for(browser, lambda b: b.find_element(By.ID, "settings").is_displayed(), 5) @@ -4854,7 +4858,7 @@ def meeting_told_once(now: dt.datetime) -> None: time.sleep(2) check("its minutes failed: one notification, the failure's, naming the meeting — the transcript not told on its own", failed and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) - and "Compte rendu prêt" not in told(mark) and names(told(mark)), told(mark)[-600:]) + and "Compte rendu prêt" not in told(mark) and names(told(mark)), seen(mark)) # Its minutes not started — nobody named to write them: the transcript's end is the last # step's, one notification still, D25's, naming the meeting (D25, D92). @@ -4869,7 +4873,7 @@ def meeting_told_once(now: dt.datetime) -> None: time.sleep(2) check("its minutes not started: one notification, what to do for them, naming the meeting — the transcript not told on its own", unchosen and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) - and names(told(mark)), told(mark)[-600:]) + and names(told(mark)), seen(mark)) finally: (WORK / "fail-minutes").unlink(missing_ok=True) if other is not None: From 6c3c6be216c06d39f64e497dabe02b3cf46c944d Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:33:48 +0100 Subject: [PATCH 12/16] shell: the meeting named first is read in D94's title test, its title kept (D92) `for_meeting` returns a notification: named in `NOTIFYING` and each notice read again through it. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/tests/words.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index 9d09635e..f32899df 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1834,7 +1834,8 @@ const TITLES_TOO_LONG: [&str; 2] = [ /// The functions of `words.rs` that return a notification, each read below: one added there fails /// the title's test until it is named here — and read in `every_notice`, which the review checks. -const NOTIFYING: [&str; 17] = [ +const NOTIFYING: [&str; 18] = [ + "for_meeting", "of", "notice", "trouble", @@ -2028,6 +2029,12 @@ fn every_notice(language: Language) -> Vec { notices.push(words::fetched(&outcome, chosen, language)); } } + // Each one sent again with its meeting named first (D92): its title kept. + let named: Vec<_> = notices + .iter() + .map(|notice| words::for_meeting(notice.clone(), "x", language)) + .collect(); + notices.extend(named); notices } From c167d8bad1b770b1ed3ab93b0ae918cd2cde3ffd Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:43:43 +0100 Subject: [PATCH 13/16] shell: a meeting's end told after a real stop, and its not started notices only where Kitokey is not in front (D92) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit D25's notices for minutes that cannot start, and a transcript whose model or program is missing, go through the one path that names the meeting and holds back while a window of Kitokey has the focus: criterion 3's « none when one has ». AL now makes each case through a stop — the page's own click, which moves no focus —, a redo kept for its own path: the minutes ready and clicked, made again, a titled meeting's failed minutes named by its title, no model, no transcription program, no one to write the minutes; that last one again with Kitokey in front, nothing told and Settings opened. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 140 +++++++++++++++++++++------- modules/shell/src/main.rs | 24 ++--- 2 files changed, 118 insertions(+), 46 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 7a568478..9d2a0443 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -4977,15 +4977,48 @@ def meeting_told_once(now: dt.datetime) -> None: # The meeting as the notification names it: no title of its own, so its day and hour. names = lambda text: "18 oct." in text and "12:00" in text other = None + done = WORK / "telling-done" + done.mkdir() + + def stopped(browser, title: str | None = None) -> bool: + """A recording started and stopped from the window, as the record button does — by the page's + own click, which moves no focus —; the meeting before it set out of the list first, its folder + being the one the played recorder writes. `title`: the meeting named while it is recorded.""" + if meeting.exists(): + shutil.move(meeting, done / str(len(list(done.iterdir())))) + browser.execute_script("document.getElementById('record').click()") + started = wait_for(browser, lambda b: (meeting / "session.json").exists() and live(b), 10) + if title: + (meeting / "title.txt").write_text(title + "\n") + # The button says it at the click now (D68); a press within half a second is the same press. + time.sleep(0.6) + browser.execute_script("document.getElementById('record').click()") + return started + + def elsewhere(browser) -> bool: + """Another application's window in front, Kitokey's still seen.""" + nonlocal other + if other is not None: + other.terminate() + other.wait(timeout=10) + other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return wait_for(browser, lambda b: not focused(b), 10) + + def one_told(browser, mark: int, until) -> bool: + """The making's end awaited, then two seconds more for a notification that would follow it.""" + ended = wait_for(browser, lambda b: until(told(mark)) and idle(b), 20) + time.sleep(2) + return ended and told(mark).count("member=Notify") == 1 + + unchosen = f'after = "minutes"\nreminder = false\nmodel = "{model}"\n' try: time.sleep(0.5) window = Window(meetings, "fr_FR.UTF-8", settings) with window as browser: - # The window has the focus: made after a stop, transcript then minutes, nothing told. + # 1. The window has the focus: made after a stop, transcript then minutes, nothing told. check("the window has the focus, as the desktop gives it", wait_for(browser, focused, 5)) browser.find_element(By.ID, "record").click() wait_for(browser, lambda b: (meeting / "session.json").exists() and live(b), 10) - # The button says it at the click now (D68); a press within half a second is the same press. time.sleep(0.6) browser.find_element(By.ID, "record").click() made = wait_for(browser, lambda b: (meeting / "minutes.md").exists() and idle(b), 20) @@ -4993,17 +5026,15 @@ def meeting_told_once(now: dt.datetime) -> None: check("a window of Kitokey has the focus: the stop, the transcript and its minutes made, nothing told", made and focused(browser) and told(0).count("member=Notify") == 0, seen(0)) - # Another application has the focus, Kitokey's window seen beside it: made again — the - # transcript, then its minutes —, one notification, the minutes', naming the meeting. - other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + # 2. Another application has the focus: a stop, its transcript then its minutes — one + # notification, the minutes', naming the meeting. check("another application has the focus, Kitokey's window still seen", - wait_for(browser, lambda b: not focused(b), 10) and browser.find_element(By.ID, "meeting").is_displayed()) + elsewhere(browser) and browser.find_element(By.ID, "meeting").is_displayed()) mark = len(notified.read_text()) - browser.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", meeting.name) - ready = wait_for(browser, lambda b: "Compte rendu prêt" in told(mark) and idle(b), 20) - time.sleep(2) - check("the focus elsewhere: one notification, the minutes', naming the meeting — the transcript not told on its own", - ready and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) + recorded = stopped(browser) + ready = one_told(browser, mark, lambda t: "Compte rendu prêt" in t) + check("the focus elsewhere, a stop: one notification, the minutes', naming the meeting — the transcript not told on its own", + recorded and ready and not focused(browser) and "Transcription prête" not in told(mark) and names(told(mark)) and "Cliquez pour l’ouvrir." in told(mark), seen(mark)) # Clicked as the desktop clicks it: the full window opens on that meeting's page. browser.execute_script("location.hash = '#/settings'") @@ -5016,34 +5047,74 @@ def meeting_told_once(now: dt.datetime) -> None: check("clicked: the full window opens on that meeting's page, never the file manager", opened, browser.execute_script("return location.hash")) - # Failed, its last step: one notification still — the failure's, naming the meeting. - other.terminate(); other.wait(timeout=10) - other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - wait_for(browser, lambda b: not focused(b), 10) - (WORK / "fail-minutes").touch() + # The same meeting made again, its minutes after: their notification alone — the redo's + # own path, which tells nothing of the transcript when the minutes follow it. + elsewhere(browser) mark = len(notified.read_text()) browser.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", meeting.name) - failed = wait_for(browser, lambda b: told(mark).count("member=Notify") >= 1 and idle(b), 20) - time.sleep(2) - check("its minutes failed: one notification, the failure's, naming the meeting — the transcript not told on its own", - failed and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) - and "Compte rendu prêt" not in told(mark) and names(told(mark)), seen(mark)) - - # Its minutes not started — nobody named to write them: the transcript's end is the last - # step's, one notification still, D25's, naming the meeting (D25, D92). - (WORK / "fail-minutes").unlink(missing_ok=True) - window.file.write_text(f'after = "minutes"\nreminder = false\nmodel = "{model}"\n') - other.terminate(); other.wait(timeout=10) - other = subprocess.Popen(["/usr/bin/python3", "-c", ELSEWHERE], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - wait_for(browser, lambda b: not focused(b), 10) + again = one_told(browser, mark, lambda t: "Compte rendu prêt" in t) + check("made again, its minutes after: one notification, the minutes', naming the meeting", + again and "Transcription prête" not in told(mark) and names(told(mark)), seen(mark)) + + # 3. A meeting given a title, its minutes failed: one notification, the failure's, naming + # it by its title, not its hour. + elsewhere(browser) + (WORK / "fail-minutes").touch() mark = len(notified.read_text()) - browser.execute_script("window.__TAURI__.core.invoke('context_redo', {name: arguments[0]})", meeting.name) - unchosen = wait_for(browser, lambda b: told(mark).count("member=Notify") >= 1 and idle(b), 20) - time.sleep(2) + recorded = stopped(browser, "Point hebdo") + failed = one_told(browser, mark, lambda t: "member=Notify" in t) + check("titled, its minutes failed: one notification, the failure's, naming the meeting by its title — the transcript not told on its own", + recorded and failed and not focused(browser) and "Transcription prête" not in told(mark) + and "Compte rendu prêt" not in told(mark) and "Point hebdo" in told(mark) and not names(told(mark)), seen(mark)) + (WORK / "fail-minutes").unlink() + + # 4. No model where the settings name one: the transcript cannot start, the meeting's + # last step; then its program missing. Each told once, naming the meeting (D92). + window.file.write_text(settings.replace(str(model), str(WORK / "telling-absent.bin"))) + elsewhere(browser) + mark = len(notified.read_text()) + recorded = stopped(browser) + missing = one_told(browser, mark, lambda t: "member=Notify" in t) + check("no model: one notification, what to do, naming the meeting", + recorded and missing and not focused(browser) and "le modèle manque" in told(mark) + and "Placez le modèle Whisper" in told(mark) and names(told(mark)), seen(mark)) + window.file.write_text(settings) + elsewhere(browser) + HEARING.chmod(0o644) + mark = len(notified.read_text()) + recorded = stopped(browser) + unstarted = one_told(browser, mark, lambda t: "member=Notify" in t) + HEARING.chmod(0o755) + check("its transcription program cannot start: one notification, what to do, naming the meeting", + recorded and unstarted and not focused(browser) and "Kitokey ne peut pas transcrire" in told(mark) + and "réinstaller Kitokey" in told(mark) and names(told(mark)), seen(mark)) + + # 5. Its minutes not started — nobody named to write them: the transcript's end is the last + # step's, one notification still, D25's, saying what to do and naming the meeting (D25, D92). + window.file.write_text(unchosen) + elsewhere(browser) + mark = len(notified.read_text()) + recorded = stopped(browser) + asked = one_told(browser, mark, lambda t: "member=Notify" in t) check("its minutes not started: one notification, what to do for them, naming the meeting — the transcript not told on its own", - unchosen and told(mark).count("member=Notify") == 1 and "Transcription prête" not in told(mark) - and names(told(mark)), seen(mark)) + recorded and asked and "Transcription prête" not in told(mark) and "Aucun modèle choisi" in told(mark) + and "Choisissez-le dans les réglages" in told(mark) and names(told(mark)), seen(mark)) + + # 6. The same with Kitokey's window focused: nothing told, the window says it — Settings, + # where the model is chosen. + other.terminate() + other.wait(timeout=10) + other = None + check("Kitokey's window has the focus again", wait_for(browser, focused, 10)) + browser.execute_script("location.hash = '#/'") + mark = len(notified.read_text()) + recorded = stopped(browser) + shown = wait_for(browser, lambda b: b.execute_script("return location.hash") == "#/settings" and idle(b), 20) + time.sleep(2) + check("its minutes not started, a window of Kitokey focused: nothing told, the window opened on Settings", + recorded and shown and focused(browser) and told(mark).count("member=Notify") == 0, seen(mark)) finally: + HEARING.chmod(0o755) (WORK / "fail-minutes").unlink(missing_ok=True) if other is not None: other.terminate() @@ -5052,7 +5123,6 @@ def meeting_told_once(now: dt.datetime) -> None: monitor.terminate() monitor.wait(timeout=10) - def two_panes(now: dt.datetime) -> None: """AD. The window in two panes: the meetings in a sidebar, the one chosen beside them (D61).""" print("AD. the window in two panes: the sidebar, the meeting chosen beside it, as wide as the window (D61)") diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index d9e73470..765a0fbb 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -3249,9 +3249,10 @@ fn write_minutes_from( let asked_again = chosen.clone(); drop(writing); shell.minutes_tried.lock().unwrap().insert(folder.clone(), chosen.clone()); - // Not started: said on the meeting's page as well as in a notification (D25) — the one that - // ends a meeting made after a stop, then, its transcript's own not told: its meeting named (D92). - let told = |notice: Notice| tell(app, &of_meeting(app, ¬ice, &folder)); + // Not started: said on the meeting's page, and in a notification (D25) — the one that ends a + // meeting made after a stop, then, its transcript's own not told: its meeting named, and only + // where no window of Kitokey has the focus (D92). + let told = |notice: Notice| tell_made(app, ¬ice, &folder, false); let refused = |why: String| { shell.awaiting.lock().unwrap().retain(|(aside, _)| *aside != folder); shell.minutes_failed.lock().unwrap().insert(folder.clone(), (why, None, None)); @@ -4108,8 +4109,9 @@ fn transcribe(app: &AppHandle, folder: PathBuf, cancel: Cancel) { .transcripts_failed .lock() .unwrap() - .insert(folder, format!("{} is no model on this computer", model.display())); - tell(app, &words::trouble(&trouble, shell.language())); + .insert(folder.clone(), format!("{} is no model on this computer", model.display())); + // The meeting's last step, failed: told as its end is (D92). + tell_made(app, &words::trouble(&trouble, shell.language()), &folder, false); } return; } @@ -4125,9 +4127,9 @@ fn transcribe(app: &AppHandle, folder: PathBuf, cancel: Cancel) { let (transcription, made) = match started { Ok(started) => started, Err(error) => { - shell.transcripts_failed.lock().unwrap().insert(folder, error.to_string()); - tell(app, &words::trouble(&Trouble::NoTranscriber(error.to_string()), shell.language())); - return; + shell.transcripts_failed.lock().unwrap().insert(folder.clone(), error.to_string()); + let notice = words::trouble(&Trouble::NoTranscriber(error.to_string()), shell.language()); + return tell_made(app, ¬ice, &folder, false); } }; // Held by its token: cancelled meanwhile, it is stopped at once (D92). @@ -4553,9 +4555,9 @@ fn of_meeting(app: &AppHandle, notice: &Notice, folder: &Path) -> Notice { words::for_meeting(notice.clone(), &meeting, language) } -/// The notification that ends a meeting's making — its last step written or failed (D92): told -/// once, naming the meeting, and only when no window of Kitokey has the focus, the page saying it -/// there. `opening`: its click opens the meeting (D44). +/// The notification that ends a meeting's making — its last step written or failed, or the next +/// one unable to start (D25) —: told naming the meeting, and only when no window of Kitokey has the +/// focus, the window saying it there (D92). `opening`: its click opens the meeting (D44). fn tell_made(app: &AppHandle, notice: &Notice, folder: &Path, opening: bool) { if window_focused(app) { tracing::info!("shell.made_not_told"); From 6e8d557efb971eb5139c8e98ef8dfee72d753726 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:23:25 +0100 Subject: [PATCH 14/16] =?UTF-8?q?shell:=20e2e=20=E2=80=94=20D92's=20one=20?= =?UTF-8?q?notification=20lettered=20BN,=20AL=20being=20the=20meeting=20na?= =?UTF-8?q?med=20by=20its=20minutes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two scenarios said « AL. » on main: meeting_named (D48) and meeting_told_once (D92). The second takes BN, free (BM is #844's, BL press_on_the_page_left). The print and the docstring alone: no MANIFEST line names it. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 9d2a0443..0326e765 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -4952,8 +4952,8 @@ def actions_rows(now: dt.datetime) -> None: def meeting_told_once(now: dt.datetime) -> None: - """AL. A meeting made after a stop is told once, naming it, and only where no window of Kitokey has the focus (D44, D92).""" - print("AL. the last step's end: none told while a window of Kitokey has the focus; else one notification, naming the meeting, its click opening it (D92)") + """BN. A meeting made after a stop is told once, naming it, and only where no window of Kitokey has the focus (D44, D92).""" + print("BN. the last step's end: none told while a window of Kitokey has the focus; else one notification, naming the meeting, its click opening it (D92)") meetings = WORK / "telling" meetings.mkdir() model = WORK / "telling-model.bin" From fc22e25634f420ff879c01176b7ccfc3f55f3460 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:57:50 +0100 Subject: [PATCH 15/16] shell: D92's words carry their comment inside their bodies, where #812's reader looks (D92) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `day`, `hour`, `meeting` and `for_meeting`: Shows, When, At most and Placeholders, inside each body, `for_meeting`'s moved there and its placeholder named as its sentence writes it, {meeting}. With them, the sentences without their comment are main's own: 600, against the 602 #812 left — `WITHOUT_COMMENT` lowered, as the test asks (red on main as it is). Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/src/words.rs | 14 ++++++++++---- modules/shell/tests/words.rs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 4a24ea48..2a7407a5 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -66,6 +66,8 @@ pub struct Notice { /// A day as the window's `Intl` says it, with CLDR's abbreviated months: « 18 oct. », "Oct 18". /// One formatter for every day Kitokey says beside a meeting (D92, D93). pub fn day(day: chrono::NaiveDate, language: Language) -> String { + // Shows: in a notification's body, the day a meeting was recorded. When: a meeting is named by + // its day and hour, not recorded today. At most: no limit. Placeholders: none. use chrono::Datelike; // CLDR's abbreviated months, as `Intl.DateTimeFormat` gives them with `month: "short"`. let month = day.month0() as usize; @@ -85,6 +87,8 @@ pub fn day(day: chrono::NaiveDate, language: Language) -> String { /// An hour as the window's `Intl` says it, two digits: « 09:42 », "09:42 AM". pub fn hour(time: chrono::NaiveTime, language: Language) -> String { + // Shows: in a notification's body, the hour a meeting was recorded. When: a meeting is named by + // its hour. At most: no limit. Placeholders: none. match language { Language::English => time.format("%I:%M %p").to_string(), // `%R`: the hour and minutes on 24 hours, as `%H:%M`. @@ -96,6 +100,8 @@ pub fn hour(time: chrono::NaiveTime, language: Language) -> String { /// hour on the day it is said, its day and hour after. Used where a sentence names the meeting it /// is about; the window names it in its list and page itself. pub fn meeting(title: Option<&str>, started: Option, today: chrono::NaiveDate, language: Language) -> String { + // Shows: in a notification's body, the meeting it is about. When: a meeting is named, without a + // title of its own. At most: no limit. Placeholders: {} its hour, or its day then its hour. use Language::{English, French}; match (title.map(str::trim).filter(|title| !title.is_empty()), started, language) { (Some(title), _, French) => format!("«\u{a0}{title}\u{a0}»"), @@ -117,11 +123,11 @@ pub fn meeting(title: Option<&str>, started: Option, toda } } -/// The notification that ends a meeting's making, its meeting named first (D92). Shows: a -/// notification's body, before the sentences it had. When: the meeting's last step ended — written -/// or failed —, no window of Kitokey having the focus. At most: no limit. Placeholders: {} the -/// meeting, as `meeting` names it. +/// The notification that ends a meeting's making, its meeting named first (D92). pub fn for_meeting(notice: Notice, meeting: &str, language: Language) -> Notice { + // Shows: a notification's body, before the sentences it had. When: the meeting's last step + // ended — written or failed —, no window of Kitokey having the focus. At most: no limit. + // Placeholders: {meeting} the meeting, as `meeting` names it. let named = match language { Language::French => format!("Pour {meeting}."), Language::English => format!("For {meeting}."), diff --git a/modules/shell/tests/words.rs b/modules/shell/tests/words.rs index 20885b43..9000722f 100644 --- a/modules/shell/tests/words.rs +++ b/modules/shell/tests/words.rs @@ -1231,7 +1231,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 = 600; /// A sentence of `src/words.rs`, as the file arranges it. #[derive(Debug)] From 8b568406ac41496c0ab54aaefc9ab99741209cc2 Mon Sep 17 00:00:00 2001 From: "kitokey-marc[bot]" <356215105+kitokey-marc[bot]@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:44:12 +0100 Subject: [PATCH 16/16] =?UTF-8?q?shell:=20e2e=20=E2=80=94=20a=20making's?= =?UTF-8?q?=20end=20from=20its=20page=20in=20front=20notified=20no=20more,?= =?UTF-8?q?=20and=20BN=20counts=20Kitokey's=20own=20notifications=20(D92)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Criterion 3 and its D25 notices: nothing notified while a window of Kitokey has the focus, the window saying it there. Four older checks asked a notification of a making started from its page, the window in front: the minutes made again that fail, the cause they name, the redo through the agreement, the first meeting with no one chosen. They now ask none, the page or Settings saying it. BN counted every Notify on the bus: the desktop relays a notification once more, from its own connection (`x-shell-sender`), which it counted twice. It now counts those Kitokey sent. Agent-Session: 14f73956-90b9-46a3-9fcc-52dc45c43948 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 37 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 7188c681..98a4fb34 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -2041,10 +2041,12 @@ def last_screen(browser) -> str: browser.execute_script(f"location.hash = '#/meeting/{first.name}'") wait_for(browser, lambda b: b.find_elements(By.ID, "make-minutes"), 10) press(browser, "make-minutes") - told = wait_for(browser, lambda b: "Aucun modèle choisi pour les comptes rendus" in notified.read_text(), 10) - opened = wait_for(browser, lambda b: b.find_element(By.ID, "settings").is_displayed(), 5) - check("connected, no service chosen after: the first meeting's minutes say none is, and open Settings", - told and opened and not (first / "minutes.md").exists() and "minutes_provider" not in window.file.read_text(), + # Asked from its page in front: Settings opened say it, never a notification (D25, D92). + opened = wait_for(browser, lambda b: b.find_element(By.ID, "settings").is_displayed(), 10) + time.sleep(1) + told = "Aucun modèle choisi pour les comptes rendus" in notified.read_text() + check("connected, no service chosen after: the first meeting's minutes open Settings, nothing notified from its page in front (D92)", + not told and opened and not (first / "minutes.md").exists() and "minutes_provider" not in window.file.read_text(), (notified.read_text()[-300:], window.file.read_text())) finally: monitor.terminate() @@ -5619,6 +5621,8 @@ def meeting_told_once(now: dt.datetime) -> None: # (`x-shell-sender`), its title and body — a count alone does not say which. seen = lambda mark: [(m.split(' ', 1)[0], 'x-shell-sender' in m, re.findall(r'^ string "(.*)"$', m, re.M)[2:4]) for m in told(mark).split('sender=')[1:] if 'member=Notify' in m.split('\n', 1)[0]] + # Those Kitokey sent: the desktop may relay one (`x-shell-sender`), the same notification again. + sent = lambda mark: [notice for notice in seen(mark) if not notice[1]] # The meeting as the notification names it: no title of its own, so its day and hour. names = lambda text: "18 oct." in text and "12:00" in text other = None @@ -5653,7 +5657,7 @@ def one_told(browser, mark: int, until) -> bool: """The making's end awaited, then two seconds more for a notification that would follow it.""" ended = wait_for(browser, lambda b: until(told(mark)) and idle(b), 20) time.sleep(2) - return ended and told(mark).count("member=Notify") == 1 + return ended and len(sent(mark)) == 1 unchosen = f'after = "minutes"\nreminder = false\nmodel = "{model}"\n' try: @@ -5669,7 +5673,7 @@ def one_told(browser, mark: int, until) -> bool: made = wait_for(browser, lambda b: (meeting / "minutes.md").exists() and idle(b), 20) time.sleep(2) check("a window of Kitokey has the focus: the stop, the transcript and its minutes made, nothing told", - made and focused(browser) and told(0).count("member=Notify") == 0, seen(0)) + made and focused(browser) and not sent(0), seen(0)) # 2. Another application has the focus: a stop, its transcript then its minutes — one # notification, the minutes', naming the meeting. @@ -5757,7 +5761,7 @@ def one_told(browser, mark: int, until) -> bool: shown = wait_for(browser, lambda b: b.execute_script("return location.hash") == "#/settings" and idle(b), 20) time.sleep(2) check("its minutes not started, a window of Kitokey focused: nothing told, the window opened on Settings", - recorded and shown and focused(browser) and told(mark).count("member=Notify") == 0, seen(mark)) + recorded and shown and focused(browser) and not sent(mark), seen(mark)) finally: HEARING.chmod(0o755) (WORK / "fail-minutes").unlink(missing_ok=True) @@ -9181,14 +9185,16 @@ def aside(folder): wait_for(browser, lambda b: b.find_elements(By.ID, "redo-do")) redo_pick(browser, "redo-panel", "minutes", 1) browser.find_element(By.ID, "redo-do").click() - told = wait_for(browser, lambda b: "pas été refait" in heard.read_text(), 10) - check("minutes made again that fail: the ones there stay, and the notice says a redo", told and (asked / "minutes.md").read_text() == before, heard.read_text()[-400:]) - failed = wait_for(browser, lambda b: "n’a pas été fait" in state(b) and b.find_elements(By.ID, "minutes-again"), 5) + # Made from its page, Kitokey's window in front: its end told there, never by a notification (D92). + failed = wait_for(browser, lambda b: "n’a pas été fait" in state(b) and b.find_elements(By.ID, "minutes-again"), 10) + time.sleep(1) + check("minutes made again that fail, from their page in front: the ones there stay, nothing notified (D92)", + failed and (asked / "minutes.md").read_text() == before and "member=Notify" not in heard.read_text(), heard.read_text()[-400:]) check("the failure said on the meeting's page too, in plain words, with a way to try again — never what the program said", failed and "not minutes" not in state(browser) and "not minutes" not in heard.read_text(), (state(browser), heard.read_text()[-400:])) # Its cause named by the program, its gesture said, on the page and in the notice (D29). - check("the cause the program named is said with its gesture, on the page and in the notice", - "écrit de compte rendu" in state(browser) and "écrit de compte rendu" in heard.read_text(), + check("the cause the program named is said with its gesture, on the page", + "écrit de compte rendu" in state(browser), (state(browser), heard.read_text()[-400:])) # The developer mode shows what the program said, under the sentence; never in a notice (D29). to_settings() @@ -9230,11 +9236,14 @@ def aside(folder): wait_for(browser, lambda b: b.find_elements(By.ID, "agree-send")) press(browser, "agree-send") # Only what is said after this gesture: a notice may show its title more than once. - told = wait_for(browser, lambda b: "pas été refait" in heard.read_text()[since:], 10) + # Its page in front: the failure said there (below), never by a notification (D92). + ended = wait_for(browser, lambda b: "member=Notify" in heard.read_text()[since:] or b.find_elements(By.ID, "minutes-again"), 10) + time.sleep(1) said = heard.read_text()[since:] monitor.terminate() (WORK / "fail-plainly").unlink() - check("asked through the agreement, still a redo: its failure said as one", told and "pas été fait" not in said and (asked / "minutes.md").read_text() == before, said[-400:]) + check("asked through the agreement, still a redo, its page in front: the ones there stay, nothing notified (D92)", + ended and "member=Notify" not in said and (asked / "minutes.md").read_text() == before, said[-400:]) browser.execute_script("location.hash = '#/'") browser.execute_script("location.hash = '#/meeting/2026-10-18_11-00'") plain = wait_for(browser, lambda b: "n’a pas été fait" in state(b), 5)