fix: a delete question counts as asked only once the answer reached the person

A person's reply stopped counting as "unanswered" as soon as the worker sent
reply_text, so a delete question that could not be spoken (no TTS, a failed
or stopped speech) or that the app could not post still let the next
"응, 지워" confirm the delete.

- Worker: an answer reaches the person on a tts_done neither failed nor
  cancelled (spoken answers), on the app's reply_delivered ok (chat
  answers), or at reply_text (unspoken voice answers). tts_unavailable, a
  failed or cancelled tts_done, reply_delivered ok=false, no report within
  30 s and the session ending all mean it never did: a turn number is
  skipped, so the delete asked in it lapses. A reply sent before the
  previous answer reached them is still not their next turn.
- App: a chat answer reports reply_delivered with whether Discord took the
  post; a late, failed or empty answer reports it was not posted.
- Tests: no TTS, a failed speech, a chat post the app reports failed, and
  no report at all do not delete; a spoken and a posted question do.
  Conversation and worker client tests for the report.
- Specs: voice_worker.spec.md (reply_delivered, when an answer reaches the
  person), discord_core.spec.md, conversation.spec.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 01:39:48 +09:00
parent c328bda699
commit 9e75df266b
9 changed files with 209 additions and 32 deletions

View File

@@ -374,5 +374,11 @@ async fn a_chat_reply_is_not_spoken_and_its_text_comes_back() {
w.send(Message::text(json!({"type": "reply_text", "id": "c1", "text": "", "failed": true}).to_string()));
let e = next_matching(&mut rx, |e| !matches!(e, WorkerEvent::Ready(_))).await;
assert_eq!(e, WorkerEvent::ReplyText { id: "c1".into(), text: String::new(), failed: true });
// Whether the answer was posted goes back, so a question in it counts only once it was seen.
c.reply_delivered("c1", true);
c.reply_delivered("c2", false);
until(|| w.got().len() >= 4).await;
assert_eq!(w.got()[2..], [Got::Json(json!({"type": "reply_delivered", "id": "c1", "ok": true})),
Got::Json(json!({"type": "reply_delivered", "id": "c2", "ok": false}))]);
c.close();
}