mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Preserve aggregate turn diffs across steering (#61820)
## Why A steer can restart sampling within the same turn. Recreating the diff tracker loses earlier edits, and changing the working directory can change the meaning of relative diff paths. ## What changed Keep the diff tracker for the lifetime of the turn and retain each environment's first display root. Refresh cached diff headers when new environments are added. Emit the final aggregate `TurnDiff` before `TurnComplete` instead of at sampling completion. ## Testing Extend regression coverage for steering during the final flush, with and without additional patches and with a changed working directory. Check final diff ordering across continued sampling and header updates when adding an environment. GitOrigin-RevId: fbd1ebef072d8486a324190c9125fc1446510802
This commit is contained in:
@@ -81,12 +81,23 @@ impl TurnDiffTracker {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn with_environment_display_roots(
|
||||
/// Use each environment's first display root for the whole turn so a steer cannot
|
||||
/// change what an already published relative path refers to.
|
||||
pub(crate) fn update_environment_display_roots(
|
||||
&mut self,
|
||||
display_roots: impl IntoIterator<Item = (String, PathUri)>,
|
||||
) -> Self {
|
||||
let mut tracker = Self::new();
|
||||
tracker.display_roots_by_environment = display_roots.into_iter().collect();
|
||||
tracker
|
||||
) {
|
||||
let previous_environment_count = self.display_roots_by_environment.len();
|
||||
for (id, root) in display_roots {
|
||||
self.display_roots_by_environment.entry(id).or_insert(root);
|
||||
}
|
||||
if self.display_roots_by_environment.len() != previous_environment_count
|
||||
&& !self.rendered_diffs.is_empty()
|
||||
{
|
||||
// Adding an environment can add an environment ID prefix to existing headers.
|
||||
self.rendered_diffs.clear();
|
||||
self.refresh_unified_diff();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn track_delta(&mut self, environment_id: &str, delta: &AppliedPatchDelta) {
|
||||
|
||||
Reference in New Issue
Block a user