mirror of
https://github.com/openai/codex.git
synced 2026-11-20 07:06:24 +00:00
Defer managed worktree transitions to fresh TUI loop iterations (#43298)
## Why Managed worktree transitions run through the event handler into the large synchronous `ChatWidget` constructor. Split this work so each stage runs on a fresh event-loop stack. ## What changed - Queue worktree setup, checkout completion and configuration loading, session transition, and widget attachment as separate stages with boxed futures. - Recheck the source session before transitioning and report retained checkout cleanup instructions when the transition cannot proceed. - Keep the old configuration paired with the old widget until attachment, and protect input during the handoff. ## Testing Update worktree lifecycle and submission tests to drain the deferred stages explicitly and assert that checkout creation starts before completion. GitOrigin-RevId: 0435f56d08bf3a6392d35b5c1cfdcc0f1fe02753
This commit is contained in:
1 parent
3cd6004dc4
commit
52e12e0cb5
10 files changed
+235
-36
No files matched your search
@@ -63,6 +63,12 @@ use crate::app_backtrack::BacktrackSelection;
|
||||
use crate::app_backtrack::BacktrackState;
|
||||
use crate::app_backtrack::user_count;
|
||||
use crate::app_event::HistoryBatchEntryResponse;
|
||||
|
||||
async fn drain_managed_worktree_start(app: &mut App, server: &mut AppServerSession) {
|
||||
if let Some((mode, name)) = app.pending_start_managed_worktree.take() {
|
||||
app.start_managed_worktree(server, mode, name).await;
|
||||
}
|
||||
}
|
||||
use codex_utils_absolute_path::test_support::PathExt;
|
||||
|
||||
use crate::chatwidget::ChatWidgetInit;
|
||||
@@ -5540,6 +5546,10 @@ async fn make_test_app() -> App {
|
||||
dynamic_tool_tasks: HashMap::new(),
|
||||
pending_startup_thread_start: false,
|
||||
pending_managed_worktree_creation: false,
|
||||
pending_start_managed_worktree: None,
|
||||
pending_managed_worktree_created: None,
|
||||
pending_managed_worktree_transition: None,
|
||||
pending_managed_worktree_attach: None,
|
||||
startup_protected_input_boundary: false,
|
||||
startup_pending_protected_request: false,
|
||||
rate_limit_hard_stop_generation: 0,
|
||||
@@ -5627,6 +5637,10 @@ pub(super) async fn make_test_app_with_channels() -> (
|
||||
dynamic_tool_tasks: HashMap::new(),
|
||||
pending_startup_thread_start: false,
|
||||
pending_managed_worktree_creation: false,
|
||||
pending_start_managed_worktree: None,
|
||||
pending_managed_worktree_created: None,
|
||||
pending_managed_worktree_transition: None,
|
||||
pending_managed_worktree_attach: None,
|
||||
startup_protected_input_boundary: false,
|
||||
startup_pending_protected_request: false,
|
||||
rate_limit_hard_stop_generation: 0,
|
||||
|
||||
Reference in new issue
Block a user