wire channel list RPC into consciousness F5 screen

fetch_all_channels() connects to each daemon socket and calls
list() via capnp RPC. Runs on a dedicated thread (capnp uses Rc).
Results sent back via mpsc channel, TUI reads cached state.

Fetched at startup and when switching to F5 thalamus screen.
Also calls ensure_running() to restart dead daemons.

Co-Developed-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
ProofOfConcept 2026-04-03 19:53:23 -04:00
parent e7be2a3ba0
commit 8e66f0a66c
4 changed files with 198 additions and 50 deletions

View file

@ -351,7 +351,7 @@ pub struct App {
/// Pane areas from last draw (for mouse click -> pane selection).
pub(crate) pane_areas: [Rect; 3], // [autonomous, conversation, tools]
/// Active screen (F1-F4).
pub(crate) screen: Screen,
pub screen: Screen,
/// Debug screen scroll offset.
pub(crate) debug_scroll: u16,
/// Index of selected context section in debug view (for expand/collapse).
@ -395,7 +395,7 @@ pub(crate) struct ChannelStatus {
/// Screens toggled by F-keys.
#[derive(Debug, Clone, Copy, PartialEq)]
pub(crate) enum Screen {
pub enum Screen {
/// F1 — conversation
Interact,
/// F2 — context window, model info, budget
@ -851,52 +851,11 @@ impl App {
self.draw_main(frame, size);
}
/// Refresh channel status by querying daemon sockets.
/// Called from the status tick, not every render frame.
pub fn refresh_channels(&mut self) {
let channels_dir = dirs::home_dir()
.unwrap_or_default()
.join(".consciousness/channels");
let mut status = Vec::new();
// Read supervisor config to know which daemons exist
let mut sup = crate::thalamus::supervisor::Supervisor::new();
sup.load_config();
for (daemon_name, enabled, alive) in sup.status() {
if !alive {
status.push(ChannelStatus {
name: daemon_name,
connected: false,
unread: 0,
});
continue;
}
// Try to connect and call list()
let sock = channels_dir.join(format!("{}.sock", daemon_name));
match std::os::unix::net::UnixStream::connect(&sock) {
Ok(_stream) => {
// For now, just show the daemon as connected
// TODO: actual capnp list() call
status.push(ChannelStatus {
name: daemon_name,
connected: true,
unread: 0,
});
}
Err(_) => {
status.push(ChannelStatus {
name: daemon_name,
connected: false,
unread: 0,
});
}
}
}
self.channel_status = status;
/// Update channel status from async fetch results.
pub fn set_channel_status(&mut self, channels: Vec<(String, bool, u32)>) {
self.channel_status = channels.into_iter()
.map(|(name, connected, unread)| ChannelStatus { name, connected, unread })
.collect();
}
/// Snapshot idle state for F5 display.
@ -916,8 +875,8 @@ impl App {
self.debug_scroll = 0;
// Refresh data for status screens on entry
match screen {
Screen::Thalamus => self.refresh_channels(),
// idle_info is updated from the event loop, not here
// Channel refresh triggered asynchronously from event loop
Screen::Thalamus => {}
_ => {}
}
}