fix(app): a transcript belongs to the voice session its utterance started in

Each Joined carries a new session number; the core records, when an
utterance's speech_start arrives, the session Jarvis is in, and its Partial
and Final carry that number (Heard.session) even when they arrive after a
leave or a move. The dashboard shows only the current session's captions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 14:00:21 +09:00
parent 371e87f553
commit e8ddde5be6
6 changed files with 129 additions and 25 deletions

View File

@@ -314,8 +314,8 @@ mod tests {
c.start().await.unwrap();
let old = host.events.lock().unwrap().clone().unwrap();
// Queued right before the stop, never handled before it.
old.send(CoreEvent::Joined { guild_id: 1, channel_id: 77 }).unwrap();
old.send(CoreEvent::Partial(crate::discord::Heard { speaker_id: 11, speaker_name: "민수".into(), utt: 1 },
old.send(CoreEvent::Joined { guild_id: 1, channel_id: 77, session: 1 }).unwrap();
old.send(CoreEvent::Partial(crate::discord::Heard { speaker_id: 11, speaker_name: "민수".into(), utt: 1, session: Some(1) },
"자비스".into())).unwrap();
c.stop().await.unwrap();
tokio::time::sleep(Duration::from_millis(30)).await;
@@ -324,7 +324,7 @@ mod tests {
(json!("stopped"), Value::Null, json!([])));
// After a new start, the earlier run's sender still reaches nothing.
c.start().await.unwrap();
let _ = old.send(CoreEvent::Joined { guild_id: 1, channel_id: 78 });
let _ = old.send(CoreEvent::Joined { guild_id: 1, channel_id: 78, session: 2 });
tokio::time::sleep(Duration::from_millis(30)).await;
assert_eq!(c.snapshot().await["voiceChannel"], Value::Null);
}
@@ -335,8 +335,8 @@ mod tests {
c.start().await.unwrap();
let tx = host.events.lock().unwrap().clone().unwrap();
tx.send(CoreEvent::Ready { user_id: 1, tag: "Jarvis#0001".into() }).unwrap();
tx.send(CoreEvent::Joined { guild_id: 1, channel_id: 77 }).unwrap();
tx.send(CoreEvent::Partial(crate::discord::Heard { speaker_id: 11, speaker_name: "민수".into(), utt: 1 },
tx.send(CoreEvent::Joined { guild_id: 1, channel_id: 77, session: 1 }).unwrap();
tx.send(CoreEvent::Partial(crate::discord::Heard { speaker_id: 11, speaker_name: "민수".into(), utt: 1, session: Some(1) },
"자비스 안녕".into())).unwrap();
tokio::time::sleep(Duration::from_millis(50)).await;
let s = c.snapshot().await;