Support cancellation and deadlines for realtime attachments (#60443)

## Why

A pending realtime connection handshake can hold up subsequent attachment requests. Callers need to cancel obsolete attempts or limit how long they may take to establish a connection.

## What changed

- Add `RealtimeAttachmentOptions` with an optional cancellation receiver and `start_before` deadline to `Op::RealtimeConversationAttach`.
- Interrupt pending connection work and finish cleanup before acknowledging cancellation. Reject cancelled or expired requests before replacing an existing conversation, and recheck cancellation and the deadline before publishing a connection.
- Preserve a successfully published connection when cancellation arrives later. Dropping a cancellation sender whose value is `false` lets the attempt continue.
- Prepare the daemon startup test's socket directory with `codex_uds::prepare_private_socket_directory`.

## Testing

Add integration coverage for cancelling a held handshake, skipping cancelled or expired queued requests, preserving the next usable call, and releasing a pending handshake when its deadline expires without a cancellation receiver.

GitOrigin-RevId: 7144c1237bcbe3b859f10b654d919ae9ff20cbbb
This commit is contained in:
Jenia Varavva
2026-11-09 20:24:40 +00:00
committed by copyberry
parent 6bd17ba6ae
commit 9f04d886f3
8 changed files with 324 additions and 17 deletions
+1
View File
@@ -130,6 +130,7 @@ app_test_support = { workspace = true }
assert_cmd = { workspace = true }
assert_matches = { workspace = true }
codex-app-server-client = { workspace = true }
codex-uds = { workspace = true }
codex-utils-cargo-bin = { workspace = true }
codex-utils-pty = { workspace = true }
core_test_support = { workspace = true }
+2 -1
View File
@@ -259,7 +259,8 @@ async fn daemon_startup(command: &str) -> Result<()> {
fs::hard_link(&codex, &managed)
.or_else(|_| codex_utils_cargo_bin::copy_executable(&codex, &managed))?;
if command != "restrictive-job" {
fs::create_dir(home.path().join("app-server-daemon"))?;
codex_uds::prepare_private_socket_directory(&home.path().join("app-server-daemon"))
.await?;
fs::write(
home.path().join("app-server-daemon/settings.json"),
if persisted {