mirror of
https://github.com/openai/codex.git
synced 2026-12-05 01:00:54 +00:00
Check daemon feature overrides and prompt for mismatch recovery (#55442)
## Why A fixed feature allowlist excluded other boolean feature overrides from daemon use. Feature mismatches could also silently fall back to embedded mode, while automatic startup could persist enabled overrides without confirmation. ## What changed - Allow boolean feature overrides without a fixed allowlist and compare explicit overrides with the daemon's reported settings. Ignore removed features, treat unreported features as disabled, and include only mismatches in restart settings. - Preserve saved daemon settings during automatic startup. Prompt on feature mismatches even when embedded fallback is allowed, letting users run without the daemon, confirm a managed-daemon restart, or cancel. - Detect managed daemons during recovery, mark available restarts as recommended, and limit the displayed feature list to three entries plus a remaining count. ## Testing Update compatibility tests for mixed overrides, removed and unreported features, unreachable daemons, and required versus optional attachment. Update recovery snapshots and the TUI integration test to exercise explicit embedded-mode selection. GitOrigin-RevId: 9204620f168ff80aaef312c88e681b754908a431
This commit is contained in:
@@ -187,7 +187,7 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
notice.model_migrations.\"gpt-5.6-terra\" = \"gpt-6-sol\"\n\
|
||||
[projects.{}]\ntrust_level = \"{}\"\n",
|
||||
if command == "discovered" {
|
||||
"tui.status_line=[\"model\",\"thread-id\",\"thread-name\"]"
|
||||
"tui.status_line=[\"model\",\"thread-id\",\"thread-name\"]\nfeatures.daemon_auto_start=false"
|
||||
} else {
|
||||
""
|
||||
},
|
||||
|
||||
@@ -193,6 +193,7 @@ chatgpt_base_url = "{}/source/backend-api"
|
||||
analytics.enabled = false
|
||||
check_for_update_on_startup = false
|
||||
features.daemon_auto_start = {}
|
||||
features.mcp_oauth_refresh_coordination = true
|
||||
model_provider = "local"
|
||||
model = "test-model"
|
||||
sandbox_mode = "workspace-write"
|
||||
@@ -307,8 +308,6 @@ trust_level = "trusted"
|
||||
"worktrees".into(),
|
||||
"--no-alt-screen".into(),
|
||||
"-c".into(),
|
||||
"features.mcp_oauth_refresh_coordination=true".into(),
|
||||
"-c".into(),
|
||||
"suppress_unstable_features_warning=true".into(),
|
||||
];
|
||||
let mut owner = None;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Explicit recovery from required-daemon incompatibility. Restart is managed-only,
|
||||
//! Explicit recovery from local-daemon incompatibility. Restart is managed-only,
|
||||
//! requires a fresh confirmation, and is followed by one compatibility check, never a loop.
|
||||
|
||||
use crate::AppServerTarget;
|
||||
@@ -32,7 +32,7 @@ pub(super) async fn check(
|
||||
target: &AppServerTarget,
|
||||
config: &Config,
|
||||
cli_kv_overrides: &[(String, toml::Value)],
|
||||
managed_daemon: bool,
|
||||
mut managed_daemon: bool,
|
||||
) -> io::Result<Option<String>> {
|
||||
let issue = match startup
|
||||
.run_until(daemon_startup::compatibility_warning(
|
||||
@@ -48,6 +48,14 @@ pub(super) async fn check(
|
||||
if !(io::stdin().is_terminal() && io::stdout().is_terminal()) {
|
||||
return Err(io::Error::other(issue));
|
||||
}
|
||||
if !managed_daemon && issue.restart_features.is_some() {
|
||||
managed_daemon = startup
|
||||
.run_until(codex_app_server_daemon::run(
|
||||
codex_app_server_daemon::LifecycleCommand::Version,
|
||||
))
|
||||
.await?
|
||||
.is_ok_and(|status| status.backend.is_some());
|
||||
}
|
||||
startup.flush_pending_events().await?;
|
||||
let keymap = RuntimeKeymap::from_config(&config.tui_keymap).map_err(io::Error::other)?;
|
||||
let mut view = recovery_view(&issue, managed_daemon, &keymap);
|
||||
@@ -133,6 +141,7 @@ fn recovery_view(
|
||||
managed_daemon: bool,
|
||||
keymap: &RuntimeKeymap,
|
||||
) -> ListSelectionView {
|
||||
let can_restart = managed_daemon && issue.restart_features.is_some();
|
||||
let mut header = ColumnRenderable::new();
|
||||
header.push(Line::from(
|
||||
if issue.restart_features.is_some() {
|
||||
@@ -144,15 +153,20 @@ fn recovery_view(
|
||||
));
|
||||
header.push(Paragraph::new(issue.reason.clone()).wrap(Wrap { trim: false }));
|
||||
if let Some(features) = &issue.restart_features {
|
||||
header.push(Line::from(
|
||||
"Restart will use these shared feature settings:",
|
||||
));
|
||||
for (name, enabled) in features {
|
||||
header.push(Line::from(format!(" {name} = {enabled}").dim()));
|
||||
}
|
||||
header.push(Paragraph::new(
|
||||
"These settings persist and can disable functionality for other clients. Restart may interrupt active or queued work."
|
||||
).wrap(Wrap { trim: false }));
|
||||
header.push(Line::from(
|
||||
"Restart will use these shared feature settings:",
|
||||
));
|
||||
let mut remaining = features.iter();
|
||||
for (name, enabled) in remaining.by_ref().take(3) {
|
||||
header.push(Line::from(format!(" {name} = {enabled}").dim()));
|
||||
}
|
||||
let count = remaining.len();
|
||||
if count > 0 {
|
||||
header.push(Line::from(format!(" and {count} more").dim()));
|
||||
}
|
||||
}
|
||||
let (tx, _rx) = unbounded_channel::<AppEvent>();
|
||||
ListSelectionView::new(
|
||||
@@ -166,10 +180,15 @@ fn recovery_view(
|
||||
..Default::default()
|
||||
},
|
||||
SelectionItem {
|
||||
name: "Restart with these settings".to_string(),
|
||||
name: if can_restart {
|
||||
"Restart with these settings (recommended)"
|
||||
} else {
|
||||
"Restart with these settings"
|
||||
}
|
||||
.to_string(),
|
||||
dismiss_on_select: true,
|
||||
require_explicit_confirmation: true,
|
||||
is_disabled: !managed_daemon || issue.restart_features.is_none(),
|
||||
is_disabled: !can_restart,
|
||||
disabled_reason: if !managed_daemon {
|
||||
Some("This server is not managed by Codex.".to_string())
|
||||
} else if issue.restart_features.is_none() {
|
||||
|
||||
@@ -13,6 +13,8 @@ fn daemon_recovery_requires_explicit_restart_and_defaults_to_cancel() {
|
||||
reason: "This session requires api_key_model_discovery to be enabled".to_string(),
|
||||
restart_features: Some(BTreeMap::from([
|
||||
("api_key_model_discovery".to_string(), true),
|
||||
("code_mode_host".to_string(), true),
|
||||
("instant_interrupt".to_string(), true),
|
||||
("mcp_oauth_refresh_coordination".to_string(), false),
|
||||
])),
|
||||
};
|
||||
|
||||
@@ -3,21 +3,17 @@
|
||||
//! require a compatible shared server and a successful connection, except when
|
||||
//! the Windows launcher forbids detaching a missing server. Elevated local
|
||||
//! Windows sessions use explicit embedded behavior before discovery or startup.
|
||||
//! Explicit feature overrides are compared with the daemon's reported
|
||||
//! configuration; removed features are inert, and unreported features are assumed disabled.
|
||||
|
||||
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::ExperimentalFeatureStage;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
const SERVER_FEATURES: [Feature; 4] = [
|
||||
Feature::ApiKeyModelDiscovery,
|
||||
Feature::CodeModeHost,
|
||||
Feature::AuthElicitation,
|
||||
Feature::McpOAuthRefreshCoordination,
|
||||
];
|
||||
|
||||
pub(super) const FAILURE_HINT: &str = "To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).";
|
||||
pub(super) const WSL_DRVFS_EXCLUSION: &str = "a Windows-mounted WSL CODEX_HOME (DrvFS/9p)";
|
||||
|
||||
@@ -108,12 +104,13 @@ pub(super) fn config_exclusion(
|
||||
.is_some_and(toml::Value::is_bool)
|
||||
}),
|
||||
"features" => value.as_table().is_some_and(|features| {
|
||||
!features.is_empty()
|
||||
&& features
|
||||
.iter()
|
||||
.all(|(name, value)| allowed_feature(name) && value.is_bool())
|
||||
!features.is_empty() && features.values().all(toml::Value::is_bool)
|
||||
}),
|
||||
_ => key.strip_prefix("features.").is_some_and(allowed_feature) && value.is_bool(),
|
||||
_ => {
|
||||
key.strip_prefix("features.")
|
||||
.is_some_and(|name| !name.contains('.'))
|
||||
&& value.is_bool()
|
||||
}
|
||||
})
|
||||
{
|
||||
Some("command-line configuration overrides (-c, --enable, --disable, or --search)")
|
||||
@@ -128,35 +125,6 @@ pub(super) fn config_exclusion(
|
||||
}
|
||||
}
|
||||
|
||||
fn allowed_feature(name: &str) -> bool {
|
||||
matches!(
|
||||
name,
|
||||
// Client gates and per-thread settings already forwarded in thread requests.
|
||||
"daemon_auto_start" | "standalone_web_search"
|
||||
| "app_server_websocket_compression"
|
||||
// Shared services and threadless MCP operations need daemon compatibility checks.
|
||||
| "api_key_model_discovery" | "code_mode_host" | "auth_elicitation"
|
||||
| "mcp_oauth_refresh_coordination"
|
||||
// Removed flags still passed by older launch scripts.
|
||||
| "worktrees" | "realtime_conversation"
|
||||
| "remote_models" | "request_rule" | "responses_websockets_v2"
|
||||
| "workspace_owner_usage_nudge" | "tool_search_always_defer_mcp_tools"
|
||||
| "remote_compaction_v2" | "multi_agent_mode"
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn server_features(overrides: &[(String, toml::Value)]) -> BTreeMap<String, bool> {
|
||||
let layer = codex_config::build_cli_overrides_layer(overrides);
|
||||
SERVER_FEATURES
|
||||
.into_iter()
|
||||
.filter_map(|feature| {
|
||||
let name = feature.key();
|
||||
let enabled = layer.get("features")?.get(name)?.as_bool()?;
|
||||
Some((name.to_string(), enabled))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Best-effort configured readback, not a guarantee about startup-captured service state.
|
||||
pub(super) async fn compatibility_warning(
|
||||
target: &AppServerTarget,
|
||||
@@ -170,14 +138,28 @@ pub(super) async fn compatibility_warning(
|
||||
else {
|
||||
return Ok(None);
|
||||
};
|
||||
// File settings and defaults belong to the daemon until it restarts.
|
||||
// Only explicit invocation flags can request a shared-service restart.
|
||||
let mut requested: BTreeMap<_, _> = codex_config::build_cli_overrides_layer(cli_kv_overrides)
|
||||
.get("features")
|
||||
.and_then(toml::Value::as_table)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|(name, value)| {
|
||||
let name = match codex_features::feature_for_key(name) {
|
||||
Some(feature) if feature.stage() == codex_features::Stage::Removed => return None,
|
||||
Some(feature) => feature.key(),
|
||||
None => name,
|
||||
};
|
||||
Some((name.to_string(), value.as_bool()?))
|
||||
})
|
||||
.collect();
|
||||
let mut restart_features = None;
|
||||
let check = async {
|
||||
// Connect even without overrides so startup can recover from an unreachable daemon.
|
||||
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(());
|
||||
@@ -237,25 +219,27 @@ 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())??;
|
||||
for (name, enabled) in &requested {
|
||||
if features
|
||||
.iter()
|
||||
.find(|feature| feature.name == *name)
|
||||
.is_some_and(|feature| feature.enabled)
|
||||
!= *enabled
|
||||
{
|
||||
let state = if *enabled { "enabled" } else { "disabled" };
|
||||
let reason = format!("This session requires {name} to be {state}");
|
||||
restart_features = Some(requested);
|
||||
return Err(reason);
|
||||
requested.retain(|name, enabled| {
|
||||
match features.iter().find(|feature| feature.name == *name) {
|
||||
Some(feature) => {
|
||||
feature.stage != ExperimentalFeatureStage::Removed
|
||||
&& feature.enabled != *enabled
|
||||
}
|
||||
None => *enabled,
|
||||
}
|
||||
});
|
||||
if let Some((name, enabled)) = requested.first_key_value() {
|
||||
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>(())
|
||||
}
|
||||
.await;
|
||||
match check {
|
||||
Ok(()) => Ok(None),
|
||||
Err(reason) if *allow_embedded_fallback => Ok(Some(format!(
|
||||
Err(reason) if *allow_embedded_fallback && restart_features.is_none() => Ok(Some(format!(
|
||||
"Running without the shared background server: {reason}."
|
||||
))),
|
||||
Err(reason) => Err(CompatibilityError {
|
||||
|
||||
@@ -6,25 +6,15 @@ use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn audited_overrides_allow_daemon_without_allowing_arbitrary_config() {
|
||||
fn feature_overrides_allow_daemon_without_allowing_arbitrary_config() {
|
||||
for (raw, eligible) in [
|
||||
("features.app_server_websocket_compression=true", true),
|
||||
("features.app_server_websocket_compression=false", true),
|
||||
("features.worktrees=true", true),
|
||||
("features.worktrees=false", true),
|
||||
("features={worktrees=true}", true),
|
||||
("features.worktrees='true'", false),
|
||||
(
|
||||
"features={worktrees=true,api_key_model_discovery=false}",
|
||||
true,
|
||||
),
|
||||
("features.auth_elicitation=false", true),
|
||||
("features.code_mode_host=false", true),
|
||||
("features.mcp_oauth_refresh_coordination=false", true),
|
||||
("features={worktrees=true,shell_tool=false}", true),
|
||||
("suppress_unstable_features_warning=true", true),
|
||||
("suppress_unstable_features_warning='true'", false),
|
||||
("features={worktrees=true,shell_tool=false}", false),
|
||||
("features.shell_tool=false", false),
|
||||
("features.shell_tool=false", true),
|
||||
("features.worktrees.enabled=true", false),
|
||||
("tui.fullscreen_transcript=true", true),
|
||||
("tui.fullscreen_transcript=false", true),
|
||||
@@ -54,71 +44,6 @@ fn audited_overrides_allow_daemon_without_allowing_arbitrary_config() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn monorepo_wrapper_overrides_are_eligible_and_select_only_server_features() {
|
||||
let overrides = codex_utils_cli::CliConfigOverrides {
|
||||
raw_overrides: [
|
||||
"features.realtime_conversation=true",
|
||||
"features.app_server_websocket_compression=true",
|
||||
"features.worktrees=true",
|
||||
"features.remote_models=true",
|
||||
"features.api_key_model_discovery=true",
|
||||
"features.request_rule=true",
|
||||
"features.auth_elicitation=true",
|
||||
"features.mcp_oauth_refresh_coordination=true",
|
||||
"features.responses_websockets_v2=true",
|
||||
"features.workspace_owner_usage_nudge=true",
|
||||
"features.tool_search_always_defer_mcp_tools=true",
|
||||
"features.remote_compaction_v2=true",
|
||||
"features.standalone_web_search=true",
|
||||
"features.multi_agent_mode=true",
|
||||
"features.code_mode_host=true",
|
||||
"suppress_unstable_features_warning=true",
|
||||
]
|
||||
.map(str::to_string)
|
||||
.to_vec(),
|
||||
}
|
||||
.parse_overrides()
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
daemon_startup::config_exclusion(
|
||||
&overrides,
|
||||
&LoaderOverrides::default(),
|
||||
/*strict_config*/ false,
|
||||
/*bypass_hook_trust*/ false,
|
||||
),
|
||||
None
|
||||
);
|
||||
assert_eq!(
|
||||
daemon_startup::server_features(&overrides),
|
||||
std::collections::BTreeMap::from([
|
||||
("api_key_model_discovery".to_string(), true),
|
||||
("auth_elicitation".to_string(), true),
|
||||
("code_mode_host".to_string(), true),
|
||||
("mcp_oauth_refresh_coordination".to_string(), true),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn daemon_features_follow_cli_table_replacement_and_last_value() {
|
||||
let overrides = codex_utils_cli::CliConfigOverrides {
|
||||
raw_overrides: [
|
||||
"features.api_key_model_discovery=true",
|
||||
"features={code_mode_host=false}",
|
||||
"features.code_mode_host=true",
|
||||
]
|
||||
.map(str::to_string)
|
||||
.to_vec(),
|
||||
}
|
||||
.parse_overrides()
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
daemon_startup::server_features(&overrides),
|
||||
std::collections::BTreeMap::from([("code_mode_host".to_string(), true),])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn daemon_launch_telemetry_records_once_on_connection_or_early_return() {
|
||||
for connected in [false, true] {
|
||||
@@ -151,40 +76,54 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment(
|
||||
for allow_embedded_fallback in [false, true] {
|
||||
for scenario in [
|
||||
"matching",
|
||||
"stale overrides",
|
||||
"unreachable daemon",
|
||||
"conflicting client",
|
||||
"explicit enable",
|
||||
"mixed flags",
|
||||
"missing enabled",
|
||||
"managed",
|
||||
"legacy managed",
|
||||
"old requirements server",
|
||||
"unsupported RPC",
|
||||
] {
|
||||
let cli_overrides = codex_utils_cli::CliConfigOverrides {
|
||||
raw_overrides: match scenario {
|
||||
"matching" => vec![
|
||||
"features.instant_interrupt=true",
|
||||
"features.remote_compaction_v2=true",
|
||||
"features.shell_tool=true",
|
||||
"features.zz_missing=false",
|
||||
],
|
||||
"unreachable daemon" => Vec::new(),
|
||||
"explicit enable" => vec!["features.api_key_model_discovery=true"],
|
||||
"mixed flags" => vec![
|
||||
"features.zz_overridden=true",
|
||||
"features={api_key_model_discovery=false,code_mode_host=false,instant_interrupt=true}",
|
||||
"features.code_mode_host=true",
|
||||
],
|
||||
"missing enabled" => vec!["features.zz_missing=true"],
|
||||
_ => vec!["features.api_key_model_discovery=false"],
|
||||
}
|
||||
.into_iter()
|
||||
.map(str::to_string)
|
||||
.collect(),
|
||||
}
|
||||
.parse_overrides()
|
||||
.unwrap();
|
||||
let home = TempDir::new()?;
|
||||
let mut config = ConfigBuilder::default()
|
||||
let config = ConfigBuilder::default()
|
||||
.codex_home(home.path().to_path_buf())
|
||||
.loader_overrides(LoaderOverrides::without_managed_config_for_tests())
|
||||
.build()
|
||||
.await?;
|
||||
config.features.enable(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 && matches!(scenario, "stale overrides" | "explicit enable") {
|
||||
false
|
||||
} else {
|
||||
config.features.enabled(feature)
|
||||
};
|
||||
json!({"name": feature.key(), "stage": "beta", "enabled": enabled, "defaultEnabled": false})
|
||||
(Feature::ApiKeyModelDiscovery, scenario != "explicit enable", "beta"),
|
||||
(Feature::CodeModeHost, false, "beta"),
|
||||
(Feature::InstantInterrupt, true, "beta"),
|
||||
(Feature::RemoteCompactionV2, false, "stable"),
|
||||
(Feature::ShellTool, false, "removed"),
|
||||
].map(|(feature, enabled, stage)| {
|
||||
json!({"name": feature.key(), "stage": stage, "enabled": enabled, "defaultEnabled": false})
|
||||
});
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?;
|
||||
let target = AppServerTarget::LocalDaemon {
|
||||
@@ -194,6 +133,16 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment(
|
||||
},
|
||||
allow_embedded_fallback,
|
||||
};
|
||||
if cli_overrides.is_empty() {
|
||||
drop(listener);
|
||||
let result =
|
||||
daemon_startup::compatibility_warning(&target, &config, &cli_overrides).await;
|
||||
assert!(matches!(
|
||||
(allow_embedded_fallback, result),
|
||||
(true, Ok(Some(_))) | (false, Err(_))
|
||||
));
|
||||
continue;
|
||||
}
|
||||
let server = tokio::spawn(async move {
|
||||
let (stream, _) = listener.accept().await.unwrap();
|
||||
let mut socket = tokio_tungstenite::accept_async(stream).await.unwrap();
|
||||
@@ -240,30 +189,39 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment(
|
||||
let result =
|
||||
daemon_startup::compatibility_warning(&target, &config, &cli_overrides).await;
|
||||
server.await?;
|
||||
if matches!(
|
||||
scenario,
|
||||
"matching" | "stale overrides" | "managed" | "legacy managed"
|
||||
) {
|
||||
if matches!(scenario, "matching" | "managed" | "legacy managed") {
|
||||
assert_eq!(result?, None);
|
||||
continue;
|
||||
}
|
||||
let reason = match scenario {
|
||||
"explicit enable" => "This session requires api_key_model_discovery to be enabled",
|
||||
"conflicting client" | "old requirements server" => {
|
||||
"conflicting client" | "old requirements server" | "mixed flags" => {
|
||||
"This session requires api_key_model_discovery to be disabled"
|
||||
}
|
||||
"missing enabled" => "This session requires zz_missing to be enabled",
|
||||
"unsupported RPC" => "Experimental feature request failed",
|
||||
_ => unreachable!(),
|
||||
};
|
||||
if allow_embedded_fallback {
|
||||
let restartable = scenario != "unsupported RPC";
|
||||
if allow_embedded_fallback && !restartable {
|
||||
let warning = result?.expect("optional attachment should fall back");
|
||||
assert_eq!(
|
||||
result?,
|
||||
Some(format!(
|
||||
"Running without the shared background server: {reason}."
|
||||
))
|
||||
warning,
|
||||
format!("Running without the shared background server: {reason}.")
|
||||
);
|
||||
} else {
|
||||
let error = result.unwrap_err().to_string();
|
||||
let error = result.unwrap_err();
|
||||
assert_eq!(error.restart_features.is_some(), restartable);
|
||||
if scenario == "mixed flags" {
|
||||
assert_eq!(
|
||||
error.restart_features,
|
||||
Some(std::collections::BTreeMap::from([
|
||||
("api_key_model_discovery".to_string(), false),
|
||||
("code_mode_host".to_string(), true),
|
||||
]))
|
||||
);
|
||||
}
|
||||
let error = error.to_string();
|
||||
assert_eq!(
|
||||
error,
|
||||
format!(
|
||||
@@ -271,7 +229,7 @@ async fn daemon_feature_compatibility_respects_required_and_optional_attachment(
|
||||
daemon_startup::FAILURE_HINT
|
||||
)
|
||||
);
|
||||
if scenario == "explicit enable" {
|
||||
if scenario == "explicit enable" && !allow_embedded_fallback {
|
||||
insta::assert_snapshot!("daemon_feature_mismatch_error", error);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -1,17 +1,20 @@
|
||||
---
|
||||
source: tui/src/daemon_recovery_tests.rs
|
||||
assertion_line: 55
|
||||
expression: text
|
||||
---
|
||||
|
||||
Background server has incompatible feature settings
|
||||
This session requires api_key_model_discovery to be enabled
|
||||
Restart will use these shared feature settings:
|
||||
api_key_model_discovery = true
|
||||
mcp_oauth_refresh_coordination = false
|
||||
These settings persist and can disable functionality for other clients. Restart may
|
||||
interrupt active or queued work.
|
||||
Restart will use these shared feature settings:
|
||||
api_key_model_discovery = true
|
||||
code_mode_host = true
|
||||
instant_interrupt = true
|
||||
and 1 more
|
||||
|
||||
|
||||
1. Run without daemon this time
|
||||
2. Restart with these settings
|
||||
2. Restart with these settings (recommended)
|
||||
› 3. Cancel
|
||||
|
||||
+6
-3
@@ -1,15 +1,18 @@
|
||||
---
|
||||
source: tui/src/daemon_recovery_tests.rs
|
||||
assertion_line: 55
|
||||
expression: text
|
||||
---
|
||||
|
||||
Background server has incompatible feature settings
|
||||
This session requires api_key_model_discovery to be enabled
|
||||
Restart will use these shared feature settings:
|
||||
api_key_model_discovery = true
|
||||
mcp_oauth_refresh_coordination = false
|
||||
These settings persist and can disable functionality for other clients. Restart may
|
||||
interrupt active or queued work.
|
||||
Restart will use these shared feature settings:
|
||||
api_key_model_discovery = true
|
||||
code_mode_host = true
|
||||
instant_interrupt = true
|
||||
and 1 more
|
||||
|
||||
|
||||
1. Run without daemon this time
|
||||
|
||||
@@ -580,16 +580,15 @@ pub(super) async fn run_main_inner(
|
||||
{
|
||||
daemon_exclusion = Some(daemon_startup::WSL_DRVFS_EXCLUSION);
|
||||
}
|
||||
let mut daemon_features = daemon_startup::server_features(&cli_kv_overrides);
|
||||
// Disabling shared services requires confirmation, even on a fresh auto-start.
|
||||
daemon_features.retain(|_, enabled| *enabled);
|
||||
let mut managed_daemon = cli.managed_daemon;
|
||||
if auto_start_daemon && daemon_exclusion.is_none() {
|
||||
let output = startup_draft
|
||||
.run_until(async {
|
||||
// Daemon startup needs no terminal input. Keep the composer visible and
|
||||
// responsive while it checks the running server or prepares an installation.
|
||||
let result = codex_app_server_daemon::start_with_features(&daemon_features).await;
|
||||
// Preserve saved daemon settings until any mismatch is confirmed in recovery.
|
||||
let result =
|
||||
codex_app_server_daemon::start_with_features(&Default::default()).await;
|
||||
daemon_telemetry::record_start(&config, &result).await;
|
||||
match result {
|
||||
Ok(output) => Ok(Some(output)),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Exercises daemon compatibility fallback through real TUI startup.
|
||||
//! Exercises daemon compatibility recovery through real TUI startup.
|
||||
|
||||
use super::focus_palette::PtyCodex;
|
||||
use super::focus_palette::write_test_config;
|
||||
@@ -13,7 +13,7 @@ use tokio::net::UnixListener;
|
||||
use tokio_tungstenite::tungstenite::Message;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn incompatible_daemon_falls_back_for_explicit_features() -> Result<()> {
|
||||
async fn incompatible_daemon_can_run_embedded_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")?;
|
||||
@@ -61,6 +61,8 @@ async fn incompatible_daemon_falls_back_for_explicit_features() -> Result<()> {
|
||||
vec!["-c", "features.api_key_model_discovery=true"]
|
||||
};
|
||||
let mut terminal = PtyCodex::start(&cwd, home, &args)?;
|
||||
terminal.wait_for_screen("Background server has incompatible feature settings")?;
|
||||
terminal.write_input(b"1")?;
|
||||
terminal.wait_for_startup()?;
|
||||
terminal.wait_for_screen("warning")?;
|
||||
terminal.write_input(b"\x14")?;
|
||||
|
||||
Reference in New Issue
Block a user