Skip to content

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.

fix: stop the Windows app hanging on "Starting the host…"

leepokai83418215358e
diff --git a/apps/desktop/src/main/host-controller.ts b/apps/desktop/src/main/host-controller.ts
index 68bb4a13..c3cc6508 100644
--- a/apps/desktop/src/main/host-controller.ts
+++ b/apps/desktop/src/main/host-controller.ts
@@ -40,9 +40,10 @@ export async function fetchHealth(url = baseURL, timeoutMs = 2000): Promise<Heal
export function run(bin: string, args: string[]): Promise<{ status: number; output: string }> {
return new Promise((resolve) => {
- execFile(bin, args, { maxBuffer: 8 * 1024 * 1024, windowsHide: true }, (error, stdout, stderr) => {
+ // A command that never finishes would leave the window on "Starting the host…" for good.
+ execFile(bin, args, { maxBuffer: 8 * 1024 * 1024, windowsHide: true, timeout: 120_000 }, (error, stdout, stderr) => {
const status = error ? (typeof error.code === 'number' ? error.code : 1) : 0
- resolve({ status, output: `${stdout}${stderr}`.trim() })
+ resolve({ status, output: `${stdout}${stderr}`.trim() || (error?.killed ? `codync-host ${args[0]} didn't finish within 2 minutes.` : '') })
})
})
}
diff --git a/docs/architecture/desktop-app.md b/docs/architecture/desktop-app.md
index f7b72ce6..9b91d121 100644
--- a/docs/architecture/desktop-app.md
+++ b/docs/architecture/desktop-app.md
@@ -76,7 +76,8 @@ The TUI connects to one host at a time, so it keeps its single roster.
`codync-host.exe` and `codync-hostw.exe` in `resources/`. `codync-host install` writes the
per-user Run key (`HKCU\…\Run\CodyncHost`), which starts `codync-hostw.exe` at sign-in: a
windowless launcher that runs the host with a hidden console (the agents share it, so none
- opens a window) and restarts it when it exits. App updates stop the host first, as on macOS.
+ opens a window) and restarts it when it exits. One launcher runs per data folder (a second one,
+ say from the Run key and the app at once, exits). App updates stop the host first, as on macOS.
Agents start through `cmd /c` (`host/src/shell.rs`), setup terminals use ConPTY
(`portable-pty`), and the vault key lives in Credential Manager. Not on Windows yet: Remote
screen and the `computer` MCP (no screen helper), on-device speech, the Claude Code status
diff --git a/host/src/bin/codync-hostw.rs b/host/src/bin/codync-hostw.rs
index d3116068..eb8e3136 100644
--- a/host/src/bin/codync-hostw.rs
+++ b/host/src/bin/codync-hostw.rs
@@ -22,6 +22,23 @@ fn main() {
let data = std::env::var_os("CODYNC_HOME")
.map(std::path::PathBuf::from)
.or_else(|| dirs::home_dir().map(|h| h.join(environment::Environment::current().data_folder())));
+ // One supervisor per data folder: the Run key and the app can both start one, and the second's
+ // host could only fail on the data folder's lock, forever. It waits a little first, since
+ // `install` starts the new supervisor right after stopping the old one.
+ let lock = data.as_ref().and_then(|d| {
+ std::fs::create_dir_all(d).ok()?;
+ std::fs::OpenOptions::new().create(true).truncate(false).write(true).open(d.join("hostw.lock")).ok()
+ });
+ if let Some(lock) = &lock {
+ let mut tries = 0;
+ while fs2::FileExt::try_lock_exclusive(lock).is_err() {
+ tries += 1;
+ if tries == 20 {
+ return;
+ }
+ std::thread::sleep(Duration::from_millis(500));
+ }
+ }
loop {
let mut command = std::process::Command::new(&host);
command.args(&args).creation_flags(CREATE_NO_WINDOW);
diff --git a/host/src/service/windows.rs b/host/src/service/windows.rs
index a2d28021..0a56532f 100644
--- a/host/src/service/windows.rs
+++ b/host/src/service/windows.rs
@@ -33,7 +33,17 @@ pub fn stop() -> Result<()> {
pub fn start() -> Result<()> {
let (program, args) = configured()?;
- let spawn = |flags| Command::new(&program).args(&args).creation_flags(flags).spawn();
+ // No inherited pipes: the supervisor never exits, and whoever ran `install` (the app) would
+ // wait on them forever.
+ let spawn = |flags| {
+ Command::new(&program)
+ .args(&args)
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .creation_flags(flags)
+ .spawn()
+ };
let detached = DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP;
spawn(detached | CREATE_BREAKAWAY_FROM_JOB)
.or_else(|_| spawn(detached))