mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Trim TUI legacy telemetry and migration dependencies (#27487)
## Why The TUI still reached through `codex-app-server-client::legacy_core` for process telemetry setup and personality migration, exposing core-only details after the TUI moved onto the app-server layer. This is part of our ongoing efforts to whittle away at the legacy_core shim that was left over after migrating the TUI to the app server. This change is just a refactor/rename and should be behavior-neutral and low risk. ## What changed - expose OTEL provider construction through the app-server client and keep the small process/SQLite telemetry adapters local to the TUI - collapse personality migration results to the config-reload decision the TUI needs - remove the `legacy_core::otel_init` and `legacy_core::personality_migration` subnamespaces
This commit is contained in:
committed by
GitHub
Unverified
parent
a6f435ea94
commit
ab4ce40042
@@ -22,6 +22,7 @@ use std::fmt;
|
||||
use std::io::Error as IoError;
|
||||
use std::io::ErrorKind;
|
||||
use std::io::Result as IoResult;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -48,7 +49,11 @@ use codex_config::LoaderOverrides;
|
||||
use codex_config::NoopThreadConfigLoader;
|
||||
use codex_config::RemoteThreadConfigLoader;
|
||||
use codex_config::ThreadConfigLoader;
|
||||
use codex_config::config_toml::ConfigToml;
|
||||
use codex_core::config::Config;
|
||||
pub use codex_core::otel_init::build_provider as build_otel_provider;
|
||||
use codex_core::personality_migration::PersonalityMigrationStatus;
|
||||
use codex_core::personality_migration::maybe_migrate_personality;
|
||||
pub use codex_exec_server::EnvironmentManager;
|
||||
pub use codex_exec_server::ExecServerRuntimePaths;
|
||||
use codex_feedback::CodexFeedback;
|
||||
@@ -82,14 +87,6 @@ pub mod legacy_core {
|
||||
}
|
||||
}
|
||||
|
||||
pub mod otel_init {
|
||||
pub use codex_core::otel_init::*;
|
||||
}
|
||||
|
||||
pub mod personality_migration {
|
||||
pub use codex_core::personality_migration::*;
|
||||
}
|
||||
|
||||
pub mod windows_sandbox {
|
||||
pub use codex_core::windows_sandbox::*;
|
||||
}
|
||||
@@ -97,6 +94,23 @@ pub mod legacy_core {
|
||||
|
||||
const SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
/// Runs the embedded app-server personality migration.
|
||||
///
|
||||
/// Returns `true` when the migration changed config and the caller should reload it.
|
||||
pub async fn migrate_personality_if_needed(
|
||||
codex_home: &Path,
|
||||
config_toml: &ConfigToml,
|
||||
state_db: Option<StateDbHandle>,
|
||||
) -> IoResult<bool> {
|
||||
let status = maybe_migrate_personality(codex_home, config_toml, state_db).await?;
|
||||
match status {
|
||||
PersonalityMigrationStatus::Applied => Ok(true),
|
||||
PersonalityMigrationStatus::SkippedMarker
|
||||
| PersonalityMigrationStatus::SkippedExplicitPersonality
|
||||
| PersonalityMigrationStatus::SkippedNoSessions => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
/// Raw app-server request result for typed in-process requests.
|
||||
///
|
||||
/// Even on the in-process path, successful responses still travel back through
|
||||
|
||||
+10
-15
@@ -1125,7 +1125,7 @@ pub async fn run_main(
|
||||
|
||||
let otel_originator = originator().value;
|
||||
let otel = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
crate::legacy_core::otel_init::build_provider(
|
||||
codex_app_server_client::build_otel_provider(
|
||||
&config,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
/*service_name_override*/ None,
|
||||
@@ -1148,26 +1148,25 @@ pub async fn run_main(
|
||||
None
|
||||
}
|
||||
};
|
||||
crate::legacy_core::otel_init::record_process_start(otel.as_ref(), otel_originator.as_str());
|
||||
crate::legacy_core::otel_init::install_sqlite_telemetry(
|
||||
otel.as_ref(),
|
||||
otel_originator.as_str(),
|
||||
);
|
||||
if let Some(metrics) = otel.as_ref().and_then(codex_otel::OtelProvider::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 state_db = init_state_db_for_app_server_target(&config, &app_server_target).await?;
|
||||
|
||||
let effective_toml = config.config_layer_stack.effective_config();
|
||||
match effective_toml.try_into() {
|
||||
Ok(config_toml) => {
|
||||
match crate::legacy_core::personality_migration::maybe_migrate_personality(
|
||||
match codex_app_server_client::migrate_personality_if_needed(
|
||||
&config.codex_home,
|
||||
&config_toml,
|
||||
state_db.clone(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(
|
||||
crate::legacy_core::personality_migration::PersonalityMigrationStatus::Applied,
|
||||
) => {
|
||||
Ok(true) => {
|
||||
config = load_config_or_exit(
|
||||
cli_kv_overrides.clone(),
|
||||
overrides.clone(),
|
||||
@@ -1177,11 +1176,7 @@ pub async fn run_main(
|
||||
)
|
||||
.await;
|
||||
}
|
||||
Ok(
|
||||
crate::legacy_core::personality_migration::PersonalityMigrationStatus::SkippedMarker
|
||||
| crate::legacy_core::personality_migration::PersonalityMigrationStatus::SkippedExplicitPersonality
|
||||
| crate::legacy_core::personality_migration::PersonalityMigrationStatus::SkippedNoSessions,
|
||||
) => {}
|
||||
Ok(false) => {}
|
||||
Err(err) => {
|
||||
tracing::warn!(error = %err, "failed to run personality migration");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user