Skip to content

TUI: use cumulative turn duration for worked-for separator#19929

Merged
etraut-openai merged 1 commit intomainfrom
etraut/waiting-for-timing
Apr 28, 2026
Merged

TUI: use cumulative turn duration for worked-for separator#19929
etraut-openai merged 1 commit intomainfrom
etraut/waiting-for-timing

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Apr 28, 2026

Why

Fixes #19814.

The TUI's current Worked for ... timing behavior is a leftover from #9599. At that point, models could emit multiple assistant messages in one turn for preambles/commentary, but the TUI did not yet have a reliable signal that an assistant message was the final answer when it started streaming. To avoid showing an ever-growing elapsed time on each preamble separator, #9599 made the separator timer incremental by tracking elapsed time since the previous separator.

That workaround is no longer the right model for the final completed-turn display. Since then, #16638 added protocol-native turn timing, including duration_ms on turn completion. With that cumulative duration available at the point where the TUI renders the completed-turn separator, the UI can show the actual turn duration directly instead of carrying per-separator timing state.

What Changed

  • Thread duration_ms into ChatWidget::on_task_complete from both legacy TurnCompleteEvent handling and app-server TurnCompleted notifications.
  • Use duration_ms for the final Worked for ... separator, falling back to the status indicator timer only when the protocol duration is unavailable.
  • Keep mid-turn separators before later assistant text as plain visual dividers instead of clocked Worked for ... separators.
  • Remove the old incremental separator timer state and helper (last_separator_elapsed_secs / worked_elapsed_from).
  • Add a snapshot regression test for a turn that runs a command and then completes with a final answer, verifying the final separator uses the cumulative turn duration.

Verification

  • cargo test -p codex-tui final_worked_for_uses_cumulative_turn_duration_snapshot
  • just fix -p codex-tui

Manual repro prompt:

Manual timing repro. First send a short preamble/commentary sentence before using tools. Then run exactly this shell command: sleep 75; echo MANUAL_TIMING_DONE. After the command finishes, give a final answer that says "done". Do not skip the preamble.

After this change, the mid-turn break before the final answer should be a plain divider, and the final completed-turn separator should show Worked for ... using the cumulative turn duration.

Before:
Screenshot 2026-04-27 at 10 09 01 PM

After:
Screenshot 2026-04-27 at 10 09 07 PM

Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to replicate the issue on alpha codex and confirmed the fix works.

@etraut-openai etraut-openai merged commit 087c9c1 into main Apr 28, 2026
25 checks passed
@etraut-openai etraut-openai deleted the etraut/waiting-for-timing branch April 28, 2026 16:24
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex no longer shows reliable full prompt elapsed time

2 participants