Skip to content

Commit 8043dd2

Browse files
committed
tui: keep coalesced change ordering stable
1 parent ade7598 commit 8043dd2

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

tui/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Divergences must be documented in places below to avoid regression when syncing
4646
- All `Ran` and `Explored` items are hidden
4747
- `Worked for ...` separators are hidden
4848
- Consecutive Change (Edited, Created, Deleted) items are coalesced into one, and provide file list only, no diff body.
49-
- The coalesced Change file list preserves patch event order (last touch wins) instead of sorting paths alphabetically.
49+
- The coalesced Change file list preserves patch event order instead of sorting paths alphabetically.
5050
- Additional codex-potter items (e.g. project creation hints, stream recovery retries, project-finished summary on success).
5151

5252
### Shimmer

tui/src/history_cell.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
543543
pub 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

Comments
 (0)