Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

revert: mark Feature::RemoteControl as removed (#22520)

Owen Lin2b3b220605a8
diff --git a/codex-rs/app-server-daemon/src/backend/pid.rs b/codex-rs/app-server-daemon/src/backend/pid.rs
index 7f8aa1660d..64228d9c9b 100644
--- a/codex-rs/app-server-daemon/src/backend/pid.rs
+++ b/codex-rs/app-server-daemon/src/backend/pid.rs
@@ -349,7 +349,13 @@ impl PidBackend {
match self.command_kind {
PidCommandKind::AppServer {
remote_control_enabled: true,
- } => vec!["app-server", "--remote-control", "--listen", "unix://"],
+ } => vec![
+ "--enable",
+ "remote_control",
+ "app-server",
+ "--listen",
+ "unix://",
+ ],
PidCommandKind::AppServer {
remote_control_enabled: false,
} => vec!["app-server", "--listen", "unix://"],
diff --git a/codex-rs/app-server/src/in_process.rs b/codex-rs/app-server/src/in_process.rs
index d4fc50fea7..c75c2d5ad1 100644
--- a/codex-rs/app-server/src/in_process.rs
+++ b/codex-rs/app-server/src/in_process.rs
@@ -433,6 +433,7 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult<InProcessClie
auth_manager,
installation_id,
rpc_transport: AppServerRpcTransport::InProcess,
+ remote_control_handle: None,
plugin_startup_tasks: crate::PluginStartupTasks::Start,
}));
let mut thread_created_rx = processor.thread_created_receiver();
diff --git a/codex-rs/app-server/src/lib.rs b/codex-rs/app-server/src/lib.rs
index 3bcf896753..b4e5f9a04d 100644
--- a/codex-rs/app-server/src/lib.rs
+++ b/codex-rs/app-server/src/lib.rs
@@ -8,6 +8,7 @@ use codex_config::RemoteThreadConfigLoader;
use codex_config::ThreadConfigLoader;
use codex_core::config::Config;
use codex_core::resolve_installation_id;
+use codex_features::Feature;
use codex_login::AuthManager;
use codex_utils_cli::CliConfigOverrides;
use std::collections::HashMap;
@@ -400,14 +401,12 @@ pub enum PluginStartupTasks {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AppServerRuntimeOptions {
pub plugin_startup_tasks: PluginStartupTasks,
- pub remote_control_enabled: bool,
}
impl Default for AppServerRuntimeOptions {
fn default() -> Self {
Self {
plugin_startup_tasks: PluginStartupTasks::Start,
- remote_control_enabled: false,
}
}
}
@@ -682,15 +681,15 @@ pub async fn run_main_with_transport_options(
let auth_manager =
AuthManager::shared_from_config(&config, /*enable_codex_api_key_env*/ false).await;
- let remote_control_requested = runtime_options.remote_control_enabled;
- let remote_control_enabled = remote_control_requested && state_db.is_some();
- if remote_control_requested && state_db.is_none() {
+ let remote_control_config_enabled = config.features.enabled(Feature::RemoteControl);
+ let remote_control_enabled = remote_control_config_enabled && state_db.is_some();
+ if remote_control_config_enabled && state_db.is_none() {
error!("remote control disabled because sqlite state db is unavailable");
}
if transport_accept_handles.is_empty() && !remote_control_enabled {
return Err(std::io::Error::new(
ErrorKind::InvalidInput,
- if remote_control_requested && state_db.is_none() {
+ if remote_control_config_enabled && state_db.is_none() {
"no transport configured; remote control disabled because sqlite state db is unavailable"
} else {
"no transport configured; use --listen or enable remote control"
@@ -794,6 +793,7 @@ pub async fn run_main_with_transport_options(
auth_manager,
installation_id,
rpc_transport: analytics_rpc_transport(&transport),
+ remote_control_handle: Some(remote_control_handle.clone()),
plugin_startup_tasks: runtime_options.plugin_startup_tasks,
}));
let mut thread_created_rx = processor.thread_created_receiver();
diff --git a/codex-rs/app-server/src/main.rs b/codex-rs/app-server/src/main.rs
index 6f5ecabf90..af30db8cf0 100644
--- a/codex-rs/app-server/src/main.rs
+++ b/codex-rs/app-server/src/main.rs
@@ -48,10 +48,6 @@ struct AppServerArgs {
#[cfg(debug_assertions)]
#[arg(long = "disable-plugin-startup-tasks-for-tests", hide = true)]
disable_plugin_startup_tasks_for_tests: bool,
-
- /// Enable remote control for this app-server process.
- #[arg(long = "remote-control", hide = true)]
- remote_control: bool,
}
fn main() -> anyhow::Result<()> {
@@ -63,7 +59,6 @@ fn main() -> anyhow::Result<()> {
strict_config,
#[cfg(debug_assertions)]
disable_plugin_startup_tasks_for_tests,
- remote_control,
} = AppServerArgs::parse();
let loader_overrides = if disable_managed_config_from_debug_env() {
LoaderOverrides::without_managed_config_for_tests()
@@ -79,7 +74,6 @@ fn main() -> anyhow::Result<()> {
if disable_plugin_startup_tasks_for_tests {
runtime_options.plugin_startup_tasks = PluginStartupTasks::Skip;
}
- runtime_options.remote_control_enabled = remote_control;
run_main_with_transport_options(
arg0_paths,
diff --git a/codex-rs/app-server/src/message_processor.rs b/codex-rs/app-server/src/message_processor.rs
index 86a3de09e9..a4eb9b6c9d 100644
--- a/codex-rs/app-server/src/message_processor.rs
+++ b/codex-rs/app-server/src/message_processor.rs
@@ -42,6 +42,7 @@ use crate::skills_watcher::SkillsWatcher;
use crate::thread_state::ConnectionCapabilities;
use crate::thread_state::ThreadStateManager;
use crate::transport::AppServerTransport;
+use crate::transport::RemoteControlHandle;
use async_trait::async_trait;
use codex_analytics::AnalyticsEventsClient;
use codex_analytics::AppServerRpcTransport;
@@ -264,6 +265,7 @@ pub(crate) struct MessageProcessorArgs {
pub(crate) auth_manager: Arc<AuthManager>,
pub(crate) installation_id: String,
pub(crate) rpc_transport: AppServerRpcTransport,
+ pub(crate) remote_control_handle: Option<RemoteControlHandle>,
pub(crate) plugin_startup_tasks: crate::PluginStartupTasks,
}
@@ -286,6 +288,7 @@ impl MessageProcessor {
auth_manager,
installation_id,
rpc_transport,
+ remote_control_handle,
plugin_startup_tasks,
} = args;
auth_manager.set_external_auth(Arc::new(ExternalAuthRefreshBridge {
@@ -443,6 +446,7 @@ impl MessageProcessor {
auth_manager,
thread_manager.clone(),
analytics_events_client,
+ remote_control_handle,
);
let external_agent_config_processor = ExternalAgentConfigRequestProcessor::new(
outgoing.clone(),
diff --git a/codex-rs/app-server/src/message_processor_tracing_tests.rs b/codex-rs/app-server/src/message_processor_tracing_tests.rs
index 3daeeeb5c9..c955d06ba2 100644
--- a/codex-rs/app-server/src/message_processor_tracing_tests.rs
+++ b/codex-rs/app-server/src/message_processor_tracing_tests.rs
@@ -265,6 +265,7 @@ async fn build_test_processor(
auth_manager,
installation_id: "11111111-1111-4111-8111-111111111111".to_string(),
rpc_transport: AppServerRpcTransport::Stdio,
+ remote_control_handle: None,
plugin_startup_tasks: crate::PluginStartupTasks::Start,
}));
(processor, outgoing_rx)
diff --git a/codex-rs/app-server/src/request_processors/config_processor.rs b/codex-rs/app-server/src/request_processors/config_processor.rs
index b7f973b076..1533728e9f 100644
--- a/codex-rs/app-server/src/request_processors/config_processor.rs
+++ b/codex-rs/app-server/src/request_processors/config_processor.rs
@@ -6,6 +6,7 @@ use crate::error_code::internal_error;
use crate::error_code::invalid_request;
use crate::outgoing_message::ConnectionRequestId;
use crate::outgoing_message::OutgoingMessageSender;
+use crate::transport::RemoteControlHandle;
use codex_analytics::AnalyticsEventsClient;
use codex_app_server_protocol::AppListUpdatedNotification;
use codex_app_server_protocol::ClientResponsePayload;
@@ -38,6 +39,7 @@ use codex_config::MatcherGroup as CoreMatcherGroup;
use codex_config::ResidencyRequirement as CoreResidencyRequirement;
use codex_config::SandboxModeRequirement as CoreSandboxModeRequirement;
use codex_core::ThreadManager;
+use codex_features::Feature;
use codex_features::canonical_feature_for_key;
use codex_features::feature_for_key;
use codex_login::AuthManager;
@@ -65,6 +67,7 @@ pub(crate) struct ConfigRequestProcessor {
auth_manager: Arc<AuthManager>,
thread_manager: Arc<ThreadManager>,
analytics_events_client: AnalyticsEventsClient,
+ remote_control_handle: Option<RemoteControlHandle>,
}
impl ConfigRequestProcessor {
@@ -74,6 +77,7 @@ impl ConfigRequestProcessor {
auth_manager: Arc<AuthManager>,
thread_manager: Arc<ThreadManager>,
analytics_events_client: AnalyticsEventsClient,
+ remote_control_handle: Option<RemoteControlHandle>,
) -> Self {
Self {
outgoing,
@@ -81,6 +85,7 @@ impl ConfigRequestProcessor {
auth_manager,
thread_manager,
analytics_events_client,
+ remote_control_handle,
}
}
@@ -182,6 +187,21 @@ impl ConfigRequestProcessor {
pub(crate) async fn handle_config_mutation(&self) {
self.thread_manager.plugins_manager().clear_cache();
self.thread_manager.skills_manager().clear_cache();
+ let Some(remote_control_handle) = &self.remote_control_handle else {
+ return;
+ };
+
+ match self.load_latest_config(/*fallback_cwd*/ None).await {
+ Ok(config) => {
+ remote_control_handle.set_enabled(config.features.enabled(Feature::RemoteControl));
+ }
+ Err(error) => {
+ tracing::warn!(
+ "failed to load config for remote control enablement refresh after config mutation: {}",
+ error.message
+ );
+ }
+ }
}
async fn handle_config_mutation_result<T>(
diff --git a/codex-rs/app-server/src/transport.rs b/codex-rs/app-server/src/transport.rs
index 3d18cf321b..4eae17e469 100644
--- a/codex-rs/app-server/src/transport.rs
+++ b/codex-rs/app-server/src/transport.rs
@@ -18,6 +18,7 @@ pub(crate) use codex_app_server_transport::ConnectionId;
pub(crate) use codex_app_server_transport::ConnectionOrigin;
pub(crate) use codex_app_server_transport::OutgoingMessage;
pub(crate) use codex_app_server_transport::QueuedOutgoingMessage;
+pub(crate) use codex_app_server_transport::RemoteControlHandle;
pub(crate) use codex_app_server_transport::RemoteControlStartConfig;
pub(crate) use codex_app_server_transport::TransportEvent;
pub use codex_app_server_transport::app_server_control_socket_path;
diff --git a/codex-rs/cli/src/main.rs b/codex-rs/cli/src/main.rs
index df3a9ab44e..ef54aa52cd 100644
--- a/codex-rs/cli/src/main.rs
+++ b/codex-rs/cli/src/main.rs
@@ -449,10 +449,6 @@ struct AppServerCommand {
)]
listen: codex_app_server::AppServerTransport,
- /// Enable remote control for this app-server process.
- #[arg(long = "remote-control", hide = true)]
- remote_control: bool,
-
/// Controls whether analytics are enabled by default.
///
/// Analytics are disabled by default for app-server. Users have to explicitly opt in
@@ -531,10 +527,10 @@ enum AppServerDaemonSubcommand {
/// Restart the local app server daemon.
Restart,
- /// Enable remote control for future starts and a currently running managed daemon.
+ /// Enable remote_control for future starts and a currently running managed daemon.
EnableRemoteControl,
- /// Disable remote control for future starts and a currently running managed daemon.
+ /// Disable remote_control for future starts and a currently running managed daemon.
DisableRemoteControl,
/// Stop the local app server daemon.
@@ -557,7 +553,7 @@ struct AppServerProxyCommand {
#[derive(Debug, Args)]
struct AppServerBootstrapCommand {
- /// Launch the managed app-server with remote control enabled.
+ /// Launch the managed app-server with remote_control enabled.
#[arg(long = "remote-control")]
remote_control: bool,
}
@@ -929,7 +925,6 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
subcommand,
strict_config: app_server_strict_config,
listen,
- remote_control,
analytics_default_enabled,
auth,
} = app_server_cli;
@@ -944,10 +939,6 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
None => {
let transport = listen;
let auth = auth.try_into_settings()?;
- let runtime_options = codex_app_server::AppServerRuntimeOptions {
- remote_control_enabled: remote_control,
- ..Default::default()
- };
codex_app_server::run_main_with_transport_options(
arg0_paths.clone(),
root_config_overrides,
@@ -957,7 +948,7 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
transport,
codex_protocol::protocol::SessionSource::VSCode,
auth,
- runtime_options,
+ codex_app_server::AppServerRuntimeOptions::default(),
)
.await?;
}
@@ -2560,7 +2551,6 @@ mod tests {
fn app_server_analytics_default_disabled_without_flag() {
let app_server = app_server_from_args(["codex", "app-server"].as_ref());
assert!(!app_server.analytics_default_enabled);
- assert!(!app_server.remote_control);
assert_eq!(
app_server.listen,
codex_app_server::AppServerTransport::Stdio
diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs
index e019178c21..75535cbaaa 100644
--- a/codex-rs/features/src/lib.rs
+++ b/codex-rs/features/src/lib.rs
@@ -1126,7 +1126,7 @@ pub const FEATURES: &[FeatureSpec] = &[
FeatureSpec {
id: Feature::RemoteControl,
key: "remote_control",
- stage: Stage::Removed,
+ stage: Stage::UnderDevelopment,
default_enabled: false,
},
FeatureSpec {
diff --git a/codex-rs/features/src/tests.rs b/codex-rs/features/src/tests.rs
index 073c2064eb..a635ca0740 100644
--- a/codex-rs/features/src/tests.rs
+++ b/codex-rs/features/src/tests.rs
@@ -287,8 +287,8 @@ fn auth_elicitation_is_under_development() {
}
#[test]
-fn remote_control_is_removed_and_disabled_by_default() {
- assert_eq!(Feature::RemoteControl.stage(), Stage::Removed);
+fn remote_control_is_under_development() {
+ assert_eq!(Feature::RemoteControl.stage(), Stage::UnderDevelopment);
assert_eq!(Feature::RemoteControl.default_enabled(), false);
}