feat(app): M5 step 2, service control and the dashboard data
- control: one Controller starts, stops and restarts the services (stopped, starting, running, stopping, failed); a failed start leaves nothing running and keeps its error with secrets masked. The app binary uses it. - dashboard: built from the core's events alone: the bot's tag, the voice channel, live captions (screen only, cleared on leaving or stopping), the last 20 voice answers split into stages with medians (matched by the new AnswerAsked event), and missed requests without text. - system: memory in use and per NVIDIA GPU its use and VRAM (nvidia-smi). - DiscordCore::voice_members, WorkerClient::hello, the conversation's missed requests shared with the dashboard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,8 @@ 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 },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -318,6 +320,22 @@ impl DiscordCore {
|
||||
|
||||
// --- voice ------------------------------------------------------------------------------------
|
||||
|
||||
/// The people in Jarvis's voice channel that it hears (ID and display name), as reported to the
|
||||
/// worker; empty outside a voice channel.
|
||||
pub fn voice_members(&self) -> Vec<(u64, String)> {
|
||||
let inner = &self.inner;
|
||||
let Some((guild, channel)) = inner.session.lock().unwrap().as_ref().map(|s| (s.guild_id, s.channel_id)) else {
|
||||
return vec![];
|
||||
};
|
||||
let users: Vec<u64> = inner.cache.get()
|
||||
.and_then(|c| c.guild(GuildId::new(guild)).map(|g| g.voice_states.values()
|
||||
.filter(|v| v.channel_id.map(|c| c.get()) == Some(channel))
|
||||
.map(|v| v.user_id.get())
|
||||
.collect()))
|
||||
.unwrap_or_default();
|
||||
users.into_iter().filter(|u| should_hear(inner, *u)).map(|u| (u, name_of(inner, u))).collect()
|
||||
}
|
||||
|
||||
pub fn voice_channel_id(&self) -> Option<u64> {
|
||||
self.inner.session.lock().unwrap().as_ref().map(|s| s.channel_id)
|
||||
}
|
||||
@@ -410,6 +428,7 @@ impl DiscordCore {
|
||||
pub fn answer(&self, user: u64, text: &str) -> 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 });
|
||||
self.inner.worker.reply(&id, user, text, "voice", true);
|
||||
Some(id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user