mirror of
https://github.com/openai/codex.git
synced 2026-12-05 01:00:54 +00:00
## Why The TUI ignored dynamic tool items, and replayed tool activity could differ from live output. Concurrent tool completion also needs to preserve transcript order when writing to terminal scrollback. ## What changed - Retain dynamic tool rows, update them when calls finish out of order, and mark unfinished calls interrupted when a turn ends. - Queue terminal output behind unfinished dynamic tools and drain settled rows in bounded batches. Preserve queued output through stream consolidation, resize, and rollback without emitting it twice. - Align replayed file changes, MCP results, and exploration groups with live rendering. Keep hidden reasoning and terminal interaction details within compatible activity groups, and preserve finalized plan fragments. - Ignore stale history-page responses, bound turn metadata requests to missing turns, and insert older history after session headers. Keep hidden review prompts as activity-group boundaries. ## Testing Add regression tests and snapshots for out-of-order tool completion, interruption, ordered scrollback emission, rollback, deferred usage updates, replay consistency, overlapping history, and repeated hidden prompts. GitOrigin-RevId: a3636cfcf4c9c43a0a5bc52a842b80a7834f1409
55 lines
1.7 KiB
Rust
55 lines
1.7 KiB
Rust
//! Retain dynamic tool state in either renderer; the app emits only finished rows to terminal history.
|
|
|
|
use super::*;
|
|
|
|
impl ChatWidget {
|
|
pub(super) fn on_dynamic_tool_item(&mut self, item: ThreadItem) {
|
|
let started = matches!(
|
|
&item,
|
|
ThreadItem::DynamicToolCall {
|
|
status: codex_app_server_protocol::DynamicToolCallStatus::InProgress,
|
|
..
|
|
}
|
|
);
|
|
self.defer_or_handle(
|
|
item,
|
|
|interrupts, item| {
|
|
if started {
|
|
interrupts.push_item_started(item);
|
|
} else {
|
|
interrupts.push_item_completed(item);
|
|
}
|
|
},
|
|
Self::handle_dynamic_tool_item_now,
|
|
);
|
|
}
|
|
|
|
pub(crate) fn handle_dynamic_tool_item_now(&mut self, item: ThreadItem) {
|
|
let ThreadItem::DynamicToolCall { id, .. } = &item else {
|
|
return;
|
|
};
|
|
let id = id.clone();
|
|
if let Some(cell) = self.transcript.dynamic_calls.get(&id) {
|
|
cell.update_from_item(item);
|
|
if !cell.is_active() {
|
|
self.transcript.dynamic_calls.remove(&id);
|
|
}
|
|
} else if let Some(cell) = history_cell::DynamicToolCallCell::from_item(item) {
|
|
self.flush_answer_stream_with_separator();
|
|
if cell.is_active() {
|
|
self.transcript
|
|
.dynamic_calls
|
|
.insert(cell.call_id().to_owned(), cell.clone());
|
|
}
|
|
self.add_to_history(cell);
|
|
}
|
|
self.request_redraw();
|
|
}
|
|
|
|
pub(super) fn finish_dynamic_activity(&mut self) {
|
|
for (_, cell) in self.transcript.dynamic_calls.drain() {
|
|
cell.mark_interrupted();
|
|
}
|
|
}
|
|
}
|