Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

sandbox NUX metrics update (#11667)

iceweasel-oai99466f1f9045
diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs
index 9fd9ae5b9c..0e878aafb6 100644
--- a/codex-rs/tui/src/app.rs
+++ b/codex-rs/tui/src/app.rs
@@ -3,8 +3,6 @@ use crate::app_event::AppEvent;
use crate::app_event::ExitMode;
#[cfg(target_os = "windows")]
use crate::app_event::WindowsSandboxEnableMode;
-#[cfg(target_os = "windows")]
-use crate::app_event::WindowsSandboxFallbackReason;
use crate::app_event_sender::AppEventSender;
use crate::bottom_pane::ApprovalRequest;
use crate::bottom_pane::FeedbackAudience;
@@ -1707,7 +1705,7 @@ impl App {
AppEvent::OpenWindowsSandboxEnablePrompt { preset } => {
self.chat_widget.open_windows_sandbox_enable_prompt(preset);
}
- AppEvent::OpenWindowsSandboxFallbackPrompt { preset, reason } => {
+ AppEvent::OpenWindowsSandboxFallbackPrompt { preset } => {
self.otel_manager
.counter("codex.windows_sandbox.fallback_prompt_shown", 1, &[]);
self.chat_widget.clear_windows_sandbox_setup_status();
@@ -1719,7 +1717,7 @@ impl App {
);
}
self.chat_widget
- .open_windows_sandbox_fallback_prompt(preset, reason);
+ .open_windows_sandbox_fallback_prompt(preset);
}
AppEvent::BeginWindowsSandboxElevatedSetup { preset } => {
#[cfg(target_os = "windows")]
@@ -1795,10 +1793,7 @@ impl App {
error = %err,
"failed to run elevated Windows sandbox setup"
);
- AppEvent::OpenWindowsSandboxFallbackPrompt {
- preset,
- reason: WindowsSandboxFallbackReason::ElevationFailed,
- }
+ AppEvent::OpenWindowsSandboxFallbackPrompt { preset }
}
};
tx.send(event);
@@ -1819,6 +1814,7 @@ impl App {
std::env::vars().collect();
let codex_home = self.config.codex_home.clone();
let tx = self.app_event_tx.clone();
+ let otel_manager = self.otel_manager.clone();
self.chat_widget.show_windows_sandbox_setup_status();
tokio::task::spawn_blocking(move || {
@@ -1829,6 +1825,11 @@ impl App {
&env_map,
codex_home.as_path(),
) {
+ otel_manager.counter(
+ "codex.windows_sandbox.legacy_setup_preflight_failed",
+ 1,
+ &[],
+ );
tracing::warn!(
error = %err,
"failed to preflight non-admin Windows sandbox setup"
diff --git a/codex-rs/tui/src/app_event.rs b/codex-rs/tui/src/app_event.rs
index c04665eb24..8bf3ab3703 100644
--- a/codex-rs/tui/src/app_event.rs
+++ b/codex-rs/tui/src/app_event.rs
@@ -36,13 +36,8 @@ pub(crate) enum WindowsSandboxEnableMode {
Legacy,
}
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
-pub(crate) enum WindowsSandboxFallbackReason {
- ElevationFailed,
-}
-
#[derive(Debug, Clone)]
+#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
pub(crate) struct ConnectorsSnapshot {
pub(crate) connectors: Vec<AppInfo>,
}
@@ -205,7 +200,6 @@ pub(crate) enum AppEvent {
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
OpenWindowsSandboxFallbackPrompt {
preset: ApprovalPreset,
- reason: WindowsSandboxFallbackReason,
},
/// Begin the elevated Windows sandbox setup flow.
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs
index 81c9faed60..b2b064378e 100644
--- a/codex-rs/tui/src/chatwidget.rs
+++ b/codex-rs/tui/src/chatwidget.rs
@@ -162,7 +162,6 @@ use crate::app_event::ConnectorsSnapshot;
use crate::app_event::ExitMode;
#[cfg(target_os = "windows")]
use crate::app_event::WindowsSandboxEnableMode;
-use crate::app_event::WindowsSandboxFallbackReason;
use crate::app_event_sender::AppEventSender;
use crate::bottom_pane::ApprovalRequest;
use crate::bottom_pane::BottomPane;
@@ -5738,7 +5737,7 @@ impl ChatWidget {
name: "Use non-admin sandbox (higher risk if prompt injected)".to_string(),
description: None,
actions: vec![Box::new(move |tx| {
- legacy_otel.counter("codex.windows_sandbox.fallback_use_legacy", 1, &[]);
+ legacy_otel.counter("codex.windows_sandbox.elevated_prompt_use_legacy", 1, &[]);
tx.send(AppEvent::BeginWindowsSandboxLegacySetup {
preset: legacy_preset.clone(),
});
@@ -5750,7 +5749,7 @@ impl ChatWidget {
name: "Quit".to_string(),
description: None,
actions: vec![Box::new(move |tx| {
- quit_otel.counter("codex.windows_sandbox.elevated_prompt_decline", 1, &[]);
+ quit_otel.counter("codex.windows_sandbox.elevated_prompt_quit", 1, &[]);
tx.send(AppEvent::Exit(ExitMode::ShutdownFirst));
})],
dismiss_on_select: true,
@@ -5771,15 +5770,9 @@ impl ChatWidget {
pub(crate) fn open_windows_sandbox_enable_prompt(&mut self, _preset: ApprovalPreset) {}
#[cfg(target_os = "windows")]
- pub(crate) fn open_windows_sandbox_fallback_prompt(
- &mut self,
- preset: ApprovalPreset,
- reason: WindowsSandboxFallbackReason,
- ) {
+ pub(crate) fn open_windows_sandbox_fallback_prompt(&mut self, preset: ApprovalPreset) {
use ratatui_macros::line;
- let _ = reason;
-
let mut lines = Vec::new();
lines.push(line![
"Couldn't set up your sandbox with Administrator permissions".bold()
@@ -5835,7 +5828,7 @@ impl ChatWidget {
name: "Quit".to_string(),
description: None,
actions: vec![Box::new(move |tx| {
- quit_otel.counter("codex.windows_sandbox.fallback_stay_current", 1, &[]);
+ quit_otel.counter("codex.windows_sandbox.fallback_prompt_quit", 1, &[]);
tx.send(AppEvent::Exit(ExitMode::ShutdownFirst));
})],
dismiss_on_select: true,
@@ -5853,12 +5846,7 @@ impl ChatWidget {
}
#[cfg(not(target_os = "windows"))]
- pub(crate) fn open_windows_sandbox_fallback_prompt(
- &mut self,
- _preset: ApprovalPreset,
- _reason: WindowsSandboxFallbackReason,
- ) {
- }
+ pub(crate) fn open_windows_sandbox_fallback_prompt(&mut self, _preset: ApprovalPreset) {}
#[cfg(target_os = "windows")]
pub(crate) fn maybe_prompt_windows_sandbox_enable(&mut self, show_now: bool) {