mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
Restore thread cwd from owned settings snapshots (#41567)
## Why Resuming a thread without an explicit `cwd` should restore that thread's latest retained setting. Forked history can contain settings copied from another thread, while compaction can move the latest setting outside the replay window. ## What changed - Record the owning thread ID on new settings snapshots and only use snapshots owned by the resumed thread when restoring `cwd`. Older snapshots without an owner remain readable but do not override the startup `cwd`. - Checkpoint the current settings after compaction and serialize checkpoints with settings updates so the retained history contains an accepted, current snapshot. - Cover resume behavior across compaction, forks, reverts, legacy histories, and concurrent settings updates. GitOrigin-RevId: 1efc9cf55472d6b88c465c4efe44672a232dbf64
This commit is contained in:
1 parent
4210c08def
commit
f5636bb733
20 files changed
+462
-35
No files matched your search
@@ -3634,6 +3634,9 @@ impl Session {
|
||||
.map(|id| id.to_string()),
|
||||
window_id: Some(metadata.window_ids.window_id.to_string()),
|
||||
};
|
||||
// Wait for accepted updates to finish persisting, then keep later updates from
|
||||
// overtaking the current settings snapshot while its checkpoint is written.
|
||||
let _settings_guard = thread_settings::acquire_persistence_lock(self).await;
|
||||
// Compaction starts a new history window, so its WorldState baseline must be full.
|
||||
let mut world_state_item = None;
|
||||
{
|
||||
@@ -3646,17 +3649,19 @@ impl Session {
|
||||
}
|
||||
}
|
||||
|
||||
self.persist_rollout_items(&[RolloutItem::Compacted(compacted_item)])
|
||||
.await;
|
||||
let mut rollout_items = vec![RolloutItem::Compacted(compacted_item)];
|
||||
// Persist the baseline after the replacement history that established it.
|
||||
if let Some(world_state_item) = world_state_item {
|
||||
self.persist_rollout_items(&[RolloutItem::WorldState(world_state_item)])
|
||||
.await;
|
||||
rollout_items.push(RolloutItem::WorldState(world_state_item));
|
||||
}
|
||||
if let Some(turn_context_item) = reference_context_item {
|
||||
self.persist_rollout_items(&[RolloutItem::TurnContext(turn_context_item)])
|
||||
.await;
|
||||
rollout_items.push(RolloutItem::TurnContext(turn_context_item));
|
||||
}
|
||||
// The frozen turn context must not override current settings in persisted metadata.
|
||||
rollout_items.push(RolloutItem::EventMsg(
|
||||
thread_settings::applied_event(self).await,
|
||||
));
|
||||
self.persist_rollout_items(&rollout_items).await;
|
||||
{
|
||||
let mut state = self.state.lock().await;
|
||||
state.queue_pending_session_start_source(codex_hooks::SessionStartSource::Compact);
|
||||
|
||||
Reference in new issue
Block a user