Support the app-server daemon on Windows (#42405)

## Why

The managed app-server daemon and automatic TUI attachment were limited to
Unix, so Windows users could not share a background server across Codex
sessions.

## What changed

- Enable daemon lifecycle commands, `codex agents` startup, and AF_UNIX daemon
  discovery on Windows.
- Require Windows daemons to start non-elevated and verify the discovered
  socket directory and peer before connecting.
- Preflight detached process support, preserve path-based environment settings,
  and keep daemon processes out of the launching project's working directory.
- Fall back to an embedded server when an implicitly discovered daemon cannot
  connect, while preserving errors for explicit remote endpoints and bypassing
  daemon reuse when `CODEX_EXEC_SERVER_URL` is set.

## Testing

Add coverage for Windows launch restrictions and socket validation, implicit
connection fallback, executor selection, daemon discovery, and the agents
dashboard startup result.

GitOrigin-RevId: e7fd63cf8690bcca8b5155266416f31f2f792aa2
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-03 01:26:35 +00:00
1 parent deb1471166
commit b7f710273e
25 files changed
+659 -92

No files matched your search

+17 -7
View File
@@ -56,14 +56,14 @@ impl App {
subtitle: Some(
if workload_identity_selected {
"The agents dashboard is unavailable while workload identity is active."
} else if cfg!(unix) {
} else if cfg!(any(unix, windows)) {
"This session isn’t connected to a shared background server."
} else {
"Connect to a remote background server to use the agents dashboard."
}
.to_string(),
),
footer_note: (cfg!(unix) && !workload_identity_selected).then(|| {
footer_note: (cfg!(any(unix, windows)) && !workload_identity_selected).then(|| {
Line::from(
"Starting a background server will not interrupt or move this session."
.dim(),
@@ -71,7 +71,7 @@ impl App {
}),
footer_hint: Some(standard_popup_hint_line_for_keymap(&self.keymap.list)),
items: [
#[cfg(unix)]
#[cfg(any(unix, windows))]
(!workload_identity_selected).then(|| SelectionItem {
name: "Start background server".to_string(),
description: Some(
@@ -737,7 +737,7 @@ impl App {
}
}
#[cfg(unix)]
#[cfg(any(unix, windows))]
pub(super) fn start_agents_daemon(&self) {
let app_event_tx = self.app_event_tx.clone();
tokio::spawn(async move {
@@ -746,9 +746,19 @@ impl App {
std::env::current_exe().map_err(|error| error.to_string())?;
let executable = if current_executable
.file_stem()
.is_some_and(|name| name == "codex-tui")
{
current_executable.with_file_name("codex")
.and_then(std::ffi::OsStr::to_str)
.is_some_and(|name| {
if cfg!(windows) {
name.eq_ignore_ascii_case("codex-tui")
} else {
name == "codex-tui"
}
}) {
current_executable.with_file_name(if cfg!(windows) {
"codex.exe"
} else {
"codex"
})
} else {
current_executable
};