Show file destinations in TUI change approvals (#39285)

## What changed

- Show a description and the destination paths affected by each file-change approval.
- Include both source and target paths for moves, format cross-platform paths for display, and show `unavailable` when change details are missing.
- Recover file changes from buffered events and thread snapshots so live and replayed approvals retain their destination details.

## Testing

- Add coverage for active and replayed approvals, moved and cross-platform paths, and the missing-destination fallback.

GitOrigin-RevId: 24f90b313fd8643f90cbead1504c788b140d7fed
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-18 21:43:22 +00:00
1 parent ba37d0c45b
commit e7f9fa9cd9
14 files changed
+411 -73

No files matched your search

+33 -29
View File
@@ -196,35 +196,7 @@ impl ThreadEventStore {
turn_id: &str,
item_id: &str,
) -> Option<Vec<codex_app_server_protocol::FileUpdateChange>> {
self.buffer
.iter()
.rev()
.find_map(|event| match event {
ThreadBufferedEvent::Notification(notification) => match notification.as_ref() {
ServerNotification::ItemStarted(notification)
if turn_id_matches(turn_id, &notification.turn_id) =>
{
file_change_item_changes(&notification.item, item_id)
}
ServerNotification::ItemCompleted(notification)
if turn_id_matches(turn_id, &notification.turn_id) =>
{
file_change_item_changes(&notification.item, item_id)
}
_ => None,
},
ThreadBufferedEvent::Request(_)
| ThreadBufferedEvent::HistoryEntryResponse(_)
| ThreadBufferedEvent::FeedbackSubmission(_) => None,
})
.or_else(|| {
self.turns
.iter()
.rev()
.filter(|turn| turn_id_matches(turn_id, &turn.id))
.flat_map(|turn| turn.items.iter().rev())
.find_map(|item| file_change_item_changes(item, item_id))
})
file_change_changes(self.buffer.iter(), &self.turns, turn_id, item_id)
}
pub(super) fn snapshot(&self) -> ThreadEventSnapshot {
@@ -298,6 +270,38 @@ fn turn_id_matches(request_turn_id: &str, candidate_turn_id: &str) -> bool {
request_turn_id.is_empty() || request_turn_id == candidate_turn_id
}
pub(super) fn file_change_changes<'a>(
events: impl DoubleEndedIterator<Item = &'a ThreadBufferedEvent>,
turns: &'a [Turn],
turn_id: &str,
item_id: &str,
) -> Option<Vec<codex_app_server_protocol::FileUpdateChange>> {
let event_items = events.rev().filter_map(|event| {
let ThreadBufferedEvent::Notification(notification) = event else {
return None;
};
let (candidate_turn_id, item) = match notification.as_ref() {
ServerNotification::ItemStarted(notification) => {
(&notification.turn_id, &notification.item)
}
ServerNotification::ItemCompleted(notification) => {
(&notification.turn_id, &notification.item)
}
_ => return None,
};
turn_id_matches(turn_id, candidate_turn_id).then_some(item)
});
event_items
.chain(
turns
.iter()
.rev()
.filter(|turn| turn_id_matches(turn_id, &turn.id))
.flat_map(|turn| turn.items.iter().rev()),
)
.find_map(|item| file_change_item_changes(item, item_id))
}
fn file_change_item_changes(
item: &ThreadItem,
item_id: &str,