diff --git a/modules/shell/scripts/e2e_times.txt b/modules/shell/scripts/e2e_times.txt index fcd09862..a029760c 100644 --- a/modules/shell/scripts/e2e_times.txt +++ b/modules/shell/scripts/e2e_times.txt @@ -55,7 +55,9 @@ axe_first_surfaces 14.9 bar_after_stop 40.4 ends_on_sigterm 7.0 focus_kept 40.2 -focus_swept 691.3 +# focus_swept measured again at 711445bd (e2e-history 20261130T214828): ~1060 s since 2026-11-30, not 691 s; counted at 691 s, +# its shard took 14 scenarios more, 1188 s of the window's 1200 s, and the attest was cut in versions_kept (#1340). +focus_swept 1062.5 key_kept_to_its_host 5.5 keys_first_surfaces 74.0 meeting_trashed 17.0 diff --git a/modules/shell/scripts/e2e_window.py b/modules/shell/scripts/e2e_window.py index dfad716f..45e991a7 100644 --- a/modules/shell/scripts/e2e_window.py +++ b/modules/shell/scripts/e2e_window.py @@ -76,6 +76,8 @@ printf '%s' "$context" > "$here/summary-context" echo '{"event": "sending", "host": "h", "model": "m", "characters": 1}' named=""; [ -n "$STANDIN" ] && named="provider: $provider\\n" + # A format given (D130): minutes/v5 in it, as the real one writes them — its file's structure and sections. + [ "$6" = --format ] && { python3 -c "$FIFTH" "$1" "$7" "$5"; echo '{"event": "written", "file": "x"}'; exit 0; } printf -- "---\\ncontract: minutes/v1\\n${named}model: %s\\ncontext: %s\\n---\\n\\n## A\\n\\n## B\\n\\n## C\\n" "$5" "$context" > "$1/minutes.md" echo '{"event": "written", "file": "x"}' exit 0 @@ -192,6 +194,15 @@ "import json, pathlib, sys; f = pathlib.Path(sys.argv[1], 'context.txt'); " "t = f.read_text().strip() if f.exists() else ''; print(json.dumps(t or None, ensure_ascii=False))" ) +# minutes/v5 in the format a file of `--format` holds (D130): its structure, its sections, a title each. +os.environ["FIFTH"] = ( + "import json, pathlib, sys; f = json.loads(pathlib.Path(sys.argv[2]).read_text()); " + "front = ['contract: minutes/v5', 'made: 2026-11-27T10:00:00+01:00', 'provider: \"local\"', 'model: ' + json.dumps(sys.argv[3])," + " 'context: null', 'structure: ' + f['structure'], 'sections: ' + json.dumps(f['sections'], ensure_ascii=False)]" + " + (['actions: ' + f['actions']] if 'actions' in f else []); " + "body = ''.join(f'## {s[\"id\"]}\\n\\n- x\\n\\n' for s in f['sections']); " + "pathlib.Path(sys.argv[1], 'minutes.md').write_text('---\\n' + '\\n'.join(front) + '\\n---\\n\\n' + body)" +) # The host of a provider's address, and a request sent to a stand-in service, for the two above. os.environ["HOST"] = "import sys, urllib.parse; print(urllib.parse.urlsplit(sys.argv[1]).hostname)" os.environ["SEND"] = "import sys, urllib.request; urllib.request.urlopen(urllib.request.Request(sys.argv[1], data=b'x', method='POST'), timeout=5)" @@ -16643,6 +16654,135 @@ def log_message(self, *_): tags.shutdown() +def formats_redone(now: dt.datetime) -> None: + """DI. D130: Refaire's dialog offers the formats — the six built in by their names, a person's own after them, + the default marked and chosen —; the summary is written in the one chosen, through summarising/v1's + `--structure` or `--format`, and its line names it. The summary is the stand-in's.""" + print("DI. Refaire's dialog offers the formats, the default marked; the summary written in the one chosen names it (D130)") + meetings = WORK / "formats-redone" + meeting = meetings / "2026-11-27_09-00" + session(meeting, now - dt.timedelta(days=1), 10, {"local.wav": 1000}) + (meeting / "transcript.jsonl").write_text( + '{"type":"header","contract":"transcript/v1","engine":"whisper.cpp","model":"m","language":null,"context":null}\n' + '{"type":"segment","speaker":"me","track":"local","start":0.0,"end":1.0,"text":"Bonjour."}\n{"type":"complete","duration":1.0}\n') + (meeting / "minutes.md").write_text( + "---\ncontract: minutes/v1\nmade: 2026-11-27T10:00:00+01:00\nprovider: local\nmodel: m\ncontext: null\n---\n\n" + "## 1.\n\nLe point.\n\n## 2.\n\n- Rien\n\n## 3.\n\n- Rien\n") + kept = ('reminder = false\nminutes_provider = "http://127.0.0.1:9/v1"\nminutes_model = "m"\nformat_default = "point_client"\n' + 'formats_hidden = ["interview"]\n\n[[formats]]\nstructure = "point_client"\nname = "Point client"\nactions = 1\n' + 'sections = [{ title = "Contexte", about = "Où en est le client" }, { title = "Suites", about = "Qui fait quoi, pour quand" }]\n') + # Ollama on this computer, its recommended model held: the making the confidential switch starts (D60). + class Ollama(http.server.BaseHTTPRequestHandler): + protocol_version = "HTTP/1.0" + + def do_GET(self): + body = json.dumps({"models": [{"name": "qwen3:8b"}]}).encode() + self.send_response(200) + self.send_header("content-length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def log_message(self, *_): + pass + + ollama = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Ollama) + threading.Thread(target=ollama.serve_forever, daemon=True).start() + window = Window(meetings, "fr_FR.UTF-8", kept, ollama=f"http://127.0.0.1:{ollama.server_port}") + args = WORK / "summary-args" + offered = ("const p = document.getElementById('redo-format');" + " return p ? [...p.options].map((o) => [o.value, o.textContent, o.selected]) : []") + redone = lambda browser, value: ( + redo_open(browser, "minutes"), + wait_for(browser, lambda b: len(b.execute_script(offered)) == 6, 5), + Select(browser.find_element(By.ID, "redo-format")).select_by_value(value) if value else None, + args.unlink(missing_ok=True), + press(browser, "redo-dialog-do"), + wait_for(None, lambda b: args.exists(), 15), + wait_for(browser, lambda b: b.execute_script(idle), 15)) + 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)") + with window as browser: + browser.execute_script(f"location.hash = '#/meeting/{meeting.name}'") + wait_for(browser, lambda b: b.find_elements(By.ID, "redo-open"), 10) + redo_open(browser, "minutes") + listed = wait_for(browser, lambda b: len(b.execute_script(offered)) == 6, 5) and browser.execute_script(offered) + check("Refaire's dialog offers the built-in formats by their names, interview hidden, the person's own after; its default marked and chosen", + listed == [["general", "Général", False], ["one_to_one", "Point individuel", False], ["stand_up", "Point d’équipe", False], + ["client_call", "Appel client", False], ["project_review", "Revue de projet", False], + ["point_client", "Point client (par défaut)", True]], listed) + shot(browser, "cz-redo-formats") + press(browser, "redo-dialog-cancel") + redo_closed(browser) + redone(browser, None) + given = args.read_text().split() + file = window.file.parent / "formats" / "point_client.json" + written = json.loads(file.read_text()) if file.exists() else None + check("the default, a person's own: kitokey-summary given --format and its file, summarising/v1's format", + given[-2:] == ["--format", str(file)] and written == {"structure": "point_client", "sections": [ + {"id": "contexte", "about": "Où en est le client"}, {"id": "suites", "about": "Qui fait quoi, pour quand"}], "actions": "suites"}, + (given, written)) + browser.execute_script("location.hash = '#/'") + browser.execute_script(f"location.hash = '#/meeting/{meeting.name}'") + named = wait_for(browser, lambda b: b.execute_script("return document.getElementById('minutes-format')?.textContent") + == "Format «\u00a0Point client\u00a0»", 10) + check("the summary written in it names its format on its line", + named, browser.execute_script("return document.getElementById('minutes-format')?.textContent")) + shot(browser, "cz-minutes-format") + redone(browser, "stand_up") + given = args.read_text().split() + check("another built-in chosen: --structure and its name, for that making", given[-2:] == ["--structure", "stand_up"], given) + redone(browser, "general") + given = args.read_text().split() + check("Général chosen: no structure, as before (minutes/v4)", "--structure" not in given and "--format" not in given, given) + # lina's points 1 and 2 on #1340: no list when the formats cannot be read — the making then in the default —, + # and no line for minutes written in a format the person deleted since, never its id. + # Tauri freezes `core` (its bundle.global.js): the whole object replaced, the page reading it at each call. + took = browser.execute_script( + "const t = window.__TAURI__, real = t.core.invoke;" + " window.__TAURI__ = { ...t, core: { ...t.core, invoke: (command, args) =>" + " command === 'formats_offered' ? Promise.reject('read') : real(command, args) } };" + " return window.__TAURI__.core.invoke !== real") + check("the formats made unreadable for this check", took is True, took) + redo_open(browser, "minutes") + time.sleep(1) + row = browser.execute_script("const p = document.getElementById('redo-format'); return p && p.closest('label').getClientRects().length > 0") + check("the formats unread: Refaire's dialog shows no empty « Format » list", row is False, row) + press(browser, "redo-dialog-cancel") + redo_closed(browser) + gone = meetings / "2026-11-27_11-00" + session(gone, now - dt.timedelta(hours=20), 10, {"local.wav": 1000}) + (gone / "transcript.jsonl").write_text((meeting / "transcript.jsonl").read_text()) + (gone / "minutes.md").write_text( + "---\ncontract: minutes/v5\nmade: 2026-11-27T12:00:00+01:00\nprovider: \"local\"\nmodel: \"m\"\ncontext: null\n" + 'structure: point_ancien\nsections: [{"id": "contexte", "about": "Le contexte"}]\n---\n\n## Contexte\n\nLe point.\n') + browser.execute_script("location.reload()") + wait_for(browser, lambda b: b.find_elements(By.ID, "redo-open"), 10) + browser.execute_script(f"location.hash = '#/meeting/{gone.name}'") + wait_for(browser, lambda b: b.execute_script("return document.querySelectorAll('#meeting .minutes .body h2').length === 1"), 10) + time.sleep(1) + line = browser.execute_script("return document.getElementById('minutes-format')?.textContent ?? null") + check("minutes in a format deleted since: no line naming it, never its id", line is None, line) + # lina's F4 on #1340: a format chosen in Refaire serves that making alone. The next one, started outside Refaire + # — the switch said confidential, its minutes a service's —, is in Settings' default, through write_minutes_from. + browser.execute_script(f"location.hash = '#/meeting/{meeting.name}'") + wait_for(browser, lambda b: b.find_elements(By.ID, "redo-open"), 10) + redone(browser, "stand_up") + chosen = args.read_text().split() + text = (meeting / "minutes.md").read_text() + # Its minutes said written by a service (the stand-in names none): the switch makes them again here. + text = re.sub(r"(?m)^provider: .*\n", "", text, count=1) + (meeting / "minutes.md").write_text(text.replace("---\n", '---\nprovider: "writes.example"\n', 1)) + args.unlink(missing_ok=True) + browser.execute_script("location.hash = '#/'") + browser.execute_script(f"location.hash = '#/meeting/{meeting.name}'") + wait_for(browser, lambda b: b.find_elements(By.ID, "confidential-switch"), 10) + press(browser, "confidential-switch") + made = wait_for(None, lambda b: args.exists(), 15) and args.read_text().split() + wait_for(browser, lambda b: b.execute_script(idle), 15) + check("Refaire in Point d’équipe, then made again here as the switch says confidential: Settings' default, its file, never Point d’équipe", + chosen[-2:] == ["--structure", "stand_up"] and made and made[-2:] == ["--format", str(file)], (chosen, made)) + + def settings_engine_cards(now: dt.datetime) -> None: """EC. D122 in Settings: « Écoute et rédaction » draws each job's engine cards first, engineCards()'s own structure (CS reads it in its three scopes), « Auto » first and chosen when Settings name no @@ -18679,6 +18819,7 @@ def aside(folder): bar_window(now) bar_opened(now) bar_offers_no_engine_nor_language(now) + formats_redone(now) engine_cards_drawn(now) settings_engine_cards(now) bar_after_stop(now) diff --git a/modules/shell/src/formats.rs b/modules/shell/src/formats.rs index 1289cf27..1bf59ffa 100644 --- a/modules/shell/src/formats.rs +++ b/modules/shell/src/formats.rs @@ -252,6 +252,31 @@ impl Formats { } } +/// The format a making of the meeting in `folder` is written in: the one chosen for it in Refaire, taken +/// (it serves that making alone), else `default`, Settings' (D130). +pub fn for_making(chosen: &mut std::collections::HashMap, folder: &std::path::Path, default: &str) -> String { + chosen.remove(folder).unwrap_or_else(|| default.to_string()) +} + +/// What `kitokey-summary` is given after its model for the format of that structure: nothing for +/// `general` — `minutes/v4`, its sections the same —, `--structure` and its name for another built-in +/// one, `--format` and its file for a person's own, written in `folder` as [`file`] says. One +/// deleted or hidden since it was chosen: the default. +pub fn argument(formats: &Formats, structure: &str, folder: &std::path::Path) -> std::io::Result> { + let offered = formats.shown().contains(&structure); + let structure = if offered { structure } else { formats.default.as_str() }; + if structure == BUILT_IN[0] { + return Ok(Vec::new()); + } + let Some(format) = formats.own(structure) else { + return Ok(vec!["--structure".into(), structure.into()]); + }; + std::fs::create_dir_all(folder)?; + let path = folder.join(format!("{structure}.json")); + std::fs::write(&path, file(format).to_string())?; + Ok(vec!["--format".into(), path.to_string_lossy().into_owned()]) +} + /// The file `kitokey-summary --format` reads (`summarising/v1`'s `format.schema.json`). pub fn file(format: &Format) -> Value { let ids = ids(&format.sections); diff --git a/modules/shell/src/main.rs b/modules/shell/src/main.rs index 1dde3061..b1625994 100644 --- a/modules/shell/src/main.rs +++ b/modules/shell/src/main.rs @@ -30,7 +30,7 @@ use kitokey_shell::microphone; use kitokey_shell::{ autostart, confidential::{self, Left, Wait, What}, - context, correction, dates, desktop, engines, example, exporting, keys, + context, correction, dates, desktop, engines, example, exporting, formats, keys, licence::{self, Licence}, log, meeting::{self, Read, Transcript}, @@ -148,6 +148,9 @@ struct Shell { /// The model each meeting's last minutes were asked with, when one was named (a Refaire…): /// tried again, with that one (D25). minutes_tried: Mutex>>, + /// The format a *Refaire…* chose for its meeting (D130), its structure: that making alone; + /// none, Settings' default. + format_chosen: Mutex>, /// The sessions whose transcripts wait for the one being made, or for the model — in /// the order they were asked, each once; made again as a *Refaire…* asked (D25, D59). waiting: Mutex, Cancel)>>, @@ -419,6 +422,7 @@ fn main() { busy_meetings, freed, minutes_redo, + formats_offered, making_cancelled, context_shown, context_saved, @@ -594,6 +598,7 @@ fn main() { served: Mutex::new(None), minutes_made: Mutex::new(HashMap::new()), minutes_tried: Mutex::new(HashMap::new()), + format_chosen: Mutex::new(HashMap::new()), asked_again: Mutex::new(HashMap::new()), waiting: Mutex::new(VecDeque::new()), examples: Mutex::default(), @@ -1305,8 +1310,14 @@ fn minutes_redo( name: String, provider: Option, model: Option, + format: Option, ) -> Result<(), Told> { let folder = session_folder(&shell, &name)?; + // The format chosen in its dialog, for this making (D130); none, Settings' default. + match format { + Some(format) => shell.format_chosen.lock().unwrap().insert(folder.clone(), format), + None => shell.format_chosen.lock().unwrap().remove(&folder), + }; // The settings' model, as they name it now, when none is chosen: still a redo, which waits // its turn behind the meeting's own making — never taken for a second first one. let chosen = match provider.zip(model) { @@ -1320,6 +1331,37 @@ fn minutes_redo( Ok(()) } +/// A format as *Refaire…* offers it and the summary's line names it (D130): its structure, a +/// person's own name — a built-in one is named by the page's words —, and whether it is the default. +#[derive(serde::Serialize)] +struct FormatOffered { + structure: String, + name: Option, + default: bool, + shown: bool, +} + +/// The formats: those offered in Settings' order, then the built-in ones hidden — a summary written +/// in one still names it. +#[tauri::command] +fn formats_offered(shell: State<'_, Shell>) -> Vec { + let formats = shell.settings().formats; + let shown = formats.shown(); + let hidden = formats::BUILT_IN.iter().copied().filter(|built| !shown.contains(built)); + shown + .iter() + .copied() + .map(|structure| (structure, true)) + .chain(hidden.map(|structure| (structure, false))) + .map(|(structure, offered)| FormatOffered { + structure: structure.into(), + name: formats.own(structure).map(|format| format.name.clone()), + default: formats.default == structure, + shown: offered, + }) + .collect() +} + /// « Annuler » on a meeting's page (D92, the decider's word of 2026-11-13): what is being made of /// it — its transcript, its minutes — ends within two seconds, and what waits its turn leaves the /// line. The version already whole stays; the user may at once start another making. @@ -4557,6 +4599,7 @@ fn write_minutes_from( shell.stopped.lock().unwrap().remove(&folder); minuting(app, true); let app = app.clone(); + let formats = settings.formats.clone(); // The keyring may ask the user first: never on the window's and the tray's thread. std::thread::spawn(move || { let shell = app.state::(); @@ -4585,13 +4628,23 @@ fn write_minutes_from( // Cancelled while the keyring was asked: never started (D92). Err(std::io::Error::other("cancelled")) } else { - Summarising::start( - &program("kitokey-summary", "KITOKEY_SUMMARY"), - &folder, - &provider, - &model, - key.as_deref(), - ) + // In the format chosen for it, else Settings' default (D130): its file, when it is a + // person's own, written beside the settings. + let structure = formats::for_making(&mut shell.format_chosen.lock().unwrap(), &folder, &formats.default); + let beside = settings::file().and_then(|file| file.parent().map(|folder| folder.join("formats"))); + beside + .ok_or_else(|| std::io::Error::other("this system names no folder for settings")) + .and_then(|beside| formats::argument(&formats, &structure, &beside)) + .and_then(|shape| { + Summarising::start_as( + &program("kitokey-summary", "KITOKEY_SUMMARY"), + &folder, + &provider, + &model, + key.as_deref(), + &shape, + ) + }) }; let events = match started { Ok((making, events)) => { diff --git a/modules/shell/src/minutes.rs b/modules/shell/src/minutes.rs index 701e7edd..ce79db69 100644 --- a/modules/shell/src/minutes.rs +++ b/modules/shell/src/minutes.rs @@ -40,6 +40,9 @@ pub struct Minutes { /// Which section holds the actions, counted from one: v1 to v4's second, v5's whose id its /// `actions` names (D111), none when it names none. The page reads its actions there alone. pub actions: Option, + /// The format they were written in, as `minutes/v5`'s front matter names it (D130); v1 to v4 + /// name none. + pub structure: Option, } /// The minutes of a session's folder, their three sections named as the page names them. @@ -407,5 +410,6 @@ fn parse_minutes(text: &str, sections: [&str; 3], by_id: &[(&str, &str)]) -> Opt body: html, markdown, actions, + structure: if fifth { field("structure") } else { None }, }) } diff --git a/modules/shell/src/summarising.rs b/modules/shell/src/summarising.rs index 7a6e51f5..c42c53b6 100644 --- a/modules/shell/src/summarising.rs +++ b/modules/shell/src/summarising.rs @@ -91,12 +91,25 @@ impl Summarising { /// Starts `kitokey-summary` on a session's folder. The key goes to its environment only — a /// key in Kitokey's own environment never does. pub fn start(program: &Path, folder: &Path, provider: &str, model: &str, key: Option<&str>) -> io::Result<(Self, Receiver)> { + Self::start_as(program, folder, provider, model, key, &[]) + } + + /// The same, in the format chosen (D130): what `formats::argument` gives, after the model. + pub fn start_as( + program: &Path, + folder: &Path, + provider: &str, + model: &str, + key: Option<&str>, + shape: &[String], + ) -> io::Result<(Self, Receiver)> { let (trace, making) = crate::log::making(); let _making = making.enter(); let mut command = Command::new(program); command .arg(folder) .args(["--provider", provider, "--model", model]) + .args(shape) .env("KITOKEY_TRACE", &trace); let host = crate::providers::host(provider).unwrap_or_default(); info!(session = %crate::transcription::named(folder), host, model, key = key.is_some(), "shell.minutes"); diff --git a/modules/shell/src/words.rs b/modules/shell/src/words.rs index 707cc64f..85cd94f5 100644 --- a/modules/shell/src/words.rs +++ b/modules/shell/src/words.rs @@ -1600,6 +1600,15 @@ pub struct Window { /// Shows: Redo…'s list of formats, and the summary's line naming its format. When: a built-in /// format is offered or named. At most: about 20 characters. Placeholders: none. pub format_names: [&'static str; 6], + /// Shows: a meeting's page, its Redo… panel, as the label of the list of formats. When: redo the + /// minutes. At most: about 12 characters. Placeholders: none. + pub redo_format: &'static str, + /// Shows: Redo…'s list of formats, as a choice. When: the format Settings name the default. + /// At most: about 30 characters. Placeholders: {} the format's name. + pub format_default: &'static str, + /// Shows: a meeting's page, the summary's line of provenance, after who wrote it. When: the + /// minutes name their format. At most: about 30 characters. Placeholders: {} the format's name. + pub minutes_format: &'static str, /// Shows: the summary's redo panel, its one button that starts, naming the making and its model /// (D96): « Refaire le compte rendu avec Qwen3 14b ». When: a summary model is known, the meeting's, /// the one chosen in « Avancé » or Settings'; else `redo_title`. At most: wraps inside the panel. @@ -2624,6 +2633,9 @@ pub fn window(language: Language) -> Window { free_done: "Done — moved to the trash.", redo_title: "Write the summary again", format_names: ["General", "One-to-one", "Stand-up", "Client call", "Interview", "Project review"], + redo_format: "Format", + format_default: "{} (default)", + minutes_format: "{} format", redo_note: "The current summary stays in place until the new one is ready, then goes to the trash.", redo_minutes_do: "Write the summary again with {}", redo_transcript_do: "Write the transcript again with {}", @@ -3255,6 +3267,9 @@ pub fn window(language: Language) -> Window { "Entretien", "Revue de projet", ], + redo_format: "Format", + format_default: "{} (par défaut)", + minutes_format: "Format «\u{a0}{}\u{a0}»", redo_note: "Le compte rendu actuel reste en place tant que le nouveau n’est pas prêt, et se retrouve ensuite dans la corbeille.", redo_minutes_do: "Refaire le compte rendu avec {}", redo_transcript_do: "Refaire la transcription avec {}", diff --git a/modules/shell/tests/formats.rs b/modules/shell/tests/formats.rs index 6919bb2d..33e5ee20 100644 --- a/modules/shell/tests/formats.rs +++ b/modules/shell/tests/formats.rs @@ -342,3 +342,63 @@ fn a_structure_taken_at_forty_characters_gets_one_of_forty_with_its_number() { assert_eq!(second, "reunion_hebdomadaire_de_l_equipe_produ_2"); assert_eq!(second.chars().count(), 40); } +#[test] +fn kitokey_summary_is_given_the_format_chosen_as_summarising_v1_says() { + let folder = tempfile::tempdir().unwrap(); + let mut formats = Formats::default(); + let made = formats.made("Point client hebdo", weekly(), Some(2)).unwrap(); + // `general`: no structure, as before — minutes/v4, its sections the same. + assert!(formats::argument(&formats, "general", folder.path()).unwrap().is_empty()); + // Another built-in: its name. + assert_eq!( + formats::argument(&formats, "stand_up", folder.path()).unwrap(), + ["--structure", "stand_up"] + ); + // A person's own: the file --format reads, written in the formats' folder. + let given = formats::argument(&formats, &made, folder.path()).unwrap(); + let file = folder.path().join("point_client_hebdo.json"); + assert_eq!(given, ["--format".to_string(), file.to_string_lossy().into_owned()]); + let written: serde_json::Value = serde_json::from_str(&std::fs::read_to_string(&file).unwrap()).unwrap(); + assert_eq!(written, formats::file(formats.own(&made).unwrap())); + // One deleted, or hidden, since it was chosen: the default. + formats.default_to("client_call").unwrap(); + formats.hide("interview", true).unwrap(); + for gone in ["interview", "deleted_since"] { + assert_eq!( + formats::argument(&formats, gone, folder.path()).unwrap(), + ["--structure", "client_call"] + ); + } +} + +/// lina's point 3 on #1340: the page names the built-in formats in `formats::BUILT_IN`'s order, its own copy +/// the same — `words.format_names` follows that order. +#[test] +fn the_page_lists_the_built_in_formats_as_formats_rs_does() { + let page = include_str!("../ui/window.js"); + let line = page + .lines() + .find(|line| line.starts_with("const BUILT_IN = [")) + .expect("window.js's BUILT_IN"); + let listed: Vec<&str> = line.split('"').skip(1).step_by(2).collect(); + assert_eq!(listed, formats::BUILT_IN); +} + +/// lina's mutant on #1340: a format chosen in Refaire serves that making alone. The next making of the +/// meeting, started elsewhere (the confidential switch, a model fetched for the meetings that waited), +/// is in Settings' default, never the format chosen once. +#[test] +fn a_format_chosen_in_refaire_serves_one_making_alone() { + let mut chosen = std::collections::HashMap::new(); + let folder = std::path::Path::new("meetings/2026-11-27_09-00"); + let other = std::path::Path::new("meetings/2026-11-27_11-00"); + chosen.insert(folder.to_path_buf(), "stand_up".to_string()); + chosen.insert(other.to_path_buf(), "interview".to_string()); + assert_eq!(formats::for_making(&mut chosen, folder, "point_client"), "stand_up"); + assert_eq!(formats::for_making(&mut chosen, folder, "point_client"), "point_client"); + assert_eq!( + chosen.get(other).map(String::as_str), + Some("interview"), + "another meeting's choice kept" + ); +} diff --git a/modules/shell/tests/minutes.rs b/modules/shell/tests/minutes.rs index 9cb9854e..89047832 100644 --- a/modules/shell/tests/minutes.rs +++ b/modules/shell/tests/minutes.rs @@ -705,3 +705,19 @@ fn an_about_of_200_characters_is_within_its_bounds() { "200 characters is the most, not too many" ); } + +/// D130: the format the minutes were written in, as v5's front matter names it — the summary's +/// line of provenance says it; v1 to v4 name none. +#[test] +fn minutes_v5_say_their_structure_and_earlier_ones_none() { + let Read::Present(minutes) = read_v5(&v5_example()) else { + panic!("v5's own example not read") + }; + assert_eq!(minutes.structure.as_deref(), Some("project_review")); + let own = v5_example().replace("structure: project_review", "structure: point_client_hebdo"); + let Read::Present(minutes) = read_v5(&own) else { + panic!("not read: {own}") + }; + assert_eq!(minutes.structure.as_deref(), Some("point_client_hebdo")); + assert_eq!(present(&third("", "- a", "- d")).structure, None); +} diff --git a/modules/shell/tests/silence.rs b/modules/shell/tests/silence.rs index 5fdd3998..e6de63ad 100644 --- a/modules/shell/tests/silence.rs +++ b/modules/shell/tests/silence.rs @@ -34,6 +34,11 @@ const SILENT: &[(&str, usize, &str)] = &[ "Settings' engine cards (D122): not read, no cards are drawn and each job's setup is there under « Avancé », every choice as before; the next drawing reads again", ), ("makings", 2, "returns no `Result`: it cannot fail"), + ( + "formats_offered", + 2, + "returns no `Result`: it cannot fail — Refaire's list and the summary's format named (D130)", + ), ( "searched", 1, diff --git a/modules/shell/tests/summarising.rs b/modules/shell/tests/summarising.rs index c2a12699..42a0b997 100644 --- a/modules/shell/tests/summarising.rs +++ b/modules/shell/tests/summarising.rs @@ -262,3 +262,21 @@ fn cancelled_minutes_end_within_two_seconds_with_what_they_started_the_minutes_t assert!(gone(&stat), "its child still runs a second after its making ended: {stat}"); assert_eq!(fs::read_to_string(&minutes).unwrap(), "the minutes before"); } + +#[test] +fn the_format_chosen_is_given_after_the_model() { + let _held = ONE_AT_A_TIME.lock().unwrap_or_else(|poisoned| poisoned.into_inner()); + let folder = session(); + let path = folder.path().join("kitokey-summary"); + fs::write( + &path, + "#!/bin/sh\n[ \"$6\" = --structure ] && [ \"$7\" = stand_up ] && [ $# = 7 ] || exit 9\necho '## A' > \"$1/minutes.md\"\necho '{\"event\":\"written\",\"file\":\"x\"}'\n", + ) + .unwrap(); + fs::set_permissions(&path, fs::Permissions::from_mode(0o755)).unwrap(); + let shape = ["--structure".to_string(), "stand_up".to_string()]; + let (_making, events) = + Summarising::start_as(&path, &folder.path().join("session"), "http://127.0.0.1:9/v1", "m", None, &shape).unwrap(); + let ended = std::iter::from_fn(|| events.recv_timeout(Duration::from_secs(10)).ok()).find(|event| matches!(event, Event::Ended(_))); + assert_eq!(ended, Some(Event::Ended(Made::Written(folder.path().join("session")))), "{ended:?}"); +} diff --git a/modules/shell/ui/window.js b/modules/shell/ui/window.js index d72d6bc6..cd447c2b 100644 --- a/modules/shell/ui/window.js +++ b/modules/shell/ui/window.js @@ -187,7 +187,9 @@ async function redoDialog(session, words, step, corrected = false) { const cards = engineCards({ job: writing ? "write" : "transcribe", offered, words, scope: "meeting", services }); const note = element("p", "says", writing ? words.redo_note : words.redo_transcript_note); note.id = "redo-dialog-note"; - const notes = [note]; + // The summary's formats, the default chosen, for this making alone (D130). + const [formatRow, formatChosen] = writing ? formatPick(words) : [null, () => null]; + const notes = writing ? [formatRow, note] : [note]; // Made again, the transcript alone: the summary there is kept, said so (the decider, 2026-11-18, D113). if (!writing && session.minutes) { const kept = element("p", "says", words.redo_keeps_minutes); @@ -239,7 +241,7 @@ async function redoDialog(session, words, step, corrected = false) { pageOffered = null; } await (writing - ? window.__TAURI__.core.invoke("minutes_redo", { name, provider: null, model: null }) + ? window.__TAURI__.core.invoke("minutes_redo", { name, provider: null, model: null, format: formatChosen() }) : window.__TAURI__.core.invoke("transcript_redo_own", { name })); close(); readMakings(); @@ -2094,6 +2096,36 @@ function offer(card, label, id, command, session, words) { return button; } +// The six formats built in, in `formats::BUILT_IN`'s order: named by the page's words (D130). +const BUILT_IN = ["general", "one_to_one", "stand_up", "client_call", "interview", "project_review"]; + +// A format as a person reads it: a built-in one by the page's words, their own by its name. +function formatSaid(words, format) { + const built = BUILT_IN.indexOf(format.structure); + return built >= 0 ? words.format_names[built] : format.name ?? format.structure; +} + +// *Refaire…*'s formats (D130): those offered, the default marked and chosen; the choice for that +// making alone. None read: no list, the making in the default. +function formatPick(words) { + const row = element("label", "models-row"); + row.htmlFor = "redo-format"; + row.hidden = true; + const pick = element("select"); + pick.id = "redo-format"; + row.append(element("span", "name", words.redo_format), pick); + window.__TAURI__.core.invoke("formats_offered").then((formats) => { + for (const format of formats.filter((format) => format.shown)) { + const option = element("option", "", format.default ? fill(words.format_default, formatSaid(words, format)) : formatSaid(words, format)); + option.value = format.structure; + option.selected = format.default; + pick.append(option); + } + row.hidden = pick.options.length === 0; + }, () => {}); + return [row, () => pick.value || null]; +} + // D93, criterion 5: what a meeting's page offers to make it by — models_offered's answer, read once a // page's opening by the first line that offers a choice, never at each drawing; shared by its two // lines, which keep the meeting's own choice whole between them. Dropped once another meeting is @@ -2662,6 +2694,19 @@ function minutesCard(read, words, session, transcript, onPage, previous, otherVe const [pick, said] = modelOnPage(onPage, words, "minutes", version, go, words.redo_minutes_do, words.redo_title, box); card.append(lineWith(maker, pick), said, box); } else card.append(element("p", "maker", maker)); + // The format they were written in, named (D130): v5 names it; v1 to v4, none; one deleted since, none. + if (read.structure) { + const named = element("p", "says", ""); + named.id = "minutes-format"; + named.hidden = true; + card.append(named); + window.__TAURI__.core.invoke("formats_offered").then((formats) => { + const format = formats.find((format) => format.structure === read.structure); + if (!format) return named.remove(); + named.textContent = fill(words.minutes_format, formatSaid(words, format)); + named.hidden = false; + }, () => named.remove()); + } // A language model wrote them, said where they are read (Store Policies 11.16, #1092). const written = element("p", "note", words.minutes_ai); written.id = "minutes-ai";