mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Simplify backtrack mode sync and generalize pending sync naming
This commit is contained in:
@@ -2792,9 +2792,10 @@ mod handlers {
|
||||
}
|
||||
|
||||
let current_context = sess.new_default_turn_with_sub_id(sub_id).await;
|
||||
let has_model_visible_state_update = next_collaboration_mode.is_some();
|
||||
let pending_model_visible_state_sync = {
|
||||
let mut state = sess.state.lock().await;
|
||||
state.take_pending_model_visible_state_sync(next_collaboration_mode.is_some())
|
||||
state.take_pending_model_visible_state_sync(has_model_visible_state_update)
|
||||
};
|
||||
let update_items = sess.build_settings_update_items(
|
||||
Some(&previous_context),
|
||||
@@ -2877,9 +2878,10 @@ mod handlers {
|
||||
// Attempt to inject input into current task
|
||||
if let Err(items) = sess.inject_input(items).await {
|
||||
sess.seed_initial_context_if_needed(¤t_context).await;
|
||||
let has_model_visible_state_update = next_collaboration_mode.is_some();
|
||||
let pending_model_visible_state_sync = {
|
||||
let mut state = sess.state.lock().await;
|
||||
state.take_pending_model_visible_state_sync(next_collaboration_mode.is_some())
|
||||
state.take_pending_model_visible_state_sync(has_model_visible_state_update)
|
||||
};
|
||||
let update_items = sess.build_settings_update_items(
|
||||
previous_context.as_ref(),
|
||||
|
||||
@@ -117,15 +117,15 @@ impl SessionState {
|
||||
self.turn_context_history = turn_context_history;
|
||||
}
|
||||
|
||||
/// Consume pending model-visible state sync only when a collaboration update is being built.
|
||||
/// Consume pending model-visible state sync only when a model-visible update is being built.
|
||||
///
|
||||
/// If the next operation does not carry a collaboration update (for example, model-only
|
||||
/// overrides), keep the pending sync for a later turn that does.
|
||||
/// If the next operation does not carry any model-visible update, keep the pending sync for a
|
||||
/// later turn that does.
|
||||
pub(crate) fn take_pending_model_visible_state_sync(
|
||||
&mut self,
|
||||
has_collaboration_update: bool,
|
||||
has_model_visible_state_update: bool,
|
||||
) -> PendingModelVisibleStateSync {
|
||||
if has_collaboration_update {
|
||||
if has_model_visible_state_update {
|
||||
std::mem::take(&mut self.pending_model_visible_state_sync)
|
||||
} else {
|
||||
PendingModelVisibleStateSync::None
|
||||
|
||||
Reference in New Issue
Block a user