mirror of
https://github.com/openai/codex.git
synced 2026-11-20 15:07:25 +00:00
Format multi-day goal durations in the TUI (#20558)
## Why Goal mode shows elapsed time in compact hour/minute form. That is easy to scan for shorter runs, but once a goal runs past 24 hours, large hour counts become harder to read at a glance. ## What changed Updated `codex-rs/tui/src/goal_display.rs` so unbudgeted goal elapsed time keeps the existing compact format below one day, then switches to a day-aware format once the elapsed time reaches 24 hours: - `23h 59m` - `1d 0h 0m` - `2d 23h 42m` The formatter now covers the 24-hour boundary in unit tests, and the TUI status-line snapshot for a completed elapsed goal now exercises the multi-day display. ## Verification - `cargo test -p codex-tui` Here's my longest-running test task: <img width="186" height="23" alt="image" src="https://github.com/user-attachments/assets/cedfcdab-7f6e-44e6-8495-8a39f63973fb" />
This commit is contained in:
1 parent
fe05acad23
commit
d898cc8f3f
3 files changed
+22
-6
No files matched your search
@@ -15,6 +15,12 @@ pub(crate) fn format_goal_elapsed_seconds(seconds: i64) -> String {
|
||||
|
||||
let hours = minutes / 60;
|
||||
let remaining_minutes = minutes % 60;
|
||||
if hours >= 24 {
|
||||
let days = hours / 24;
|
||||
let remaining_hours = hours % 24;
|
||||
return format!("{days}d {remaining_hours}h {remaining_minutes}m");
|
||||
}
|
||||
|
||||
if remaining_minutes == 0 {
|
||||
format!("{hours}h")
|
||||
} else {
|
||||
@@ -64,6 +70,14 @@ mod tests {
|
||||
assert_eq!(format_goal_elapsed_seconds(30 * 60), "30m");
|
||||
assert_eq!(format_goal_elapsed_seconds(90 * 60), "1h 30m");
|
||||
assert_eq!(format_goal_elapsed_seconds(2 * 60 * 60), "2h");
|
||||
let just_before_one_day = 24 * 60 * 60 - 1;
|
||||
assert_eq!(format_goal_elapsed_seconds(just_before_one_day), "23h 59m");
|
||||
|
||||
let one_day = 24 * 60 * 60;
|
||||
assert_eq!(format_goal_elapsed_seconds(one_day), "1d 0h 0m");
|
||||
|
||||
let almost_three_days = 2 * 24 * 60 * 60 + 23 * 60 * 60 + 42 * 60;
|
||||
assert_eq!(format_goal_elapsed_seconds(almost_three_days), "2d 23h 42m");
|
||||
}
|
||||
|
||||
fn test_thread_goal(token_budget: Option<i64>, tokens_used: i64) -> ThreadGoal {
|
||||
|
||||
Reference in new issue
Block a user