forked from kent/consciousness
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:
parent
e7be2a3ba0
commit
8e66f0a66c
4 changed files with 198 additions and 50 deletions
|
|
@ -814,6 +814,17 @@ async fn run(cli: cli::CliArgs) -> Result<()> {
|
|||
let mut idle_state = poc_memory::thalamus::idle::State::new();
|
||||
idle_state.load();
|
||||
|
||||
// Channel status fetcher — async results sent back via mpsc
|
||||
let (channel_tx, mut channel_rx) = tokio::sync::mpsc::channel::<Vec<(String, bool, u32)>>(4);
|
||||
// Kick off initial fetch
|
||||
{
|
||||
let tx = channel_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
let result = poc_memory::thalamus::channels::fetch_all_channels().await;
|
||||
let _ = tx.send(result).await;
|
||||
});
|
||||
}
|
||||
|
||||
// Create UI channel
|
||||
let (ui_tx, mut ui_rx) = ui_channel::channel();
|
||||
|
||||
|
|
@ -940,6 +951,14 @@ async fn run(cli: cli::CliArgs) -> Result<()> {
|
|||
}
|
||||
app.handle_key(key);
|
||||
idle_state.user_activity();
|
||||
// Trigger async channel refresh on F5
|
||||
if app.screen == tui::Screen::Thalamus {
|
||||
let tx = channel_tx.clone();
|
||||
tokio::spawn(async move {
|
||||
let result = poc_memory::thalamus::channels::fetch_all_channels().await;
|
||||
let _ = tx.send(result).await;
|
||||
});
|
||||
}
|
||||
dirty = true;
|
||||
}
|
||||
Some(Ok(Event::Mouse(mouse))) => {
|
||||
|
|
@ -988,6 +1007,12 @@ async fn run(cli: cli::CliArgs) -> Result<()> {
|
|||
dirty = true;
|
||||
}
|
||||
|
||||
// Channel status arrived from async fetch
|
||||
Some(channels) = channel_rx.recv() => {
|
||||
app.set_channel_status(channels);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
// UI messages (lowest priority — processed in bulk during render)
|
||||
Some(msg) = ui_rx.recv() => {
|
||||
app.handle_ui_message(msg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue