From f9cba5cb168c3e3bf325d30ef73d47c87ed895e1 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 10 Mar 2026 09:57:41 -0600 Subject: [PATCH] Log ChatGPT user ID for feedback tags (#13901) There are some bug investigations that currently require us to ask users for their user ID even though they've already uploaded logs and session details via `/feedback`. This frustrates users and increases the time for diagnosis. This PR includes the ChatGPT user ID in the metadata uploaded for `/feedback` (both the TUI and app-server). --- codex-rs/app-server/src/codex_message_processor.rs | 7 +++++++ codex-rs/core/src/auth.rs | 7 +++++++ codex-rs/tui/src/chatwidget.rs | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index e8b0c9f3b..c269fc73d 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -6694,6 +6694,13 @@ impl CodexMessageProcessor { None => None, }; + if let Some(chatgpt_user_id) = self + .auth_manager + .auth_cached() + .and_then(|auth| auth.get_chatgpt_user_id()) + { + tracing::info!(target: "feedback_tags", chatgpt_user_id); + } let snapshot = self.feedback.snapshot(conversation_id); let thread_id = snapshot.thread_id.clone(); let sqlite_feedback_logs = if include_logs { diff --git a/codex-rs/core/src/auth.rs b/codex-rs/core/src/auth.rs index ddce81b24..9f13cdf2b 100644 --- a/codex-rs/core/src/auth.rs +++ b/codex-rs/core/src/auth.rs @@ -266,6 +266,12 @@ impl CodexAuth { self.get_current_token_data().and_then(|t| t.id_token.email) } + /// Returns `None` if `is_chatgpt_auth()` is false. + pub fn get_chatgpt_user_id(&self) -> Option { + self.get_current_token_data() + .and_then(|t| t.id_token.chatgpt_user_id) + } + /// Account-facing plan classification derived from the current token. /// Returns a high-level `AccountPlanType` (e.g., Free/Plus/Pro/Team/…) /// mapped from the ID token's internal plan value. Prefer this when you @@ -1466,6 +1472,7 @@ mod tests { .unwrap(); assert_eq!(None, auth.api_key()); assert_eq!(AuthMode::Chatgpt, auth.auth_mode()); + assert_eq!(auth.get_chatgpt_user_id().as_deref(), Some("user-12345")); let auth_dot_json = auth .get_current_auth_json() diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 676ce4a95..7fdc294da 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -1369,6 +1369,13 @@ impl ChatWidget { category: crate::app_event::FeedbackCategory, include_logs: bool, ) { + if let Some(chatgpt_user_id) = self + .auth_manager + .auth_cached() + .and_then(|auth| auth.get_chatgpt_user_id()) + { + tracing::info!(target: "feedback_tags", chatgpt_user_id); + } let snapshot = self.feedback.snapshot(self.thread_id); self.show_feedback_note(category, include_logs, snapshot); } @@ -1403,6 +1410,13 @@ impl ChatWidget { } pub(crate) fn open_feedback_consent(&mut self, category: crate::app_event::FeedbackCategory) { + if let Some(chatgpt_user_id) = self + .auth_manager + .auth_cached() + .and_then(|auth| auth.get_chatgpt_user_id()) + { + tracing::info!(target: "feedback_tags", chatgpt_user_id); + } let snapshot = self.feedback.snapshot(self.thread_id); let params = crate::bottom_pane::feedback_upload_consent_params( self.app_event_tx.clone(),