docs(voice): document interrupt-latest as a design choice

VoiceSession.play() replaces the currently playing TTS on every new
message instead of queueing it. Without this comment a future reader
(or code review) is likely to file it as a missing-feature bug, but
the absence of a queue is intentional: in a many-user voice channel,
queueing causes a speaker's own message to lag far behind the chat
context. Document the policy at the call site.
This commit is contained in:
Claude Owner
2026-05-26 14:59:43 +09:00
parent 204b813ecc
commit 2002b1cc12

View File

@@ -60,6 +60,13 @@ export class VoiceSession {
}, this.endTimeMs);
}
/**
* 새 TTS가 들어오면 이전 재생을 의도적으로 interrupt한다 (큐잉 없음).
* 다중 사용자 환경에서 모든 메시지를 큐로 쌓으면 자기 발화가 수십 초
* 밀려 채팅 맥락과 어긋나므로, "최신 발화 우선, 앞건 잘림"을 정책으로
* 채택했다. generation 카운터는 같은 메시지에 대해 한 번만 play 되도록
* 보호하는 용도이고, 이전 mp3가 잘리는 동작 자체는 설계 의도이다.
*/
public async play(mp3Buf: Buffer) {
if (this.isSessionEnd) return;
const myGen = ++this.generation;