codex: update create-api-key snapshots

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Michael Fan
2026-03-26 00:16:01 -04:00
parent 39821795d4
commit 3d5d514b09
6 changed files with 18 additions and 25 deletions

View File

@@ -8,7 +8,6 @@ use crate::file_watcher::WatchRegistration;
use crate::protocol::Event;
use crate::protocol::Op;
use crate::protocol::Submission;
use std::collections::HashMap;
use codex_features::Feature;
use codex_protocol::config_types::ApprovalsReviewer;
use codex_protocol::config_types::Personality;
@@ -23,6 +22,7 @@ use codex_protocol::protocol::SessionSource;
use codex_protocol::protocol::TokenUsage;
use codex_protocol::protocol::W3cTraceContext;
use codex_protocol::user_input::UserInput;
use std::collections::HashMap;
use std::path::PathBuf;
use tokio::sync::Mutex;
use tokio::sync::watch;
@@ -124,7 +124,7 @@ impl CodexThread {
}
pub async fn set_dependency_env(&self, values: HashMap<String, String>) {
self.codex.set_dependency_env(values).await;
self.codex.session.set_dependency_env(values).await;
}
pub(crate) fn subscribe_status(&self) -> watch::Receiver<AgentStatus> {

View File

@@ -30,9 +30,7 @@ impl ChatWidget {
}
}
fn start_create_api_key_command(
app_event_tx: AppEventSender,
) -> Result<PlainHistoryCell, String> {
fn start_create_api_key_command(app_event_tx: AppEventSender) -> Result<PlainHistoryCell, String> {
if read_openai_api_key_from_env().is_some() {
return Ok(existing_shell_api_key_message());
}
@@ -40,11 +38,8 @@ fn start_create_api_key_command(
let session = start_create_api_key_flow()
.map_err(|err| format!("Failed to start API key creation: {err}"))?;
let browser_opened = session.open_browser();
let start_message = continue_in_browser_message(
session.auth_url(),
session.callback_port(),
browser_opened,
);
let start_message =
continue_in_browser_message(session.auth_url(), session.callback_port(), browser_opened);
let app_event_tx_for_task = app_event_tx;
tokio::spawn(async move {
@@ -129,11 +124,8 @@ async fn complete_command(
}
};
let copy_result = clipboard_text::copy_text_to_clipboard(&provisioned.project_api_key);
let session_env_result = apply_api_key_to_current_session(
&provisioned.project_api_key,
app_event_tx,
)
.await;
let session_env_result =
apply_api_key_to_current_session(&provisioned.project_api_key, app_event_tx).await;
success_cell(&provisioned, copy_result, session_env_result)
}
@@ -197,9 +189,7 @@ fn success_cell(
let hint = Some(format!("{copy_status} {session_env_status}"));
history_cell::new_info_event(
format!(
"Created an API key for {organization} / {project}: {masked_api_key}"
),
format!("Created an API key for {organization} / {project}: {masked_api_key}"),
hint,
)
}

View File

@@ -1,5 +1,6 @@
---
source: tui/src/chatwidget/create_api_key.rs
assertion_line: 260
expression: render_cell(&cell)
---
• Finish API key creation via your browser.
@@ -10,6 +11,6 @@ expression: render_cell(&cell)
https://auth.openai.com/oauth/authorize?client_id=abc
Codex will save OPENAI_API_KEY to /tmp/workspace/.env.local and hot-apply it here when allowed.
Codex will display the new OPENAI_API_KEY here and copy it to your clipboard.
On a remote or headless machine, forward localhost:5000 back to this Codex host before opening the link.

View File

@@ -1,5 +1,6 @@
---
source: tui/src/chatwidget/create_api_key.rs
assertion_line: 232
expression: render_cell(&cell)
---
• Created an API key for Default Org / Default Project and saved OPENAI_API_KEY to /tmp/workspace/.env.local. Updated this session to use the newly created API key without touching auth.json.
• Created an API key for Default Org / Default Project: sk-proj-123 Copied the full key to your clipboard. Set OPENAI_API_KEY in this Codex session for spawned commands.

View File

@@ -0,0 +1,6 @@
---
source: tui/src/chatwidget/create_api_key.rs
assertion_line: 249
expression: render_cell(&cell)
---
• Created an API key for org-default / proj-default: sk-proj-123 Could not copy the key to your clipboard: clipboard unavailable Could not set OPENAI_API_KEY in this Codex session: dependency env unavailable

View File

@@ -1,5 +0,0 @@
---
source: tui/src/chatwidget/create_api_key.rs
expression: render_cell(&cell)
---
• Created an API key for org-default / proj-default and saved OPENAI_API_KEY to /tmp/workspace/.env.local. Saved OPENAI_API_KEY to .env.local, but left this session unchanged because ChatGPT login is required here.