Skip to content

[codex] fix: tolerate invalid latest user message timestamps#3521

Open
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:staging/fix-invalid-latest-user-message-at
Open

[codex] fix: tolerate invalid latest user message timestamps#3521
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:staging/fix-invalid-latest-user-message-at

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Treat malformed latestUserMessageAt values like missing values in thread recency sorting.
  • Preserve the existing fallback order: valid user messages, then updatedAt, then createdAt.
  • Add package-level coverage for invalid latestUserMessageAt fallback behavior.

Root cause

getLatestUserMessageTimestamp returned Number.NEGATIVE_INFINITY as soon as latestUserMessageAt was 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.ts
  • PATH="$HOME/.vite-plus/bin:$PATH" vp check (0 errors, 20 warnings)
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheck

Note

Low Risk
Localized sorting logic fix with new unit tests; no auth, persistence, or API changes.

Overview
Fixes sidebar updated_at thread ordering when latestUserMessageAt is set but not a parseable date. Those threads were sorted as if they had no activity because getLatestUserMessageTimestamp returned Number.NEGATIVE_INFINITY immediately instead of using the same fallbacks as a missing field.

getLatestUserMessageTimestamp now only uses latestUserMessageAt when toSortableTimestamp succeeds; otherwise it keeps the existing chain: latest valid user message timestamps, then updatedAt / createdAt, then NEGATIVE_INFINITY. created_at sorting and id tie-breakers are unchanged.

Adds threadSort.test.ts with 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 getLatestUserMessageTimestamp to tolerate invalid latestUserMessageAt timestamps

Previously, if latestUserMessageAt was present but not a valid date, the function returned Number.NEGATIVE_INFINITY, causing threads to sort incorrectly. Now, when latestUserMessageAt is invalid, the function falls back to scanning user messages for a valid timestamp, then to updatedAt/createdAt, before using Number.NEGATIVE_INFINITY. Tests are added in threadSort.test.ts covering both fallback paths.

Macroscope summarized 6f3ac79.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 34ccd9a1-95da-4809-8f98-99602dfc0099

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Jun 23, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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>
@StiensWout StiensWout force-pushed the staging/fix-invalid-latest-user-message-at branch from 12dbf5e to 6f3ac79 Compare June 23, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant