F5 thalamus: cached channel status, refresh on entry
Channel status is cached on App and refreshed when switching to F5, not polled every render frame. Shows connected/disconnected status and unread count per channel daemon. Co-Developed-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
48b8ba73d8
commit
36afa90cdb
3 changed files with 89 additions and 22 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// thalamus_screen.rs — F5: attention routing and channel status
|
||||
//
|
||||
// Shows presence/idle/activity status, then channel daemon status.
|
||||
// Shows presence/idle/activity status, then channel status.
|
||||
// Channel data is cached on App and refreshed on screen entry.
|
||||
|
||||
use ratatui::{
|
||||
layout::Rect,
|
||||
|
|
@ -11,7 +12,6 @@ use ratatui::{
|
|||
};
|
||||
|
||||
use super::{App, SCREEN_LEGEND};
|
||||
use crate::thalamus::supervisor::Supervisor;
|
||||
|
||||
fn fetch_daemon_status() -> Vec<String> {
|
||||
std::process::Command::new("poc-daemon")
|
||||
|
|
@ -35,7 +35,7 @@ impl App {
|
|||
let dim = Style::default().fg(Color::DarkGray);
|
||||
let mut lines: Vec<Line> = Vec::new();
|
||||
|
||||
// Presence status first
|
||||
// Presence status
|
||||
let daemon_status = fetch_daemon_status();
|
||||
if !daemon_status.is_empty() {
|
||||
lines.push(Line::styled("── Presence ──", section));
|
||||
|
|
@ -46,36 +46,35 @@ impl App {
|
|||
lines.push(Line::raw(""));
|
||||
}
|
||||
|
||||
// Channel status
|
||||
// Channel status from cached data
|
||||
lines.push(Line::styled("── Channels ──", section));
|
||||
lines.push(Line::raw(""));
|
||||
|
||||
let mut sup = Supervisor::new();
|
||||
sup.load_config();
|
||||
let status = sup.status();
|
||||
|
||||
if status.is_empty() {
|
||||
if self.channel_status.is_empty() {
|
||||
lines.push(Line::styled(" no channels configured", dim));
|
||||
} else {
|
||||
for (name, enabled, alive) in &status {
|
||||
let (symbol, color) = if *alive {
|
||||
for ch in &self.channel_status {
|
||||
let (symbol, color) = if ch.connected {
|
||||
("●", Color::Green)
|
||||
} else if *enabled {
|
||||
} else {
|
||||
("○", Color::Red)
|
||||
} else {
|
||||
("○", Color::DarkGray)
|
||||
};
|
||||
let state = if *alive {
|
||||
"running"
|
||||
} else if *enabled {
|
||||
"stopped"
|
||||
|
||||
let unread_str = if ch.unread > 0 {
|
||||
format!(" ({} unread)", ch.unread)
|
||||
} else {
|
||||
"disabled"
|
||||
String::new()
|
||||
};
|
||||
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::styled(symbol, Style::default().fg(color)),
|
||||
Span::raw(format!(" {:<20} {}", name, state)),
|
||||
Span::raw(format!(" {:<24}", ch.name)),
|
||||
Span::styled(
|
||||
if ch.connected { "connected" } else { "disconnected" },
|
||||
Style::default().fg(color),
|
||||
),
|
||||
Span::styled(unread_str, Style::default().fg(Color::Yellow)),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue