Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 65 additions & 3 deletions modules/shell/scripts/e2e_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,9 @@ def do_GET(self):
body = serving["signature"] if self.path.endswith(".minisig") else serving["list"]
self.send_response(404 if body is None else 200)
self.send_header("Content-Length", str(len(body or b"")))
# HTTP/1.0 closes each connection: said, so that the shell's client never sends the
# signature's request on the list's, closed under it (« Peer disconnected », #866).
self.send_header("Connection", "close")
self.end_headers()
self.wfile.write(body or b"")

Expand All @@ -935,7 +938,10 @@ def log_message(self, *_):
window.env.update(KITOKEY_REGISTRY=f"http://{at}/models.json")
with window as browser:
browser.find_element(By.ID, "settings-link").click()
button = wait_for(browser, lambda b: b.find_elements(By.ID, "offered-refresh"), 10)
# « Modèles à télécharger » folded at first (#782): unfolded, as the user does, to reach its button.
wait_for(browser, lambda b: b.find_elements(By.ID, "offered-toggle"), 10)
press(browser, "offered-toggle")
button = wait_for(browser, lambda b: b.find_elements(By.ID, "offered-refresh") and b.find_element(By.ID, "offered-refresh").is_displayed(), 10)
check("the key built in: a button offers to read the list again, its host shown, nothing said of a key awaited",
button and at in browser.find_element(By.ID, "offered-refresh").text and "attend la clé" not in browser.execute_script(said)
and asked == [], (browser.execute_script(said), asked))
Expand Down Expand Up @@ -1187,8 +1193,10 @@ def log_message(self, *_):
models and listed == ["/api/v1/key", "/api/v1/models?output_modalities=transcription"] and not browser.find_element(By.ID, "transcription-provider").is_displayed(),
(offered(browser, "transcription-models"), listed))
Select(browser.find_element(By.ID, "transcription-models")).select_by_value("vendor/scribe")
if not browser.find_element(By.ID, "transcription-agreed").is_selected():
browser.find_element(By.ID, "transcription-agreed").click()
# The stand-in is on this computer: no agreement asked, and it saves without one (#859); a host
# elsewhere is agreed to above, under « Avancé ».
asked = browser.execute_script("const a = document.getElementById('transcription-agreed'); return !!a && a.getClientRects().length > 0")
check("OpenRouter's stand-in on this computer: no agreement asked to send the sound (#859)", not asked, asked)
press(browser, "transcription-save")
saved = wait_for(browser, lambda b: f'transcription_provider = "{stand}"' in window.file.read_text(), 5)
text = window.file.read_text()
Expand Down Expand Up @@ -1411,6 +1419,13 @@ def transcription_guided(now: dt.datetime) -> None:
address typed but under « Avancé ». The stand-in is on this computer: D43's agreement, owed to a
host elsewhere, is held by tests/transcription.rs."""
print("BG. Settings: the transcription set up in a few guided steps, a service's key tested at once (D95)")
# This computer's Whisper models, as K writes them in main(): BG's own, so that it reads the same
# alone (KITOKEY_E2E_ONLY) as in the whole run; K's, when it ran, left as they are.
models = WORK / "data" / "kitokey" / "models"
models.mkdir(parents=True, exist_ok=True)
for name in ("ggml-large-v3-turbo-q8_0.bin", "ggml-small.bin"):
if not (models / name).exists():
(models / name).write_bytes(b"x" * 1000)
good, false = "sk-stand-in-good", "sk-stand-in-false"
asked = []

Expand Down Expand Up @@ -1500,12 +1515,18 @@ def log_message(self, *_):
# address elsewhere can be named without being asked: tests/transcription.rs,
# a_service_is_saved_only_once_its_host_elsewhere_is_agreed_to.
choose(browser, "transcription-models", "openai/whisper-large-v3-turbo")
# No agreement asked where none is owed: the address is this computer's (#859).
agreement_shown = browser.execute_script("const a = document.getElementById('transcription-agreed'); return !!a && a.getClientRects().length > 0")
check("the service on this computer: no agreement to send the sound asked (#859)", not agreement_shown, agreement_shown)
press(browser, "transcription-save")
saved = wait_for(browser, lambda b: 'transcription_model = "openai/whisper-large-v3-turbo"' in window.file.read_text(), 5)
text = window.file.read_text()
check("saved: who hears is the service, its address, the model chosen; its host this computer's, no agreement recorded; never the key",
saved and 'engine = "service"' in text and f'transcription_provider = "{stand}"' in text and "transcription_agreed" not in text
and "sk-stand-in" not in text, text)
host = stand.split("/")[2]
told = browser.execute_script("return document.getElementById('transcription-said')?.textContent || ''")
check("saved on this computer: said so, not as an address and a port (#775)", "cet ordinateur" in told and host not in told, told)
logged = [str(f) for f in (WORK / "state").rglob("*") if f.is_file() and "sk-stand-in" in f.read_text(errors="ignore")]
check("the key never logged", logged == [], logged)
# Drawn again: the service and its model said as chosen, no address shown.
Expand All @@ -1519,6 +1540,17 @@ def log_message(self, *_):
press(browser, "transcription-advanced")
unfolded = wait_for(browser, lambda b: b.find_element(By.ID, "transcription-provider").is_displayed(), 3)
check("« Avancé » unfolded: an address of one's own, and a model named by hand", unfolded and browser.find_element(By.ID, "transcription-model").is_displayed())
# One's own address: an agreement asked for a host elsewhere, none for this computer (#859).
own_agreement = "const a = document.getElementById('transcription-own-agreed'); return !!a && a.getClientRects().length > 0"
own = browser.find_element(By.ID, "transcription-provider")
own.clear()
own.send_keys("http://localhost:8000/v1")
here_none = wait_for(browser, lambda b: not b.execute_script(own_agreement), 3)
own.clear()
own.send_keys("https://hears.example/v1")
away_asked = wait_for(browser, lambda b: b.execute_script(own_agreement), 3)
check("one's own address: no agreement for this computer, one for a host elsewhere (#859)", here_none and away_asked, [here_none, away_asked])
own.clear()
browser.execute_script("document.getElementById('transcription-where').scrollIntoView({block: 'start'})")
shot_themed(browser, "d95-transcription-service-light", "light")
shot_themed(browser, "d95-transcription-service-dark", "dark")
Expand Down Expand Up @@ -4336,6 +4368,35 @@ def choose(browser, row: int) -> bool:
captured.write_text(left)


def settings_folded(now: dt.datetime) -> None:
"""BN. Settings after D95, what the 0.2.5 audit still saw (#782): « Modèles à télécharger » folded, a
disclosure (ARIA APG) that stays as the user left it when the page is drawn again; « Refaire le
réglage » in « Général », not among the models."""
print("BN. Settings: « Modèles à télécharger » folded, kept as left when drawn again; « Refaire le réglage » in « Général » (#782)")
taping = WORK / "settings-folded"
taping.mkdir()
toggle = ("const t = document.getElementById('offered-toggle'), l = document.getElementById('offered');"
" return {toggle: !!t, expanded: t && t.getAttribute('aria-expanded'), controls: t && t.getAttribute('aria-controls'),"
" name: t && t.textContent.trim(), list: !!l && l.getClientRects().length > 0, rows: l ? l.querySelectorAll('li').length : 0}")
card = ("const b = document.getElementById('welcome-again'); const c = b && b.closest('section.card');"
" return c ? c.querySelector('h2').textContent : null")
with Window(taping, "fr_FR.UTF-8", 'after = "nothing"\n') as browser:
browser.execute_script("location.hash = '#/settings'")
drawn = wait_for(browser, lambda b: b.find_elements(By.ID, "model") and b.find_element(By.ID, "model").is_displayed(), 10)
got = browser.execute_script(toggle)
check("« Modèles à télécharger » folded at first: a disclosure, closed, its list not shown (#782)",
drawn and got["toggle"] and got["expanded"] == "false" and got["controls"] == "offered" and got["name"] == "Modèles à télécharger"
and not got["list"] and got["rows"] > 0, got)
if got["toggle"]:
press(browser, "offered-toggle")
opened = wait_for(browser, lambda b: b.execute_script(toggle)["list"], 3)
check("pressed: unfolded, the list shown (#782)", opened and browser.execute_script(toggle)["expanded"] == "true", browser.execute_script(toggle))
browser.execute_async_script("const done = arguments[0]; refresh().then(() => done(true), () => done(false))")
check("drawn again: still unfolded, as the user left it (#782)",
browser.execute_script(toggle)["list"] and browser.execute_script(toggle)["expanded"] == "true", browser.execute_script(toggle))
check("« Refaire le réglage » in « Général », not among the models (#782)", browser.execute_script(card) == "Général", browser.execute_script(card))


def bar_opened(now: dt.datetime) -> None:
"""BA. The bar opened (D90, board 6): at rest, the microphone, « Vérifier le son » — D88's panel in
the bar — and « Avancé » closed; recording, the context, the microphone recorded, « Confidentielle »
Expand Down Expand Up @@ -9698,6 +9759,7 @@ def aside(folder):
microphone_chosen(now)
microphone_latest_answer(now)
microphone_rollback(now)
settings_folded(now)
sound_checked(now)
bar_window(now)
bar_opened(now)
Expand Down
2 changes: 0 additions & 2 deletions modules/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2337,7 +2337,6 @@ struct SettingsShown {
/// host it is read again from on the user's gesture (D40).
offered: Vec<Offered>,
registry_host: String,
registry_waits: bool,
/// The services that hear, offered by name (D63).
hearing: Vec<providers::Hearing>,
/// The language meetings are spoken in, none: detected; and those offered first (D65).
Expand Down Expand Up @@ -2423,7 +2422,6 @@ async fn settings_shown(app: AppHandle, shell: State<'_, Shell>) -> Result<Setti
transcription_agreed: settings.transcription_agreed.clone(),
models,
registry_host: registry::host(&registry_address()).to_owned(),
registry_waits: registry::PUBLIC_KEY.is_none(),
hearing: providers::hearing(),
meeting_language: settings.meeting_language.clone(),
languages: spoken::OFFERED.to_vec(),
Expand Down
8 changes: 5 additions & 3 deletions modules/shell/src/words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ pub struct Window {
/// what is said when it could not be.
pub offered_refresh: &'static str,
pub offered_refresh_failed: &'static str,
pub offered_refresh_waits: &'static str,
/// Apple's SpeechAnalyzer among who hears, on a Mac with macOS 26 (D42): its name in the
/// choice; its model not on the Mac yet; the gesture that has macOS fetch it, and from whom;
/// while it comes; when it did not.
Expand All @@ -451,6 +450,9 @@ pub struct Window {
pub service_test: &'static str,
pub service_tested: &'static str,
pub service_saved: &'static str,
/// Shows: Settings, « Transcription », under the service's form, once saved. When: the address saved is
/// this computer's, where nothing leaves it (#775). At most: one line. Placeholders: none.
pub service_saved_here: &'static str,
pub service_agree_first: &'static str,
pub service_address_bad: &'static str,
pub service_model_named: &'static str,
Expand Down Expand Up @@ -908,7 +910,6 @@ pub fn window(language: Language) -> Window {
offered_needs_ollama: "Needs Ollama — install it from ollama.com",
offered_refresh: "Update the list ({})",
offered_refresh_failed: "The list could not be updated: the models above are still offered.",
offered_refresh_waits: "The list cannot be updated yet: it waits on the key that signs it. The models above are still offered.",
speech_option: "Apple's SpeechAnalyzer, on this Mac",
speech_missing: "Apple's model is not on this Mac yet",
speech_fetch: "Download Apple's model (macOS fetches it from Apple)",
Expand All @@ -923,6 +924,7 @@ pub fn window(language: Language) -> Window {
service_test: "Test",
service_tested: "It hears, with each segment’s times: a sound of Kitokey’s own was transcribed.",
service_saved: "Saved: {} hears your next meetings.",
service_saved_here: "Saved: this computer hears your next meetings.",
service_agree_first: "Nothing is saved: agree first that your meetings’ sound is sent to {}.",
service_address_bad: "Nothing is saved: the address starts with https:// or http://, then the service’s host — for example https://api.groq.com/openai/v1.",
service_model_named: "Nothing is saved: name the model the service hears with — for example whisper-large-v3.",
Expand Down Expand Up @@ -1333,7 +1335,6 @@ pub fn window(language: Language) -> Window {
offered_needs_ollama: "Nécessite Ollama, à installer depuis ollama.com",
offered_refresh: "Mettre à jour la liste ({})",
offered_refresh_failed: "La liste n’a pas pu être mise à jour\u{a0}: les modèles ci-dessus restent proposés.",
offered_refresh_waits: "La liste ne peut pas encore être mise à jour\u{a0}: elle attend la clé qui la signe. Les modèles ci-dessus restent proposés.",
speech_option: "SpeechAnalyzer d’Apple, sur ce Mac",
speech_missing: "le modèle d’Apple n’est pas encore sur ce Mac",
speech_fetch: "Télécharger le modèle d’Apple (macOS le télécharge depuis Apple)",
Expand All @@ -1348,6 +1349,7 @@ pub fn window(language: Language) -> Window {
service_test: "Tester",
service_tested: "Il entend, avec les temps de chaque segment\u{a0}: un son propre à Kitokey a été transcrit.",
service_saved: "Enregistré\u{a0}: {} transcrira vos prochaines réunions.",
service_saved_here: "Enregistré\u{a0}: cet ordinateur transcrira vos prochaines réunions.",
service_agree_first: "Rien n’est enregistré\u{a0}: acceptez d’abord que le son de vos réunions soit envoyé à {}.",
service_address_bad: "Rien n’est enregistré\u{a0}: l’adresse commence par https:// ou http://, puis l’hôte du service — par exemple https://api.groq.com/openai/v1.",
service_model_named: "Rien n’est enregistré\u{a0}: nommez le modèle avec lequel le service entend — par exemple whisper-large-v3.",
Expand Down
9 changes: 1 addition & 8 deletions modules/shell/tests/words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ const STILL_WRONG: &str = include_str!("words_still_wrong.txt");

/// The sentences still without their comment, counted: 602 keys would be three review budgets.
/// The number only goes down, as the list does.
const WITHOUT_COMMENT: usize = 597;
const WITHOUT_COMMENT: usize = 596;

/// A sentence of `src/words.rs`, as the file arranges it.
#[derive(Debug)]
Expand Down Expand Up @@ -1699,13 +1699,6 @@ fn no_sentence_says_a_word_the_lexicon_refuses() {
still_wrong("lexicon", wrong);
}

#[test]
fn a_list_waiting_on_its_key_says_so_and_what_stays_offered() {
let (english, french) = (words::window(Language::English), words::window(Language::French));
assert!(english.offered_refresh_waits.contains("waits on the key") && english.offered_refresh_waits.contains("still offered"));
assert!(french.offered_refresh_waits.contains("attend la clé") && french.offered_refresh_waits.contains("restent proposés"));
}

#[test]
fn the_bar_says_a_silence_as_the_notifications_do() {
// D49: the same gesture as the notification's, in each language; the side's own. D90: a
Expand Down
Loading
Loading