From edbe47e4348afde6429c65c45cd94af82d5bcaa7 Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Sat, 31 Jan 2026 15:56:49 -0800 Subject: [PATCH] Clarify rollback mode flow --- codex-rs/core/src/codex.rs | 2 +- codex-rs/tui/src/app_backtrack.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index e72a2111b7..62e847f680 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -3193,7 +3193,7 @@ mod handlers { && let Some(collaboration_mode) = state .turn_context_history .last() - .and_then(|turn_context| turn_context.as_ref()) + .and_then(Option::as_ref) .and_then(|turn_context| turn_context.collaboration_mode.clone()) { state.session_configuration.collaboration_mode = collaboration_mode; diff --git a/codex-rs/tui/src/app_backtrack.rs b/codex-rs/tui/src/app_backtrack.rs index 3f2a4ed7b9..5a3dda029d 100644 --- a/codex-rs/tui/src/app_backtrack.rs +++ b/codex-rs/tui/src/app_backtrack.rs @@ -207,6 +207,8 @@ impl App { return; } + // Optimistically apply the target mode for the rollback preview, but remember the + // prior mode so we can restore it if core rejects the rollback. let previous_collaboration_mask = self .chat_widget .replace_collaboration_mask(selection.collaboration_mode.clone()); @@ -472,6 +474,7 @@ impl App { if pending.thread_id != self.chat_widget.thread_id() { return; } + // Rollback failed: revert the optimistic mode switch to the pre-rollback mask. self.chat_widget .replace_collaboration_mask(pending.previous_collaboration_mask); }