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
16 changes: 16 additions & 0 deletions modules/shell/scripts/e2e_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,20 @@ def log_message(self, *_):
# « Avancé », the address left empty, saved with the service chosen above, and read again.
press(browser, "transcription-advanced")
wait_for(browser, lambda b: b.find_element(By.ID, "transcription-model").is_displayed(), 3)
# One save per setting (#860), as macOS's and GNOME's settings have it: « Avancé » unfolded shows one
# « Enregistrer » and one agreement at most, and that one saves what the page shows — the address
# left empty, the model typed or else the one chosen in the list.
shown_of = ("return arguments[0].filter((id) => { const e = document.getElementById(id); return !!e && e.getClientRects().length > 0; })")
saves, agreements = ["transcription-save", "transcription-own-save"], ["transcription-agreed", "transcription-own-agreed"]
one = browser.execute_script(shown_of, saves)
check("« Avancé » unfolded: one « Enregistrer » shown, one agreement at most (#860)",
len(one) == 1 and len(browser.execute_script(shown_of, agreements)) <= 1, [one, browser.execute_script(shown_of, agreements)])
if one:
press(browser, one[0])
kept = wait_for(browser, lambda b: "cet ordinateur transcrira" in b.execute_script(said), 5)
check("nothing typed under « Avancé »: that « Enregistrer » saves the service chosen above, the model chosen in its list (#860)",
kept and 'transcription_model = "vendor/scribe"' in window.file.read_text() and f'transcription_provider = "{stand}"' in window.file.read_text(),
(browser.execute_script(said), window.file.read_text()))
check("« Avancé », its address left empty: the service chosen above shown standing in",
browser.find_element(By.ID, "transcription-provider").get_attribute("placeholder") == stand,
browser.find_element(By.ID, "transcription-provider").get_attribute("placeholder"))
Expand Down Expand Up @@ -1550,6 +1564,8 @@ def log_message(self, *_):
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])
both = browser.execute_script("return ['transcription-agreed', 'transcription-own-agreed'].filter((id) => { const e = document.getElementById(id); return !!e && e.getClientRects().length > 0; })")
check("a host elsewhere typed under « Avancé »: one agreement shown, its own (#860)", both == ["transcription-own-agreed"], both)
own.clear()
browser.execute_script("document.getElementById('transcription-where').scrollIntoView({block: 'start'})")
shot_themed(browser, "d95-transcription-service-light", "light")
Expand Down
25 changes: 20 additions & 5 deletions modules/shell/ui/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -2578,13 +2578,22 @@ function showSettings(shown, minutes, words) {
const [modelsWrap, serviceModels] = guidedList("transcription-models", words.service_model, locked);
const [agreeWrap, agreeBox, agreeHost, agreeShown] = agreement("transcription-agreed");
const saveService = guidedButton("transcription-save", words.service_save, true, locked);
// One « Enregistrer » and one agreement at a time (#860): the service's, « Avancé » folded; unfolded,
// its own, which saves what the page shows.
let listedShown = false;
const paintSaves = () => {
const open = guided.transcription.advanced;
saveService.hidden = !listedShown || open;
agreeShown(listedShown && !open);
};
// The models listed with its key, the one saved chosen.
const shownListed = (models) => {
serviceModels.replaceChildren();
for (const id of models) guidedOption(serviceModels, id, modelSaid(id));
if (models.includes(shown.transcription_model)) serviceModels.value = shown.transcription_model;
modelsWrap.hidden = saveService.hidden = models.length === 0;
agreeShown(models.length > 0);
modelsWrap.hidden = models.length === 0;
listedShown = models.length > 0;
paintSaves();
};
// This service's last answer, said again; else the model saved with it — the others come with its key.
const shownSaved = () => {
Expand All @@ -2595,8 +2604,9 @@ function showSettings(shown, minutes, words) {
if (answer?.models) return shownListed(answer.models);
serviceModels.replaceChildren();
if (saved) guidedOption(serviceModels, shown.transcription_model, modelSaid(shown.transcription_model));
modelsWrap.hidden = saveService.hidden = !saved;
agreeShown(!!saved);
modelsWrap.hidden = !saved;
listedShown = !!saved;
paintSaves();
};
shownSaved();
guidedKeyTested("transcription", words, locked, { servicePick, key: serviceKey, keyTest, keySaid, modelsPick: serviceModels },
Expand All @@ -2619,6 +2629,11 @@ function showSettings(shown, minutes, words) {
});
const ownSave = guidedButton("transcription-own-save", words.service_save, false, locked);
const [hearToggle, hearAdvanced] = guidedAdvanced("transcription", words, own, [addressWrap, modelWrap, ownAgreeWrap, ownSave]);
hearToggle.addEventListener("click", paintSaves);
paintSaves();
// What « Avancé »'s « Enregistrer » saves: its model typed, or else — its address left empty, the
// service chosen above — the model chosen in that service's list (#860).
const ownModel = () => serviceModel.value.trim() || (address.value.trim() ? "" : serviceModels.value);
const serviceSaid = element("p", "says");
serviceSaid.id = "transcription-said";
serviceSaid.setAttribute("role", "status");
Expand Down Expand Up @@ -2647,7 +2662,7 @@ function showSettings(shown, minutes, words) {
serviceSaid.textContent = saved;
};
saveService.addEventListener("click", () => saveHearing(hearing().address, serviceModels.value, serviceKey.value, agreeBox, null, serviceModels));
ownSave.addEventListener("click", () => saveHearing(ownAddress(), serviceModel.value, serviceKey.value, ownAgreeBox, address, serviceModel));
ownSave.addEventListener("click", () => saveHearing(ownAddress(), ownModel(), serviceKey.value, ownAgreeBox, address, serviceModel));
const testService = element("button", "open", words.service_test);
testService.type = "button";
testService.id = "transcription-test";
Expand Down
Loading