forked from Blendman974/faceclaw
Wait for final results from Whisper before completing
<details> <summary>Prompts Used</summary> User: This checkout corresponds to https://github.com/jimrandomh/faceclaw/pull/27. Review this branch. GPT-6 Astra: > Found one issue: > > - **[P2] Wait for Whisper’s final result before completing dictation** — [FaceclawVoiceController.java:729](/Users/jbabcock/repositories/g2/faceclaw/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawVoiceController.java:729). Skipping partial decodes leaves short utterances without text until release, but the dialog still finalizes after its existing timeout. If decoding exceeds roughly 2.7 seconds (native stop’s 1.5-second wait plus the dialog’s 1.2-second timeout), auto-send can abandon a short command or send an incomplete longer one. Continue can append the late editing instruction literally instead of refining the message. I reproduced these outcomes with delayed transcript events. These flows should await recognition completion. > > Validation: TypeScript and a clean Android build passed. All 21 test failures also occur on `main`. Actual Whisper latency was not tested on hardware. <hr> User: Thanks, let's fix that issue. GPT-6 Astra: > Fixed. Dictation now waits for native recognition to finish before fallback timers run. Auto-send, Continue, and AI Chat preserve delayed Whisper results; cancellation ignores late transcripts. > > TypeScript and Android builds pass. All 11 new regression tests pass. The full suite still has the same 21 pre-existing failures. </details>
This commit is contained in:
1 parent
91890a25ac
commit
25c398d60f
11 files changed
+385
-28
No files matched your search
+30
-2
@@ -125,7 +125,7 @@ test('synchronous provider errors do not leave a permanently active turn', () =>
|
||||
assert.equal(session.status, 'failed');
|
||||
});
|
||||
|
||||
function draftEnv({ prepare = async () => true, start = async () => {}, initialStatus = 'Ready' } = {}) {
|
||||
function draftEnv({ prepare = async () => true, start = async () => {}, stop = () => {}, initialStatus = 'Ready' } = {}) {
|
||||
const transcripts = new Set(), statuses = new Set(), timers = new Map();
|
||||
const sent = [];
|
||||
let starts = 0, stops = 0, mic = false, timerId = 0;
|
||||
@@ -139,7 +139,7 @@ function draftEnv({ prepare = async () => true, start = async () => {}, initialS
|
||||
setTimeout(cb) { timers.set(++timerId, cb); return timerId; },
|
||||
clearTimeout(id) { timers.delete(id); },
|
||||
});
|
||||
const draft = new VoiceDraft({ startVoiceCapture: async () => { starts++; await start(); }, stopVoiceCapture: () => { stops++; } }, prepare, () => {}, (text) => sent.push(text));
|
||||
const draft = new VoiceDraft({ startVoiceCapture: async () => { starts++; await start(); }, stopVoiceCapture: () => { stops++; return stop(); } }, prepare, () => {}, (text) => sent.push(text));
|
||||
return { draft, sent, starts: () => starts, stops: () => stops, mic: () => mic,
|
||||
transcript(text, isFinal = false) { for (const cb of [...transcripts]) cb({ text, isFinal }); },
|
||||
status(status) { for (const cb of [...statuses]) cb({ status }); },
|
||||
@@ -174,6 +174,34 @@ test('release before permission resolves never starts a microphone', async () =>
|
||||
assert.deepEqual(env.sent, []);
|
||||
});
|
||||
|
||||
test('chat waits past its fallback deadline for native recognition', async () => {
|
||||
let complete;
|
||||
const stopped = new Promise(resolve => { complete = resolve; });
|
||||
const env = draftEnv({ stop: () => stopped });
|
||||
await env.draft.start();
|
||||
env.transcript('first segment');
|
||||
env.draft.release(); env.timeout();
|
||||
assert.deepEqual(env.sent, []);
|
||||
assert.equal(env.draft.phase, 'finishing');
|
||||
env.transcript('first segment and the rest', true);
|
||||
complete(); await stopped; env.timeout();
|
||||
assert.deepEqual(env.sent, ['first segment and the rest']);
|
||||
});
|
||||
|
||||
test('a cancelled chat capture cannot finish a newer capture when native stop resolves', async () => {
|
||||
let complete;
|
||||
const stopped = new Promise(resolve => { complete = resolve; });
|
||||
const env = draftEnv({ stop: () => stopped });
|
||||
await env.draft.start();
|
||||
env.draft.release(); env.draft.cancel();
|
||||
await env.draft.start();
|
||||
env.transcript('new speech');
|
||||
complete(); await stopped; env.timeout();
|
||||
assert.deepEqual(env.sent, []);
|
||||
assert.equal(env.draft.phase, 'listening');
|
||||
env.draft.cancel();
|
||||
});
|
||||
|
||||
test('release during async mic startup stops capture after it starts', async () => {
|
||||
let started;
|
||||
const env = draftEnv({ start: () => new Promise((resolve) => { started = resolve; }) });
|
||||
|
||||
Reference in new issue
Block a user