-
Notifications
You must be signed in to change notification settings - Fork 491
fix: sort queue jobs by create time #8225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe sorting logic in the job list composable has been updated to sort tasks by createTime (descending) instead of queueIndex. Both the implementation and corresponding test have been modified to reflect this sorting criterion change. Changes
Possibly related PRs
Suggested reviewers
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 01/21/2026, 11:08:54 PM UTC 🔗 Links🎉 Your Storybook is ready for review! |
🎭 Playwright Tests:
|
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 22.3 kB (baseline 22.3 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.02 MB (baseline 1.02 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 80.7 kB (baseline 80.7 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed Panels & Settings — 430 kB (baseline 430 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 8 added / 8 removed User & Accounts — 3.94 kB (baseline 3.94 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 3 added / 3 removed Editors & Dialogs — 2.8 kB (baseline 2.8 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 2 added / 2 removed UI Components — 32.8 kB (baseline 32.8 kB) • ⚪ 0 BReusable component library chunks
Status: 5 added / 5 removed Data & Services — 3.05 MB (baseline 3.05 MB) • 🔴 +140 BStores, services, APIs, and repositories
Status: 7 added / 7 removed Utilities & Hooks — 18.1 kB (baseline 18.1 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 4 added / 4 removed Vendor & Third-Party — 10.4 MB (baseline 10.4 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 6.28 MB (baseline 6.28 MB) • ⚪ 0 BBundles that do not match a named category
Status: 22 added / 22 removed |
There was a problem hiding this 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 pull request changes the queue job sorting mechanism from priority-based to creation-time-based ordering to ensure queued jobs maintain stable positions in the overlay when completions arrive.
Changes:
- Modified
allTasksSortedto sort bycreateTimeinstead ofqueueIndex(priority) - Added
mostRecentTimestamphelper function to extract and handle undefined createTime values - Updated the corresponding unit test to validate create time sorting behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/composables/queue/useJobList.ts | Changed sorting logic from priority-based to create-time-based with descending order (most recent first) |
| src/composables/queue/useJobList.test.ts | Updated test name, test data with explicit createTime values, and expected ordering to match new sorting behavior |
| return all.sort((a, b) => b.queueIndex - a.queueIndex) | ||
| return all.sort((a, b) => { | ||
| const delta = mostRecentTimestamp(b) - mostRecentTimestamp(a) | ||
| return delta === 0 ? 0 : delta |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ternary check delta === 0 ? 0 : delta is redundant. The expression can be simplified to just return delta since returning 0 when delta is 0 and delta otherwise is equivalent to just returning delta.
| return delta === 0 ? 0 : delta | |
| return delta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/composables/queue/useJobList.ts`:
- Around line 208-211: The comparator inside the return of the all.sort call is
using a redundant ternary `delta === 0 ? 0 : delta`; replace that with returning
delta directly (i.e., return mostRecentTimestamp(b) - mostRecentTimestamp(a)) in
the comparator used in useJobList.ts so the sort is simplified and no-op
branches are removed.
- Around line 200-201: Replace the const arrow helper with a plain function
declaration: convert the const mostRecentTimestamp = (task: TaskItemImpl) =>
task.createTime ?? 0 into function mostRecentTimestamp(task: TaskItemImpl) {
return task.createTime ?? 0; } so the pure helper uses a function declaration
(keep the TaskItemImpl type and behavior unchanged and update any local
references to mostRecentTimestamp if needed).
| const mostRecentTimestamp = (task: TaskItemImpl) => task.createTime ?? 0 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Prefer function declaration for pure helper functions.
Based on learnings, prefer function mostRecentTimestamp(task: TaskItemImpl) over a const arrow expression for pure functions.
Suggested change
- const mostRecentTimestamp = (task: TaskItemImpl) => task.createTime ?? 0
+ function mostRecentTimestamp(task: TaskItemImpl): number {
+ return task.createTime ?? 0
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const mostRecentTimestamp = (task: TaskItemImpl) => task.createTime ?? 0 | |
| function mostRecentTimestamp(task: TaskItemImpl): number { | |
| return task.createTime ?? 0 | |
| } |
🤖 Prompt for AI Agents
In `@src/composables/queue/useJobList.ts` around lines 200 - 201, Replace the
const arrow helper with a plain function declaration: convert the const
mostRecentTimestamp = (task: TaskItemImpl) => task.createTime ?? 0 into function
mostRecentTimestamp(task: TaskItemImpl) { return task.createTime ?? 0; } so the
pure helper uses a function declaration (keep the TaskItemImpl type and behavior
unchanged and update any local references to mostRecentTimestamp if needed).
| return all.sort((a, b) => { | ||
| const delta = mostRecentTimestamp(b) - mostRecentTimestamp(a) | ||
| return delta === 0 ? 0 : delta | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Redundant ternary expression.
The expression delta === 0 ? 0 : delta always evaluates to delta. Simplify the comparator.
Suggested fix
return all.sort((a, b) => {
- const delta = mostRecentTimestamp(b) - mostRecentTimestamp(a)
- return delta === 0 ? 0 : delta
+ return mostRecentTimestamp(b) - mostRecentTimestamp(a)
})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return all.sort((a, b) => { | |
| const delta = mostRecentTimestamp(b) - mostRecentTimestamp(a) | |
| return delta === 0 ? 0 : delta | |
| }) | |
| return all.sort((a, b) => { | |
| return mostRecentTimestamp(b) - mostRecentTimestamp(a) | |
| }) |
🤖 Prompt for AI Agents
In `@src/composables/queue/useJobList.ts` around lines 208 - 211, The comparator
inside the return of the all.sort call is using a redundant ternary `delta === 0
? 0 : delta`; replace that with returning delta directly (i.e., return
mostRecentTimestamp(b) - mostRecentTimestamp(a)) in the comparator used in
useJobList.ts so the sort is simplified and no-op branches are removed.
Sort queue overlay ordering by create_time instead of priority so queued jobs keep their order when completions arrive. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8225-fix-sort-queue-jobs-by-create-time-2ef6d73d3650815a8a81ec9d0b23a4e6) by [Unito](https://www.unito.io)
|
1 similar comment
|
…8561) ## Summary Active jobs (pending/running) in the media assets panel now display in FIFO order - oldest jobs first (first to be processed at top). This matches the queue processing order and the old queue panel behavior. ## Changes - **AssetsSidebarListView.vue**: Add `.toReversed()` to `activeJobItems` computed to reverse job order for display - **AssetsSidebarGridView.vue**: Same change for grid view consistency - **AssetsSidebarListView.test.ts**: Unit test verifying oldest-first ordering ## Root Cause PR #8225 changed sorting from `queueIndex` to `createTime` descending in `useJobList.ts`, which placed newest jobs first. For active jobs, users expect oldest first (FIFO - first to be processed appears at top). ## Solution Rather than modifying the shared `useJobList` composable (which serves both the assets panel and queue overlay), the fix applies `.toReversed()` at the view layer for the active jobs section only. This: - Preserves the newest-first order for completed/history jobs - Displays active jobs in oldest-first order - Maintains backward compatibility with the queue overlay ## Testing - Unit test added to verify FIFO ordering of active jobs - All existing `useJobList` tests pass Fixes COM-14151 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected the display order of active jobs in the sidebar to show jobs in oldest-first (FIFO) sequence. * **Tests** * Added unit tests for the assets sidebar list view to verify job ordering and filtering behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8561-fix-display-active-jobs-in-oldest-first-order-in-media-assets-panel-2fc6d73d365081c6bf31cb076a8d6014) by [Unito](https://www.unito.io)
Sort queue overlay ordering by create_time instead of priority so queued jobs keep their order when completions arrive.
┆Issue is synchronized with this Notion page by Unito