-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Store match metadata #876
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
Store match metadata #876
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "ExecutedRule" ADD COLUMN "matchMetadata" JSONB; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,8 +95,12 @@ export function sortByInternalDate<T extends { internalDate?: string | null }>( | |
| direction: "asc" | "desc" = "asc", | ||
| ) { | ||
| return (a: T, b: T): number => { | ||
| const aTime = internalDateToDate(a.internalDate).getTime() || 0; | ||
| const bTime = internalDateToDate(b.internalDate).getTime() || 0; | ||
| const aTime = a.internalDate | ||
| ? internalDateToDate(a.internalDate).getTime() | ||
| : 0; | ||
| const bTime = b.internalDate | ||
| ? internalDateToDate(b.internalDate).getTime() | ||
| : 0; | ||
|
Comment on lines
+98
to
+103
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the behavior change for items without This changes sort behavior:
Items without 🏁 Script executed: #!/bin/bash
# Find all usages of sortByInternalDate to assess impact
rg -n "sortByInternalDate" --type=ts -C3Length of output: 3256 🏁 Script executed: #!/bin/bash
# Get full context on internalDateToDate function
rg -n "function internalDateToDate|export.*internalDateToDate" --type=ts -A10Length of output: 729 🏁 Script executed: #!/bin/bash
# Check what happens with undefined/null internalDate in actual data flow
rg -n "internalDate\?" --type=ts -B2 -A2 apps/web/utils/date.tsLength of output: 369 🏁 Script executed: #!/bin/bash
# Get more context around the outbound.ts logic to understand the latestMessage selection
rg -n "actualLatestMessage" --type=ts -B5 -A5 apps/web/utils/reply-tracker/outbound.tsLength of output: 779 🏁 Script executed: #!/bin/bash
# Check if there's validation or filtering for internalDate before sorting
rg -n "internalDate" --type=ts apps/web/utils/reply-tracker/ -B2 -A2 | head -60Length of output: 1811 🏁 Script executed: #!/bin/bash
# Get the complete sortByInternalDate function to see the exact comparison logic
cat apps/web/utils/date.ts | sed -n '94,110p'Length of output: 420 🏁 Script executed: #!/bin/bash
# Check where threadMessages parameter comes from and if internalDate is guaranteed
rg -n "getLatestMessageFromThread|isLatest.*boolean" --type=ts -B10 apps/web/utils/reply-tracker/outbound.ts | head -100Length of output: 277 🏁 Script executed: #!/bin/bash
# Look for where messages are queried/loaded and if internalDate is filtered
rg -n "threadMessages|\.include|\.select" --type=ts apps/web/utils/reply-tracker/ -B2 -A2 | head -80Length of output: 5901 🏁 Script executed: #!/bin/bash
# Check the ParsedMessage type to understand internalDate requirement
rg -n "type ParsedMessage|interface ParsedMessage" --type=ts -A15Length of output: 5774 🏁 Script executed: #!/bin/bash
# Search for any validation or filtering of internalDate before sorting
rg -n "filter.*internalDate|internalDate.*filter" --type=ts -C3Length of output: 0 Fix the sort logic or validate This change introduces a critical bug in how "latest" messages are identified. Both
Since Required fixes:
🤖 Prompt for AI Agents |
||
| return direction === "asc" ? aTime - bTime : bTime - aTime; | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v2.17.11 | ||
| v2.17.12 |
Uh oh!
There was an error while loading. Please reload this page.
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.
Defaulting falsy internalDate values to 0 changes the comparator semantics: previously internalDateToDate(undefined) returned the current time, so records without an internalDate still sorted chronologically. Now they sort as the Unix epoch, pushing them to the front of ascending lists (and the end of descending ones) and breaking message ordering for those cases.
Prompt for AI agents