Fix /monitor-job to pick up most recent job by timestamp, not cache order#62
Merged
punit-naik-amp merged 1 commit intomainfrom Jan 13, 2026
Merged
Conversation
…rder The /monitor-job command was incorrectly selecting old jobs when called without a job ID because get_last_job_id() relied on cache insertion order rather than actual job timestamps. Root cause: - When /jobs runs, it queries and caches job status for all jobs - Jobs with errors or not found get cached with state "UNKNOWN" - Cache uses deque.appendleft(), moving re-cached jobs to position 0 - get_last_job_id() simply returned cache[0], which could be an old job that was just re-cached, not the most recently started job Changes: - Modified get_last_job_id() to find job with most recent start-time or created-at timestamp from job_data, with fallback to cached_at - Updated /jobs command to cache running/pending jobs to maintain proper ordering and avoid unnecessary re-caching of UNKNOWN state jobs - Added tests for timestamp-based selection and fallback behavior Result: /monitor-job now correctly picks up the most recently started job even after /jobs re-caches older jobs
pragyan-amp
approved these changes
Jan 13, 2026
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.
The /monitor-job command was incorrectly selecting old jobs when called without a job ID because get_last_job_id() relied on cache insertion order rather than actual job timestamps.
Root cause:
Changes:
Result:
/monitor-job now correctly picks up the most recently started job even after /jobs re-caches older jobs