aKode fase 2c: eliminato il codice di invio dati (crate analytics, otel-trace-websocket, sentry, esportatori OTLP); /feedback salva solo in locale; chiavi legacy [analytics]/[otel] accettate e ignorate; test di analytics/OTLP/upload rimossi
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled

This commit is contained in:
Andrea
2026-11-09 18:45:41 +01:00
parent 981745ccc8
commit 60532b6337
509 changed files with 2043 additions and 46606 deletions

View File

@@ -4,8 +4,6 @@
//! configuration and app-server initialization remain responsive to safe local editing.
use super::*;
use codex_terminal_detection::Multiplexer;
use codex_terminal_detection::TerminalName;
pub(super) async fn run_main_inner(
mut cli: Cli,
@@ -64,7 +62,6 @@ pub(super) async fn run_main_inner(
.take_auto_review_config_overrides(&mut cli.config_overrides);
// Map the legacy --search flag to the canonical web_search mode.
let overrides_before_search = cli.config_overrides.raw_overrides.len();
if cli.web_search {
cli.config_overrides
.raw_overrides
@@ -221,14 +218,6 @@ pub(super) async fn run_main_inner(
std::env::var_os(codex_exec_server::CODEX_EXEC_SERVER_URL_ENV_VAR).as_deref(),
);
let reuse_implicit_local_daemon = daemon_exclusion.is_none();
let search_forces_embedded = cli.web_search
&& daemon_startup::config_exclusion(
&cli_kv_overrides[..overrides_before_search],
&launch_loader_overrides,
strict_config,
cli.bypass_hook_trust,
)
.is_none();
let search_only_config_override = !workload_identity_selected
&& cli.web_search
&& startup_preflight::has_only_search_config_override(&cli_kv_overrides)
@@ -320,9 +309,6 @@ pub(super) async fn run_main_inner(
})
.await
.map_err(std::io::Error::other)??;
// Snapshot the backend size sampled during init, before any viewport changes or resizes.
let initial_terminal_size = initialized_terminal.terminal.last_known_screen_size;
let terminal_size_tags = crate::terminal_size_telemetry::tags(initial_terminal_size);
let startup_presentation::StartupPresentation {
bootstrap_config,
config_cwd,
@@ -596,7 +582,6 @@ pub(super) async fn run_main_inner(
let result =
codex_app_server_daemon::start_with_features_classified(&Default::default())
.await;
daemon_telemetry::record_start(&config, &result).await;
match result.map_err(|err| err.error) {
Ok(output) => Ok(Some(output)),
#[cfg(windows)]
@@ -666,156 +651,6 @@ pub(super) async fn run_main_inner(
remove_legacy_tui_log_file(config.codex_home.as_path());
let otel_originator = originator().value;
let otel = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
codex_app_server_client::build_otel_provider(
&config,
env!("CARGO_PKG_VERSION"),
/*service_name_override*/ None,
/*default_analytics_enabled*/ true,
)
})) {
Ok(Ok(otel)) => otel,
Ok(Err(e)) => {
startup_draft.flush_pending_events().await?;
startup_draft
.tui_mut()
.with_restored(crate::tui::TerminalHandoff::Restore, || async {
#[allow(clippy::print_stderr)]
{
eprintln!("Could not create otel exporter: {e}");
}
})
.await;
None
}
Err(_) => {
#[allow(clippy::print_stderr)]
{
eprintln!("Could not create otel exporter: panicked during initialization");
}
startup_draft.tui_mut().recover_after_caught_panic()?;
None
}
};
let metrics = otel
.as_ref()
.and_then(codex_otel::OtelProvider::metrics)
.cloned();
if let Some(metrics) = &metrics {
let _ = codex_otel::record_process_start_once(metrics, otel_originator.as_str());
let telemetry =
codex_rollout::sqlite_telemetry_recorder(metrics.clone(), otel_originator.as_str());
let _ = codex_state::install_process_db_telemetry(telemetry);
}
let selection_reason = match (&app_server_target, daemon_exclusion) {
(AppServerTarget::Remote { .. }, _) => "explicit_remote",
(AppServerTarget::Cloud, _) => "cloud",
_ if cli.agents_overview => "agents",
_ if elevated_warning.is_some() => "elevated_windows",
(_, Some("--no-daemon")) => "explicit_no_daemon",
(_, Some(_)) => "incompatible_option",
_ if auto_start_daemon => "auto_start",
(AppServerTarget::LocalDaemon { .. }, _) => "existing_daemon",
(AppServerTarget::Embedded, None) => "auto_start_disabled",
};
let daemon_settings = if metrics.is_some() {
codex_app_server_daemon::telemetry::settings_tags(&config.codex_home)
.await
.to_vec()
} else {
Vec::new()
};
let mut launch_tags = daemon_settings.to_vec();
launch_tags.extend(terminal_size_tags);
launch_tags.extend([
("daemon_selection_reason", selection_reason),
(
"daemon_auto_start",
if config.features.enabled(Feature::DaemonAutoStart) {
"enabled"
} else {
"disabled"
},
),
]);
let selected_local_daemon = matches!(app_server_target, AppServerTarget::LocalDaemon { .. });
let launch_telemetry = move |app_server_mode| {
let Some(metrics) = metrics else {
return Vec::new();
};
// Use a fixed category, not the versioned or user-provided terminal identifier.
let terminal_info = codex_terminal_detection::terminal_info();
let terminal_name = match terminal_info.name {
TerminalName::AppleTerminal => "apple_terminal",
TerminalName::Ghostty => "ghostty",
TerminalName::Rex => "rex",
TerminalName::Iterm2 => "iterm2",
TerminalName::WarpTerminal => "warp",
TerminalName::VsCode => "vscode",
TerminalName::WezTerm => "wezterm",
TerminalName::Kitty => "kitty",
TerminalName::Alacritty => "alacritty",
TerminalName::Konsole => "konsole",
TerminalName::GnomeTerminal => "gnome_terminal",
TerminalName::Vte => "vte",
TerminalName::WindowsTerminal => "windows_terminal",
TerminalName::Dumb => "dumb",
TerminalName::Unknown => "unknown",
};
let multiplexer = match terminal_info.multiplexer {
Some(Multiplexer::Tmux { .. }) => "tmux",
Some(Multiplexer::Zellij { .. }) => "zellij",
None => "none",
};
launch_tags.extend([
("app_server_mode", app_server_mode),
("terminal_name", terminal_name),
("multiplexer", multiplexer),
]);
let _ = metrics.counter("codex.tui.start", /*inc*/ 1, &launch_tags);
if app_server_mode == "in_process" {
let reason = match daemon_exclusion {
_ if elevated_warning.is_some() => "windows_elevated",
Some("--no-daemon") => "explicit_no_daemon",
Some("--profile") => "profile",
Some("--oss") => "oss",
Some("--strict-config") => "strict_config",
Some("--dangerously-bypass-hook-trust") => "bypass_hook_trust",
Some("workload identity") => "workload_identity",
Some("executor selection (CODEX_EXEC_SERVER_URL)") => "exec_server_url",
Some("custom configuration loader") => "custom_config_loader",
Some(
"command-line configuration overrides (-c, --enable, --disable, or --search)",
) => {
if search_forces_embedded {
"search"
} else {
"config_override"
}
}
Some("GCP sign-in") => "gcp_sign_in",
Some(daemon_startup::GATEWAY_SIGN_IN_EXCLUSION) => "gateway_sign_in",
Some(daemon_startup::WSL_DRVFS_EXCLUSION) => "wsl_drvfs",
Some("this Windows launcher") => "windows_detach_restricted",
Some("daemon feature settings") => "daemon_compatibility",
None if selection_reason == "auto_start_disabled" => {
"auto_start_disabled_no_daemon"
}
None if selected_local_daemon => "daemon_connection_failed",
None if selection_reason == "agents" => "agents_no_daemon_discovered",
Some(_) | None => "unclassified",
};
let _ = metrics.counter(
"codex.tui.embedded_start",
/*inc*/ 1,
&[("reason", reason)],
);
}
launch_tags.retain(|(key, _)| !matches!(*key, "terminal_columns" | "terminal_rows"));
launch_tags
};
let launch_telemetry = daemon_telemetry::Launch(Some(launch_telemetry));
let state_db = startup_draft
.run_until(init_state_db_for_app_server_target(
&config,
@@ -847,12 +682,6 @@ pub(super) async fn run_main_inner(
if let Some(worktree) = managed_worktree.as_ref() {
worktree.report_startup_failure();
}
drop(launch_telemetry);
if let Some(otel) = otel {
let _ = otel
.shutdown_with_timeout(INTERACTIVE_OTEL_SHUTDOWN_TIMEOUT)
.await;
}
std::process::exit(1);
}
}
@@ -868,12 +697,6 @@ pub(super) async fn run_main_inner(
if let Some(worktree) = managed_worktree.as_ref() {
worktree.report_startup_failure();
}
drop(launch_telemetry);
if let Some(otel) = otel {
let _ = otel
.shutdown_with_timeout(INTERACTIVE_OTEL_SHUTDOWN_TIMEOUT)
.await;
}
std::process::exit(1);
}
}
@@ -942,10 +765,6 @@ pub(super) async fn run_main_inner(
.await?;
}
let otel_logger_layer = otel.as_ref().and_then(|o| o.logger_layer());
let otel_tracing_layer = otel.as_ref().and_then(|o| o.tracing_layer());
let log_db = state_db
.clone()
.map(|state_db| log_db::start(state_db, std::sync::Arc::new(feedback.clone())));
@@ -958,8 +777,6 @@ pub(super) async fn run_main_inner(
.with(feedback_layer)
.with(feedback_metadata_layer)
.with(log_db_layer)
.with(otel_logger_layer)
.with(otel_tracing_layer)
.try_init();
if let Err(err) = screen_reader_result {
@@ -987,7 +804,6 @@ pub(super) async fn run_main_inner(
managed_worktree.clone(),
daemon_startup_warning,
managed_daemon,
launch_telemetry,
startup_draft,
))
.await
@@ -1000,33 +816,5 @@ pub(super) async fn run_main_inner(
worktree.report_startup_failure();
}
// The TUI owns this request's consent. The child is silent; installation remains unconfirmed.
if let Ok(exit) = &app_result
&& let Some(UpdateAction::Daemon(source)) = exit.update_action
&& let Some(metrics) = otel.as_ref().and_then(codex_otel::OtelProvider::metrics)
{
let mut tags = daemon_settings.to_vec();
tags.extend([
("initiation_source", "tui_handoff"),
(
"update_target",
match source {
DaemonUpdateSource::PublicStable => "public_stable",
DaemonUpdateSource::ThisCli => "this_cli",
},
),
("outcome", "handoff_requested"),
]);
let _ = metrics.counter("codex.daemon.update", /*inc*/ 1, &tags);
}
if let Some(otel) = otel
&& let Err(err) = otel
.shutdown_with_timeout(INTERACTIVE_OTEL_SHUTDOWN_TIMEOUT)
.await
{
warn!(error = %err, "failed to finish interactive telemetry shutdown");
}
app_result
}