mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Cancel folder trust prompts when the app server disconnects (#63262)
## Why A daemon restart can invalidate the connection while a folder trust prompt is open. A queued confirmation can otherwise still be handled against that closed connection. ## What changed Dismiss the folder trust prompt when the connection closes, giving the disconnect priority over queued input. Leave the disconnect event for the Agents overview to handle. During startup, exit with a message asking the user to restart Codex. ## Testing Add tests for daemon restarts during folder consent in the Agents overview and at startup. Both check that the restart leaves the trust setting unset. A unit test checks that disconnect wins over queued Enter. GitOrigin-RevId: 21ee1ca625ed8bc2266a9a37a260254d4e87369d
This commit is contained in:
committed by
copyberry
parent
326bac6ce0
commit
794584993e
@@ -32,6 +32,18 @@ async fn agents_defers_launch_directory_trust_until_starting_a_task() -> Result<
|
||||
daemon_startup("agents-untrusted").await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(unix)]
|
||||
async fn agents_cancels_folder_consent_when_daemon_restarts() -> Result<()> {
|
||||
daemon_startup("agents-trust-restart").await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(unix)]
|
||||
async fn startup_folder_consent_explains_connection_loss() -> Result<()> {
|
||||
daemon_startup("startup-trust-restart").await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(unix)]
|
||||
async fn discovered_managed_daemon_can_restart_with_auto_start_disabled() -> Result<()> {
|
||||
@@ -177,6 +189,14 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
"failed to prepare CLI test executable"
|
||||
);
|
||||
let bedrock_onboarding = matches!(command, "bedrock" | "bedrock-running");
|
||||
let trust_restart = matches!(command, "agents-trust-restart" | "startup-trust-restart");
|
||||
if trust_restart {
|
||||
fs::create_dir(workspace_path.join(".codex"))?;
|
||||
fs::write(
|
||||
workspace_path.join(".codex/config.toml"),
|
||||
"# project settings\n",
|
||||
)?;
|
||||
}
|
||||
fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!(
|
||||
@@ -187,7 +207,7 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
tui.disable_paste_burst = true\n\
|
||||
{}\n\
|
||||
notice.model_migrations.\"gpt-5.6-terra\" = \"gpt-6-sol\"\n\
|
||||
[projects.{}]\ntrust_level = \"{}\"\n",
|
||||
[projects.{}]\n{}\n",
|
||||
if command == "discovered" {
|
||||
"tui.status_line=[\"model\",\"thread-id\",\"thread-name\"]\nfeatures.daemon_auto_start=false"
|
||||
} else if bedrock_onboarding {
|
||||
@@ -196,10 +216,12 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
""
|
||||
},
|
||||
serde_json::to_string(&workspace_path)?,
|
||||
if command == "agents-untrusted" {
|
||||
"untrusted"
|
||||
if trust_restart {
|
||||
""
|
||||
} else if command == "agents-untrusted" {
|
||||
"trust_level = \"untrusted\""
|
||||
} else {
|
||||
"trusted"
|
||||
"trust_level = \"trusted\""
|
||||
},
|
||||
),
|
||||
)?;
|
||||
@@ -245,6 +267,7 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
| "bedrock-running"
|
||||
| "restrictive-job"
|
||||
) || mismatch
|
||||
|| trust_restart
|
||||
{
|
||||
// A selected package with a stopped daemon avoids installing a release.
|
||||
let managed = home
|
||||
@@ -314,6 +337,15 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
steps.push_back(("GPT-5.6-Terra", b"/daemon\r"));
|
||||
steps.push_back(("Restartbackgroundserver", b"\x1b[F\r"));
|
||||
"Restartbackgroundserver?"
|
||||
} else if trust_restart {
|
||||
steps.push_back(("Trustandcontinue", b""));
|
||||
if command == "agents-trust-restart" {
|
||||
args.push("agents".into());
|
||||
steps.push_front(("Notasksyet", b"n"));
|
||||
"Notasksyet"
|
||||
} else {
|
||||
"RestartCodextocontinue."
|
||||
}
|
||||
} else if command == "agents-untrusted" {
|
||||
args.push("agents".into());
|
||||
steps.push_back(("Notasksyet", b"n"));
|
||||
@@ -527,10 +559,26 @@ async fn daemon_startup(command: &str) -> Result<()> {
|
||||
ensure!(settings["featureOverrides"]["auth_elicitation"].is_null());
|
||||
}
|
||||
}
|
||||
writer.send(input.to_vec()).await?;
|
||||
if trust_restart && *ready == "Trustandcontinue" {
|
||||
let restarted = tokio::process::Command::new(&codex)
|
||||
.env_clear()
|
||||
.envs(&env)
|
||||
.current_dir(&workspace_path)
|
||||
.args(["app-server", "daemon", "restart"])
|
||||
.kill_on_drop(true)
|
||||
.output()
|
||||
.await?;
|
||||
ensure!(restarted.status.success(), "{}", String::from_utf8_lossy(&restarted.stderr));
|
||||
} else {
|
||||
writer.send(input.to_vec()).await?;
|
||||
}
|
||||
steps.pop_front();
|
||||
output.clear();
|
||||
} else if steps.is_empty() && text.contains(expected) {
|
||||
if trust_restart {
|
||||
let config = fs::read_to_string(home.path().join("config.toml"))?;
|
||||
ensure!(!config.contains("trust_level"), "restart must not grant trust");
|
||||
}
|
||||
if command == "agents-untrusted" {
|
||||
let transition = format!(
|
||||
"{initial_agents_screen}\n\n--- Start a task ---\n\n{}",
|
||||
|
||||
Reference in New Issue
Block a user