aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT

- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser,
  device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity,
  runtime agent instance, backend-client e openapi-models, workspace routing.
- Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin
  remoti (catalogo, sync, share), cyber access program, daybreak, cloud config
  e requirements (config_server ora fail-closed), attestation, frozen cloud
  skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/
  routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime.
- Messaggi d'errore senza link a chatgpt.com.
- Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed.
- Test: cancellati solo quelli del codice rimosso; test di sicurezza
  (sandbox estensioni, permessi, redazione, auth storage, requirements)
  adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents).
- Istruzioni di sistema invariate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:20:15 +01:00
parent 82347a58ed
commit 6089fbde91
1573 changed files with 10289 additions and 177679 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -7,23 +7,11 @@ use pretty_assertions::assert_eq;
#[tokio::test]
async fn held_enter_requires_a_fresh_confirmation_to_save_a_prefilled_api_key() {
let (mut widget, _home) = tests::widget_forced_chatgpt().await;
let (mut widget, _home) = tests::widget_api_login_forbidden().await;
widget.auth_config.forced_login_method = None;
let enter = |kind| KeyEvent::new_with_kind(KeyCode::Enter, KeyModifiers::NONE, kind);
widget.handle_key_event(KeyCode::Up.into());
widget.handle_key_event(enter(KeyEventKind::Press));
widget.handle_key_event(enter(KeyEventKind::Repeat));
widget.handle_key_event(enter(KeyEventKind::Press));
widget.handle_key_event(KeyCode::Down.into());
widget.handle_key_event(enter(KeyEventKind::Repeat));
assert_eq!(widget.highlighted_mode, SignInOption::ApiKey);
assert!(matches!(
*widget.sign_in_state.read().unwrap(),
SignInState::PickMode
));
widget.handle_key_event(enter(KeyEventKind::Release));
widget.handle_key_event(enter(KeyEventKind::Press));
{
let mut state = widget.sign_in_state.write().unwrap();

View File

@@ -1,313 +0,0 @@
use codex_app_server_protocol::ClientRequest;
use codex_app_server_protocol::LoginAccountParams;
use codex_app_server_protocol::LoginAccountResponse;
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::prelude::Widget;
use ratatui::style::Stylize;
use ratatui::text::Line;
use ratatui::widgets::Paragraph;
use ratatui::widgets::Wrap;
use uuid::Uuid;
use crate::motion::MotionMode;
use crate::motion::shimmer_text;
use super::AuthModeWidget;
use super::ContinueWithDeviceCodeState;
use super::SignInState;
use super::cancel_login_attempt;
use super::mark_url_hyperlink;
use super::onboarding_request_id;
pub(super) fn start_headless_chatgpt_login(widget: &mut AuthModeWidget) {
let request_id = Uuid::new_v4().to_string();
*widget.sign_in_state.write().unwrap() =
SignInState::ChatGptDeviceCode(ContinueWithDeviceCodeState::pending(request_id.clone()));
widget.request_frame.schedule_frame();
let request_handle = widget.app_server_request_handle.clone();
let sign_in_state = widget.sign_in_state.clone();
let request_frame = widget.request_frame.clone();
let error = widget.error.clone();
tokio::spawn(async move {
match request_handle
.request_typed::<LoginAccountResponse>(ClientRequest::LoginAccount {
request_id: onboarding_request_id(),
params: LoginAccountParams::ChatgptDeviceCode,
})
.await
{
Ok(LoginAccountResponse::ChatgptDeviceCode {
login_id,
verification_url,
user_code,
}) => {
let updated = set_device_code_state_for_active_attempt(
&sign_in_state,
&request_frame,
&request_id,
ContinueWithDeviceCodeState::ready(
request_id.clone(),
login_id.clone(),
verification_url,
user_code,
),
);
if updated {
*error.write().unwrap() = None;
} else {
cancel_login_attempt(&request_handle, login_id).await;
}
}
Ok(other) => {
let _updated = set_device_code_error_for_active_attempt(
&sign_in_state,
&request_frame,
&error,
&request_id,
format!("Unexpected account/login/start response: {other:?}"),
);
}
Err(err) => {
let _updated = set_device_code_error_for_active_attempt(
&sign_in_state,
&request_frame,
&error,
&request_id,
err.to_string(),
);
}
}
});
}
pub(super) fn render_device_code_login(
widget: &AuthModeWidget,
area: Rect,
buf: &mut Buffer,
state: &ContinueWithDeviceCodeState,
) {
let banner = if state.is_showing_copyable_auth() {
"Finish signing in via your browser"
} else {
"Preparing device code login"
};
let mut spans = vec![" ".into()];
if widget.animations_enabled && !widget.animations_suppressed.get() {
widget
.request_frame
.schedule_frame_in(std::time::Duration::from_millis(100));
spans.extend(shimmer_text(banner, MotionMode::Animated));
} else {
spans.push(banner.into());
}
let mut lines = vec![spans.into(), "".into()];
let verification_url = if let (Some(verification_url), Some(user_code)) =
(&state.verification_url, &state.user_code)
{
lines.push(" 1. Open this link in your browser and sign in".into());
lines.push("".into());
lines.push(Line::from(vec![
" ".into(),
verification_url.as_str().cyan().underlined(),
]));
lines.push("".into());
lines.push(
" 2. Enter this one-time code after you are signed in (expires in 15 minutes)".into(),
);
lines.push("".into());
lines.push(Line::from(vec![
" ".into(),
user_code.as_str().cyan().bold(),
]));
lines.push("".into());
lines.push(
" Continue only if you started this login in Codex. If a website or another person gave you this code, cancel."
.dim()
.into(),
);
lines.push("".into());
Some(verification_url.clone())
} else {
lines.push(" Requesting a one-time code...".dim().into());
lines.push("".into());
None
};
lines.push(Line::from(vec![
" Press ".dim(),
widget.cancel_binding().into(),
" to cancel".dim(),
]));
Paragraph::new(lines)
.wrap(Wrap { trim: false })
.render(area, buf);
if let Some(url) = &verification_url {
mark_url_hyperlink(buf, area, url);
}
}
fn device_code_attempt_matches(state: &SignInState, request_id: &str) -> bool {
matches!(
state,
SignInState::ChatGptDeviceCode(state) if state.request_id == request_id
)
}
fn set_device_code_state_for_active_attempt(
sign_in_state: &std::sync::Arc<std::sync::RwLock<SignInState>>,
request_frame: &crate::tui::FrameRequester,
request_id: &str,
next_state: ContinueWithDeviceCodeState,
) -> bool {
let mut guard = sign_in_state.write().unwrap();
if !device_code_attempt_matches(&guard, request_id) {
return false;
}
*guard = SignInState::ChatGptDeviceCode(next_state);
drop(guard);
request_frame.schedule_frame();
true
}
fn set_device_code_error_for_active_attempt(
sign_in_state: &std::sync::Arc<std::sync::RwLock<SignInState>>,
request_frame: &crate::tui::FrameRequester,
error: &std::sync::Arc<std::sync::RwLock<Option<String>>>,
request_id: &str,
message: String,
) -> bool {
let mut guard = sign_in_state.write().unwrap();
if !device_code_attempt_matches(&guard, request_id) {
return false;
}
*guard = SignInState::PickMode;
drop(guard);
*error.write().unwrap() = Some(message);
request_frame.schedule_frame();
true
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
use std::sync::Arc;
use std::sync::RwLock;
fn pending_device_code_state(request_id: &str) -> Arc<RwLock<SignInState>> {
Arc::new(RwLock::new(SignInState::ChatGptDeviceCode(
ContinueWithDeviceCodeState::pending(request_id.to_string()),
)))
}
#[test]
fn device_code_attempt_matches_only_for_matching_request_id() {
let state = SignInState::ChatGptDeviceCode(ContinueWithDeviceCodeState::pending(
"request-1".to_string(),
));
assert_eq!(device_code_attempt_matches(&state, "request-1"), true);
assert_eq!(device_code_attempt_matches(&state, "request-2"), false);
assert_eq!(
device_code_attempt_matches(&SignInState::PickMode, "request-1"),
false
);
}
#[test]
fn set_device_code_state_for_active_attempt_updates_only_when_active() {
let request_frame = crate::tui::FrameRequester::test_dummy();
let sign_in_state = pending_device_code_state("request-1");
assert_eq!(
set_device_code_state_for_active_attempt(
&sign_in_state,
&request_frame,
"request-1",
ContinueWithDeviceCodeState::ready(
"request-1".to_string(),
"login-1".to_string(),
"https://example.com/device".to_string(),
"ABCD-EFGH".to_string(),
),
),
true
);
assert!(matches!(
&*sign_in_state.read().unwrap(),
SignInState::ChatGptDeviceCode(state) if state.login_id() == Some("login-1")
));
let sign_in_state = pending_device_code_state("request-2");
assert_eq!(
set_device_code_state_for_active_attempt(
&sign_in_state,
&request_frame,
"request-1",
ContinueWithDeviceCodeState::ready(
"request-1".to_string(),
"login-1".to_string(),
"https://example.com/device".to_string(),
"ABCD-EFGH".to_string(),
),
),
false
);
assert!(matches!(
&*sign_in_state.read().unwrap(),
SignInState::ChatGptDeviceCode(state) if state.login_id.is_none()
));
}
#[test]
fn set_device_code_error_for_active_attempt_updates_only_when_active() {
let request_frame = crate::tui::FrameRequester::test_dummy();
let error = Arc::new(RwLock::new(None));
let sign_in_state = pending_device_code_state("request-1");
assert_eq!(
set_device_code_error_for_active_attempt(
&sign_in_state,
&request_frame,
&error,
"request-1",
"device code unavailable".to_string(),
),
true
);
assert!(matches!(
&*sign_in_state.read().unwrap(),
SignInState::PickMode
));
assert_eq!(
error.read().unwrap().as_deref(),
Some("device code unavailable")
);
let error = Arc::new(RwLock::new(None));
let sign_in_state = pending_device_code_state("request-2");
assert_eq!(
set_device_code_error_for_active_attempt(
&sign_in_state,
&request_frame,
&error,
"request-1",
"device code unavailable".to_string(),
),
false
);
assert!(matches!(
&*sign_in_state.read().unwrap(),
SignInState::ChatGptDeviceCode(_)
));
assert_eq!(*error.read().unwrap(), None);
}
}

View File

@@ -19,7 +19,6 @@ use codex_app_server_protocol::GatewayOAuthChangedNotification;
use codex_app_server_protocol::GatewayOAuthLoginResponse;
use codex_app_server_protocol::GatewayOAuthReadResponse;
use codex_app_server_protocol::GatewayOAuthStatus;
use codex_protocol::config_types::ForcedLoginMethod;
use color_eyre::Result;
use color_eyre::eyre::OptionExt;
@@ -58,13 +57,6 @@ pub(crate) async fn authenticate_gateway(
.auth_widget_mut()
.ok_or_eyre("The gateway login screen is unavailable.")?;
match login {
Login::Primary
if widget
.auth_config
.is_login_method_allowed(ForcedLoginMethod::Chatgpt) =>
{
widget.start_chatgpt_login();
}
Login::Primary => widget.start_api_key_entry(),
Login::GatewayOAuth => widget.start_gateway_oauth(config.model_provider_id.clone()),
}

View File

@@ -31,13 +31,12 @@ fn screen(widget: &AuthModeWidget, height: u16) -> String {
#[tokio::test]
async fn select_a_saved_gateway_during_sign_in() -> color_eyre::Result<()> {
let (mut widget, home) = super::tests::widget_forced_chatgpt().await;
let (mut widget, home) = super::tests::widget_api_login_forbidden().await;
widget.auth_config.forced_login_method = None;
widget.bedrock_setup_enabled = true;
widget.gcp_setup_enabled = true;
widget.gateway_setup_enabled = true;
widget.handle_key_event(KeyCode::Char('3').into());
insta::assert_snapshot!("gateway_sign_in_menu", screen(&widget, /*height*/ 8));
widget.handle_key_event(KeyCode::Char('4').into());
widget.advance_gateway_request().await;
@@ -77,7 +76,7 @@ wire_api = "responses"
#[tokio::test]
async fn create_highlights_the_saved_gateway_until_explicitly_selected() -> color_eyre::Result<()> {
let (mut widget, home) = super::tests::widget_forced_chatgpt().await;
let (mut widget, home) = super::tests::widget_api_login_forbidden().await;
widget.auth_config.forced_login_method = None;
widget.bedrock_setup_enabled = true;
widget.gcp_setup_enabled = true;
@@ -94,7 +93,6 @@ async fn create_highlights_the_saved_gateway_until_explicitly_selected() -> colo
)
.await
.map_err(color_eyre::Report::msg)?;
widget.handle_key_event(KeyCode::Char('3').into());
widget.handle_key_event(KeyCode::Char('4').into());
widget.advance_gateway_request().await;
widget.handle_key_event(KeyCode::Down.into());
@@ -182,7 +180,7 @@ async fn create_highlights_the_saved_gateway_until_explicitly_selected() -> colo
#[tokio::test]
async fn gateway_oauth_displays_the_browser_link_and_retry_action() {
let (widget, _home) = super::tests::widget_forced_chatgpt().await;
let (widget, _home) = super::tests::widget_api_login_forbidden().await;
*widget.sign_in_state.write().unwrap() = SignInState::GatewayOAuth {
provider_id: "office".into(),
url: Some("https://office.example.test/authorize".into()),

View File

@@ -14,7 +14,7 @@ use serde_json::json;
#[tokio::test]
async fn gcp_menu_gating_and_setup_flow() {
let (mut widget, home) = super::tests::widget_forced_chatgpt().await;
let (mut widget, home) = super::tests::widget_api_login_forbidden().await;
widget.auth_config.forced_login_method = None;
widget.handle_sign_in_option(SignInOption::Gcp);
assert!(matches!(
@@ -41,7 +41,6 @@ async fn gcp_menu_gating_and_setup_flow() {
let press = |key| KeyEvent::new(key, KeyModifiers::NONE);
widget.gcp_setup_enabled = true;
widget.handle_key_event(press(KeyCode::Char('3')));
assert_eq!(
widget.displayed_sign_in_options(),
vec![SignInOption::ApiKey, SignInOption::Gcp]
@@ -59,16 +58,11 @@ async fn gcp_menu_gating_and_setup_flow() {
));
snapshot(&widget, "gcp_sign_in_menu", Rect::new(0, 0, 76, 21));
widget.handle_key_event(press(KeyCode::Up));
assert_eq!(widget.highlighted_mode, SignInOption::Gcp);
snapshot(&widget, "gcp_sign_in_menu_short", Rect::new(0, 0, 76, 8));
widget.handle_key_event(press(KeyCode::Esc));
assert_eq!(widget.highlighted_mode, SignInOption::OtherMethods);
let area = Rect::new(0, 0, 76, 12);
widget.auth_config.forced_login_method = Some(ForcedLoginMethod::Chatgpt);
assert_eq!(
widget.displayed_sign_in_options(),
vec![SignInOption::ChatGpt, SignInOption::DeviceCode]
);
widget.handle_sign_in_option(SignInOption::Gcp);
assert!(matches!(
&*widget.sign_in_state.read().unwrap(),
@@ -76,23 +70,7 @@ async fn gcp_menu_gating_and_setup_flow() {
));
widget.auth_config.forced_login_method = None;
*widget.sign_in_state.write().unwrap() =
SignInState::ChatGptDeviceCode(ContinueWithDeviceCodeState::pending("login".into()));
widget.handle_key_event(press(KeyCode::Char('3')));
assert!(matches!(
&*widget.sign_in_state.read().unwrap(),
SignInState::ChatGptDeviceCode(_)
));
widget.cancel_active_attempt();
widget.handle_key_event(press(KeyCode::Char('3')));
widget.handle_key_event(press(KeyCode::Char('1')));
widget.handle_key_event(press(KeyCode::Esc));
assert_eq!(widget.highlighted_mode, SignInOption::ApiKey);
widget.handle_key_event(press(KeyCode::Char('3')));
widget.handle_key_event(press(KeyCode::Esc));
assert_eq!(widget.highlighted_mode, SignInOption::Gcp);
widget.handle_key_event(press(KeyCode::Enter));
assert!(widget.is_text_entry_active());
assert!(widget.should_suppress_printable_quit());
widget.handle_key_event(KeyEvent::new_with_kind(

View File

@@ -26,7 +26,6 @@ pub(crate) const SELECT_THIRD: [KeyBinding; 1] = [key_hint::plain(KeyCode::Char(
pub(crate) const SELECT_FOURTH: [KeyBinding; 1] = [key_hint::plain(KeyCode::Char('4'))];
pub(crate) const CONFIRM: [KeyBinding; 1] = [key_hint::plain(KeyCode::Enter)];
pub(crate) const CANCEL: [KeyBinding; 1] = [key_hint::plain(KeyCode::Esc)];
pub(crate) const COPY_LINK: [KeyBinding; 1] = [key_hint::plain(KeyCode::Char('c'))];
pub(crate) const QUIT: [KeyBinding; 3] = [
key_hint::plain(KeyCode::Char('q')),
key_hint::ctrl(KeyCode::Char('c')),

View File

@@ -29,12 +29,8 @@ use ratatui::style::Color;
use ratatui::widgets::Clear;
use ratatui::widgets::WidgetRef;
use codex_protocol::config_types::ForcedLoginMethod;
use crate::LoginStatus;
use crate::app_server_session::AppServerSession;
use crate::clipboard_copy::CopyFormat;
use crate::clipboard_copy::CopyStatus;
use crate::config_update::RemoteProjectTrust;
use crate::config_update::format_config_error;
use crate::config_update::replace_config_value;
@@ -172,12 +168,7 @@ impl OnboardingScreen {
#[cfg(not(target_os = "windows"))]
let show_windows_create_sandbox_hint = false;
if show_login_screen {
let highlighted_mode =
if auth_config.is_login_method_allowed(ForcedLoginMethod::Chatgpt) {
SignInOption::ChatGpt
} else {
SignInOption::OtherMethods
};
let highlighted_mode = SignInOption::ApiKey;
if let Some(app_server_request_handle) = app_server_request_handle {
steps.push(Step::Auth(AuthModeWidget {
request_frame: tui.frame_requester(),
@@ -193,9 +184,6 @@ impl OnboardingScreen {
gcp_setup_enabled,
gateway_setup_enabled,
gateway: None,
animations_enabled: local_settings.tui.animations
&& local_settings.tui.effects.shimmer,
animations_suppressed: std::cell::Cell::new(false),
}));
} else {
tracing::warn!("skipping onboarding login step without app-server request handle");
@@ -268,15 +256,6 @@ impl OnboardingScreen {
out
}
fn should_suppress_animations(&self) -> bool {
// Freeze the whole onboarding screen when auth is showing copyable login
// material so terminal selection is not interrupted by redraws.
self.current_steps().into_iter().any(|step| match step {
Step::Auth(widget) => widget.should_suppress_animations(),
Step::Welcome(_) | Step::TrustDirectory(_) | Step::GovCloudGuidance { .. } => false,
})
}
fn is_auth_in_progress(&self) -> bool {
self.steps.iter().any(|step| {
matches!(step, Step::Auth(_)) && matches!(step.get_step_state(), StepState::InProgress)
@@ -303,14 +282,6 @@ impl OnboardingScreen {
.is_some_and(|step| matches!(step, Step::TrustDirectory(_)))
}
fn cancel_auth_if_active(&self) {
for step in &self.steps {
if let Step::Auth(widget) = step {
widget.cancel_active_attempt();
}
}
}
pub(super) fn auth_widget_mut(&mut self) -> Option<&mut AuthModeWidget> {
self.steps.iter_mut().find_map(|step| match step {
Step::Auth(widget) => Some(widget),
@@ -320,11 +291,6 @@ impl OnboardingScreen {
fn handle_app_server_notification(&mut self, notification: ServerNotification) {
match notification {
ServerNotification::AccountLoginCompleted(notification) => {
if let Some(widget) = self.auth_widget_mut() {
widget.on_account_login_completed(notification);
}
}
ServerNotification::GatewayOAuthChanged(notification) => {
if let Some(widget) = self.auth_widget_mut() {
widget.on_gateway_oauth_changed(notification);
@@ -375,7 +341,6 @@ impl KeyboardHandler for OnboardingScreen {
&& !suppress_quit_while_typing(key_event, text_entry_context);
if should_quit {
if self.is_auth_in_progress() {
self.cancel_auth_if_active();
// If the user cancels the auth menu, exit the app rather than
// leave the user at a prompt in an unauthed state.
self.should_exit = true;
@@ -440,10 +405,7 @@ fn suppress_quit_while_typing(key_event: KeyEvent, text_entry_context: TextEntry
impl WidgetRef for &OnboardingScreen {
fn render_ref(&self, area: Rect, buf: &mut Buffer) {
let suppress_animations = self.should_suppress_animations();
let logo_presentation = if suppress_animations {
Presentation::Hidden
} else if self.text_entry_context().active {
let logo_presentation = if self.text_entry_context().active {
Presentation::Faded
} else {
Presentation::Animated
@@ -451,8 +413,7 @@ impl WidgetRef for &OnboardingScreen {
for step in self.current_steps() {
match step {
Step::Welcome(widget) => widget.set_presentation(logo_presentation),
Step::Auth(widget) => widget.set_animations_suppressed(suppress_animations),
Step::TrustDirectory(_) | Step::GovCloudGuidance { .. } => {}
Step::Auth(_) | Step::TrustDirectory(_) | Step::GovCloudGuidance { .. } => {}
}
}
@@ -642,8 +603,6 @@ async fn run_onboarding_screen_inner(
use tokio_stream::StreamExt;
let mut directory_trust_persisted = false;
// One-time guard to fully clear the screen after ChatGPT login success message is shown
let mut did_full_clear_after_success = false;
let mut pending_copy: Option<(u64, String)> = None;
tui.draw(u16::MAX, |frame| {
frame.render_widget_ref(&onboarding_screen, frame.area());
@@ -667,36 +626,7 @@ async fn run_onboarding_screen_inner(
tui.screen_size_for_event(&event)?;
match event {
TuiEvent::Key(key_event) => {
let copy_link = if key_event.kind == KeyEventKind::Press
&& keys::COPY_LINK.is_pressed(key_event)
&& let Some(Step::Auth(widget)) = onboarding_screen.current_steps().last()
&& let Ok(state) = widget.sign_in_state.read()
&& let SignInState::ChatGptContinueInBrowser(state) = &*state
&& !state.auth_url.is_empty()
{
Some((state.login_id.clone(), Arc::<str>::from(state.auth_url.as_str())))
} else {
None
};
if let Some((login_id, url)) = copy_link {
let result = tui.clipboard.copy(url, CopyFormat::PlainText, tui.frame_requester());
let message = match result {
Ok(CopyStatus::Pending(id)) => {
pending_copy = Some((id, login_id));
"Copying link…".to_string()
}
Ok(CopyStatus::Busy) => "Clipboard busy; try again".to_string(),
Ok(CopyStatus::Confirmed) => "Copied link to clipboard".to_string(),
Ok(CopyStatus::Unconfirmed) => "Copy requested; check your clipboard".to_string(),
Err(error) => format!("Could not copy link: {error}"),
};
if let Some(Step::Auth(widget)) = onboarding_screen.current_steps_mut().into_iter().last() {
*widget.error.write().unwrap_or_else(std::sync::PoisonError::into_inner) = Some(message);
}
tui.frame_requester().schedule_frame();
} else {
onboarding_screen.handle_key_event(key_event);
}
onboarding_screen.handle_key_event(key_event);
if !directory_trust_persisted {
directory_trust_persisted = persist_selected_trust(
&mut onboarding_screen,
@@ -713,25 +643,6 @@ async fn run_onboarding_screen_inner(
| TuiEvent::Resize(_)
| TuiEvent::FocusGained
| TuiEvent::FocusLost => {
if let Some((id, result)) = tui.clipboard.poll().cloned()
&& let Some((pending_id, login_id)) = &pending_copy
&& id == *pending_id
{
if let Some(Step::Auth(widget)) = onboarding_screen.current_steps_mut().into_iter().last()
&& widget.sign_in_state.read().is_ok_and(|state| {
matches!(&*state, SignInState::ChatGptContinueInBrowser(state) if state.login_id == *login_id)
})
{
let message = match result {
Ok(CopyStatus::Confirmed) => "Copied link to clipboard".to_string(),
Ok(CopyStatus::Unconfirmed) => "Copy requested; check your clipboard".to_string(),
Ok(CopyStatus::Busy | CopyStatus::Pending(_)) => "Clipboard busy; try again".to_string(),
Err(error) => format!("Could not copy link: {error}"),
};
*widget.error.write().unwrap_or_else(std::sync::PoisonError::into_inner) = Some(message);
}
pending_copy = None;
}
for step in &onboarding_screen.steps {
if let Step::Welcome(widget) = step {
if matches!(&event, TuiEvent::Resume) {
@@ -740,36 +651,6 @@ async fn run_onboarding_screen_inner(
widget.set_focused(tui.is_terminal_focused());
}
}
if !did_full_clear_after_success
&& onboarding_screen.steps.iter().any(|step| {
if let Step::Auth(w) = step {
w.sign_in_state.read().is_ok_and(|g| {
matches!(&*g, super::auth::SignInState::ChatGptSuccessMessage)
})
} else {
false
}
})
{
// Reset any lingering SGR (underline/color) before clearing
let _ = ratatui::crossterm::execute!(
std::io::stdout(),
ratatui::crossterm::style::SetAttribute(
ratatui::crossterm::style::Attribute::Reset
),
ratatui::crossterm::style::SetAttribute(
ratatui::crossterm::style::Attribute::NoUnderline
),
ratatui::crossterm::style::SetForegroundColor(
ratatui::crossterm::style::Color::Reset
),
ratatui::crossterm::style::SetBackgroundColor(
ratatui::crossterm::style::Color::Reset
)
);
let _ = tui.terminal.clear();
did_full_clear_after_success = true;
}
tui.draw(u16::MAX, |frame| {
frame.render_widget_ref(&onboarding_screen, frame.area());
})?;

View File

@@ -1,12 +1,12 @@
---
source: tui/src/onboarding/gateway_tests.rs
expression: terminal.backend().to_string()
assertion_line: 40
expression: "screen(&widget, 8)"
---
Sign in another way
Choose how you want to use Codex.
> 1. Use an OpenAI API key
2. Use Amazon Bedrock
3. Use Google Cloud Vertex AI
4. Use a custom provider or gateway
Press enter to continue
Press esc to go back

View File

@@ -1,8 +1,9 @@
---
source: tui/src/onboarding/gcp_tests.rs
assertion_line: 34
expression: terminal.backend().to_string()
---
Sign in another way
Choose how you want to use Codex.
> 1. Use an OpenAI API key
Pay for what you use
@@ -14,4 +15,3 @@ expression: terminal.backend().to_string()
Connect using your Google Cloud credentials
Press enter to continue
Press esc to go back

View File

@@ -1,11 +1,11 @@
---
source: tui/src/onboarding/gcp_tests.rs
assertion_line: 34
expression: terminal.backend().to_string()
---
Sign in another way
Choose how you want to use Codex.
1. Use an OpenAI API key
2. Use Amazon Bedrock
> 3. Use Google Cloud Vertex AI
Press enter to continue
Press esc to go back

View File

@@ -1,11 +1,11 @@
---
source: tui/src/onboarding/gcp_tests.rs
assertion_line: 34
expression: terminal.backend().to_string()
---
Sign in with ChatGPT to use Codex as part of your paid plan
or connect an API key for usage-based billing
Connect an API key to use Codex.
> 1. Use an OpenAI API key
Pay for what you use
> 1. Sign in with ChatGPT
2. Sign in with Device Code
3. Sign in another way
Press enter to continue

View File

@@ -1,25 +0,0 @@
---
source: tui/src/onboarding/auth.rs
expression: contents
---
Finish signing in via your browser
If the link doesn't open automatically,
press c to copy it:
https://auth.openai.com/oauth/authorize?re
sponse_type=code&client_id=app_EMoamEEZ73f0C
kXaXp7hrann&redirect_uri=http%3A%2F%2Flocalh
ost%3A1455%2Fauth%2Fcallback&scope=openid%20
profile%20email%20offline_access%20api.conne
ctors.read%20api.connectors.invoke&code_chal
lenge=1YM3Z8QbrLbdt9C3eX3j7UQ4GmFRmKz4OeVYwD
6s5xA&code_challenge_method=S256&id_token_ad
d_organizations=true&codex_cli_simplified_fl
ow=true&state=8cHjQ4nVx2Yp7Lm9Rk3Wf6Ta1Bs5Du
0Ei4Go7Nz2PqM&originator=codex_cli_rs
On a remote or headless machine? Press esc
and choose Sign in with Device Code.
Press esc to cancel