Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix(host): keep the host running when a phone drops or its log output is gone
leepokaib0c2e8fe4fa1
diff --git a/host/src/main.rs b/host/src/main.rsindex 6e553a0f..d54c93ed 100644--- a/host/src/main.rs+++ b/host/src/main.rs@@ -525,6 +525,9 @@ async fn serve(bind: &str, port: u16) -> Result<()> {.with_env_filter(tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "codync_host=info".into()),)+ // A failed log write would be reported with `eprintln!`, which panics when stderr is gone+ // too (a closed terminal, a full disk): a log line must never take a task down.+ .log_internal_errors(false).init();let (store, host_id, token) = open_store()?;write_token_file(&token)?;diff --git a/host/src/remote/channel.rs b/host/src/remote/channel.rsindex 51522ee6..72d629d4 100644--- a/host/src/remote/channel.rs+++ b/host/src/remote/channel.rs@@ -202,7 +202,10 @@ pub async fn run(hub: Arc<Hub>, t: Transport, kind: ChannelKind) {let _ = ch.tx.send(ToDevice::Close(code, reason)).await;let hub = ch.hub.clone();drop(ch);- let _ = writer.await;+ // `serve` already took the writer's end when it stopped first; polling it again panics.+ if !writer.is_finished() {+ let _ = writer.await;+ }// Only now, with the answer and the `4100` handed to the transport: a relay publishes the// new ACL (offer gone) behind them on the same socket, so the pairing link isn't cut first.if code == close::PAIRED {@@ -625,14 +628,16 @@ mod tests {rx: mpsc::Receiver<Out>,sealer: Option<Sealer>,opener: Option<Opener>,+ /// The host's side of this channel.+ run: tokio::task::JoinHandle<()>,}impl Phone {fn connect(hub: &Arc<Hub>, key: SigningKey, kind: ChannelKind) -> Self {let (tx, incoming) = mpsc::channel(64);let (outgoing, rx) = mpsc::channel(64);- tokio::spawn(run(hub.clone(), Transport { incoming, outgoing }, kind));- Self { key, tx, rx, sealer: None, opener: None }+ let run = tokio::spawn(run(hub.clone(), Transport { incoming, outgoing }, kind));+ Self { key, tx, rx, sealer: None, opener: None, run }}fn direct(hub: &Arc<Hub>, key: SigningKey) -> Self {@@ -950,4 +955,17 @@ mod tests {}assert!(matches!(last, Some(Out::Close(close::PAIRED, _))), "got {last:?}");}++ #[tokio::test]+ async fn a_device_that_stops_reading_ends_the_channel_cleanly() {+ let hub = temp_hub();+ let key = paired_phone(&hub).await;+ let mut p = Phone::direct(&hub, key);+ p.hello(&hub, false).await;+ assert_eq!(p.call(1, "hello", json!({})).await["id"], 1);+ // The transport is gone: the next answer can't be written, so the writer ends first.+ p.rx.close();+ p.send(json!({"id": 2, "m": "hello", "b": {}})).await;+ timeout(Duration::from_secs(5), p.run).await.expect("the channel ends").expect("without a panic");+ }}