{"record":{"id":"c87e8be1996fd424","repo":"Hmbown/CodeWhale","slug":"the-per-session-control-socket-is-unix-only","errorCode":null,"errorMessage":"the per-session control socket is unix-only","messagePattern":"the per-session control socket is unix-only","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tui/control_socket.rs","lineNumber":658,"sourceCode":"    let thread_stop = Arc::clone(&stop);\n    let thread = thread::Builder::new()\n        .name(format!(\"codewhale-control-{session_id}\"))\n        .spawn(move || serve(listener, path, identity, thread_stop, commands_tx, status))?;\n\n    Ok(ControlSocketHandle {\n        stop,\n        thread: Some(thread),\n    })\n}\n\n#[cfg(not(unix))]\npub(crate) fn bind_control_socket(\n    _sessions_dir: &Path,\n    _session_id: &str,\n    _commands_tx: mpsc::Sender<PendingCommand>,\n    _status: Arc<Mutex<StatusSnapshot>>,\n) -> io::Result<ControlSocketHandle> {\n    Err(io::Error::new(\n        io::ErrorKind::Unsupported,\n        \"the per-session control socket is unix-only\",\n    ))\n}\n\n/// Take over the socket path, or refuse when a live server already holds it.\n#[cfg(unix)]\nfn prepare_socket_path(path: &Path) -> io::Result<()> {\n    match fs::symlink_metadata(path) {\n        Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(()),\n        Err(error) => Err(error),\n        Ok(metadata) => {\n            if !metadata.file_type().is_socket() {\n                // A plain file (or directory) in the way: not ours to keep.\n                fs::remove_file(path)?;\n                return Ok(());\n            }\n            match UnixStream::connect(path) {","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/control_socket.rs#L640-L676","documentation":"bind_control_socket is the non-Unix (e.g. Windows) stub of the per-session control socket API. On platforms other than Unix it unconditionally returns ErrorKind::Unsupported with this message — the control socket feature is simply not implemented there.","triggerScenarios":"Calling bind_control_socket on a non-Unix target (the cfg-gated stub at control_socket.rs:658), e.g. building/running the TUI on Windows and trying to start the session control server.","commonSituations":"Running Codewhale on Windows where per-session command sockets were never implemented; cross-platform code paths that assume the socket always binds.","solutions":["Run on a Unix platform (Linux/macOS) if the control socket is required","Guard the caller with a platform check and skip control-socket setup on non-Unix targets","Treat the returned ErrorKind::Unsupported as 'feature unavailable' and degrade gracefully","Implement or request a Windows transport (e.g. named pipes) for the control socket"],"exampleFix":"// before\nlet handle = bind_control_socket(&dir, &id, tx, status)?;\n// after\nlet handle = if cfg!(unix) {\n    Some(bind_control_socket(&dir, &id, tx, status)?)\n} else {\n    None // control socket unsupported on this platform\n};","handlingStrategy":"fallback","validationCode":"let supported = cfg!(unix);\nif !supported {\n    // skip control-socket setup entirely\n}","typeGuard":null,"tryCatchPattern":"match bind_control_socket(&dir, &id, tx, status) {\n    Ok(h) => Some(h),\n    Err(e) if e.kind() == io::ErrorKind::Unsupported => None,\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Gate control-socket feature code behind #[cfg(unix)]","Document platform support for the control socket","Add a cross-platform transport if Windows support is needed","Test the degraded (no-socket) path on CI"],"tags":["platform","unix-only","unsupported","control-socket"],"backgroundTag":"unsupported-platform","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}