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

+42 -1
View File
@@ -606,7 +606,7 @@ async fn shared_overview_shows_only_root_sessions() {
assert!(app.last_rendered_history_tail.is_some());
}
#[cfg(unix)]
#[cfg(any(unix, windows))]
#[tokio::test]
async fn embedded_sessions_offer_to_start_a_background_server_without_migrating() {
let mut app = make_test_app().await;
@@ -625,6 +625,47 @@ async fn embedded_sessions_offer_to_start_a_background_server_without_migrating(
app_server.shutdown().await.expect("shutdown app server");
}
#[cfg(any(unix, windows))]
#[tokio::test]
async fn daemon_start_result_snapshots() -> Result<()> {
let (mut app, mut app_event_rx, _op_rx) =
crate::app::tests::make_test_app_with_channels().await;
let mut app_server =
crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref()).await?;
let mut tui = crate::tui::test_support::make_test_tui()?;
for (name, result) in [
("agents_daemon_started", Ok(())),
(
"agents_daemon_start_failed",
Err("The host does not allow detached processes".to_string()),
),
] {
app.handle_event(
&mut tui,
&mut app_server,
AppEvent::AgentsDaemonStarted { result },
)
.await?;
let cell = match app_event_rx.try_recv()? {
AppEvent::InsertHistoryCell(cell) => cell,
other => panic!("expected daemon result history, got {other:?}"),
};
let rendered = cell
.display_lines(/*width*/ 80)
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>()
.join("\n");
insta::with_settings!({snapshot_path => "../snapshots"}, {
insta::assert_snapshot!(name, rendered);
});
}
app_server.shutdown().await?;
Ok(())
}
#[tokio::test]
async fn filtered_dashboard_actions_use_configured_shortcuts() {
let mut app = make_test_app().await;