fix(autopilot): honor allowUserBargeIn during the greeting and the idle message

The greeting and announcingIdleTimeout states accepted SPEECH_START
unconditionally, so the caller cut the first message and the idle prompt
short even with allowUserBargeIn set to false, unlike processingUserRequest
and waitingForSpeechTimeout which already guard that event.

Guarding the event alone would drop the utterance: idle only listens for
SPEECH_START, so speech produced while the assistant was talking would
never be processed. Both playing states now buffer SPEECH_RESULT without
stopping playback and hand it to waitingForSpeechTimeout when the message
finishes, and idle accepts a SPEECH_RESULT that lands right after playback
ended.

Closes #891
This commit is contained in:
dualfroz committed 2026-09-11 23:06:26 +02:00
1 parent 69e3ce7154
commit affe71f68c
3 files changed
+332 -12

No files matched your search

+6 -2
View File
@@ -307,8 +307,10 @@ describe("@autopilot/machine", function () {
const actor = createActor(machine, { input });
// Act: get to processingUserRequest
// Act: get to processingUserRequest. With barge-in off the greeting cannot
// be cut short, so wait for it to finish before speaking.
actor.start();
await waitFor(4600);
actor.send({ type: "SPEECH_START" });
await waitFor(50);
actor.send({ type: "SPEECH_RESULT", speech: "Hello", responseTime: 1000 });
@@ -341,8 +343,10 @@ describe("@autopilot/machine", function () {
const actor = createActor(machine, { input });
// Act: get to processingUserRequest
// Act: get to processingUserRequest. With barge-in off the greeting cannot
// be cut short, so wait for it to finish before speaking.
actor.start();
await waitFor(4600);
actor.send({ type: "SPEECH_START" });
await waitFor(50);
actor.send({ type: "SPEECH_RESULT", speech: "Hello?", responseTime: 1000 });