@@ -538,8 +538,8 @@ pub fn new_patch_event(
538538/// This is used by the `Verbosity::Minimal` renderer to avoid repeating many one-line `Edited ...`
539539/// items when an agent applies several small patches consecutively.
540540///
541- /// Divergence (codex-potter): file paths are listed in patch event order (last touch wins), not
542- /// sorted alphabetically.
541+ /// Divergence (codex-potter): file paths are listed in patch event order (first occurrence),
542+ /// not sorted alphabetically.
543543pub fn new_coalesced_compact_patch_event (
544544 change_sets : & [ HashMap < PathBuf , FileChange > ] ,
545545 cwd : & Path ,
@@ -622,9 +622,8 @@ pub fn new_coalesced_compact_patch_event(
622622 }
623623
624624 let mut merged: HashMap < PathBuf , Summary > = HashMap :: new ( ) ;
625- // Track output ordering in the same order patch events arrive. If a file is touched multiple
626- // times, move it to the end so the final list reflects the chronological stream as closely as
627- // possible while still rendering each path once.
625+ // Track output ordering in the same order patch events arrive. Use first occurrence so the
626+ // list remains stable as counts are updated by later patch events.
628627 let mut path_order: Vec < PathBuf > = Vec :: new ( ) ;
629628
630629 for changes in change_sets {
@@ -662,13 +661,11 @@ pub fn new_coalesced_compact_patch_event(
662661
663662 let entry = match merged. entry ( path. clone ( ) ) {
664663 Entry :: Occupied ( entry) => entry. into_mut ( ) ,
665- Entry :: Vacant ( entry) => entry. insert ( Summary :: new ( verb) ) ,
664+ Entry :: Vacant ( entry) => {
665+ path_order. push ( path. clone ( ) ) ;
666+ entry. insert ( Summary :: new ( verb) )
667+ }
666668 } ;
667-
668- if let Some ( pos) = path_order. iter ( ) . position ( |p| p == path) {
669- path_order. remove ( pos) ;
670- }
671- path_order. push ( path. clone ( ) ) ;
672669 entry. update_verb ( verb) ;
673670 if move_path. is_some ( ) {
674671 entry. move_path = move_path;
0 commit comments