From 786546a74a55b614e82c5a00dc183db05b07c165 Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:09:42 +0100 Subject: [PATCH 1/8] =?UTF-8?q?Start=20D131=20=E2=80=94=20Each=20line=20of?= =?UTF-8?q?=20a=20transcript=20says=20who=20spoke,=20named=20by=20the=20us?= =?UTF-8?q?er:=20a=20name=20given=20to=20one=20line,=20or=20to=20a=20voice?= =?UTF-8?q?=20everywhere?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 From b3929e75232b792dc1fde1e3cb5fed748f8b5db2 Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:16:25 +0100 Subject: [PATCH 2/8] =?UTF-8?q?D131=20oracle:=20each=20line=20of=20a=20tra?= =?UTF-8?q?nscript=20named=20by=20the=20user=20=E2=80=94=20one=20line,=20a?= =?UTF-8?q?=20voice=20everywhere,=20kept=20across=20a=20redo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/voices.rs (8 tests) on a `voices` stub that refuses everything: a name given to one line gives it alone a voice of the person's own (`#1`, `given`), its name in speakers.json's `voices`; the same name is the same voice; a name given to a voice names every line of it (a voice not told: its side, as #1205); a producer's label is given a label of the person's own first; refusals write nothing; a transcript made again carries the voices given by their stretch of the clock, the one given last within two, and returns the given lines it cannot find (transcript/v1, #1244, #1251). e2e speakers_by_line: the same three criteria through the window, by keyboard alone, axe on the open field, no name logged. Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 135 ++++++++++++++ modules/shell/src/lib.rs | 1 + modules/shell/src/voices.rs | 35 ++++ modules/shell/tests/voices.rs | 272 ++++++++++++++++++++++++++++ 4 files changed, 443 insertions(+) create mode 100644 modules/shell/src/voices.rs create mode 100644 modules/shell/tests/voices.rs diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 1ec5996d3..931273568 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6059,6 +6059,140 @@ def page(folder): check("the naming is logged, never a name", lines and not any(name in line for line in lines for name in ("Sarah", "équipe", "Camille")), lines) +def speakers_by_line(now: dt.datetime) -> None: + """D131, #1230's S2: each line of a complete transcript says who spoke, named by the user. Its speaker, a button + on the line, opens « Qui parle sur cette ligne ? »: a name given to this line alone gives it a voice of the + person's own (`transcript/v1`'s `voice` and `given`, #1244), its name in `speakers.json`'s `voices`; « Toutes les + lignes de cette voix » names every line of it; Escape closes it as it was. A transcript made again keeps the + voices given, carried by their stretch of the clock, and says the named lines it could not find again (D113). + By keyboard alone; axe on the open field. No name is logged.""" + print("D131. each line of a transcript named by the user: one line, or a voice everywhere, kept across a redo") + meetings = WORK / "speakers-by-line" + meeting = meetings / "2026-11-30_14-00" + session(meeting, now - dt.timedelta(hours=2), 30, {"local.wav": 1000}, form="v3") + current = meeting / "transcript.jsonl" + current.write_text( + '{"type":"header","contract":"transcript/v1","engine":"whisper.cpp","model":"m","language":null,"context":null}\n' + '{"type":"segment","speaker":"me","track":"local","voice":null,"start":0.0,"end":1.0,"text":"On commence."}\n' + '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":1.5,"end":3.0,"text":"Les tests passent."}\n' + '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":3.5,"end":5.0,"text":"Je confirme pour la 2.4."}\n' + '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":5.5,"end":7.0,"text":"Et la démo vendredi."}\n' + '{"type":"complete","duration":7.0}\n') + data = WORK / "data-speakers-by-line" + model = data / "kitokey" / "models" / "ggml-tiny-a.bin" + model.parent.mkdir(parents=True) + model.write_bytes(b"\0" * 16) + 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)") + whos = "return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.textContent.trim())" + def text() -> str: + # Set aside while it is made again: absent for a moment, read as empty, never raised. + try: + return current.read_text() + except OSError: + return "" + held = lambda: [json.loads(line) for line in text().splitlines() if line.strip()] + voices = lambda: (json.loads((meeting / "speakers.json").read_text()) if (meeting / "speakers.json").is_file() else {}).get("voices") + panel_open = lambda b: bool(b.find_elements(By.ID, "voice-name")) + window = Window(meetings, "fr_FR.UTF-8", f'after = "nothing"\nreminder = false\nmodel = "{model}"\n') + window.env.update(XDG_DATA_HOME=str(data)) + with window as browser: + def page(): + browser.execute_script("location.hash = '#/'") + wait_for(browser, lambda b: not b.find_elements(By.ID, "meeting"), 5) + browser.execute_script("location.hash = arguments[0]", f"#/meeting/{meeting.name}") + return wait_for(browser, lambda b: b.execute_script( + "return document.querySelectorAll('#meeting .transcript .lines .who').length") > 0 and b.execute_script(idle), 15) + + def who(index): + found = browser.find_elements(By.CSS_SELECTOR, "#meeting .transcript .lines .who") + return found[index] if index < len(found) else None + + def name(index, typed, everywhere=False, key=Keys.ENTER): + """Line `index`'s speaker by keyboard alone: focused, Enter, the scope chosen, the name typed, `key`.""" + button = who(index) + if button is None: + return False + browser.execute_script("arguments[0].focus()", button) + ActionChains(browser).send_keys(Keys.ENTER).perform() + if not wait_for(browser, panel_open, 5): + return False + if everywhere and browser.find_elements(By.ID, "voice-all"): + browser.execute_script("document.getElementById('voice-all').click(); document.getElementById('voice-name').focus()") + field = browser.find_element(By.ID, "voice-name") + field.send_keys(Keys.CONTROL, "a") + field.send_keys(typed) + ActionChains(browser).send_keys(key).perform() + return wait_for(browser, lambda b: not panel_open(b), 5) + + page() + tags = browser.execute_script("return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.tagName)") + check("each line's speaker is a button, its side as the page says it", + browser.execute_script(whos) == ["Vous", "Les autres", "Les autres", "Les autres"] and set(tags) == {"BUTTON"}, + [browser.execute_script(whos), tags]) + button = who(2) + if button is not None: + browser.execute_script("arguments[0].focus()", button) + ActionChains(browser).send_keys(Keys.ENTER).perform() + opened = wait_for(browser, panel_open, 5) + got = browser.execute_script( + "const f = document.getElementById('voice-name'); return f ? [document.activeElement.id, f.labels[0]?.textContent.trim()," + " document.getElementById('voice-line')?.checked, arguments[0]?.getAttribute('aria-expanded')] : null", button) + check("Enter on a line's speaker opens « Qui parle sur cette ligne ? », its field focused and labelled, « Cette ligne seulement » chosen", + opened and got == ["voice-name", "Qui parle sur cette ligne ?", True, "true"], got) + violations = axe_violations(browser) if opened else [("the field absent", None, 0, [])] + check("axe: the open field, WCAG 2.2 A and AA, no violation", violations == [], violations) + ActionChains(browser).send_keys("Personne").perform() + ActionChains(browser).send_keys(Keys.ESCAPE).perform() + closed = wait_for(browser, lambda b: not panel_open(b), 5) + check("Escape closes it as it was: nothing written, the focus back on the line's speaker", + closed and all("given" not in line for line in held()) and voices() is None + and browser.execute_script("return document.activeElement === arguments[0]", button), + [closed, voices(), browser.execute_script("return document.activeElement?.className")]) + + # Criterion 1: one line named, that line alone. + done = name(2, "Maya") + lines = held() + check("a name given to one line: that line alone takes it, its voice the person's own (#1), given the instant", + done and browser.execute_script(whos) == ["Vous", "Les autres", "Maya", "Les autres"] + and [line.get("voice") for line in lines[1:5]] == [None, None, "#1", None] + and bool(lines[3].get("given")) and voices() == {"remote/#1": "Maya"}, + [browser.execute_script(whos), [line.get("voice") for line in lines[1:5]], voices()]) + check("saved: the focus back on that line's speaker", + browser.execute_script("return document.activeElement === arguments[0]", who(2)), browser.execute_script("return document.activeElement?.textContent")) + done = name(3, "Maya") + check("the same name on another line is the same voice", + done and [line.get("voice") for line in held()[1:5]] == [None, None, "#1", "#1"] + and browser.execute_script(whos) == ["Vous", "Les autres", "Maya", "Maya"], browser.execute_script(whos)) + + # Criterion 2: a voice named, every line of it. + done = name(3, "Maya Durand", everywhere=True) + check("« Toutes les lignes de cette voix »: every line of it takes the name, the others as they were", + done and browser.execute_script(whos) == ["Vous", "Les autres", "Maya Durand", "Maya Durand"] + and voices() == {"remote/#1": "Maya Durand"}, [browser.execute_script(whos), voices()]) + page() + check("read again with the meeting: the names stay", + browser.execute_script(whos) == ["Vous", "Les autres", "Maya Durand", "Maya Durand"], browser.execute_script(whos)) + + # Criterion 3: a redo keeps them. The stand-in writes one line, local, 0.0–1.0: « Vous »'s line given to + # Sarah falls within it; the call's two named lines have none and are said. + name(0, "Sarah") + browser.execute_script("window.__TAURI__.core.invoke('transcript_redo', {name: arguments[0], model: arguments[1]})", + meeting.name, str(model)) + made = wait_for(browser, lambda b: "Refait avec" in text() and b.execute_script(idle), 20) + carried = wait_for(None, lambda b: (held()[1:2] or [{}])[0].get("voice") == "#1", 10) + page() + said = "return [...document.querySelectorAll('#meeting [role=status]')].map(s => s.textContent).join(' ')" + check("made again: the line given to Sarah keeps its voice and its name (D113)", + made and carried and browser.execute_script(whos) == ["Sarah"], [made, held()[1:2], browser.execute_script(whos)]) + check("the named lines the new transcript does not hold are said, never dropped silently", + wait_for(browser, lambda b: "2 lignes nommées" in b.execute_script(said), 5), browser.execute_script(said)) + logs = WORK / "state" / "kitokey" / "logs" + logged = [line for log in sorted(logs.glob("*.jsonl")) for line in log.read_text().splitlines()] + check("no name is logged", not any(n in line for line in logged for n in ("Maya", "Sarah", "Personne")), + [line for line in logged if any(n in line for n in ("Maya", "Sarah"))][:3]) + + def example_tried(now: dt.datetime) -> None: """CR. D126: « Essayer sur un exemple » from the empty window. The example of the window's language, bundled with Kitokey, is placed as a meeting of its own — its two tracks, its title saying it is an example — and runs @@ -18223,6 +18357,7 @@ def aside(folder): confidential_sent(now) example_tried(now) speakers_named(now) + speakers_by_line(now) waveform_drawn(now) settings_version(now) settings_narrow_without_model(now) diff --git a/modules/shell/src/lib.rs b/modules/shell/src/lib.rs index efa6570f3..91380bc20 100644 --- a/modules/shell/src/lib.rs +++ b/modules/shell/src/lib.rs @@ -43,4 +43,5 @@ pub mod spoken; pub mod summarising; pub mod transcription; pub mod trial; +pub mod voices; pub mod words; diff --git a/modules/shell/src/voices.rs b/modules/shell/src/voices.rs new file mode 100644 index 000000000..f6ebd34ee --- /dev/null +++ b/modules/shell/src/voices.rs @@ -0,0 +1,35 @@ +//! D131: each line of a transcript says who spoke, named by the user (`transcript/v1`, « a voice given », #1244). +//! Oracle stub: nothing is built yet, every call refuses. + +use std::{collections::BTreeMap, path::Path}; + +/// Why a name is not given. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Refused { + /// No `complete` line: the transcript is still made, or was stopped. + NotComplete, + /// No segment of that track starts there. + NoSuchLine, + /// A name the contract refuses: blank, over 60 characters, a line break. + Name, + /// A meeting before `session-audio/v3`, which holds no names. + NotOffered, + /// The file could not be read or written. + File(String), +} + +pub fn line_named(_folder: &Path, _track: &str, _start: f64, _name: &str, _when: &str) -> Result { + Err(Refused::File("not built".into())) +} + +pub fn voice_named(_folder: &Path, _track: &str, _start: f64, _name: &str, _when: &str) -> Result<(), Refused> { + Err(Refused::File("not built".into())) +} + +pub fn carried(_previous: &Path, _made: &Path) -> Result, Refused> { + Err(Refused::File("not built".into())) +} + +pub fn names(_folder: &Path) -> BTreeMap { + BTreeMap::new() +} diff --git a/modules/shell/tests/voices.rs b/modules/shell/tests/voices.rs new file mode 100644 index 000000000..737618ca3 --- /dev/null +++ b/modules/shell/tests/voices.rs @@ -0,0 +1,272 @@ +//! D131: each line of a transcript says who spoke, named by the user (#1230's S2, `transcript/v1`'s « a voice given », +//! #1244, #1251). A name given to one line gives that line alone a voice of the person's own — a label starting with +//! `#`, its `given` the instant —, the name kept in `speakers.json`'s `voices` (`session-audio/v3`); a name given to a +//! voice names every line of that voice; a transcript made again keeps the voices given, carried over by the +//! segment's stretch of the clock (D113), and a given line no new one falls within is returned, never dropped. + +use std::{fs, path::Path}; + +use kitokey_shell::voices::{self, Refused}; +use serde_json::{Value, json}; + +const HEADER: &str = r#"{"type":"header","contract":"transcript/v1","engine":"whisper.cpp","model":"m","language":null,"context":null}"#; + +fn segment(speaker: &str, track: &str, start: f64, end: f64, text: &str) -> String { + json!({"type": "segment", "speaker": speaker, "track": track, "voice": null, "start": start, "end": end, "text": text}).to_string() +} + +/// Four lines: one of « Vous », three of the call, and the `complete` line when `complete`. +fn transcript(complete: bool) -> String { + let mut lines = vec![ + HEADER.to_string(), + segment("me", "local", 0.0, 1.0, "On commence."), + segment("others", "remote", 1.5, 3.0, "Les tests passent."), + segment("others", "remote", 3.5, 5.0, "Je confirme pour la 2.4."), + segment("others", "remote", 5.5, 7.0, "Et la démo vendredi."), + ]; + if complete { + lines.push(r#"{"type":"complete","duration":7.0}"#.to_string()); + } + lines.iter().map(|line| format!("{line}\n")).collect() +} + +fn meeting(contract: &str, complete: bool) -> tempfile::TempDir { + let folder = tempfile::tempdir().unwrap(); + fs::write( + folder.path().join("session.json"), + format!(r#"{{"contract":"{contract}","started":"2026-11-30T14:05:00+01:00","stopped":"2026-11-30T14:35:00+01:00","tracks":{{}}}}"#), + ) + .unwrap(); + fs::write(folder.path().join("transcript.jsonl"), transcript(complete)).unwrap(); + folder +} + +fn lines(folder: &Path) -> Vec { + fs::read_to_string(folder.join("transcript.jsonl")) + .unwrap() + .lines() + .map(|line| serde_json::from_str(line).unwrap()) + .collect() +} + +fn speakers(folder: &Path) -> Value { + fs::read(folder.join("speakers.json")) + .ok() + .and_then(|bytes| serde_json::from_slice(&bytes).ok()) + .unwrap_or(Value::Null) +} + +const WHEN: &str = "2026-11-30T15:00:00+01:00"; +const LATER: &str = "2026-11-30T15:05:00+01:00"; + +#[test] +fn a_name_given_to_one_line_gives_that_line_alone_a_voice_of_the_person_s_own() { + let folder = meeting("session-audio/v3", true); + let before = lines(folder.path()); + let label = voices::line_named(folder.path(), "remote", 3.5, " Maya ", WHEN); + assert_eq!(label, Ok("#1".to_string())); + let after = lines(folder.path()); + assert_eq!(after.len(), before.len(), "the lines in the same order, none added"); + for (at, (was, now)) in before.iter().zip(&after).enumerate() { + if at == 3 { + let mut expected = was.clone(); + expected["voice"] = json!("#1"); + expected["given"] = json!(WHEN); + assert_eq!(now, &expected, "the line named: its voice and given alone"); + } else { + assert_eq!(now, was, "line {at} as it was"); + } + } + assert_eq!(speakers(folder.path()), json!({"voices": {"remote/#1": "Maya"}})); + // Written whole: nothing left beside. + let left: Vec<_> = fs::read_dir(folder.path()).unwrap().map(|e| e.unwrap().file_name()).collect(); + assert_eq!(left.len(), 3, "{left:?}"); +} + +#[test] +fn the_same_name_on_another_line_of_the_track_is_the_same_voice_another_name_a_new_one() { + let folder = meeting("session-audio/v3", true); + assert_eq!(voices::line_named(folder.path(), "remote", 1.5, "Maya", WHEN), Ok("#1".to_string())); + assert_eq!(voices::line_named(folder.path(), "remote", 5.5, "Maya", WHEN), Ok("#1".to_string())); + assert_eq!( + voices::line_named(folder.path(), "remote", 3.5, "Karim", LATER), + Ok("#2".to_string()) + ); + let voices_of: Vec = lines(folder.path()) + .iter() + .skip(1) + .take(4) + .map(|line| line["voice"].clone()) + .collect(); + assert_eq!(voices_of, vec![Value::Null, json!("#1"), json!("#2"), json!("#1")]); + assert_eq!( + speakers(folder.path()), + json!({"voices": {"remote/#1": "Maya", "remote/#2": "Karim"}}) + ); +} + +#[test] +fn a_name_given_to_a_voice_names_every_line_of_it_the_transcript_unchanged() { + let folder = meeting("session-audio/v3", true); + voices::line_named(folder.path(), "remote", 1.5, "Maya", WHEN).unwrap(); + voices::line_named(folder.path(), "remote", 5.5, "Maya", WHEN).unwrap(); + let before = fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(); + assert_eq!(voices::voice_named(folder.path(), "remote", 5.5, "Maya Durand", LATER), Ok(())); + assert_eq!(fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(), before); + assert_eq!(speakers(folder.path()), json!({"voices": {"remote/#1": "Maya Durand"}})); + assert_eq!( + voices::names(folder.path()).get("remote/#1").map(String::as_str), + Some("Maya Durand") + ); +} + +#[test] +fn a_name_given_to_a_voice_not_told_names_its_side_as_before() { + let folder = meeting("session-audio/v3", true); + fs::write(folder.path().join("speakers.json"), r#"{"me":"Sarah"}"#).unwrap(); + let before = fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(); + assert_eq!(voices::voice_named(folder.path(), "remote", 3.5, "L’équipe produit", WHEN), Ok(())); + assert_eq!(fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(), before); + assert_eq!(speakers(folder.path()), json!({"me": "Sarah", "others": "L’équipe produit"})); +} + +#[test] +fn a_voice_a_producer_told_is_given_a_label_of_the_person_s_own_on_each_of_its_lines() { + let folder = meeting("session-audio/v3", true); + let told: String = transcript(true) + .lines() + .map(|line| { + let mut value: Value = serde_json::from_str(line).unwrap(); + if value["track"] == "remote" && value["start"] != json!(3.5) { + value["voice"] = json!("2"); + } + format!("{value}\n") + }) + .collect(); + fs::write(folder.path().join("transcript.jsonl"), told).unwrap(); + assert_eq!(voices::voice_named(folder.path(), "remote", 1.5, "Maya", WHEN), Ok(())); + let after = lines(folder.path()); + let given: Vec<(Value, Value)> = after + .iter() + .skip(1) + .take(4) + .map(|line| (line["voice"].clone(), line["given"].clone())) + .collect(); + assert_eq!( + given, + vec![ + (Value::Null, Value::Null), + (json!("#1"), json!(WHEN)), + (Value::Null, Value::Null), + (json!("#1"), json!(WHEN)), + ], + "the producer's label `2` never named: each of its lines given `#1`" + ); + assert_eq!(speakers(folder.path()), json!({"voices": {"remote/#1": "Maya"}})); +} + +#[test] +fn a_name_is_refused_before_complete_on_no_line_blank_too_long_or_before_v3_nothing_written() { + let cases: [(&str, bool, &str, f64, &str, Refused); 5] = [ + ("session-audio/v3", false, "remote", 3.5, "Maya", Refused::NotComplete), + ("session-audio/v3", true, "remote", 9.0, "Maya", Refused::NoSuchLine), + ("session-audio/v3", true, "remote", 3.5, " ", Refused::Name), + ("session-audio/v3", true, "remote", 3.5, &"x".repeat(61), Refused::Name), + ("session-audio/v2", true, "remote", 3.5, "Maya", Refused::NotOffered), + ]; + for (contract, complete, track, start, name, refused) in cases { + let folder = meeting(contract, complete); + let before = fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(); + assert_eq!( + voices::line_named(folder.path(), track, start, name, WHEN), + Err(refused.clone()), + "{contract} {name}" + ); + assert_eq!( + voices::voice_named(folder.path(), track, start, name, WHEN), + Err(refused), + "{contract} {name}" + ); + assert_eq!(fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(), before); + assert!(!folder.path().join("speakers.json").exists()); + } +} + +/// The transcript made again: other times, as a new making writes them. +fn made_again(complete: bool) -> String { + let mut lines = vec![ + HEADER.to_string(), + segment("me", "local", 0.1, 0.9, "On commence."), + segment("others", "remote", 1.6, 2.6, "Les tests passent."), + segment("others", "remote", 2.7, 3.3, "Oui."), + segment("others", "remote", 3.6, 4.8, "Je confirme pour la 2.4."), + ]; + if complete { + lines.push(r#"{"type":"complete","duration":7.0}"#.to_string()); + } + lines.iter().map(|line| format!("{line}\n")).collect() +} + +#[test] +fn a_transcript_made_again_keeps_the_voices_given_by_their_stretch_of_the_clock() { + let folder = meeting("session-audio/v3", true); + voices::line_named(folder.path(), "remote", 1.5, "Maya", WHEN).unwrap(); + voices::line_named(folder.path(), "remote", 5.5, "Karim", LATER).unwrap(); + voices::line_named(folder.path(), "local", 0.0, "Sarah", WHEN).unwrap(); + let previous = folder.path().join("transcript-previous.jsonl"); + fs::rename(folder.path().join("transcript.jsonl"), &previous).unwrap(); + fs::write(folder.path().join("transcript.jsonl"), made_again(true)).unwrap(); + let lost = voices::carried(&previous, &folder.path().join("transcript.jsonl")); + // Karim's line, 5.5–7.0: no new segment's middle falls within it — said, never dropped. + assert_eq!(lost, Ok(vec![("remote".to_string(), 5.5)])); + let after = lines(folder.path()); + let given: Vec<(Value, Value)> = after + .iter() + .skip(1) + .take(4) + .map(|line| (line["voice"].clone(), line["given"].clone())) + .collect(); + assert_eq!( + given, + vec![ + (json!("#1"), json!(WHEN)), // local 0.1–0.9, middle 0.5 within Sarah's 0.0–1.0 + (json!("#1"), json!(WHEN)), // remote 1.6–2.6, middle 2.1 within Maya's 1.5–3.0 + (json!("#1"), json!(WHEN)), // remote 2.7–3.3, middle 3.0 within Maya's, both ends included + (Value::Null, Value::Null), // remote 3.6–4.8, never given + ] + ); + assert_eq!( + speakers(folder.path()), + json!({"voices": {"remote/#1": "Maya", "remote/#2": "Karim", "local/#1": "Sarah"}}), + "the names stay with their labels" + ); +} + +#[test] +fn within_two_given_stretches_the_one_given_last_wins_and_nothing_is_carried_before_complete() { + let folder = meeting("session-audio/v3", true); + let previous = folder.path().join("transcript-previous.jsonl"); + let given: String = [ + HEADER.to_string(), + json!({"type": "segment", "speaker": "others", "track": "remote", "voice": "#2", "given": LATER, "start": 1.0, "end": 3.0, "text": "a"}).to_string(), + json!({"type": "segment", "speaker": "others", "track": "remote", "voice": "#1", "given": WHEN, "start": 2.0, "end": 4.0, "text": "b"}).to_string(), + r#"{"type":"complete","duration":7.0}"#.to_string(), + ] + .iter() + .map(|line| format!("{line}\n")) + .collect(); + fs::write(&previous, given).unwrap(); + let made = folder.path().join("transcript.jsonl"); + fs::write(&made, made_again(false)).unwrap(); + assert_eq!(voices::carried(&previous, &made), Err(Refused::NotComplete)); + assert_eq!( + fs::read_to_string(&made).unwrap(), + made_again(false), + "nothing carried while it is made" + ); + fs::write(&made, made_again(true)).unwrap(); + assert_eq!(voices::carried(&previous, &made), Ok(vec![])); + // 2.7–3.3, middle 3.0, within both: `#2`, given last (15:05 after 15:00). + assert_eq!(lines(folder.path())[3]["voice"], json!("#2")); + assert_eq!(lines(folder.path())[3]["given"], json!(LATER)); +} From a2c6f624af12a04c097685b4c7011854e25730f1 Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:28:05 +0100 Subject: [PATCH 3/8] =?UTF-8?q?D131:=20each=20line=20of=20a=20transcript?= =?UTF-8?q?=20says=20who=20spoke,=20named=20by=20the=20user=20=E2=80=94=20?= =?UTF-8?q?one=20line,=20a=20voice=20everywhere,=20kept=20across=20a=20red?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit voices.rs: a name given to one line gives it alone a label of the person's own (`#n`, `given`), its name in speakers.json's `voices`; the same name on the same track is the same label; a name given to a voice renames its label, names its side when no voice is told (#1205), and gives a producer's label a label of the person's own first (transcript/v1, #1244). A transcript made again takes the voices given by each segment's stretch of the clock, the one given last within two, under the making's lock, before its summary reads it. The window: each line's speaker is a button, once complete in a v3 meeting, its name « {who} : changer qui parle à {time} »; it opens « Qui parle sur cette ligne ? » under the line — « Cette ligne seulement » or « Toutes les lignes de cette voix », the meeting's names offered —, Enter saves, Escape closes it, the focus back on the line's speaker. The lines a redo found no line for are said on the transcript, the previous version keeping them. cargo test: 604 passed, 0 failed; fmt and clippy -D warnings clean. Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 2 +- modules/shell/src/correction.rs | 4 +- modules/shell/src/main.rs | 63 ++++++- modules/shell/src/speakers.rs | 43 ++++- modules/shell/src/voices.rs | 265 ++++++++++++++++++++++++++-- modules/shell/src/words.rs | 31 ++++ modules/shell/ui/window.css | 5 + modules/shell/ui/window.js | 152 +++++++++++++++- 8 files changed, 538 insertions(+), 27 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 931273568..1c8167a2c 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6139,7 +6139,7 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): "const f = document.getElementById('voice-name'); return f ? [document.activeElement.id, f.labels[0]?.textContent.trim()," " document.getElementById('voice-line')?.checked, arguments[0]?.getAttribute('aria-expanded')] : null", button) check("Enter on a line's speaker opens « Qui parle sur cette ligne ? », its field focused and labelled, « Cette ligne seulement » chosen", - opened and got == ["voice-name", "Qui parle sur cette ligne ?", True, "true"], got) + opened and got == ["voice-name", "Qui parle sur cette ligne\u202f?", True, "true"], got) violations = axe_violations(browser) if opened else [("the field absent", None, 0, [])] check("axe: the open field, WCAG 2.2 A and AA, no violation", violations == [], violations) ActionChains(browser).send_keys("Personne").perform() diff --git a/modules/shell/src/correction.rs b/modules/shell/src/correction.rs index 75cf59ea1..0c1a2f8fc 100644 --- a/modules/shell/src/correction.rs +++ b/modules/shell/src/correction.rs @@ -28,7 +28,7 @@ pub fn tidy(text: &str) -> Option { } /// The speaker a track's segments are written under (`transcript/v1`). -fn speaker(track: &str) -> &'static str { +pub(crate) fn speaker(track: &str) -> &'static str { if track == "local" { "me" } else { "others" } } @@ -73,7 +73,7 @@ pub fn correct(file: &Path, track: &str, start: f64, text: &str, when: &str) -> } /// Writes `content` beside `file`, then renames it over: read at any moment, the file is whole. -fn replace(file: &Path, content: &str) -> io::Result<()> { +pub(crate) fn replace(file: &Path, content: &str) -> io::Result<()> { let beside = file.with_extension("jsonl.part"); let written = fs::write(&beside, content).and_then(|()| fs::rename(&beside, file)); if written.is_err() { diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index d044cd62a..4013a1145 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -50,7 +50,7 @@ use kitokey_shell::{ spoken, summarising::{self, Summarising}, transcription::{self, Hearer, Made, Transcription}, - trial, + trial, voices, words::{self, Failure, Language, Notice, Refusal, Told, Trouble}, }; @@ -436,6 +436,8 @@ fn main() { summary_sent, transcript_redo, transcript_corrected, + line_named, + voice_named, transcript_asked, example_tried, transcript_again, @@ -1800,6 +1802,11 @@ struct Opened { /// The names the user gave its two sides (#1205); none where the meeting cannot hold them — before /// session-audio/v3 —: the page then offers no naming. speakers: Option, + /// The voices a person gave lines, keyed `/`: their names (D131). + voices: std::collections::BTreeMap, + /// The lines given a voice in the transcript a redo replaced that the one shown holds no line for (D131): + /// the page says how many, the earlier version keeping them. + voices_lost: usize, /// The last transcript a redo replaced, the same way (D113). previous_transcript: Option, /// The summary shown was made on the other version of the transcript, not the one shown (#1070): @@ -1935,6 +1942,8 @@ fn opened(shell: State<'_, Shell>, name: String) -> Result { _ => None, }, speakers: speakers::offered(&folder).then(|| SpeakersShown::from(speakers::read(&folder))), + voices: voices::names(&folder), + voices_lost: voices::lost(&folder.join(meeting::PREVIOUS), &folder.join(voices::TRANSCRIPT)), previous_transcript: match meeting::previous(&folder) { Read::Present(kept) => Some(Previous { made: kept.made, @@ -1967,6 +1976,48 @@ fn speakers_named(shell: State<'_, Shell>, name: String, me: Option, oth Ok(SpeakersShown::from(kept)) } +/// Who spoke on one line of a meeting's transcript, named on the user's word (D131): that line alone given a voice +/// of the person's own when `everywhere` is false, else every line of its voice. Once complete, never while it is +/// made, waits to be made again or its minutes are written — as a correction (D62). No name is logged. +fn voice_given(shell: &Shell, name: &str, track: &str, start: f64, who: &str, everywhere: bool) -> Result<(), Told> { + 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); + if (running.is_some() && hearing) || waits { + return Err(shell.told(Failure::Busy, format!("the transcript of {name} is being made"))); + } + if shell.writing_minutes.lock().unwrap().as_deref() == Some(folder.as_path()) { + return Err(shell.told(Failure::Busy, format!("the minutes of {name} are being written"))); + } + let when = chrono::Local::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, false); + let given = if everywhere { + voices::voice_named(&folder, track, start, who, &when) + } else { + voices::line_named(&folder, track, start, who, &when).map(|_| ()) + }; + given.map_err(|refused| match refused { + voices::Refused::NotComplete => shell.told(Failure::NotComplete, format!("the transcript of {name} is not complete")), + voices::Refused::NoSuchLine => shell.told(Failure::Unexpected, "no line of the transcript starts there"), + voices::Refused::Name => shell.told(Failure::Unexpected, "a name the contract session-audio/v3 refuses"), + voices::Refused::NotOffered => shell.told(Failure::Unexpected, "names are kept by a session-audio/v3 meeting alone"), + voices::Refused::File(why) => shell.told(Failure::MeetingFile, why), + })?; + drop(running); + tracing::info!(track, everywhere, "shell.voice_given"); + Ok(()) +} + +#[tauri::command] +fn line_named(shell: State<'_, Shell>, name: String, track: String, start: f64, who: String) -> Result<(), Told> { + voice_given(&shell, &name, &track, start, &who, false) +} + +#[tauri::command] +fn voice_named(shell: State<'_, Shell>, name: String, track: String, start: f64, who: String) -> Result<(), Told> { + voice_given(&shell, &name, &track, start, &who, true) +} + /// The steps whose own model a meeting chose and cannot have now (D91). fn gone_of(settings: &Settings, folder: &Path) -> Vec { let chosen = meeting_models::read(folder); @@ -5290,6 +5341,16 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again, cancel: Cancel) }) { kept_beside = name.map(|name| (name, not_put_back)); } + // The voices a person gave the one replaced, carried to the new one by their stretch of the clock (D131, + // D113), before its summary reads it; the making's lock held, as a correction holds it. Those it holds + // no line for stay in the previous version, and its page says how many. + if written { + let _writing = shell.transcription.lock().unwrap(); + match voices::carried(&folder.join(meeting::PREVIOUS), &folder.join(voices::TRANSCRIPT)) { + Ok(lost) => tracing::info!(lost = lost.len(), "shell.voices_carried"), + Err(refused) => tracing::warn!(?refused, "shell.voices_not_carried"), + } + } } if *shell.leaving.lock().unwrap() { return; diff --git a/modules/shell/src/speakers.rs b/modules/shell/src/speakers.rs index 213709e01..be3b5baa0 100644 --- a/modules/shell/src/speakers.rs +++ b/modules/shell/src/speakers.rs @@ -1,9 +1,10 @@ //! The names a person gives a meeting's speakers (#1205): `speakers.json` of `contracts/session-audio/v3`, written by //! the shell on the user's word and read by it and by `summary`. Without a producer that tells voices apart, the shell //! names the two sides alone — `me`, the local track, where it says « Vous », and `others`, the remote one, where it -//! says « Les autres » —; `voices` it never writes, and keeps as it found them. +//! says « Les autres » —. `voices` it writes for a voice a person gave (D131, `voices.rs`), and keeps the others as it +//! found them. -use std::{fs, io, path::Path}; +use std::{collections::BTreeMap, fs, io, path::Path}; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; @@ -30,7 +31,7 @@ impl Speakers { } /// A name as the contract allows it: one line, 1 to 60 characters, not blank. -fn allowed(name: &str) -> bool { +pub fn allowed(name: &str) -> bool { !name.trim().is_empty() && name.chars().count() <= LONGEST && !name.contains(['\n', '\r']) } @@ -95,11 +96,16 @@ pub fn write(folder: &Path, wanted: &Speakers) -> io::Result { None => object.remove(key), }; } + save(folder, object).map(|()| kept) +} + +/// The file written whole — beside, then renamed —; an empty object, no file. +fn save(folder: &Path, object: Map) -> io::Result<()> { let target = folder.join(FILE); if object.is_empty() { return match fs::remove_file(&target) { Err(error) if error.kind() != io::ErrorKind::NotFound => Err(error), - _ => Ok(kept), + _ => Ok(()), }; } let beside = folder.join(".speakers.json.part"); @@ -108,5 +114,32 @@ pub fn write(folder: &Path, wanted: &Speakers) -> io::Result { if written.is_err() { let _ = fs::remove_file(&beside); } - written.map(|()| kept) + written +} + +/// The voices' names the meeting holds, keyed `/`: each the contract allows, else absent. +pub fn voices(folder: &Path) -> BTreeMap { + let held = object_of(folder).and_then(|mut object| object.remove("voices")); + let Some(Value::Object(voices)) = held else { + return BTreeMap::new(); + }; + voices + .into_iter() + .filter_map(|(key, name)| match name { + Value::String(name) if allowed(&name) && key.contains('/') => Some((key, name)), + _ => None, + }) + .collect() +} + +/// A voice's name written, keyed `/`, whatever else the file holds kept. The caller has trimmed it +/// and checked the contract allows it. +pub fn voice_written(folder: &Path, key: &str, name: &str) -> io::Result<()> { + let mut object = object_of(folder).unwrap_or_default(); + let voices = object.entry("voices").or_insert_with(|| Value::Object(Map::new())); + if !voices.is_object() { + *voices = Value::Object(Map::new()); + } + voices[key] = Value::String(name.to_string()); + save(folder, object) } diff --git a/modules/shell/src/voices.rs b/modules/shell/src/voices.rs index f6ebd34ee..940491401 100644 --- a/modules/shell/src/voices.rs +++ b/modules/shell/src/voices.rs @@ -1,8 +1,18 @@ -//! D131: each line of a transcript says who spoke, named by the user (`transcript/v1`, « a voice given », #1244). -//! Oracle stub: nothing is built yet, every call refuses. +//! D131: each line of a transcript says who spoke, named by the user (#1230's S2). `transcript/v1`'s « a voice +//! given » (#1244): once complete, the shell sets one segment's `voice` to a label of the person's own — starting with +//! `#` — and its `given` to when, the file replaced whole; the label's name is kept in `speakers.json`'s `voices` +//! (`session-audio/v3`). A transcript made again keeps the voices given, carried by each segment's stretch of the +//! clock (D113); a given line no new one falls within is said, never dropped. No voice's sound is ever measured. use std::{collections::BTreeMap, path::Path}; +use serde_json::Value; + +use crate::{correction, speakers}; + +/// The transcript's name, in the meeting's folder. +pub const TRANSCRIPT: &str = "transcript.jsonl"; + /// Why a name is not given. #[derive(Debug, Clone, PartialEq, Eq)] pub enum Refused { @@ -18,18 +28,253 @@ pub enum Refused { File(String), } -pub fn line_named(_folder: &Path, _track: &str, _start: f64, _name: &str, _when: &str) -> Result { - Err(Refused::File("not built".into())) +fn file_error(error: impl ToString) -> Refused { + Refused::File(error.to_string()) +} + +/// A transcript as its lines, each kept as written, and each parsed. +struct Lines { + raw: Vec, + parsed: Vec>, +} + +impl Lines { + fn read(file: &Path) -> Result { + let text = std::fs::read_to_string(file).map_err(file_error)?; + let raw: Vec = text.split_inclusive('\n').map(str::to_string).collect(); + let parsed = raw.iter().map(|line| serde_json::from_str(line.trim_end()).ok()).collect(); + Ok(Lines { raw, parsed }) + } + + fn complete(&self) -> bool { + self.parsed.iter().flatten().any(|value| value["type"] == "complete") + } + + /// Each segment, by its index among the lines. + fn segments(&self) -> impl Iterator { + self.parsed + .iter() + .enumerate() + .filter_map(|(at, value)| value.as_ref().filter(|value| value["type"] == "segment").map(|value| (at, value))) + } + + /// The segment of `track` that starts at `start`, to the hundredth: a segment is known by its speaker and start. + fn find(&self, track: &str, start: f64) -> Option { + let speaker = correction::speaker(track); + self.segments() + .find(|(_, value)| value["speaker"] == speaker && value["start"].as_f64().is_some_and(|at| (at - start).abs() < 0.005)) + .map(|(at, _)| at) + } + + /// Segment `at` given `voice` at `given`, its line written anew, every other field as it was. + fn set(&mut self, at: usize, voice: Value, given: &str) { + if let Some(value) = self.parsed[at].as_mut() { + value["voice"] = voice; + value["given"] = Value::String(given.to_string()); + self.raw[at] = format!("{value}\n"); + } + } + + fn write(&self, file: &Path) -> Result<(), Refused> { + correction::replace(file, &self.raw.concat()).map_err(file_error) + } +} + +/// A segment's track: its own, else its speaker's (`transcript/v1`). +fn track_of(segment: &Value) -> &str { + segment["track"] + .as_str() + .unwrap_or(if segment["speaker"] == "me" { "local" } else { "remote" }) +} + +/// What every naming checks first, in this order: the meeting holds names, the name is one the contract allows, the +/// transcript is complete and holds that line. Nothing is written before. +fn ready(folder: &Path, track: &str, start: f64, name: &str) -> Result<(Lines, usize, String), Refused> { + if !speakers::offered(folder) { + return Err(Refused::NotOffered); + } + let name = name.trim(); + if !speakers::allowed(name) { + return Err(Refused::Name); + } + let lines = Lines::read(&folder.join(TRANSCRIPT))?; + if !lines.complete() { + return Err(Refused::NotComplete); + } + let at = lines.find(track, start).ok_or(Refused::NoSuchLine)?; + Ok((lines, at, name.to_string())) +} + +/// The person's label for `name` on `track`: the one already named so, else the next `#n` neither the names nor the +/// transcript use. +fn label_for(folder: &Path, lines: &Lines, track: &str, name: &str) -> String { + let names = speakers::voices(folder); + let prefix = format!("{track}/"); + if let Some(key) = names + .iter() + .find(|(key, named)| key.starts_with(&prefix) && named.as_str() == name) + .map(|(key, _)| key) + { + return key[prefix.len()..].to_string(); + } + let number = |label: &str| label.strip_prefix('#').and_then(|n| n.parse::().ok()); + let in_names = names.keys().filter_map(|key| key.strip_prefix(&prefix)).filter_map(number); + let in_lines = lines + .segments() + .filter(|(_, segment)| track_of(segment) == track) + .filter_map(|(_, segment)| segment["voice"].as_str().and_then(number)); + format!("#{}", in_names.chain(in_lines).max().unwrap_or(0) + 1) +} + +/// The line of `track` starting at `start` given to `name`, it alone: a label of the person's own, `given` set to +/// `when`, the name kept with it. The label is returned. +pub fn line_named(folder: &Path, track: &str, start: f64, name: &str, when: &str) -> Result { + let (mut lines, at, name) = ready(folder, track, start, name)?; + let label = label_for(folder, &lines, track, &name); + speakers::voice_written(folder, &format!("{track}/{label}"), &name).map_err(file_error)?; + lines.set(at, Value::String(label.clone()), when); + lines.write(&folder.join(TRANSCRIPT))?; + Ok(label) +} + +/// The voice of the line of `track` starting at `start` named `name`, every line of it: a voice of the person's own, +/// its name; a voice not told, its side's (#1205); a producer's label, a label of the person's own given first to each +/// of its lines — a producer's label holds within one transcript only (`transcript/v1`). +pub fn voice_named(folder: &Path, track: &str, start: f64, name: &str, when: &str) -> Result<(), Refused> { + let (mut lines, at, name) = ready(folder, track, start, name)?; + let voice = lines.parsed[at] + .as_ref() + .and_then(|segment| segment["voice"].as_str().map(str::to_string)); + match voice { + None => { + let mut sides = speakers::read(folder); + if track == "local" { + sides.me = Some(name); + } else { + sides.others = Some(name); + } + speakers::write(folder, &sides).map(|_| ()).map_err(file_error) + } + Some(label) if label.starts_with('#') => speakers::voice_written(folder, &format!("{track}/{label}"), &name).map_err(file_error), + Some(told) => { + let label = label_for(folder, &lines, track, &name); + speakers::voice_written(folder, &format!("{track}/{label}"), &name).map_err(file_error)?; + let same: Vec = lines + .segments() + .filter(|(_, segment)| track_of(segment) == track && segment["voice"].as_str() == Some(told.as_str())) + .map(|(at, _)| at) + .collect(); + for at in same { + lines.set(at, Value::String(label.clone()), when); + } + lines.write(&folder.join(TRANSCRIPT)) + } + } +} + +/// A segment a person gave a voice: its track, stretch, voice and when. +struct Given { + track: String, + start: f64, + end: f64, + voice: Value, + given: String, + instant: Option>, +} + +fn given_in(lines: &Lines) -> Vec { + lines + .segments() + .filter_map(|(_, segment)| { + let given = segment["given"].as_str().filter(|given| !given.is_empty())?; + Some(Given { + track: track_of(segment).to_string(), + start: segment["start"].as_f64()?, + end: segment["end"].as_f64()?, + voice: segment.get("voice").cloned().unwrap_or(Value::Null), + given: given.to_string(), + instant: chrono::DateTime::parse_from_rfc3339(given).ok(), + }) + }) + .collect() +} + +/// For each segment of `made`, the given segment it takes its voice from: of the same track, the segment's middle +/// within its stretch, both ends included; within two, the one given last. +fn matches<'a>(given: &'a [Given], made: &Lines) -> Vec<(usize, Option<&'a Given>)> { + made.segments() + .map(|(at, segment)| { + let track = track_of(segment); + let found = match (segment["start"].as_f64(), segment["end"].as_f64()) { + (Some(start), Some(end)) => { + let middle = (start + end) / 2.0; + given + .iter() + .filter(|one| one.track == track && one.start <= middle && middle <= one.end) + .max_by_key(|one| one.instant) + } + _ => None, + }; + (at, found) + }) + .collect() +} + +/// The given segments that no new segment falls within: each its track and start. +fn unmatched(given: &[Given], made: &Lines) -> Vec<(String, f64)> { + given + .iter() + .filter(|one| { + !made + .segments() + .any(|(_, segment)| match (segment["start"].as_f64(), segment["end"].as_f64()) { + (Some(start), Some(end)) => { + let middle = (start + end) / 2.0; + track_of(segment) == one.track && one.start <= middle && middle <= one.end + } + _ => false, + }) + }) + .map(|one| (one.track.clone(), one.start)) + .collect() } -pub fn voice_named(_folder: &Path, _track: &str, _start: f64, _name: &str, _when: &str) -> Result<(), Refused> { - Err(Refused::File("not built".into())) +/// The voices given in `previous` carried to `made`, a transcript made again, once it is complete: each new segment +/// whose middle falls within a given one's stretch takes its `voice` and `given` (D113, `transcript/v1`). The given +/// segments no new one falls within are returned, each its track and start. +pub fn carried(previous: &Path, made: &Path) -> Result, Refused> { + let mut lines = Lines::read(made)?; + if !lines.complete() { + return Err(Refused::NotComplete); + } + let given = given_in(&Lines::read(previous)?); + if given.is_empty() { + return Ok(Vec::new()); + } + let lost = unmatched(&given, &lines); + let taken: Vec<(usize, Value, String)> = matches(&given, &lines) + .into_iter() + .filter_map(|(at, by)| by.map(|by| (at, by.voice.clone(), by.given.clone()))) + .collect(); + if !taken.is_empty() { + for (at, voice, given) in taken { + lines.set(at, voice, &given); + } + lines.write(made)?; + } + Ok(lost) } -pub fn carried(_previous: &Path, _made: &Path) -> Result, Refused> { - Err(Refused::File("not built".into())) +/// How many given segments of `previous` `current` holds no line for: what the page says after a redo. Unreadable +/// files, none. +pub fn lost(previous: &Path, current: &Path) -> usize { + let (Ok(previous), Ok(current)) = (Lines::read(previous), Lines::read(current)) else { + return 0; + }; + unmatched(&given_in(&previous), ¤t).len() } -pub fn names(_folder: &Path) -> BTreeMap { - BTreeMap::new() +/// The voices' names the meeting holds, keyed `/`. +pub fn names(folder: &Path) -> BTreeMap { + speakers::voices(folder) } diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 6395cebe0..94abc5bbd 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -751,6 +751,25 @@ pub struct Window { /// Shows: a meeting's page, as an error under the fields, what was typed kept. When: the names could not be /// kept in the meeting's folder. At most: one line. Placeholders: none. pub speakers_not_saved: &'static str, + /// Who spoke on one line, named by the user (D131): the speaker's button on each line, its name and tooltip. + /// Shows: a meeting's page, as a button's name. When: a complete transcript of a v3 meeting. At most: one line. + /// Placeholders: {} who speaks there now, {} the line's time. + pub who_change: &'static str, + /// Shows: a meeting's page, as a field's label. When: a line's speaker being named. At most: about 30 + /// characters. Placeholders: none. + pub who_field: &'static str, + /// Shows: a meeting's page, as a choice. When: a line's speaker being named, the name for that line alone. + /// At most: about 25 characters. Placeholders: none. + pub who_line_only: &'static str, + /// Shows: a meeting's page, as a choice. When: a line's speaker being named, the name for every line of its + /// voice. At most: about 35 characters. Placeholders: none. + pub who_everywhere: &'static str, + /// Shows: a meeting's page, as a status on the transcript. When: a redo left one line a person named without + /// a line in the new transcript. At most: two lines. Placeholders: none. + pub voices_lost_one: &'static str, + /// Shows: a meeting's page, as a status on the transcript. When: a redo left several lines a person named + /// without a line in the new transcript; plural. At most: two lines. Placeholders: {} how many. + pub voices_lost: &'static str, /// Who spoke over the meeting, for whoever does not see the drawing. /// Shows: a meeting's page, as a name for a screen reader. When: screen reader: the /// speaking-time drawing. At most: no limit. Placeholders: none. @@ -2317,6 +2336,12 @@ pub fn window(language: Language) -> Window { speakers_cancel: "Cancel", speakers_hint: "Kept with this meeting. Leave a field empty to keep “You” or “Others”.", speakers_not_saved: "Kitokey could not save these names. Try again.", + who_change: "{}: change who speaks at {}", + who_field: "Who speaks on this line?", + who_line_only: "This line only", + who_everywhere: "Every line of this voice", + voices_lost_one: "1 named line was not found in this version. The previous version keeps it.", + voices_lost: "{} named lines were not found in this version. The previous version keeps them.", who_spoke: "Who spoke when: you on top, others below", who_spoke_later: "Who spoke when appears once it is transcribed.", no_transcript: "No transcript yet.", @@ -2925,6 +2950,12 @@ pub fn window(language: Language) -> Window { speakers_cancel: "Annuler", speakers_hint: "Gardés avec cette réunion. Laissez un champ vide pour garder «\u{a0}Vous\u{a0}» ou «\u{a0}Les autres\u{a0}».", speakers_not_saved: "Kitokey n’a pas pu enregistrer ces noms. Réessayez.", + who_change: "{}\u{a0}: changer qui parle à {}", + who_field: "Qui parle sur cette ligne\u{202f}?", + who_line_only: "Cette ligne seulement", + who_everywhere: "Toutes les lignes de cette voix", + voices_lost_one: "1 ligne nommée n’a pas été retrouvée dans cette version. La version précédente la garde.", + voices_lost: "{} lignes nommées n’ont pas été retrouvées dans cette version. La version précédente les garde.", who_spoke: "Temps de parole au fil de la réunion\u{a0}: vous en haut, les autres en bas", who_spoke_later: "Le temps de parole s’affichera après la transcription.", no_transcript: "Pas encore de transcription.", diff --git a/modules/shell/ui/window.css b/modules/shell/ui/window.css index 9715be55b..74e797472 100644 --- a/modules/shell/ui/window.css +++ b/modules/shell/ui/window.css @@ -141,6 +141,11 @@ mark { background: var(--mark); color: var(--mark-ink); box-shadow: inset 0 -2px .speakers-panel { margin: 8px 0 12px; } .speakers-panel > .note, .speakers-choices { flex-basis: 100%; margin: 0; } .speakers-choices { display: flex; gap: 8px; } +/* D131: a line's speaker, a button that reads as its name; its field under the line. */ +button.who { align-self: flex-start; padding: 0; border: 0; background: none; font-family: inherit; line-height: inherit; cursor: pointer; } +button.who:hover { text-decoration: underline; } +.voice-panel { cursor: auto; } +.voice-scope { display: flex; flex-wrap: wrap; flex-basis: 100%; gap: var(--sp-1) var(--sp-4); } .send-said:empty { display: none; } .sends { list-style: none; margin: 4px 0 0; padding: 0; color: var(--soft); font-size: 13px; } .sends:empty { display: none; } diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index df773632a..20452f838 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -2895,6 +2895,9 @@ function roam(lines, line) { // Its pencil follows it in the order of Tab: one line, one pencil reached by Tab (D62). const pencil = other.querySelector(".edit"); if (pencil) pencil.tabIndex = other.tabIndex; + // And its speaker's button (D131). + const who = other.querySelector("button.who"); + if (who) who.tabIndex = other.tabIndex; } } @@ -2926,10 +2929,113 @@ function tookAndCost(read, words) { // Who said a line, as the page names them: the track — by the name the user gave its side (#1205), else the // page's word —, and the voice within it when one was told. function whoSaid(segment, words, names) { + // A voice a person gave the line, by its name (D131). + const given = names?.voices?.[`${segment.track}/${segment.voice}`]; + if (given) return given; const side = segment.track === "local" ? names?.me ?? words.here : names?.others ?? words.remote; return segment.voice === null ? side : `${side} · ${fill(words.voice, segment.voice)}`; } +// A line's speaker said: its words, and on its button (D131) the name that says what pressing it does. +function sayWho(who, segment, words, names) { + who.textContent = whoSaid(segment, words, names); + if (who.tagName !== "BUTTON") return; + who.setAttribute("aria-label", fill(words.who_change, who.textContent, clock(segment.start))); + who.title = who.getAttribute("aria-label"); +} + +// Who speaks on one line, named by the user (D131), in a field under it: that line alone, or every line of its voice +// (Fireflies', Otter's two scopes). Enter saves, Escape or « Annuler » closes it as it was, the focus back on the +// line's speaker; a name not kept is said under the field, what was typed kept. The names offered are the meeting's. +function whoPanel(card, read, segment, who, words, session, names) { + // One at a time: another line's closes. + document.getElementById("voice-panel")?.remove(); + for (const open of card.querySelectorAll("button.who[aria-expanded=true]")) open.setAttribute("aria-expanded", "false"); + const panel = element("form", "fields speakers-panel voice-panel"); + panel.id = "voice-panel"; + panel.setAttribute("aria-label", words.who_field); + const close = () => { + panel.remove(); + who.setAttribute("aria-expanded", "false"); + who.focus(); + }; + const [row, input] = guidedField("voice-name", words.who_field, "text", "", false); + input.maxLength = 60; + input.autocomplete = "off"; + input.placeholder = who.textContent; + const known = element("datalist"); + known.id = "voice-names"; + for (const name of new Set([names.me, names.others, ...Object.values(names.voices ?? {})].filter(Boolean))) { + const option = element("option"); + option.value = name; + known.append(option); + } + input.setAttribute("list", "voice-names"); + const scope = element("div", "voice-scope"); + const choice = (id, text, checked) => { + const label = element("label", "choice"); + const radio = element("input"); + radio.type = "radio"; + radio.name = "voice-scope"; + radio.id = id; + radio.checked = checked; + label.append(radio, element("span", "", text)); + scope.append(label); + return radio; + }; + choice("voice-line", words.who_line_only, true); + const everywhere = choice("voice-all", words.who_everywhere, false); + const said = element("p", "note warn", ""); + said.id = "voice-said"; + said.setAttribute("role", "alert"); + said.hidden = true; + const save = element("button", "primary", words.speakers_save); + save.type = "submit"; + save.id = "voice-save"; + const cancel = element("button", "", words.speakers_cancel); + cancel.type = "button"; + cancel.id = "voice-cancel"; + cancel.addEventListener("click", close); + const choices = element("div", "speakers-choices"); + choices.append(save, cancel); + panel.append(row, known, scope, said, choices); + // Its own keys and clicks: never the line's, which plays the meeting from it. + for (const kind of ["click", "keydown"]) panel.addEventListener(kind, (event) => event.stopPropagation()); + panel.addEventListener("keydown", (event) => { + if (event.key !== "Escape") return; + event.preventDefault(); + close(); + }); + panel.addEventListener("submit", async (event) => { + event.preventDefault(); + save.disabled = true; + try { + const asked = { name: nameOf(session), track: segment.track, start: segment.start, who: input.value }; + await window.__TAURI__.core.invoke(everywhere.checked ? "voice_named" : "line_named", asked); + // The names and voices as the meeting now holds them: every line, and what a copy takes, says them. + const now = await window.__TAURI__.core.invoke("opened", { name: nameOf(session) }); + Object.assign(names, now.speakers ?? {}, { voices: now.voices ?? {} }); + const fresh = now.transcript.state === "present" ? now.transcript.segments : []; + const lines = card.querySelectorAll(".lines li"); + read.segments.forEach((one, index) => { + const same = fresh[index]; + if (same && same.track === one.track && same.start === one.start) one.voice = same.voice; + const shown = lines[index]?.querySelector(".who"); + if (shown) sayWho(shown, one, words, names); + }); + close(); + } catch { + said.textContent = words.speakers_not_saved; + said.hidden = false; + } finally { + save.disabled = false; + } + }); + who.closest(".said").append(panel); + who.setAttribute("aria-expanded", "true"); + input.focus(); +} + // The button that opens the speakers' names, and its panel under the card's top (#1205): Enter saves, Escape or // « Annuler » closes it as it was; a name refused or not kept is said under the fields, what was typed kept. function speakersButton(card, names, read, words, session) { @@ -2990,7 +3096,7 @@ function speakersButton(card, names, read, words, session) { const lines = card.querySelectorAll(".lines li"); read.segments.forEach((segment, index) => { const who = lines[index]?.querySelector(".who"); - if (who) who.textContent = whoSaid(segment, words, names); + if (who) sayWho(who, segment, words, names); }); close(); } catch { @@ -3007,9 +3113,10 @@ function speakersButton(card, names, read, words, session) { return open; } -function transcriptCard(read, words, session, onPage, previous, speakers) { - // The sides' names as kept (#1205): none where the meeting cannot hold them; renamed in place below. - const names = speakers ? { ...speakers } : null; +function transcriptCard(read, words, session, onPage, previous, speakers, voices, voicesLost) { + // The sides' names as kept (#1205), and the voices' a person gave lines (D131): none where the meeting cannot + // hold them; renamed in place below. + const names = speakers ? { ...speakers, voices: { ...(voices ?? {}) } } : null; const card = element("aside", "card transcript"); card.setAttribute("aria-label", words.transcript_title); const top = element("div", "top"); @@ -3097,6 +3204,13 @@ function transcriptCard(read, words, session, onPage, previous, speakers) { said_.id = "correction-said"; said_.setAttribute("role", "status"); card.append(said_); + // Lines a person named that a redo found no line for (D131): said, never dropped; the earlier version keeps them. + if (voicesLost > 0) { + const lost = element("p", "note", voicesLost === 1 ? words.voices_lost_one : fill(words.voices_lost, voicesLost)); + lost.id = "voices-lost"; + lost.setAttribute("role", "status"); + card.append(lost); + } for (const segment of read.segments) { const line = element("li"); line.dataset.track = segment.track; @@ -3133,7 +3247,27 @@ function transcriptCard(read, words, session, onPage, previous, speakers) { const who = whoSaid(segment, words, names); const said = element("div", "said"); const text = element("span", "text", segment.text); - said.append(element("span", `who ${segment.track}`, who), text); + // Its speaker, once complete in a meeting that holds names: a button that names who speaks there (D131). + const whoOf = element(read.complete && names ? "button" : "span", `who ${segment.track}`, who); + if (whoOf.tagName === "BUTTON") { + whoOf.type = "button"; + whoOf.id = `who-${segment.track}-${segment.start}`; + whoOf.setAttribute("aria-expanded", "false"); + whoOf.setAttribute("aria-controls", "voice-panel"); + whoOf.tabIndex = line.hasAttribute("role") ? line.tabIndex : 0; + sayWho(whoOf, segment, words, names); + whoOf.addEventListener("keydown", (event) => event.stopPropagation()); + whoOf.addEventListener("click", (event) => { + event.stopPropagation(); + if (whoOf.getAttribute("aria-expanded") === "true") { + document.getElementById("voice-panel")?.remove(); + whoOf.setAttribute("aria-expanded", "false"); + return; + } + whoPanel(card, read, segment, whoOf, words, session, names); + }); + } + said.append(whoOf, text); if (segment.edited) said.append(element("span", "edited", words.corrected)); line.append(element("span", "at", clock(segment.start)), said); // Corrected by whoever listens, once complete (D62): the line becomes a field; Enter or leaving @@ -3491,7 +3625,7 @@ function trashedFocused() { } } -function showMeeting({ session, transcript, minutes, developer, listen: listened, context, confidential, language, languages, meeting_language, apple, system_language, models_gone, previous_minutes, previous_transcript, minutes_other_version, speakers }, words) { +function showMeeting({ session, transcript, minutes, developer, listen: listened, context, confidential, language, languages, meeting_language, apple, system_language, models_gone, previous_minutes, previous_transcript, minutes_other_version, speakers, voices, voices_lost }, words) { const page = document.getElementById("meeting"); const top = element("div", "meeting-top"); const name = nameOf(session); @@ -3656,7 +3790,7 @@ function showMeeting({ session, transcript, minutes, developer, listen: listened // The models each line offers, read once for both (D93). const onPage = pageModels(session); meetingTabs(columns, nameOf(session), words, minutesCard(minutes, words, session, transcript, onPage, previous_minutes, minutes_other_version), - transcriptCard(transcript, words, session, onPage, previous_transcript, speakers), minutes.state !== "absent"); + transcriptCard(transcript, words, session, onPage, previous_transcript, speakers, voices, voices_lost), minutes.state !== "absent"); // Shown again when the window comes forward: a search in progress in this meeting is kept. const searching = page.dataset.name === nameOf(session) ? (document.getElementById("search")?.value ?? "") : ""; // A name being typed is kept the same way, with its refusal and where the caret was (D70). @@ -7270,7 +7404,9 @@ window.addEventListener("focus", () => { || document.querySelector("#settings:not([hidden]) #minutes-unsaved:not([hidden])") || [...document.querySelectorAll("#settings:not([hidden]) .fields input")].some((input) => input.value !== input.defaultValue) // The speakers being named (#1205): what is typed stays. - || document.getElementById("speakers-panel"); + || document.getElementById("speakers-panel") + // Or one line's speaker (D131). + || document.getElementById("voice-panel"); // Back from a list's menu, not from elsewhere: nothing drawn anew (#944). const menu = inMenu; inMenu = false; From fd453993f08d3b61e0ad2c517dd148e4c3cbfaf6 Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:32:15 +0100 Subject: [PATCH 4/8] =?UTF-8?q?D131a:=20the=20review=20budget=20=E2=80=94?= =?UTF-8?q?=20a=20redo's=20carrying=20over=20of=20the=20voices=20given=20m?= =?UTF-8?q?oves=20to=20D131b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What D131a holds: one line named, a voice named, by the window and by voices.rs (criteria 1 and 2). The transcript made again keeping them (criterion 3, voices::carried, the page saying the lines it found none for) is D131b, the next pull request on this one: 741 + 16 lines here. cargo test: 602 passed, 0 failed; fmt and clippy -D warnings clean. Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 21 +----- modules/shell/src/main.rs | 14 ---- modules/shell/src/voices.rs | 105 +--------------------------- modules/shell/src/words.rs | 10 --- modules/shell/tests/voices.rs | 82 +--------------------- modules/shell/ui/window.js | 13 +--- 6 files changed, 8 insertions(+), 237 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 1c8167a2c..859e5a597 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6063,10 +6063,9 @@ def speakers_by_line(now: dt.datetime) -> None: """D131, #1230's S2: each line of a complete transcript says who spoke, named by the user. Its speaker, a button on the line, opens « Qui parle sur cette ligne ? »: a name given to this line alone gives it a voice of the person's own (`transcript/v1`'s `voice` and `given`, #1244), its name in `speakers.json`'s `voices`; « Toutes les - lignes de cette voix » names every line of it; Escape closes it as it was. A transcript made again keeps the - voices given, carried by their stretch of the clock, and says the named lines it could not find again (D113). - By keyboard alone; axe on the open field. No name is logged.""" - print("D131. each line of a transcript named by the user: one line, or a voice everywhere, kept across a redo") + lignes de cette voix » names every line of it; Escape closes it as it was. By keyboard alone; axe on the open + field. No name is logged.""" + print("D131. each line of a transcript named by the user: one line, or a voice everywhere") meetings = WORK / "speakers-by-line" meeting = meetings / "2026-11-30_14-00" session(meeting, now - dt.timedelta(hours=2), 30, {"local.wav": 1000}, form="v3") @@ -6173,20 +6172,6 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): page() check("read again with the meeting: the names stay", browser.execute_script(whos) == ["Vous", "Les autres", "Maya Durand", "Maya Durand"], browser.execute_script(whos)) - - # Criterion 3: a redo keeps them. The stand-in writes one line, local, 0.0–1.0: « Vous »'s line given to - # Sarah falls within it; the call's two named lines have none and are said. - name(0, "Sarah") - browser.execute_script("window.__TAURI__.core.invoke('transcript_redo', {name: arguments[0], model: arguments[1]})", - meeting.name, str(model)) - made = wait_for(browser, lambda b: "Refait avec" in text() and b.execute_script(idle), 20) - carried = wait_for(None, lambda b: (held()[1:2] or [{}])[0].get("voice") == "#1", 10) - page() - said = "return [...document.querySelectorAll('#meeting [role=status]')].map(s => s.textContent).join(' ')" - check("made again: the line given to Sarah keeps its voice and its name (D113)", - made and carried and browser.execute_script(whos) == ["Sarah"], [made, held()[1:2], browser.execute_script(whos)]) - check("the named lines the new transcript does not hold are said, never dropped silently", - wait_for(browser, lambda b: "2 lignes nommées" in b.execute_script(said), 5), browser.execute_script(said)) logs = WORK / "state" / "kitokey" / "logs" logged = [line for log in sorted(logs.glob("*.jsonl")) for line in log.read_text().splitlines()] check("no name is logged", not any(n in line for line in logged for n in ("Maya", "Sarah", "Personne")), diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index 4013a1145..760b27892 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -1804,9 +1804,6 @@ struct Opened { speakers: Option, /// The voices a person gave lines, keyed `/`: their names (D131). voices: std::collections::BTreeMap, - /// The lines given a voice in the transcript a redo replaced that the one shown holds no line for (D131): - /// the page says how many, the earlier version keeping them. - voices_lost: usize, /// The last transcript a redo replaced, the same way (D113). previous_transcript: Option, /// The summary shown was made on the other version of the transcript, not the one shown (#1070): @@ -1943,7 +1940,6 @@ fn opened(shell: State<'_, Shell>, name: String) -> Result { }, speakers: speakers::offered(&folder).then(|| SpeakersShown::from(speakers::read(&folder))), voices: voices::names(&folder), - voices_lost: voices::lost(&folder.join(meeting::PREVIOUS), &folder.join(voices::TRANSCRIPT)), previous_transcript: match meeting::previous(&folder) { Read::Present(kept) => Some(Previous { made: kept.made, @@ -5341,16 +5337,6 @@ fn retranscribe(app: &AppHandle, folder: PathBuf, again: Again, cancel: Cancel) }) { kept_beside = name.map(|name| (name, not_put_back)); } - // The voices a person gave the one replaced, carried to the new one by their stretch of the clock (D131, - // D113), before its summary reads it; the making's lock held, as a correction holds it. Those it holds - // no line for stay in the previous version, and its page says how many. - if written { - let _writing = shell.transcription.lock().unwrap(); - match voices::carried(&folder.join(meeting::PREVIOUS), &folder.join(voices::TRANSCRIPT)) { - Ok(lost) => tracing::info!(lost = lost.len(), "shell.voices_carried"), - Err(refused) => tracing::warn!(?refused, "shell.voices_not_carried"), - } - } } if *shell.leaving.lock().unwrap() { return; diff --git a/modules/shell/src/voices.rs b/modules/shell/src/voices.rs index 940491401..39be66026 100644 --- a/modules/shell/src/voices.rs +++ b/modules/shell/src/voices.rs @@ -1,8 +1,7 @@ //! D131: each line of a transcript says who spoke, named by the user (#1230's S2). `transcript/v1`'s « a voice //! given » (#1244): once complete, the shell sets one segment's `voice` to a label of the person's own — starting with //! `#` — and its `given` to when, the file replaced whole; the label's name is kept in `speakers.json`'s `voices` -//! (`session-audio/v3`). A transcript made again keeps the voices given, carried by each segment's stretch of the -//! clock (D113); a given line no new one falls within is said, never dropped. No voice's sound is ever measured. +//! (`session-audio/v3`). No voice's sound is ever measured. use std::{collections::BTreeMap, path::Path}; @@ -172,108 +171,6 @@ pub fn voice_named(folder: &Path, track: &str, start: f64, name: &str, when: &st } } -/// A segment a person gave a voice: its track, stretch, voice and when. -struct Given { - track: String, - start: f64, - end: f64, - voice: Value, - given: String, - instant: Option>, -} - -fn given_in(lines: &Lines) -> Vec { - lines - .segments() - .filter_map(|(_, segment)| { - let given = segment["given"].as_str().filter(|given| !given.is_empty())?; - Some(Given { - track: track_of(segment).to_string(), - start: segment["start"].as_f64()?, - end: segment["end"].as_f64()?, - voice: segment.get("voice").cloned().unwrap_or(Value::Null), - given: given.to_string(), - instant: chrono::DateTime::parse_from_rfc3339(given).ok(), - }) - }) - .collect() -} - -/// For each segment of `made`, the given segment it takes its voice from: of the same track, the segment's middle -/// within its stretch, both ends included; within two, the one given last. -fn matches<'a>(given: &'a [Given], made: &Lines) -> Vec<(usize, Option<&'a Given>)> { - made.segments() - .map(|(at, segment)| { - let track = track_of(segment); - let found = match (segment["start"].as_f64(), segment["end"].as_f64()) { - (Some(start), Some(end)) => { - let middle = (start + end) / 2.0; - given - .iter() - .filter(|one| one.track == track && one.start <= middle && middle <= one.end) - .max_by_key(|one| one.instant) - } - _ => None, - }; - (at, found) - }) - .collect() -} - -/// The given segments that no new segment falls within: each its track and start. -fn unmatched(given: &[Given], made: &Lines) -> Vec<(String, f64)> { - given - .iter() - .filter(|one| { - !made - .segments() - .any(|(_, segment)| match (segment["start"].as_f64(), segment["end"].as_f64()) { - (Some(start), Some(end)) => { - let middle = (start + end) / 2.0; - track_of(segment) == one.track && one.start <= middle && middle <= one.end - } - _ => false, - }) - }) - .map(|one| (one.track.clone(), one.start)) - .collect() -} - -/// The voices given in `previous` carried to `made`, a transcript made again, once it is complete: each new segment -/// whose middle falls within a given one's stretch takes its `voice` and `given` (D113, `transcript/v1`). The given -/// segments no new one falls within are returned, each its track and start. -pub fn carried(previous: &Path, made: &Path) -> Result, Refused> { - let mut lines = Lines::read(made)?; - if !lines.complete() { - return Err(Refused::NotComplete); - } - let given = given_in(&Lines::read(previous)?); - if given.is_empty() { - return Ok(Vec::new()); - } - let lost = unmatched(&given, &lines); - let taken: Vec<(usize, Value, String)> = matches(&given, &lines) - .into_iter() - .filter_map(|(at, by)| by.map(|by| (at, by.voice.clone(), by.given.clone()))) - .collect(); - if !taken.is_empty() { - for (at, voice, given) in taken { - lines.set(at, voice, &given); - } - lines.write(made)?; - } - Ok(lost) -} - -/// How many given segments of `previous` `current` holds no line for: what the page says after a redo. Unreadable -/// files, none. -pub fn lost(previous: &Path, current: &Path) -> usize { - let (Ok(previous), Ok(current)) = (Lines::read(previous), Lines::read(current)) else { - return 0; - }; - unmatched(&given_in(&previous), ¤t).len() -} - /// The voices' names the meeting holds, keyed `/`. pub fn names(folder: &Path) -> BTreeMap { speakers::voices(folder) diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 94abc5bbd..0b38b1a8f 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -764,12 +764,6 @@ pub struct Window { /// Shows: a meeting's page, as a choice. When: a line's speaker being named, the name for every line of its /// voice. At most: about 35 characters. Placeholders: none. pub who_everywhere: &'static str, - /// Shows: a meeting's page, as a status on the transcript. When: a redo left one line a person named without - /// a line in the new transcript. At most: two lines. Placeholders: none. - pub voices_lost_one: &'static str, - /// Shows: a meeting's page, as a status on the transcript. When: a redo left several lines a person named - /// without a line in the new transcript; plural. At most: two lines. Placeholders: {} how many. - pub voices_lost: &'static str, /// Who spoke over the meeting, for whoever does not see the drawing. /// Shows: a meeting's page, as a name for a screen reader. When: screen reader: the /// speaking-time drawing. At most: no limit. Placeholders: none. @@ -2340,8 +2334,6 @@ pub fn window(language: Language) -> Window { who_field: "Who speaks on this line?", who_line_only: "This line only", who_everywhere: "Every line of this voice", - voices_lost_one: "1 named line was not found in this version. The previous version keeps it.", - voices_lost: "{} named lines were not found in this version. The previous version keeps them.", who_spoke: "Who spoke when: you on top, others below", who_spoke_later: "Who spoke when appears once it is transcribed.", no_transcript: "No transcript yet.", @@ -2954,8 +2946,6 @@ pub fn window(language: Language) -> Window { who_field: "Qui parle sur cette ligne\u{202f}?", who_line_only: "Cette ligne seulement", who_everywhere: "Toutes les lignes de cette voix", - voices_lost_one: "1 ligne nommée n’a pas été retrouvée dans cette version. La version précédente la garde.", - voices_lost: "{} lignes nommées n’ont pas été retrouvées dans cette version. La version précédente les garde.", who_spoke: "Temps de parole au fil de la réunion\u{a0}: vous en haut, les autres en bas", who_spoke_later: "Le temps de parole s’affichera après la transcription.", no_transcript: "Pas encore de transcription.", diff --git a/modules/shell/tests/voices.rs b/modules/shell/tests/voices.rs index 737618ca3..6664f399f 100644 --- a/modules/shell/tests/voices.rs +++ b/modules/shell/tests/voices.rs @@ -1,8 +1,7 @@ //! D131: each line of a transcript says who spoke, named by the user (#1230's S2, `transcript/v1`'s « a voice given », //! #1244, #1251). A name given to one line gives that line alone a voice of the person's own — a label starting with //! `#`, its `given` the instant —, the name kept in `speakers.json`'s `voices` (`session-audio/v3`); a name given to a -//! voice names every line of that voice; a transcript made again keeps the voices given, carried over by the -//! segment's stretch of the clock (D113), and a given line no new one falls within is returned, never dropped. +//! voice names every line of that voice. use std::{fs, path::Path}; @@ -191,82 +190,3 @@ fn a_name_is_refused_before_complete_on_no_line_blank_too_long_or_before_v3_noth assert!(!folder.path().join("speakers.json").exists()); } } - -/// The transcript made again: other times, as a new making writes them. -fn made_again(complete: bool) -> String { - let mut lines = vec![ - HEADER.to_string(), - segment("me", "local", 0.1, 0.9, "On commence."), - segment("others", "remote", 1.6, 2.6, "Les tests passent."), - segment("others", "remote", 2.7, 3.3, "Oui."), - segment("others", "remote", 3.6, 4.8, "Je confirme pour la 2.4."), - ]; - if complete { - lines.push(r#"{"type":"complete","duration":7.0}"#.to_string()); - } - lines.iter().map(|line| format!("{line}\n")).collect() -} - -#[test] -fn a_transcript_made_again_keeps_the_voices_given_by_their_stretch_of_the_clock() { - let folder = meeting("session-audio/v3", true); - voices::line_named(folder.path(), "remote", 1.5, "Maya", WHEN).unwrap(); - voices::line_named(folder.path(), "remote", 5.5, "Karim", LATER).unwrap(); - voices::line_named(folder.path(), "local", 0.0, "Sarah", WHEN).unwrap(); - let previous = folder.path().join("transcript-previous.jsonl"); - fs::rename(folder.path().join("transcript.jsonl"), &previous).unwrap(); - fs::write(folder.path().join("transcript.jsonl"), made_again(true)).unwrap(); - let lost = voices::carried(&previous, &folder.path().join("transcript.jsonl")); - // Karim's line, 5.5–7.0: no new segment's middle falls within it — said, never dropped. - assert_eq!(lost, Ok(vec![("remote".to_string(), 5.5)])); - let after = lines(folder.path()); - let given: Vec<(Value, Value)> = after - .iter() - .skip(1) - .take(4) - .map(|line| (line["voice"].clone(), line["given"].clone())) - .collect(); - assert_eq!( - given, - vec![ - (json!("#1"), json!(WHEN)), // local 0.1–0.9, middle 0.5 within Sarah's 0.0–1.0 - (json!("#1"), json!(WHEN)), // remote 1.6–2.6, middle 2.1 within Maya's 1.5–3.0 - (json!("#1"), json!(WHEN)), // remote 2.7–3.3, middle 3.0 within Maya's, both ends included - (Value::Null, Value::Null), // remote 3.6–4.8, never given - ] - ); - assert_eq!( - speakers(folder.path()), - json!({"voices": {"remote/#1": "Maya", "remote/#2": "Karim", "local/#1": "Sarah"}}), - "the names stay with their labels" - ); -} - -#[test] -fn within_two_given_stretches_the_one_given_last_wins_and_nothing_is_carried_before_complete() { - let folder = meeting("session-audio/v3", true); - let previous = folder.path().join("transcript-previous.jsonl"); - let given: String = [ - HEADER.to_string(), - json!({"type": "segment", "speaker": "others", "track": "remote", "voice": "#2", "given": LATER, "start": 1.0, "end": 3.0, "text": "a"}).to_string(), - json!({"type": "segment", "speaker": "others", "track": "remote", "voice": "#1", "given": WHEN, "start": 2.0, "end": 4.0, "text": "b"}).to_string(), - r#"{"type":"complete","duration":7.0}"#.to_string(), - ] - .iter() - .map(|line| format!("{line}\n")) - .collect(); - fs::write(&previous, given).unwrap(); - let made = folder.path().join("transcript.jsonl"); - fs::write(&made, made_again(false)).unwrap(); - assert_eq!(voices::carried(&previous, &made), Err(Refused::NotComplete)); - assert_eq!( - fs::read_to_string(&made).unwrap(), - made_again(false), - "nothing carried while it is made" - ); - fs::write(&made, made_again(true)).unwrap(); - assert_eq!(voices::carried(&previous, &made), Ok(vec![])); - // 2.7–3.3, middle 3.0, within both: `#2`, given last (15:05 after 15:00). - assert_eq!(lines(folder.path())[3]["voice"], json!("#2")); - assert_eq!(lines(folder.path())[3]["given"], json!(LATER)); -} diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index 20452f838..3cc6892c8 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -3113,7 +3113,7 @@ function speakersButton(card, names, read, words, session) { return open; } -function transcriptCard(read, words, session, onPage, previous, speakers, voices, voicesLost) { +function transcriptCard(read, words, session, onPage, previous, speakers, voices) { // The sides' names as kept (#1205), and the voices' a person gave lines (D131): none where the meeting cannot // hold them; renamed in place below. const names = speakers ? { ...speakers, voices: { ...(voices ?? {}) } } : null; @@ -3204,13 +3204,6 @@ function transcriptCard(read, words, session, onPage, previous, speakers, voices said_.id = "correction-said"; said_.setAttribute("role", "status"); card.append(said_); - // Lines a person named that a redo found no line for (D131): said, never dropped; the earlier version keeps them. - if (voicesLost > 0) { - const lost = element("p", "note", voicesLost === 1 ? words.voices_lost_one : fill(words.voices_lost, voicesLost)); - lost.id = "voices-lost"; - lost.setAttribute("role", "status"); - card.append(lost); - } for (const segment of read.segments) { const line = element("li"); line.dataset.track = segment.track; @@ -3625,7 +3618,7 @@ function trashedFocused() { } } -function showMeeting({ session, transcript, minutes, developer, listen: listened, context, confidential, language, languages, meeting_language, apple, system_language, models_gone, previous_minutes, previous_transcript, minutes_other_version, speakers, voices, voices_lost }, words) { +function showMeeting({ session, transcript, minutes, developer, listen: listened, context, confidential, language, languages, meeting_language, apple, system_language, models_gone, previous_minutes, previous_transcript, minutes_other_version, speakers, voices }, words) { const page = document.getElementById("meeting"); const top = element("div", "meeting-top"); const name = nameOf(session); @@ -3790,7 +3783,7 @@ function showMeeting({ session, transcript, minutes, developer, listen: listened // The models each line offers, read once for both (D93). const onPage = pageModels(session); meetingTabs(columns, nameOf(session), words, minutesCard(minutes, words, session, transcript, onPage, previous_minutes, minutes_other_version), - transcriptCard(transcript, words, session, onPage, previous_transcript, speakers, voices, voices_lost), minutes.state !== "absent"); + transcriptCard(transcript, words, session, onPage, previous_transcript, speakers, voices), minutes.state !== "absent"); // Shown again when the window comes forward: a search in progress in this meeting is kept. const searching = page.dataset.name === nameOf(session) ? (document.getElementById("search")?.value ?? "") : ""; // A name being typed is kept the same way, with its refusal and where the caret was (D70). From ef717970acf7b2c83ad799241892abd0f40dde85 Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:35:37 +0100 Subject: [PATCH 5/8] D131a e2e: each line's speaker by its id, never a reference held across a redraw; the suggestion's Enter taken The red at b3929e75 raised a StaleElementReferenceException on a button held across the page's redraw: the oracle now fails there, never crashes. The green at a2c6f624 failed from the second naming on: a name the meeting holds is offered under the field and its first Enter takes the suggestion (APG's combobox); the scenario presses Enter again when the field is still open. Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 859e5a597..fc9751383 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6103,16 +6103,19 @@ def page(): return wait_for(browser, lambda b: b.execute_script( "return document.querySelectorAll('#meeting .transcript .lines .who').length") > 0 and b.execute_script(idle), 15) + # Each line's speaker by its id, never a reference held across a redraw: absent, None. def who(index): - found = browser.find_elements(By.CSS_SELECTOR, "#meeting .transcript .lines .who") - return found[index] if index < len(found) else None + found = browser.execute_script("return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.id)") + return found[index] if index < len(found) and found[index] else None + + def focused_on(index): + return who(index) is not None and browser.execute_script("return document.activeElement?.id") == who(index) def name(index, typed, everywhere=False, key=Keys.ENTER): """Line `index`'s speaker by keyboard alone: focused, Enter, the scope chosen, the name typed, `key`.""" - button = who(index) - if button is None: + if who(index) is None: return False - browser.execute_script("arguments[0].focus()", button) + browser.execute_script("document.getElementById(arguments[0]).focus()", who(index)) ActionChains(browser).send_keys(Keys.ENTER).perform() if not wait_for(browser, panel_open, 5): return False @@ -6122,6 +6125,10 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): field.send_keys(Keys.CONTROL, "a") field.send_keys(typed) ActionChains(browser).send_keys(key).perform() + # A name the meeting already holds is offered under the field: the first Enter takes the suggestion, as a + # combobox's does (APG), the next one saves. + if not wait_for(browser, lambda b: not panel_open(b), 1.5) and panel_open(browser): + ActionChains(browser).send_keys(key).perform() return wait_for(browser, lambda b: not panel_open(b), 5) page() @@ -6129,14 +6136,13 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): check("each line's speaker is a button, its side as the page says it", browser.execute_script(whos) == ["Vous", "Les autres", "Les autres", "Les autres"] and set(tags) == {"BUTTON"}, [browser.execute_script(whos), tags]) - button = who(2) - if button is not None: - browser.execute_script("arguments[0].focus()", button) + if who(2) is not None: + browser.execute_script("document.getElementById(arguments[0]).focus()", who(2)) ActionChains(browser).send_keys(Keys.ENTER).perform() opened = wait_for(browser, panel_open, 5) got = browser.execute_script( "const f = document.getElementById('voice-name'); return f ? [document.activeElement.id, f.labels[0]?.textContent.trim()," - " document.getElementById('voice-line')?.checked, arguments[0]?.getAttribute('aria-expanded')] : null", button) + " document.getElementById('voice-line')?.checked, document.getElementById(arguments[0] ?? '')?.getAttribute('aria-expanded')] : null", who(2)) check("Enter on a line's speaker opens « Qui parle sur cette ligne ? », its field focused and labelled, « Cette ligne seulement » chosen", opened and got == ["voice-name", "Qui parle sur cette ligne\u202f?", True, "true"], got) violations = axe_violations(browser) if opened else [("the field absent", None, 0, [])] @@ -6146,7 +6152,7 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): closed = wait_for(browser, lambda b: not panel_open(b), 5) check("Escape closes it as it was: nothing written, the focus back on the line's speaker", closed and all("given" not in line for line in held()) and voices() is None - and browser.execute_script("return document.activeElement === arguments[0]", button), + and focused_on(2), [closed, voices(), browser.execute_script("return document.activeElement?.className")]) # Criterion 1: one line named, that line alone. @@ -6157,8 +6163,7 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): and [line.get("voice") for line in lines[1:5]] == [None, None, "#1", None] and bool(lines[3].get("given")) and voices() == {"remote/#1": "Maya"}, [browser.execute_script(whos), [line.get("voice") for line in lines[1:5]], voices()]) - check("saved: the focus back on that line's speaker", - browser.execute_script("return document.activeElement === arguments[0]", who(2)), browser.execute_script("return document.activeElement?.textContent")) + check("saved: the focus back on that line's speaker", focused_on(2), browser.execute_script("return document.activeElement?.id")) done = name(3, "Maya") check("the same name on another line is the same voice", done and [line.get("voice") for line in held()[1:5]] == [None, None, "#1", "#1"] From 8e596a323c7040eb0420b72e5fe876a08e733381 Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:41:04 +0100 Subject: [PATCH 6/8] =?UTF-8?q?D131a:=20ines'=20review=20at=20fd453993=20?= =?UTF-8?q?=E2=80=94=20a=20blank=20name=20said,=20a=20refusal's=20why,=20t?= =?UTF-8?q?he=20oracle=20holding=20the=20accessible=20name,=20Tab=20and=20?= =?UTF-8?q?the=20redraw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - A blank name: « Saisissez un nom, ou appuyez sur Échap pour annuler. » under the field, what was typed kept, nothing asked of the shell; a name not kept says why (« Nom non enregistré : … »), never « ces noms ». - speakers_by_line is DJ (handoff-common l.77). It now checks: the accessible name (WCAG 2.5.3), the speaker following its line in the order of Tab (D62), the field kept when the window comes back, the blank name, and the log holding shell.voice_given before it is read for names. cargo test: 602 passed, 0 failed; fmt and clippy -D warnings clean. Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 47 +++++++++++++++++++++++++---- modules/shell/src/words.rs | 10 ++++++ modules/shell/ui/window.js | 10 ++++-- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index fc9751383..23bd746ce 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6060,12 +6060,13 @@ def page(folder): def speakers_by_line(now: dt.datetime) -> None: - """D131, #1230's S2: each line of a complete transcript says who spoke, named by the user. Its speaker, a button + """DJ. D131, #1230's S2: each line of a complete transcript says who spoke, named by the user. Its speaker, a button on the line, opens « Qui parle sur cette ligne ? »: a name given to this line alone gives it a voice of the person's own (`transcript/v1`'s `voice` and `given`, #1244), its name in `speakers.json`'s `voices`; « Toutes les - lignes de cette voix » names every line of it; Escape closes it as it was. By keyboard alone; axe on the open - field. No name is logged.""" - print("D131. each line of a transcript named by the user: one line, or a voice everywhere") + lignes de cette voix » names every line of it; Escape closes it as it was; a blank name is said under the field, + what was typed kept; the field stays when the window comes back. Each line's speaker follows its line in the + order of Tab (D62). By keyboard alone; axe on the open field. No name is logged.""" + print("DJ. each line of a transcript named by the user: one line, or a voice everywhere (D131)") meetings = WORK / "speakers-by-line" meeting = meetings / "2026-11-30_14-00" session(meeting, now - dt.timedelta(hours=2), 30, {"local.wav": 1000}, form="v3") @@ -6147,7 +6148,25 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): opened and got == ["voice-name", "Qui parle sur cette ligne\u202f?", True, "true"], got) violations = axe_violations(browser) if opened else [("the field absent", None, 0, [])] check("axe: the open field, WCAG 2.2 A and AA, no violation", violations == [], violations) + typed = "return document.getElementById('voice-name')?.value ?? null" + said_now = "const s = document.getElementById('voice-said'); return s && !s.hidden ? s.textContent : ''" + # Nothing but spaces: said under the field, what was typed kept, nothing written. + ActionChains(browser).send_keys(" ").perform() + ActionChains(browser).send_keys(Keys.ENTER).perform() + shown = wait_for(browser, lambda b: b.execute_script(said_now), 5) + check("a blank name: « Saisissez un nom, ou appuyez sur Échap pour annuler. » under the field, what was typed kept, nothing written", + shown and browser.execute_script(said_now) == "Saisissez un nom, ou appuyez sur Échap pour annuler." + and browser.execute_script(typed) == " " and all("given" not in line for line in held()) and voices() is None, + [browser.execute_script(said_now), browser.execute_script(typed), voices()]) + ActionChains(browser).send_keys(Keys.CONTROL, "a").perform() ActionChains(browser).send_keys("Personne").perform() + # Back to the window while typing (window.js's focus draws the page anew): the field and what is typed stay. + browser.execute_script("window.dispatchEvent(new Event('focus'))") + time.sleep(1.5) + check("back to the window while naming: the field stays, what was typed kept", + browser.execute_script(typed) == "Personne", browser.execute_script(typed)) + if browser.find_elements(By.ID, "voice-name"): + browser.execute_script("document.getElementById('voice-name').focus()") ActionChains(browser).send_keys(Keys.ESCAPE).perform() closed = wait_for(browser, lambda b: not panel_open(b), 5) check("Escape closes it as it was: nothing written, the focus back on the line's speaker", @@ -6164,6 +6183,21 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): and bool(lines[3].get("given")) and voices() == {"remote/#1": "Maya"}, [browser.execute_script(whos), [line.get("voice") for line in lines[1:5]], voices()]) check("saved: the focus back on that line's speaker", focused_on(2), browser.execute_script("return document.activeElement?.id")) + named = browser.execute_script("return document.getElementById(arguments[0] ?? '')?.getAttribute('aria-label') ?? null", who(2)) + check("its accessible name holds the name shown, then what pressing it does (WCAG 2.5.3)", + named == "Maya\u00a0: changer qui parle à 00:03", named) + # D62's order of Tab: one line in it, its speaker with it; the arrows move both. + tabs = ("return [...document.querySelectorAll('#meeting .transcript .lines li')].map(l => [l.getAttribute('role'), l.tabIndex," + " l.querySelector('button.who')?.tabIndex])") + rows = browser.execute_script(tabs) + browser.execute_script("document.querySelector('#meeting .transcript .lines li[tabindex=\"0\"]')?.focus()") + ActionChains(browser).send_keys(Keys.ARROW_DOWN).perform() + moved = browser.execute_script(tabs) + check("each line's speaker follows its line in the order of Tab, one line at a time, the arrows moving both (D62)", + bool(rows) and all(role == "button" for role, *_ in rows) and all(line == who_ for _, line, who_ in rows) + and [line for _, line, _ in rows].count(0) == 1 and all(line == who_ for _, line, who_ in moved) and moved != rows, + [rows, moved]) + done = name(3, "Maya") check("the same name on another line is the same voice", done and [line.get("voice") for line in held()[1:5]] == [None, None, "#1", "#1"] @@ -6179,8 +6213,9 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): browser.execute_script(whos) == ["Vous", "Les autres", "Maya Durand", "Maya Durand"], browser.execute_script(whos)) logs = WORK / "state" / "kitokey" / "logs" logged = [line for log in sorted(logs.glob("*.jsonl")) for line in log.read_text().splitlines()] - check("no name is logged", not any(n in line for line in logged for n in ("Maya", "Sarah", "Personne")), - [line for line in logged if any(n in line for n in ("Maya", "Sarah"))][:3]) + given = [line for line in logged if "shell.voice_given" in line] + check("each naming is logged, never a name", len(given) >= 3 and not any(n in line for line in logged for n in ("Maya", "Sarah", "Personne")), + [len(given), [line for line in logged if any(n in line for n in ("Maya", "Sarah", "Personne"))][:3]]) def example_tried(now: dt.datetime) -> None: diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 0b38b1a8f..4bb6d3f42 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -764,6 +764,12 @@ pub struct Window { /// Shows: a meeting's page, as a choice. When: a line's speaker being named, the name for every line of its /// voice. At most: about 35 characters. Placeholders: none. pub who_everywhere: &'static str, + /// Shows: a meeting's page, as an error under the field, what was typed kept. When: a line's speaker named with + /// nothing but spaces. At most: one line. Placeholders: none. + pub who_empty: &'static str, + /// Shows: a meeting's page, as an error under the field, what was typed kept. When: the name could not be kept. + /// At most: one line. Placeholders: {} why, as the shell says it. + pub who_failed: &'static str, /// Who spoke over the meeting, for whoever does not see the drawing. /// Shows: a meeting's page, as a name for a screen reader. When: screen reader: the /// speaking-time drawing. At most: no limit. Placeholders: none. @@ -2334,6 +2340,8 @@ pub fn window(language: Language) -> Window { who_field: "Who speaks on this line?", who_line_only: "This line only", who_everywhere: "Every line of this voice", + who_empty: "Type a name, or press Escape to cancel.", + who_failed: "Name not saved: {}", who_spoke: "Who spoke when: you on top, others below", who_spoke_later: "Who spoke when appears once it is transcribed.", no_transcript: "No transcript yet.", @@ -2946,6 +2954,8 @@ pub fn window(language: Language) -> Window { who_field: "Qui parle sur cette ligne\u{202f}?", who_line_only: "Cette ligne seulement", who_everywhere: "Toutes les lignes de cette voix", + who_empty: "Saisissez un nom, ou appuyez sur Échap pour annuler.", + who_failed: "Nom non enregistré\u{a0}: {}", who_spoke: "Temps de parole au fil de la réunion\u{a0}: vous en haut, les autres en bas", who_spoke_later: "Le temps de parole s’affichera après la transcription.", no_transcript: "Pas encore de transcription.", diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index 3cc6892c8..0445833e0 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -3008,6 +3008,12 @@ function whoPanel(card, read, segment, who, words, session, names) { }); panel.addEventListener("submit", async (event) => { event.preventDefault(); + // Nothing but spaces: said under the field, what was typed kept, nothing asked of the shell. + if (input.value.trim() === "") { + said.textContent = words.who_empty; + said.hidden = false; + return input.focus(); + } save.disabled = true; try { const asked = { name: nameOf(session), track: segment.track, start: segment.start, who: input.value }; @@ -3024,8 +3030,8 @@ function whoPanel(card, read, segment, who, words, session, names) { if (shown) sayWho(shown, one, words, names); }); close(); - } catch { - said.textContent = words.speakers_not_saved; + } catch (why) { + said.textContent = fill(words.who_failed, why); said.hidden = false; } finally { save.disabled = false; From 79642908cc567370714e62d84f4c5d8c2ae7057d Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:46:13 +0100 Subject: [PATCH 7/8] =?UTF-8?q?D131a:=20within=20the=20review=20budget=20?= =?UTF-8?q?=E2=80=94=20voices::names=20folded=20into=20speakers::voices,?= =?UTF-8?q?=20two=20refusals=20as=20one,=20the=20redo's=20model=20left=20t?= =?UTF-8?q?o=20D131b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cargo test: 602 passed, 0 failed; fmt and clippy -D warnings clean. Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 7 +------ modules/shell/src/main.rs | 5 ++--- modules/shell/src/voices.rs | 7 +------ modules/shell/tests/voices.rs | 4 ---- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 23bd746ce..7c078d49b 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6078,10 +6078,6 @@ def speakers_by_line(now: dt.datetime) -> None: '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":3.5,"end":5.0,"text":"Je confirme pour la 2.4."}\n' '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":5.5,"end":7.0,"text":"Et la démo vendredi."}\n' '{"type":"complete","duration":7.0}\n') - data = WORK / "data-speakers-by-line" - model = data / "kitokey" / "models" / "ggml-tiny-a.bin" - model.parent.mkdir(parents=True) - model.write_bytes(b"\0" * 16) 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)") whos = "return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.textContent.trim())" @@ -6094,8 +6090,7 @@ def text() -> str: held = lambda: [json.loads(line) for line in text().splitlines() if line.strip()] voices = lambda: (json.loads((meeting / "speakers.json").read_text()) if (meeting / "speakers.json").is_file() else {}).get("voices") panel_open = lambda b: bool(b.find_elements(By.ID, "voice-name")) - window = Window(meetings, "fr_FR.UTF-8", f'after = "nothing"\nreminder = false\nmodel = "{model}"\n') - window.env.update(XDG_DATA_HOME=str(data)) + window = Window(meetings, "fr_FR.UTF-8", 'after = "nothing"\nreminder = false\n') with window as browser: def page(): browser.execute_script("location.hash = '#/'") diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index 760b27892..d6e6f113d 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -1939,7 +1939,7 @@ fn opened(shell: State<'_, Shell>, name: String) -> Result { _ => None, }, speakers: speakers::offered(&folder).then(|| SpeakersShown::from(speakers::read(&folder))), - voices: voices::names(&folder), + voices: speakers::voices(&folder), previous_transcript: match meeting::previous(&folder) { Read::Present(kept) => Some(Previous { made: kept.made, @@ -1995,8 +1995,7 @@ fn voice_given(shell: &Shell, name: &str, track: &str, start: f64, who: &str, ev given.map_err(|refused| match refused { voices::Refused::NotComplete => shell.told(Failure::NotComplete, format!("the transcript of {name} is not complete")), voices::Refused::NoSuchLine => shell.told(Failure::Unexpected, "no line of the transcript starts there"), - voices::Refused::Name => shell.told(Failure::Unexpected, "a name the contract session-audio/v3 refuses"), - voices::Refused::NotOffered => shell.told(Failure::Unexpected, "names are kept by a session-audio/v3 meeting alone"), + voices::Refused::Name | voices::Refused::NotOffered => shell.told(Failure::Unexpected, "a name or a meeting the page never offers"), voices::Refused::File(why) => shell.told(Failure::MeetingFile, why), })?; drop(running); diff --git a/modules/shell/src/voices.rs b/modules/shell/src/voices.rs index 39be66026..0b60a3b69 100644 --- a/modules/shell/src/voices.rs +++ b/modules/shell/src/voices.rs @@ -3,7 +3,7 @@ //! `#` — and its `given` to when, the file replaced whole; the label's name is kept in `speakers.json`'s `voices` //! (`session-audio/v3`). No voice's sound is ever measured. -use std::{collections::BTreeMap, path::Path}; +use std::path::Path; use serde_json::Value; @@ -170,8 +170,3 @@ pub fn voice_named(folder: &Path, track: &str, start: f64, name: &str, when: &st } } } - -/// The voices' names the meeting holds, keyed `/`. -pub fn names(folder: &Path) -> BTreeMap { - speakers::voices(folder) -} diff --git a/modules/shell/tests/voices.rs b/modules/shell/tests/voices.rs index 6664f399f..a929a735c 100644 --- a/modules/shell/tests/voices.rs +++ b/modules/shell/tests/voices.rs @@ -113,10 +113,6 @@ fn a_name_given_to_a_voice_names_every_line_of_it_the_transcript_unchanged() { assert_eq!(voices::voice_named(folder.path(), "remote", 5.5, "Maya Durand", LATER), Ok(())); assert_eq!(fs::read_to_string(folder.path().join("transcript.jsonl")).unwrap(), before); assert_eq!(speakers(folder.path()), json!({"voices": {"remote/#1": "Maya Durand"}})); - assert_eq!( - voices::names(folder.path()).get("remote/#1").map(String::as_str), - Some("Maya Durand") - ); } #[test] From 4cd0dfad243441ff9ecd0f1a1c3a8d0ea4c71f46 Mon Sep 17 00:00:00 2001 From: "kitokey-lina[bot]" <356214857+kitokey-lina[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 16:48:35 +0100 Subject: [PATCH 8/8] =?UTF-8?q?D131a=20e2e:=20DJ=20on=20a=20meeting=20that?= =?UTF-8?q?=20plays=20=E2=80=94=20its=20lines=20in=20the=20order=20of=20Ta?= =?UTF-8?q?b=20=E2=80=94=20and=20the=20field=20selected=20by=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The green at 79642908 failed twice on the oracle, never the product: a meeting with no sound has no line in the order of Tab (got role None, tabIndex -1 on each line, 0 on each speaker), so D62's roving was never reached — DJ's meeting now plays, as AB's; and ActionChains' Ctrl+A typed an « a » (got « aPersonne ») — the field is selected by script. The redo's helpers (idle, the transcript set aside) are D131b's. Agent-Session: a9706e0b-8e19-4419-9d88-76384b634747 Co-Authored-By: Claude Opus 5.5 --- modules/shell/scripts/e2e_window.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index 7c078d49b..166907a13 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -6069,7 +6069,14 @@ def speakers_by_line(now: dt.datetime) -> None: print("DJ. each line of a transcript named by the user: one line, or a voice everywhere (D131)") meetings = WORK / "speakers-by-line" meeting = meetings / "2026-11-30_14-00" - session(meeting, now - dt.timedelta(hours=2), 30, {"local.wav": 1000}, form="v3") + session(meeting, now - dt.timedelta(hours=2), 1, {}, form="v3") + # A sound that plays, as AB's: each line a button in the order of Tab, one at a time (D26, D62). + with wave.open(str(meeting / "local.wav"), "wb") as made: + made.setparams((2, 3, 48000, 0, "NONE", "not compressed")) + made.writeframes(bytes(6 * 48000 * 10)) + (meeting / "clock.jsonl").write_text('{"track":"local","sample":0,"at":0.0}\n') + record = json.loads((meeting / "session.json").read_text()) + (meeting / "session.json").write_text(json.dumps(record | {"tracks": {"local": {"device": "Mic"}}})) current = meeting / "transcript.jsonl" current.write_text( '{"type":"header","contract":"transcript/v1","engine":"whisper.cpp","model":"m","language":null,"context":null}\n' @@ -6078,16 +6085,8 @@ def speakers_by_line(now: dt.datetime) -> None: '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":3.5,"end":5.0,"text":"Je confirme pour la 2.4."}\n' '{"type":"segment","speaker":"others","track":"remote","voice":null,"start":5.5,"end":7.0,"text":"Et la démo vendredi."}\n' '{"type":"complete","duration":7.0}\n') - 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)") whos = "return [...document.querySelectorAll('#meeting .transcript .lines .who')].map(w => w.textContent.trim())" - def text() -> str: - # Set aside while it is made again: absent for a moment, read as empty, never raised. - try: - return current.read_text() - except OSError: - return "" - held = lambda: [json.loads(line) for line in text().splitlines() if line.strip()] + held = lambda: [json.loads(line) for line in current.read_text().splitlines() if line.strip()] voices = lambda: (json.loads((meeting / "speakers.json").read_text()) if (meeting / "speakers.json").is_file() else {}).get("voices") panel_open = lambda b: bool(b.find_elements(By.ID, "voice-name")) window = Window(meetings, "fr_FR.UTF-8", 'after = "nothing"\nreminder = false\n') @@ -6097,7 +6096,7 @@ def page(): wait_for(browser, lambda b: not b.find_elements(By.ID, "meeting"), 5) browser.execute_script("location.hash = arguments[0]", f"#/meeting/{meeting.name}") return wait_for(browser, lambda b: b.execute_script( - "return document.querySelectorAll('#meeting .transcript .lines .who').length") > 0 and b.execute_script(idle), 15) + "return document.querySelectorAll('#meeting .transcript .lines .who').length") > 0, 15) # Each line's speaker by its id, never a reference held across a redraw: absent, None. def who(index): @@ -6153,7 +6152,7 @@ def name(index, typed, everywhere=False, key=Keys.ENTER): shown and browser.execute_script(said_now) == "Saisissez un nom, ou appuyez sur Échap pour annuler." and browser.execute_script(typed) == " " and all("given" not in line for line in held()) and voices() is None, [browser.execute_script(said_now), browser.execute_script(typed), voices()]) - ActionChains(browser).send_keys(Keys.CONTROL, "a").perform() + browser.execute_script("document.getElementById('voice-name')?.select()") ActionChains(browser).send_keys("Personne").perform() # Back to the window while typing (window.js's focus draws the page anew): the field and what is typed stay. browser.execute_script("window.dispatchEvent(new Event('focus'))")