Anchor TUI Jobs Elapsed to a snapshot timestamp#353
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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_atto the TUIAppstate to capture whenjobs_allwas last refreshed. - Update Jobs table elapsed formatting to compute durations relative to
jobs_fetched_at(fallback toUtc::now()when unavailable). - Ensure
jobs_fetched_atis 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
format_elapsedusedUtc::now()on every redraw (~100 ms), and the column only renders forstatus == Running.app.jobsonly refreshes on manualr, post-popup, or the 30 s auto-refresh (off by default), so the locally-cached row stayed atRunningand Elapsed kept growing.jobs_fetched_atwheneverjobs_allis 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
rclears the row, but in the meantime no longer ticks).r(or after auto-refresh fires) while a job is genuinely Running.🤖 Generated with Claude Code