[codex] fix: tolerate invalid latest user message timestamps#3521
[codex] fix: tolerate invalid latest user message timestamps#3521StiensWout wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
ApprovabilityVerdict: Approved Straightforward bug fix adding defensive handling for invalid timestamp strings in thread sorting logic. The change is minimal, well-tested, and only affects edge cases with malformed data. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: Codex <codex@openai.com>
12dbf5e to
6f3ac79
Compare
Summary
latestUserMessageAtvalues like missing values in thread recency sorting.updatedAt, thencreatedAt.latestUserMessageAtfallback behavior.Root cause
getLatestUserMessageTimestampreturnedNumber.NEGATIVE_INFINITYas soon aslatestUserMessageAtwas present but unparseable, so it skipped the existing message and thread timestamp fallbacks.Impact
Threads with malformed latest-user-message metadata can still sort by real activity from messages or thread timestamps instead of dropping behind threads with no valid activity. Existing created-at sorting and tie-breakers are unchanged.
Validation
PATH="$HOME/.vite-plus/bin:$PATH" vp test packages/client-runtime/src/state/threadSort.test.tsPATH="$HOME/.vite-plus/bin:$PATH" vp check(0 errors, 20 warnings)PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheckNote
Low Risk
Localized sorting logic fix with new unit tests; no auth, persistence, or API changes.
Overview
Fixes sidebar updated_at thread ordering when
latestUserMessageAtis set but not a parseable date. Those threads were sorted as if they had no activity becausegetLatestUserMessageTimestampreturnedNumber.NEGATIVE_INFINITYimmediately instead of using the same fallbacks as a missing field.getLatestUserMessageTimestampnow only useslatestUserMessageAtwhentoSortableTimestampsucceeds; otherwise it keeps the existing chain: latest valid user message timestamps, thenupdatedAt/createdAt, thenNEGATIVE_INFINITY.created_atsorting and id tie-breakers are unchanged.Adds
threadSort.test.tswith cases for invalid metadata with no messages (falls back to thread timestamps) and with messages (falls back to the latest user message).Reviewed by Cursor Bugbot for commit 6f3ac79. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
getLatestUserMessageTimestampto tolerate invalidlatestUserMessageAttimestampsPreviously, if
latestUserMessageAtwas present but not a valid date, the function returnedNumber.NEGATIVE_INFINITY, causing threads to sort incorrectly. Now, whenlatestUserMessageAtis invalid, the function falls back to scanning user messages for a valid timestamp, then toupdatedAt/createdAt, before usingNumber.NEGATIVE_INFINITY. Tests are added in threadSort.test.ts covering both fallback paths.Macroscope summarized 6f3ac79.