Simplify backtrack mode sync and generalize pending sync naming

This commit is contained in:
Charles Cunningham
2026-02-02 22:29:40 -08:00
parent 4b7b5cd7cc
commit 0174a3db48
5 changed files with 41 additions and 55 deletions
+4 -2
View File
@@ -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(&current_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(),
+5 -5
View File
@@ -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