Show onboarding when Codex home lacks authentication state (#38644)

## Why

Routine state such as history, logs, sessions, or temporary files does not mean
that the default account can authenticate. Treating any non-pristine Codex home
as configured can show the composer before onboarding is complete.

## What changed

- Base the startup decision on authentication-relevant state instead of requiring
  an empty Codex home. Existing credentials, configuration, workload identity,
  managed configuration, or a running local daemon continue to keep the composer
  visible.
- Treat an unreadable or ambiguous home conservatively and keep the composer
  visible.
- Allow onboarding when the legacy `--search` flag is the only configuration
  override.

## Testing

Expanded startup preflight and draft tests to cover existing home state,
credential sources, workload identity markers, daemon state, ambiguous paths,
and search-only overrides.

GitOrigin-RevId: 76837e3fd6aa714f2a7f72d191088a3faae23515
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-08-14 20:38:52 +00:00
1 parent 6d97d4c102
commit efa97f9bc6
4 files changed
+207 -58

No files matched your search

+21 -1
View File
@@ -518,7 +518,27 @@ async fn startup_draft_waits_for_onboarding_before_accepting_input() {
]
.into_iter(),
);
pump.initial_screen = StartupDraftInitialScreen::Onboarding;
let codex_home = tempfile::tempdir().expect("create an existing custom Codex home");
std::fs::write(codex_home.path().join("history.jsonl"), "")
.expect("create existing startup history");
let system_config_path = codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path(
codex_home.path().join("system.toml"),
)
.expect("resolve missing system configuration");
let search_override = [("web_search".to_string(), toml::Value::String("live".into()))];
pump.initial_screen =
if crate::startup_preflight::has_only_search_config_override(&search_override)
&& crate::startup_preflight::should_delay_startup_composer_for_first_login(
codex_home.path(),
Ok(system_config_path),
|| Ok(false),
|name| (name == "CODEX_HOME").then(|| codex_home.path().as_os_str().to_os_string()),
)
{
StartupDraftInitialScreen::Onboarding
} else {
StartupDraftInitialScreen::Composer
};
let mut tui = crate::tui::test_support::make_test_tui().expect("create test terminal");
pump.show_initial_screen(&mut tui)
.expect("keep the composer hidden until onboarding finishes");