From a028250541f18b4f3040744be1325214ed5cc832 Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Wed, 7 Oct 2026 19:28:07 +0000 Subject: [PATCH 1/3] Enable instant interrupts by default (#51812) ## What changed Enable `instant_interrupt` by default so new user input can preempt responses and yield foreground code-mode observations. Keep the feature marked as under development and update feature-policy tests to allow this exception. Explicitly disable instant interrupts in core, TUI, and Python SDK tests that depend on responses completing before steering or processing subsequent input. GitOrigin-RevId: a8cab2d6c445bfdbd10b0b2abcf7893d32ee8595 (cherry picked from commit 406b0c44460cf71e90c21c7abe6e581add3a6421) --- .../core/tests/suite/guardian_retained_context.rs | 5 +++++ codex-rs/core/tests/suite/pending_input.rs | 14 +++++++++++++- .../tests/suite/scenarios_guardian_heartbeat.rs | 2 ++ codex-rs/features/src/lib.rs | 2 +- codex-rs/features/src/tests.rs | 6 ++++-- codex-rs/tui/src/app/tests/safety_buffering.rs | 7 +++++++ sdk/python/tests/test_app_server_turn_controls.py | 2 +- 7 files changed, 33 insertions(+), 5 deletions(-) diff --git a/codex-rs/core/tests/suite/guardian_retained_context.rs b/codex-rs/core/tests/suite/guardian_retained_context.rs index 8a4894543c..adc7804806 100644 --- a/codex-rs/core/tests/suite/guardian_retained_context.rs +++ b/codex-rs/core/tests/suite/guardian_retained_context.rs @@ -294,6 +294,11 @@ async fn streamed_question_precedes_reply_across_resume( .with_model("gpt-5.4") .with_history_mode(ThreadHistoryMode::Paginated) .with_config(|config| { + // This fixture retains the question by allowing its response to finish. + config + .features + .disable(Feature::InstantInterrupt) + .expect("disable InstantInterrupt feature"); config.experimental_thread_store = ThreadStoreConfig::Local; }) .build_with_streaming_server(&server) diff --git a/codex-rs/core/tests/suite/pending_input.rs b/codex-rs/core/tests/suite/pending_input.rs index c2e5d10013..e8ae9aa96c 100644 --- a/codex-rs/core/tests/suite/pending_input.rs +++ b/codex-rs/core/tests/suite/pending_input.rs @@ -1964,7 +1964,16 @@ async fn user_input_does_not_preempt_after_reasoning_item() { let (server, _completions) = start_streaming_sse_server(vec![first_chunks, response_completed_chunks("resp-2")]).await; - let codex = build_codex(&server).await; + let codex = test_codex() + .with_config(|config| { + config.update_plan_enabled = true; + config.features.disable(Feature::InstantInterrupt).unwrap(); + }) + .with_model("gpt-5.4") + .build_with_streaming_server(&server) + .await + .expect("build streaming Codex test session") + .codex; submit_user_input(&codex, "first prompt").await; @@ -2390,6 +2399,7 @@ async fn steered_user_input_waits_for_model_continuation_after_mid_turn_compact( let codex = test_codex() .with_model("gpt-5.4") .with_config(|config| { + config.features.disable(Feature::InstantInterrupt).unwrap(); config.model_provider.name = "OpenAI (test)".to_string(); config.model_provider.supports_websockets = false; config.model_auto_compact_token_limit = Some(200); @@ -2475,6 +2485,7 @@ async fn steered_user_input_follows_compact_when_only_the_steer_needs_follow_up( let codex = test_codex() .with_model("gpt-5.4") .with_config(|config| { + config.features.disable(Feature::InstantInterrupt).unwrap(); config.model_provider.name = "OpenAI (test)".to_string(); config.model_provider.supports_websockets = false; config.model_auto_compact_token_limit = Some(200); @@ -2592,6 +2603,7 @@ async fn steered_user_input_waits_when_tool_output_triggers_compact_before_next_ let test = test_codex() .with_model("gpt-5.4") .with_config(|config| { + config.features.disable(Feature::InstantInterrupt).unwrap(); config.model_provider.name = "OpenAI (test)".to_string(); config.model_provider.supports_websockets = false; config.model_auto_compact_token_limit = Some(200); diff --git a/codex-rs/core/tests/suite/scenarios_guardian_heartbeat.rs b/codex-rs/core/tests/suite/scenarios_guardian_heartbeat.rs index b6f8bf894c..3a8a429f51 100644 --- a/codex-rs/core/tests/suite/scenarios_guardian_heartbeat.rs +++ b/codex-rs/core/tests/suite/scenarios_guardian_heartbeat.rs @@ -58,6 +58,8 @@ async fn heartbeat_repetitions_keep_later_human_authorization() -> anyhow::Resul .features .disable(Feature::EnableRequestCompression) .unwrap(); + // Keep the acknowledgement complete before the next heartbeat is processed. + config.features.disable(Feature::InstantInterrupt).unwrap(); config.approvals_reviewer = ApprovalsReviewer::AutoReview; config.permissions.approval_policy = Constrained::allow_any(AskForApproval::OnRequest); config diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs index 44d86eb43f..c68bc3bb74 100644 --- a/codex-rs/features/src/lib.rs +++ b/codex-rs/features/src/lib.rs @@ -1159,7 +1159,7 @@ pub const FEATURES: &[FeatureSpec] = &[ id: Feature::InstantInterrupt, key: "instant_interrupt", stage: Stage::UnderDevelopment, - default_enabled: false, + default_enabled: true, }, FeatureSpec { id: Feature::CodeModeOnly, diff --git a/codex-rs/features/src/tests.rs b/codex-rs/features/src/tests.rs index 30555b50ad..5891dc0c9b 100644 --- a/codex-rs/features/src/tests.rs +++ b/codex-rs/features/src/tests.rs @@ -32,7 +32,8 @@ fn sleep_tool_config_rejects_unknown_mode() { #[test] fn under_development_features_are_disabled_by_default() { for spec in crate::FEATURES { - if matches!(spec.stage, Stage::UnderDevelopment) { + // Instant interrupts are enabled by default while retaining their development stage. + if matches!(spec.stage, Stage::UnderDevelopment) && spec.id != Feature::InstantInterrupt { assert_eq!( spec.default_enabled, false, "feature `{}` is under development and must be disabled by default", @@ -121,7 +122,8 @@ fn codex_apps_mcp_protocol_can_be_enabled_independently_of_generic_mcp() { #[test] fn default_enabled_features_are_stable() { for spec in crate::FEATURES { - if spec.default_enabled { + // Instant interrupts are enabled by default while retaining their development stage. + if spec.default_enabled && spec.id != Feature::InstantInterrupt { assert!( matches!(spec.stage, Stage::Stable | Stage::Removed), "feature `{}` is enabled by default but is not stable/removed ({:?})", diff --git a/codex-rs/tui/src/app/tests/safety_buffering.rs b/codex-rs/tui/src/app/tests/safety_buffering.rs index 1d72fae291..71a8f2b5bb 100644 --- a/codex-rs/tui/src/app/tests/safety_buffering.rs +++ b/codex-rs/tui/src/app/tests/safety_buffering.rs @@ -540,6 +540,12 @@ async fn run_safety_retry( let model_catalog_path = codex_home.path().join("models.json"); std::fs::write(&model_catalog_path, serde_json::to_vec(&model_catalog)?)?; let model_catalog_path = toml::Value::String(model_catalog_path.display().to_string()); + // The committed-steer case counts usage from the response that finishes before steering. + let instant_interrupt_config = if committed_steer.is_some() { + "instant_interrupt = false" + } else { + "" + }; std::fs::write( codex_home.path().join("config.toml"), format!( @@ -557,6 +563,7 @@ stream_max_retries = 0 [features] goals = true +{instant_interrupt_config} "#, server.uri() ), diff --git a/sdk/python/tests/test_app_server_turn_controls.py b/sdk/python/tests/test_app_server_turn_controls.py index dd994b88f9..ba85c79624 100644 --- a/sdk/python/tests/test_app_server_turn_controls.py +++ b/sdk/python/tests/test_app_server_turn_controls.py @@ -20,7 +20,7 @@ def test_turn_steer_adds_follow_up_input(tmp_path) -> None: ) with Codex(config=harness.app_server_config()) as codex: - thread = codex.thread_start() + thread = codex.thread_start(config={"features.instant_interrupt": False}) turn = thread.turn("Start a steerable turn.") harness.responses.wait_for_requests(1) steer = turn.steer("Use this steering input.") From 1a1335eefe734187e3e6b827a99b354356fa5a78 Mon Sep 17 00:00:00 2001 From: pash-openai Date: Wed, 7 Oct 2026 22:38:34 +0000 Subject: [PATCH 2/3] Preserve line breaks and links in multiline async questions (#51866) ## Why Rendering an entire question title as one terminal line removes line endings and misaligns hyperlink source ranges with the visible text. ## What changed Wrap and annotate each logical line of asynchronous question titles separately, preserving blank lines and handling both LF and CRLF endings while retaining complete hyperlink destinations. ## Testing Add a rendering regression test and snapshot covering multiline titles with code fences, Unicode text, and a URL. Check LF and CRLF rendering equivalence and hyperlink destinations at narrow and wide widths. GitOrigin-RevId: ccd7256dbaed91ce98374e52b17d3a1b87645574 (cherry picked from commit eef47199272f4eb456f45d7b795109f8c3029c76) --- .../src/bottom_pane/async_questions/mod.rs | 26 ++++++++----- ..._questions__tests__question_multiline.snap | 19 ++++++++++ .../async_questions/state_tests.rs | 38 +++++++++++++++++++ 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 codex-rs/tui/src/bottom_pane/async_questions/snapshots/codex_tui__bottom_pane__async_questions__tests__question_multiline.snap diff --git a/codex-rs/tui/src/bottom_pane/async_questions/mod.rs b/codex-rs/tui/src/bottom_pane/async_questions/mod.rs index 7753a3a677..de4232ef8f 100644 --- a/codex-rs/tui/src/bottom_pane/async_questions/mod.rs +++ b/codex-rs/tui/src/bottom_pane/async_questions/mod.rs @@ -158,16 +158,24 @@ impl AsyncQuestions { pub(super) fn wrapped_question_lines(&self, width: u16) -> Vec { self.current_question() .map(|q| { - let source = annotate_web_urls_in_line(q.title.clone().into()); - let wrapped = wrap_ranges_trim(&q.title, usize::from(width.max(1))) - .into_iter() - .map(|range| WrappedLine { - line: (&q.title[range.clone()]).into(), - range, - prefix_bytes: 0, + // Line::from removes line endings, so wrap and annotate each logical line + // separately to keep source byte ranges aligned with the visible text. + q.title + .split('\n') + .flat_map(|text| { + let text = text.strip_suffix('\r').unwrap_or(text); + let source = annotate_web_urls_in_line(text.to_owned().into()); + let wrapped = wrap_ranges_trim(text, usize::from(width.max(1))) + .into_iter() + .map(|range| WrappedLine { + line: (&text[range.clone()]).into(), + range, + prefix_bytes: 0, + }) + .collect(); + remap_source_wrapped_line(&source, wrapped) }) - .collect(); - remap_source_wrapped_line(&source, wrapped) + .collect() }) .unwrap_or_default() } diff --git a/codex-rs/tui/src/bottom_pane/async_questions/snapshots/codex_tui__bottom_pane__async_questions__tests__question_multiline.snap b/codex-rs/tui/src/bottom_pane/async_questions/snapshots/codex_tui__bottom_pane__async_questions__tests__question_multiline.snap new file mode 100644 index 0000000000..54cdcd05c7 --- /dev/null +++ b/codex-rs/tui/src/bottom_pane/async_questions/snapshots/codex_tui__bottom_pane__async_questions__tests__question_multiline.snap @@ -0,0 +1,19 @@ +--- +source: tui/src/bottom_pane/async_questions/state_tests.rs +expression: "rendered[0]" +--- + + 1 of 2 + + Run this command: + + ```sh + printf '診 断 ' + ``` + Then review (https://example.com/diagnostics?view=full)? + + + Type your answer + + enter submit ⌃] skip ⇧→ main prompt + ⇧← next question diff --git a/codex-rs/tui/src/bottom_pane/async_questions/state_tests.rs b/codex-rs/tui/src/bottom_pane/async_questions/state_tests.rs index 1345dd543f..713ac5194a 100644 --- a/codex-rs/tui/src/bottom_pane/async_questions/state_tests.rs +++ b/codex-rs/tui/src/bottom_pane/async_questions/state_tests.rs @@ -180,6 +180,44 @@ fn wrapped_question_url_keeps_its_complete_destination() { } } +#[test] +fn multiline_question_preserves_line_breaks_and_link_destinations() { + let url = "https://example.com/diagnostics?view=full"; + let title = format!("Run this command:\n\n```sh\nprintf '診断'\n```\nThen review ({url})?\n"); + let mut rendered = Vec::new(); + for line_ending in ["\n", "\r\n"] { + let mut editor = editor(); + editor.state.pending[0].question.title = title.replace('\n', line_ending); + + for width in [20, 60] { + let height = editor.desired_height(width); + let buffer = render_editor(&editor, width, height); + let linked_text = buffer + .content + .iter() + .filter_map(|cell| { + let symbol = cell.symbol(); + symbol.contains("\x1b]8;;").then(|| { + let text = crate::terminal_hyperlinks::strip_osc8(symbol); + assert_eq!( + symbol, + crate::terminal_hyperlinks::osc8_hyperlink(url, &text) + ); + text + }) + }) + .collect::(); + assert_eq!(linked_text, url); + let text = crate::terminal_hyperlinks::strip_osc8(&buffer_text(&buffer)); + if width == 60 { + rendered.push(text); + } + } + } + assert_eq!(rendered[0], rendered[1]); + insta::assert_snapshot!("question_multiline", rendered[0]); +} + #[test] fn selected_other_renders_as_a_dim_placeholder() { let mut editor = editor(); From f715d50688d35b998fb90eb30d3bd8f026cc865b Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 9 Oct 2026 17:05:23 +0000 Subject: [PATCH 3/3] Limit daemon feature compatibility checks to explicit CLI overrides (#52648) ## Why A running shared background server owns its feature settings until it restarts. Differences from a client's configuration files or defaults should not trigger a compatibility warning or a restart request. ## What changed - Check shared-service features only when explicitly overridden on the command line. - Exclude overrides superseded by active legacy managed configuration or feature requirements, while supporting older servers without `configRequirements/read`. - Pass only the remaining explicit feature overrides to a requested daemon restart. ## Testing Update compatibility tests for stale daemon overrides, explicit enable/disable requests, managed configuration, and older servers. Extend CLI startup tests to verify the feature overrides persisted after a restart. GitOrigin-RevId: ac92c9c02cd70fa233203ebef1182fd119325dd1 (cherry picked from commit d3f9b22b745602cb6b46e436e0ed8302a40c1fdf) --- codex-rs/cli/tests/daemon_startup.rs | 11 +++ codex-rs/tui/src/daemon_recovery.rs | 13 ++- codex-rs/tui/src/daemon_startup.rs | 87 ++++++++++++++----- codex-rs/tui/src/daemon_startup_tests.rs | 64 ++++++++++---- codex-rs/tui/src/startup_orchestration.rs | 1 + .../tui/tests/suite/daemon_compatibility.rs | 49 +++++------ 6 files changed, 153 insertions(+), 72 deletions(-) diff --git a/codex-rs/cli/tests/daemon_startup.rs b/codex-rs/cli/tests/daemon_startup.rs index e55abb9164..12bcba2bcf 100644 --- a/codex-rs/cli/tests/daemon_startup.rs +++ b/codex-rs/cli/tests/daemon_startup.rs @@ -364,6 +364,17 @@ async fn daemon_startup(command: &str) -> Result<()> { ensure!(text.contains("Cannotusethesharedbackgroundserver:Thissessionrequiresapi_key_model_discoverytobedisabled.")); } else { ensure!(text.contains("Server:Localbackgroundserver") == restart); + if restart { + let settings: serde_json::Value = serde_json::from_slice( + &fs::read(home.path().join("app-server-daemon/settings.json"))? + )?; + let flag = if disabling && !persisted { + "auth_elicitation" + } else { + "api_key_model_discovery" + }; + assert_eq!(settings["featureOverrides"], serde_json::json!({(flag): false})); + } } } else if command == "start" { ensure!(text.contains("Server:Localbackgroundserver")); diff --git a/codex-rs/tui/src/daemon_recovery.rs b/codex-rs/tui/src/daemon_recovery.rs index 2c9959201e..0dd9808bfb 100644 --- a/codex-rs/tui/src/daemon_recovery.rs +++ b/codex-rs/tui/src/daemon_recovery.rs @@ -31,10 +31,15 @@ pub(super) async fn check( startup: &mut StartupDraft, target: &AppServerTarget, config: &Config, + cli_kv_overrides: &[(String, toml::Value)], managed_daemon: bool, ) -> io::Result> { let issue = match startup - .run_until(daemon_startup::compatibility_warning(target, config)) + .run_until(daemon_startup::compatibility_warning( + target, + config, + cli_kv_overrides, + )) .await? { Ok(warning) => return Ok(warning), @@ -104,7 +109,11 @@ pub(super) async fn check( }) .await?; startup - .run_until(daemon_startup::compatibility_warning(target, config)) + .run_until(daemon_startup::compatibility_warning( + target, + config, + cli_kv_overrides, + )) .await? .map_err(io::Error::other) } diff --git a/codex-rs/tui/src/daemon_startup.rs b/codex-rs/tui/src/daemon_startup.rs index 6476c94c7b..91c38d7837 100644 --- a/codex-rs/tui/src/daemon_startup.rs +++ b/codex-rs/tui/src/daemon_startup.rs @@ -5,6 +5,10 @@ //! Windows sessions use explicit embedded behavior before discovery or startup. use super::*; +use codex_app_server_client::TypedRequestError; +use codex_app_server_protocol::ClientRequest; +use codex_app_server_protocol::ConfigRequirementsReadResponse; +use codex_app_server_protocol::RequestId; use std::collections::BTreeMap; const SERVER_FEATURES: [Feature; 4] = [ @@ -155,6 +159,7 @@ pub(super) fn server_features(overrides: &[(String, toml::Value)]) -> BTreeMap Result, CompatibilityError> { let AppServerTarget::LocalDaemon { allow_embedded_fallback, @@ -165,15 +170,61 @@ pub(super) async fn compatibility_warning( }; let mut restart_features = None; let check = async { - // The feature-list RPC cannot report this process-scoped structured setting. - if !config.features.enabled(Feature::CodeModeHost) - && config.code_mode.disable_in_process_fallback - { - return Err("code-mode host fallback policy requires embedded mode".to_string()); - } let client = app_server_connection::connect(target) .await .map_err(|_| "could not connect to check daemon feature settings".to_string())?; + // File settings and defaults belong to the daemon until it restarts. + // Only explicit invocation flags can request a shared-service restart. + let mut requested = server_features(cli_kv_overrides); + if requested.is_empty() { + let _ = client.shutdown().await; + return Ok(()); + } + // Both legacy managed config and current requirements override CLI flags. + let layers = crate::config_update::read_effective_config_if_supported( + client.request_handle(), + config.cwd.as_path(), + ) + .await + .map_err(|_| "could not read daemon configuration".to_string())? + .and_then(|config| config.layers) + .unwrap_or_default(); + for layer in layers.iter().filter(|layer| { + layer["disabledReason"].is_null() + && matches!( + layer["name"]["type"].as_str(), + Some("legacyManagedConfigTomlFromFile" | "legacyManagedConfigTomlFromMdm") + ) + }) { + requested.retain(|name, _| layer["config"]["features"].get(name).is_none()); + } + match client + .request_handle() + .request_typed::( + ClientRequest::ConfigRequirementsRead { + request_id: RequestId::String("tui-daemon-requirements".to_string()), + params: None, + }, + ) + .await + { + Ok(response) => { + if let Some(required) = response.requirements.and_then(|r| r.feature_requirements) { + requested.retain(|name, _| !required.contains_key(name)); + } + } + Err(TypedRequestError::Server { source, .. }) + if source.code == -32601 + || source.code == -32600 + && source.message.contains("configRequirements/read") + && (source.message.contains("unknown variant") + || source.message.contains("unknown method")) => {} + Err(_) => return Err("could not check daemon configuration requirements".to_string()), + } + if requested.is_empty() { + let _ = client.shutdown().await; + return Ok(()); + } let (tx, rx) = tokio::sync::oneshot::channel(); crate::experimental_features::fetch( client.request_handle(), @@ -184,27 +235,17 @@ pub(super) async fn compatibility_warning( let result = rx.await; let _ = client.shutdown().await; let features = result.map_err(|_| "daemon feature check was interrupted".to_string())??; - // A previous client may have launched this daemon with overrides, even if - // this client has none. Check effective values, including defaults. - for feature in SERVER_FEATURES { - let name = feature.key(); - let enabled = config.features.enabled(feature); + for (name, enabled) in &requested { if features .iter() - .find(|feature| feature.name == name) + .find(|feature| feature.name == *name) .is_some_and(|feature| feature.enabled) - != enabled + != *enabled { - restart_features = Some( - SERVER_FEATURES - .into_iter() - .map(|feature| { - (feature.key().to_string(), config.features.enabled(feature)) - }) - .collect(), - ); - let state = if enabled { "enabled" } else { "disabled" }; - return Err(format!("This session requires {name} to be {state}")); + let state = if *enabled { "enabled" } else { "disabled" }; + let reason = format!("This session requires {name} to be {state}"); + restart_features = Some(requested); + return Err(reason); } } Ok::<(), String>(()) diff --git a/codex-rs/tui/src/daemon_startup_tests.rs b/codex-rs/tui/src/daemon_startup_tests.rs index 93f169f037..2a6a2eaf1f 100644 --- a/codex-rs/tui/src/daemon_startup_tests.rs +++ b/codex-rs/tui/src/daemon_startup_tests.rs @@ -152,6 +152,10 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment( "matching", "stale overrides", "conflicting client", + "explicit enable", + "managed", + "legacy managed", + "old requirements server", "unsupported RPC", ] { let home = TempDir::new()?; @@ -161,19 +165,21 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment( .build() .await?; config.features.enable(Feature::ApiKeyModelDiscovery)?; - if scenario == "conflicting client" { - config.features.disable(Feature::ApiKeyModelDiscovery)?; - } + let cli_overrides = match scenario { + "matching" | "stale overrides" => Vec::new(), + _ => vec![( + "features.api_key_model_discovery".to_string(), + toml::Value::Boolean(scenario == "explicit enable"), + )], + }; let features = [ Feature::ApiKeyModelDiscovery, Feature::CodeModeHost, Feature::AuthElicitation, Feature::McpOAuthRefreshCoordination, ].map(|feature| { - let enabled = if feature == Feature::ApiKeyModelDiscovery && scenario == "stale overrides" { + let enabled = if feature == Feature::ApiKeyModelDiscovery && matches!(scenario, "stale overrides" | "explicit enable") { false - } else if feature == Feature::ApiKeyModelDiscovery && scenario == "conflicting client" { - true } else { config.features.enabled(feature) }; @@ -195,16 +201,34 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment( else { continue; }; - let response = if request.method == "initialize" { - json!({"id": request.id, "result": {"userAgent": "daemon-test"}}) - } else { - assert_eq!(request.method, "experimentalFeature/list"); - assert_eq!(request.params.unwrap()["threadId"], json!(null)); - if scenario == "unsupported RPC" { + let response = match request.method.as_str() { + "initialize" => { + json!({"id": request.id, "result": {"userAgent": "daemon-test"}}) + } + "config/read" => { + json!({"id": request.id, "result": {"config": {}, "layers": [{ + "name": {"type": "legacyManagedConfigTomlFromFile"}, "config": + if scenario == "legacy managed" { + json!({"features": {"api_key_model_discovery": true}}) + } else { json!({}) } + }]}}) + } + "configRequirements/read" if scenario == "old requirements server" => { + json!({"id": request.id, "error": {"code": -32600, "message": "Invalid request: unknown variant `configRequirements/read`"}}) + } + "configRequirements/read" => json!({"id": request.id, "result": { + "requirements": if scenario == "managed" { + json!({"featureRequirements": {"api_key_model_discovery": true}}) + } else { json!(null) } + }}), + "experimentalFeature/list" if scenario == "unsupported RPC" => { json!({"id": request.id, "error": {"code": -32601, "message": "method not found"}}) - } else { + } + "experimentalFeature/list" => { + assert_eq!(request.params.unwrap()["threadId"], json!(null)); json!({"id": request.id, "result": {"data": features, "nextCursor": null}}) } + _ => panic!("unexpected request: {}", request.method), }; socket .send(Message::Text(response.to_string().into())) @@ -212,15 +236,19 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment( .unwrap(); } }); - let result = daemon_startup::compatibility_warning(&target, &config).await; + let result = + daemon_startup::compatibility_warning(&target, &config, &cli_overrides).await; server.await?; - if scenario == "matching" { + if matches!( + scenario, + "matching" | "stale overrides" | "managed" | "legacy managed" + ) { assert_eq!(result?, None); continue; } let reason = match scenario { - "stale overrides" => "This session requires api_key_model_discovery to be enabled", - "conflicting client" => { + "explicit enable" => "This session requires api_key_model_discovery to be enabled", + "conflicting client" | "old requirements server" => { "This session requires api_key_model_discovery to be disabled" } "unsupported RPC" => "Experimental feature request failed", @@ -242,7 +270,7 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment( daemon_startup::FAILURE_HINT ) ); - if scenario == "stale overrides" { + if scenario == "explicit enable" { insta::assert_snapshot!("daemon_feature_mismatch_error", error); } } diff --git a/codex-rs/tui/src/startup_orchestration.rs b/codex-rs/tui/src/startup_orchestration.rs index 87c1c42f54..e09f18a29a 100644 --- a/codex-rs/tui/src/startup_orchestration.rs +++ b/codex-rs/tui/src/startup_orchestration.rs @@ -585,6 +585,7 @@ pub(super) async fn run_main_inner( &mut startup_draft, &app_server_target, &config, + &cli_kv_overrides, managed_daemon, ) .await? diff --git a/codex-rs/tui/tests/suite/daemon_compatibility.rs b/codex-rs/tui/tests/suite/daemon_compatibility.rs index 4ca27c838c..9a0ca72974 100644 --- a/codex-rs/tui/tests/suite/daemon_compatibility.rs +++ b/codex-rs/tui/tests/suite/daemon_compatibility.rs @@ -8,27 +8,16 @@ use anyhow::ensure; use codex_app_server_protocol::JSONRPCMessage; use futures::SinkExt; use futures::StreamExt; -use pretty_assertions::assert_eq; use serde_json::json; use tokio::net::UnixListener; use tokio_tungstenite::tungstenite::Message; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn incompatible_daemon_falls_back_for_default_and_explicit_features() -> Result<()> { - for scenario in ["default", "explicit", "host policy"] { +async fn incompatible_daemon_falls_back_for_explicit_features() -> Result<()> { + for scenario in ["explicit enable", "explicit disable"] { let cwd = codex_utils_cargo_bin::repo_root()?; let home = tempfile::tempdir_in("/tmp")?; write_test_config(home.path(), &cwd)?; - if scenario == "host policy" { - let path = home.path().join("config.toml"); - let contents = std::fs::read_to_string(&path)?; - std::fs::write( - path, - format!( - "features.code_mode_host = {{enabled=false, disable_in_process_fallback=true}}\n{contents}" - ), - )?; - } let socket = codex_app_server_client::app_server_control_socket_path(home.path())?; std::fs::create_dir_all(socket.parent().unwrap())?; let listener = UnixListener::bind(socket.as_path())?; @@ -43,15 +32,22 @@ async fn incompatible_daemon_falls_back_for_default_and_explicit_features() -> R let JSONRPCMessage::Request(request) = serde_json::from_str(&text)? else { continue; }; - let response = if request.method == "initialize" { - json!({"id": request.id, "result": {"userAgent": "daemon-test/0.0.0"}}) - } else { - assert_eq!(request.method, "experimentalFeature/list"); - json!({"id": request.id, "result": {"data": [{ + let response = match request.method.as_str() { + "initialize" => { + json!({"id": request.id, "result": {"userAgent": "daemon-test/0.0.0"}}) + } + "config/read" => { + json!({"id": request.id, "result": {"config": {}, "layers": []}}) + } + "configRequirements/read" => { + json!({"id": request.id, "result": {"requirements": null}}) + } + "experimentalFeature/list" => json!({"id": request.id, "result": {"data": [{ "name": "api_key_model_discovery", "stage": "stable", "displayName": null, "description": null, "announcement": null, - "enabled": scenario == "explicit", "defaultEnabled": true, - }], "nextCursor": null}}) + "enabled": scenario == "explicit disable", "defaultEnabled": true, + }], "nextCursor": null}}), + _ => panic!("unexpected request: {}", request.method), }; socket .send(Message::Text(response.to_string().into())) @@ -59,25 +55,24 @@ async fn incompatible_daemon_falls_back_for_default_and_explicit_features() -> R } Ok::<_, anyhow::Error>(()) }); - let args = if scenario == "explicit" { + let args = if scenario == "explicit disable" { vec!["-c", "features.api_key_model_discovery=false"] } else { - vec![] + vec!["-c", "features.api_key_model_discovery=true"] }; let mut terminal = PtyCodex::start(&cwd, home, &args)?; terminal.wait_for_startup()?; terminal.wait_for_screen("warning")?; terminal.write_input(b"\x14")?; let (snapshot, warning_end) = match scenario { - "default" => ( + "explicit enable" => ( "daemon_feature_mismatch", "api_key_model_discovery to be enabled.", ), - "explicit" => ( + "explicit disable" => ( "daemon_override_mismatch", "api_key_model_discovery to be disabled.", ), - "host policy" => ("daemon_host_policy_mismatch", "requires embedded mode."), _ => unreachable!(), }; terminal.wait_for_screen(warning_end)?; @@ -94,10 +89,6 @@ async fn incompatible_daemon_falls_back_for_default_and_explicit_features() -> R terminal.write_input(b"\r")?; terminal.wait_for_screen("Model:")?; ensure!(!terminal.screen_contains("unix://")); - if scenario == "host policy" { - server.abort(); - continue; - } tokio::time::timeout(std::time::Duration::from_secs(/*secs*/ 5), server).await???; } Ok(())