fix(app): the dashboard keeps each run's events, each answer's own times, and only its session's captions

- Each start gets a new dashboard; stop ends the event feeding and waits for
  it before forgetting, so queued or earlier-run events never reach the
  screen.
- AnswerAsked carries the request's speech end and final times, so a second
  waiting question does not change the first answer's timing.
- Captions are shown only while Jarvis is in a voice channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 13:55:44 +09:00
parent 0973ad9815
commit 371e87f553
6 changed files with 132 additions and 58 deletions

View File

@@ -76,8 +76,9 @@ pub enum CoreEvent {
/// The voice worker connection ended: finals of utterances in progress will not come, and the
/// restarted worker numbers utterances afresh.
WorkerLost,
/// `answer(user, ..)` queued speech `id` (the dashboard times answers by it).
AnswerAsked { id: String, user: u64 },
/// `answer(user, ..)` queued speech `id` for a request whose speech ended at `ended_at` and whose
/// final arrived at `final_at` (the dashboard times answers by it).
AnswerAsked { id: String, user: u64, ended_at: Instant, final_at: Instant },
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -424,11 +425,13 @@ impl DiscordCore {
/// Have the brain answer `user` and speak it as one request in the queue. The request id (its
/// `SpeakStart` and `SpeakEnd` follow as for `say`), or None when not in a voice channel. It ends as
/// failed when the brain gives no answer.
pub fn answer(&self, user: u64, text: &str) -> Option<String> {
/// failed when the brain gives no answer. `heard`: when the request's speech ended and its final
/// arrived, passed on in `AnswerAsked`.
pub fn answer(&self, user: u64, text: &str, heard: (Instant, Instant)) -> Option<String> {
self.voice_channel_id()?;
let id = with_playback(&self.inner, |p| p.adopt());
let _ = self.inner.events.send(CoreEvent::AnswerAsked { id: id.clone(), user });
let _ = self.inner.events.send(CoreEvent::AnswerAsked { id: id.clone(), user, ended_at: heard.0,
final_at: heard.1 });
self.inner.worker.reply(&id, user, text, "voice", true);
Some(id)
}