mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Harden TUI startup input handling (#38641)
## Why Terminal probes and other bootstrap work can leave keys or partial control sequences buffered before an interactive startup screen is visible. Those inputs must not accidentally select or confirm an action, while typeahead intended for the composer should survive terminal initialization. ## What changed - Replay user input consumed by Unix startup probes through Crossterm while filtering completed terminal color replies, and avoid consuming the Windows console input queue when detecting default colors. - Drain decoded and unread input after rendering actionable startup screens, including onboarding trust, migration, update, provider, resume, and hooks prompts. Keep incomplete control sequences quarantined and fail closed when an input boundary cannot be resolved. - Restore terminal modes if initialization exits early and bound terminal probe reads by time and byte limits. ## Testing Add parser, boundary, onboarding, and PTY coverage for preserved typeahead, split escape sequences, bracketed paste, delayed input, and fresh input after an interactive screen becomes ready. GitOrigin-RevId: 321198996cdd88fe9b43c4a762e750bff450482c
This commit is contained in:
1 parent
7e65e4f330
commit
58d2daba45
23 files changed
+939
-199
No files matched your search
@@ -181,6 +181,9 @@ impl App {
|
||||
);
|
||||
}
|
||||
Ok(ExternalAgentConfigMigrationFlowOutcome::Cancelled) => {}
|
||||
Ok(ExternalAgentConfigMigrationFlowOutcome::TerminalError(err)) => {
|
||||
return Err(err.into());
|
||||
}
|
||||
Err(error_message) => {
|
||||
self.chat_widget.add_error_message(error_message);
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ pub(super) async fn handle_model_migration_prompt_if_needed(
|
||||
model: &str,
|
||||
app_event_tx: &AppEventSender,
|
||||
available_models: &[ModelPreset],
|
||||
) -> Option<AppExitInfo> {
|
||||
) -> std::io::Result<Option<AppExitInfo>> {
|
||||
let upgrade = available_models
|
||||
.iter()
|
||||
.find(|preset| preset.model == model)
|
||||
@@ -288,7 +288,7 @@ pub(super) async fn handle_model_migration_prompt_if_needed(
|
||||
}) = upgrade
|
||||
{
|
||||
if migration_prompt_hidden(config, migration_config_key.as_str()) {
|
||||
return None;
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let target_model = target_model.to_string();
|
||||
@@ -298,12 +298,13 @@ pub(super) async fn handle_model_migration_prompt_if_needed(
|
||||
&config.notices.model_migrations,
|
||||
available_models,
|
||||
) {
|
||||
return None;
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let current_preset = available_models.iter().find(|preset| preset.model == model);
|
||||
let target_preset = target_preset_for_upgrade(available_models, &target_model);
|
||||
let target_preset = target_preset?;
|
||||
let Some(target_preset) = target_preset_for_upgrade(available_models, &target_model) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let target_display_name = target_preset.display_name.clone();
|
||||
let heading_label = if target_display_name == model {
|
||||
target_model.clone()
|
||||
@@ -323,7 +324,7 @@ pub(super) async fn handle_model_migration_prompt_if_needed(
|
||||
target_description,
|
||||
can_opt_out,
|
||||
);
|
||||
match run_model_migration_prompt(tui, prompt_copy).await {
|
||||
match run_model_migration_prompt(tui, prompt_copy).await? {
|
||||
ModelMigrationOutcome::Accepted => {
|
||||
apply_accepted_model_migration(
|
||||
config,
|
||||
@@ -340,18 +341,18 @@ pub(super) async fn handle_model_migration_prompt_if_needed(
|
||||
});
|
||||
}
|
||||
ModelMigrationOutcome::Exit => {
|
||||
return Some(AppExitInfo {
|
||||
return Ok(Some(AppExitInfo {
|
||||
token_usage: TokenUsage::default(),
|
||||
thread_id: None,
|
||||
resume_hint: None,
|
||||
update_action: None,
|
||||
exit_reason: ExitReason::UserRequested,
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
Ok(None)
|
||||
}
|
||||
pub(super) fn normalize_harness_overrides_for_cwd(
|
||||
mut overrides: ConfigOverrides,
|
||||
|
||||
Reference in new issue
Block a user