mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-18 20:29:33 +01:00
fix(voice): 30 s and Manual outlast silent Web Speech runs
_onWebSpeechEnd counted every run that ended without a result toward the two-retry cap, however long the run lasted. Under 30 s or Manual, each no-speech window of the engine is one silent run, so the third ended the recording at about 18 s of silence, before the deadline, and Manual stopped on its own. Both recognition.start() sites now stamp the run start; an empty run counts toward the cap only when it ended within a second of starting (a recognizer that cannot listen), and any other run resets it. The 250 ms backoff is unchanged. The vm harness in test/voice-silence-timeout.test.ts now passes the test's Date into the context, whose own Date ignores fake timers. Also from review: the VoiceInput stubs of the four settings-ui.js tests carry SILENCE_TIMEOUT_SECONDS; Settings-Reference lists Stop after silence; the touchscreen Linux fallback leaves out ChromeOS and says a touch Linux laptop still matches; the dead _webSpeechStream teardown is gone; the two voice tests use vitest expect instead of node:assert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d7cd46565
commit
308de1fd4d
11 files changed
+139
-98
No files matched your search
@@ -1,8 +1,7 @@
|
||||
// Real Chromium rendering/input; native Android/Windows recognition is simulated.
|
||||
import { readFileSync } from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { chromium, type Browser } from 'playwright';
|
||||
import { beforeAll, afterAll, it } from 'vitest';
|
||||
import { afterAll, beforeAll, expect, it } from 'vitest';
|
||||
const source = readFileSync(new URL('../src/web/public/voice-input.js', import.meta.url), 'utf8');
|
||||
const styles = readFileSync(new URL('../src/web/public/styles.css', import.meta.url), 'utf8');
|
||||
let browser: Browser;
|
||||
@@ -46,7 +45,7 @@ it.each([
|
||||
`\nwindow.voice=VoiceInput;VoiceInput._getDeepgramConfig=()=>({provider:'webspeech',insertMode:'compose',silenceTimeout:0});document.getElementById('mic').onclick=()=>VoiceInput.toggle();`,
|
||||
});
|
||||
await page.click('#mic');
|
||||
assert.equal(await page.evaluate(() => (window as any).voice.recognition.continuous), platform === 'Windows');
|
||||
expect(await page.evaluate(() => (window as any).voice.recognition.continuous)).toBe(platform === 'Windows');
|
||||
await page.evaluate(() => (window as any).voice.recognition.onsoundstart());
|
||||
await page.waitForFunction(() => document.querySelectorAll('.voice-level-bar.active').length > 0);
|
||||
const counts = new Set();
|
||||
@@ -54,7 +53,7 @@ it.each([
|
||||
await page.waitForTimeout(90);
|
||||
counts.add(await page.locator('.voice-level-bar.active').count());
|
||||
}
|
||||
assert.ok(counts.size > 1, 'speech bars must animate');
|
||||
expect(counts.size, 'speech bars must animate').toBeGreaterThan(1);
|
||||
await page.evaluate(() => (window as any).voice.recognition.onsoundend());
|
||||
await page.waitForFunction(() => document.querySelectorAll('.voice-level-bar.active').length === 0);
|
||||
await page.evaluate(() => {
|
||||
@@ -63,13 +62,10 @@ it.each([
|
||||
voice.recognition.partial(text);
|
||||
voice.recognition.final('one two three four five');
|
||||
});
|
||||
assert.equal(
|
||||
await page.evaluate(() => (window as any).voice._previewTextNode.textContent),
|
||||
'one two three four five'
|
||||
);
|
||||
expect(await page.evaluate(() => (window as any).voice._previewTextNode.textContent)).toBe('one two three four five');
|
||||
await page.click('#mic');
|
||||
await page.waitForFunction(() => document.querySelector('textarea')?.value === 'one two three four five');
|
||||
assert.equal(await page.evaluate(() => (window as any).voice.isRecording), false);
|
||||
expect(await page.evaluate(() => (window as any).voice.isRecording)).toBe(false);
|
||||
await page.click('#mic');
|
||||
await page.evaluate(() => {
|
||||
const voice = (window as any).voice;
|
||||
@@ -79,7 +75,7 @@ it.each([
|
||||
});
|
||||
await page.click('#mic');
|
||||
await page.waitForFunction(() => document.querySelector('textarea')?.value === 'go go go go');
|
||||
assert.equal(await page.evaluate(() => (window as any).micRequests), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
expect(await page.evaluate(() => (window as any).micRequests)).toBe(0);
|
||||
expect(errors).toEqual([]);
|
||||
await page.close();
|
||||
});
|
||||
Reference in new issue
Block a user