From 33156d9ab39db99dbd65b412ff998f4ffc940b52 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 12 Apr 2026 20:11:34 -0400 Subject: [PATCH] channels: improve tmux state tracking and config persistence tmux channel: - Track connected state per-pane (shows true channel availability) - Persist pane config on add/remove (survives restarts) - Remove cleanup_pipes on exit (unnecessary with persisted config) - Reorder PaneConfig fields for consistency telegram channel: - Use json5 crate for config parsing (matches tmux) Co-Authored-By: Proof of Concept --- channels/telegram/Cargo.toml | 1 + channels/telegram/src/main.rs | 2 +- channels/tmux/Cargo.toml | 2 +- channels/tmux/src/main.rs | 143 +++++++++++++++++++++------------- 4 files changed, 90 insertions(+), 58 deletions(-) diff --git a/channels/telegram/Cargo.toml b/channels/telegram/Cargo.toml index 97c60f0..a6d3a61 100644 --- a/channels/telegram/Cargo.toml +++ b/channels/telegram/Cargo.toml @@ -8,6 +8,7 @@ capnp = "0.25" capnp-rpc = "0.25" dirs = "6" futures = "0.3" +json5 = "1.3" consciousness = { path = "../.." } serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/channels/telegram/src/main.rs b/channels/telegram/src/main.rs index af36cab..d3753f7 100644 --- a/channels/telegram/src/main.rs +++ b/channels/telegram/src/main.rs @@ -40,7 +40,7 @@ fn load_config() -> Config { let config_path = dir.join("telegram.json5"); let text = std::fs::read_to_string(&config_path) .unwrap_or_else(|_| panic!("failed to read {}", config_path.display())); - let mut config: Config = serde_json::from_str(&text) + let mut config: Config = json5::from_str(&text) .unwrap_or_else(|e| panic!("failed to parse {}: {}", config_path.display(), e)); // Read token from secrets file diff --git a/channels/tmux/Cargo.toml b/channels/tmux/Cargo.toml index 6e4c0aa..571b383 100644 --- a/channels/tmux/Cargo.toml +++ b/channels/tmux/Cargo.toml @@ -8,11 +8,11 @@ capnp = "0.25" capnp-rpc = "0.25" dirs = "6" libc = "0.2" -scopeguard = "1" futures = "0.3" json5 = "1.3" consciousness = { path = "../.." } serde = { version = "1", features = ["derive"] } +serde_json = "1" tokio = { version = "1", features = ["full"] } tokio-util = { version = "0.7", features = ["compat"] } log = "0.4" diff --git a/channels/tmux/src/main.rs b/channels/tmux/src/main.rs index 4255671..f49bdc1 100644 --- a/channels/tmux/src/main.rs +++ b/channels/tmux/src/main.rs @@ -24,26 +24,30 @@ use consciousness::thalamus::channel_log::ChannelLog; // ── Config ───────────────────────────────────────────────────── -#[derive(Clone, serde::Deserialize)] +#[derive(Clone, serde::Serialize, serde::Deserialize)] struct PaneConfig { - /// Tmux pane ID, e.g. "0:1.0" - pane_id: String, /// Human-readable label, becomes the channel name "tmux.