Skip to content

Anchor TUI Jobs Elapsed to a snapshot timestamp#353

Merged
daniel-thom merged 1 commit into
mainfrom
fix/tui-elapsed-snapshot
May 26, 2026
Merged

Anchor TUI Jobs Elapsed to a snapshot timestamp#353
daniel-thom merged 1 commit into
mainfrom
fix/tui-elapsed-snapshot

Conversation

@daniel-thom
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes the Jobs-tab Elapsed value ticking up indefinitely after a job completes.
  • Root cause: format_elapsed used Utc::now() on every redraw (~100 ms), and the column only renders for status == Running. app.jobs only refreshes on manual r, post-popup, or the 30 s auto-refresh (off by default), so the locally-cached row stayed at Running and Elapsed kept growing.
  • Capture jobs_fetched_at whenever jobs_all is loaded from the server and compute Elapsed relative to that snapshot. The value reflects "how long the job had been running as of the last refresh" and stops advancing on its own when the data goes stale.

Test plan

  • Run a workflow with a short-lived job in the TUI; confirm the Jobs tab's Elapsed value stops growing once the job is no longer Running on the server (verified after r clears the row, but in the meantime no longer ticks).
  • Confirm Elapsed still updates after pressing r (or after auto-refresh fires) while a job is genuinely Running.
  • Verify other Jobs-tab behavior is unchanged: filter, pagination, sort, popup-driven workflow runs.

🤖 Generated with Claude Code

The Jobs tab's Elapsed column was computed from `Utc::now() - start_time`
on every redraw, and the TUI main loop redraws every ~100 ms. The cell
only renders for jobs whose locally-cached status is Running, but
`app.jobs` only refreshes on demand (manual `r`, post-popup, or 30 s
auto-refresh which is off by default). So after the server completed a
job, the local row stayed at Running and Elapsed kept ticking up
indefinitely until the user pressed `r`.

Capture the wall-clock time when `jobs_all` is fetched from the server
in a new `jobs_fetched_at` field and compute Elapsed relative to that
snapshot rather than `Utc::now()`. The value now reflects "how long the
job had been running as of the last refresh", matching the rest of the
(snapshot) data in the row, and stops advancing on its own when the
fetch goes stale.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the TUI Jobs tab “Elapsed” column continuously increasing after a job has completed by anchoring elapsed-time calculations to the timestamp when the jobs list was last fetched from the server, rather than recomputing against Utc::now() on every redraw.

Changes:

  • Add jobs_fetched_at to the TUI App state to capture when jobs_all was last refreshed.
  • Update Jobs table elapsed formatting to compute durations relative to jobs_fetched_at (fallback to Utc::now() when unavailable).
  • Ensure jobs_fetched_at is set/reset across relevant job fetch and clear paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/tui/ui.rs Compute displayed job elapsed time relative to a snapshot timestamp to avoid ticking on stale cached rows.
src/tui/app.rs Introduce and maintain jobs_fetched_at in app state when jobs are fetched/cleared.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@daniel-thom daniel-thom merged commit ba21bb8 into main May 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants