mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
## What changed Replace horizontal turn separators with dim completion metadata after the final answer, including plain conversational answers. Show local completion times such as `done 2:32 PM`, adding the date for other days and the year for other years. Retain `Worked for` durations above sixty seconds and runtime metrics, and wrap metadata on narrow terminals. Restore saved completion metadata when resuming conversations or loading older history. Keep each footer after its turn's items and deduplicate it across repeated notifications and overlapping pages. Only live completions fall back to the current time when a saved timestamp is unavailable. Failed, interrupted, and in-progress turns do not receive success footers. Avoid submitting queued input or emitting completion notifications while replaying history. ## Testing Add unit and snapshot coverage for timestamp formatting, duration thresholds, muted styling, narrow layouts, live and replayed completions, missing metadata, and pagination boundaries with overlapping pages. GitOrigin-RevId: 308c35c6720720da43c9a391aa5a68c1b231c9a5
54 lines
1.8 KiB
Rust
54 lines
1.8 KiB
Rust
//! Completion metadata for live and restored turns. Saved timestamps are authoritative;
|
|
//! only a live completion may fall back to the local clock. Labels are deduplicated per thread.
|
|
|
|
use super::*;
|
|
|
|
impl ChatWidget {
|
|
pub(crate) fn completion_cell(
|
|
&mut self,
|
|
turn: &Turn,
|
|
replay_kind: Option<ReplayKind>,
|
|
) -> Option<history_cell::FinalMessageSeparator> {
|
|
if self
|
|
.turn_lifecycle
|
|
.rendered_completion_turn_ids
|
|
.contains(&turn.id)
|
|
{
|
|
return None;
|
|
}
|
|
let elapsed_seconds = turn
|
|
.duration_ms
|
|
.and_then(|duration| u64::try_from(duration).ok())
|
|
.map(|duration| duration / 1_000)
|
|
.or_else(|| {
|
|
if replay_kind.is_none() {
|
|
self.bottom_pane
|
|
.status_elapsed()
|
|
.map(|elapsed| elapsed.as_secs())
|
|
} else {
|
|
None
|
|
}
|
|
})
|
|
.filter(|seconds| *seconds > 60);
|
|
let completed_at = turn
|
|
.completed_at
|
|
.and_then(|timestamp| chrono::DateTime::from_timestamp(timestamp, /*nsecs*/ 0))
|
|
.map(|timestamp| timestamp.with_timezone(&Local))
|
|
.or_else(|| replay_kind.is_none().then(Local::now));
|
|
if completed_at.is_none() && elapsed_seconds.is_none() {
|
|
return None;
|
|
}
|
|
self.turn_lifecycle
|
|
.rendered_completion_turn_ids
|
|
.insert(turn.id.clone());
|
|
let cell = history_cell::FinalMessageSeparator::new(
|
|
elapsed_seconds,
|
|
/*runtime_metrics*/ None,
|
|
);
|
|
Some(match completed_at {
|
|
Some(completed_at) => cell.with_completed_at(completed_at),
|
|
None => cell,
|
|
})
|
|
}
|
|
}
|