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

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());
})?;