-
Notifications
You must be signed in to change notification settings - Fork 121
Change event sorting to event id #963
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
Change event sorting to event id #963
Conversation
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 PR changes the workflow history event sorting mechanism from time-based to event ID-based sorting to improve user experience and fix issues with dynamic group positioning.
- Adds
firstEventId
field to history group types and implementations - Replaces time-based sorting with numeric event ID sorting using a new helper function
- Updates all test fixtures and mocks to include the new
firstEventId
field
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
workflow-history.types.ts | Adds firstEventId field to BaseHistoryGroup type definition |
workflow-history.tsx | Updates sorting logic to use getSortableEventId instead of timeMs |
get-sortable-event-id.ts | New helper function to convert event IDs to sortable numeric values |
get-common-history-group-fields.ts | Extracts and assigns firstEventId from the first event in each group |
Various test files | Updates test fixtures and mocks to include the new firstEventId field |
if (!eventId) return Number.MAX_SAFE_INTEGER; | ||
const numericEventId = parseInt(eventId, 10); |
Copilot
AI
Jul 23, 2025
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 function treats empty strings as falsy but parseInt(' ', 10) would return NaN, which is handled later. However, parseInt('', 10) also returns NaN. The current logic will return MAX_SAFE_INTEGER for empty strings in the first check, but the test expects it to handle whitespace-only strings. Consider using eventId?.trim() to handle whitespace consistently.
if (!eventId) return Number.MAX_SAFE_INTEGER; | |
const numericEventId = parseInt(eventId, 10); | |
const trimmedEventId = eventId?.trim(); | |
if (!trimmedEventId) return Number.MAX_SAFE_INTEGER; | |
const numericEventId = parseInt(trimmedEventId, 10); |
Copilot uses AI. Check for mistakes.
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.
This was done to avoid typescript issue about non string values passed to parseInt
expect(getSortableEventId(null)).toBe(Number.MAX_SAFE_INTEGER); | ||
expect(getSortableEventId(undefined)).toBe(Number.MAX_SAFE_INTEGER); | ||
expect(getSortableEventId('')).toBe(Number.MAX_SAFE_INTEGER); | ||
expect(getSortableEventId(' ')).toBe(Number.MAX_SAFE_INTEGER); |
Copilot
AI
Jul 23, 2025
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.
This test expects whitespace-only strings to return MAX_SAFE_INTEGER, but the current implementation only checks for falsy values. A string with spaces is truthy, so it will proceed to parseInt(' ', 10) which returns NaN, then return MAX_SAFE_INTEGER. While the test passes, the logic path is inconsistent with the other empty value checks.
Copilot uses AI. Check for mistakes.
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 confusion is from the way the typescript issue was handled which made a split in the handling but the results are consistent at the end
Will we change the existing usages of group ID to use firstEventId instead? |
expect(getSortableEventId('-999999')).toBe(-999999); | ||
}); | ||
|
||
it('should return Number.MAX_SAFE_INTEGER for strings starting with non-digits', () => { |
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.
How does this work for pending events? Will pending event IDs even be passed to this function?
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.
Pending events are always the second event so the sorting would happen on the scheduled event
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.
In case we want to have them sorted we can have use computedEventId
for sorting too but also change the id to be scheduledId-Pending
instead of Pending-scheduledId
so that it will be ordered by id and ignore the string postfix -Pending
Summary:
Event groups sorting now is based on last event time. This is causing some inconveniance because of the following:
Changes:
firstEventId
for groups to be more representable than group id.firstEventId
Screenshots:
