Skip to content

[codex] Fix visited timestamp under clock skew#2408

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/fix-clock-skew-visited
Apr 30, 2026
Merged

[codex] Fix visited timestamp under clock skew#2408
juliusmarminge merged 1 commit into
mainfrom
codex/fix-clock-skew-visited

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Apr 29, 2026

Summary

Fixes #2087.

This updates the settled-turn visited marker to use the server-provided turn completion timestamp instead of falling back to the client wall clock. That prevents the active thread from repeatedly trying to mark itself visited when the client clock is slightly behind the server completion time.

A focused regression test now covers preserving provided visited timestamps and refusing to move visit state backwards under skew.

Validation

  • bun run --filter @t3tools/web test -- uiStateStore.test.ts
  • bun fmt
  • bun lint (passes with existing warnings)
  • bun typecheck

Note

Fix visited timestamp in markThreadVisited under clock skew

  • Updates ChatView.tsx to pass activeLatestTurn.completedAt as a second argument to markThreadVisited, so the stored timestamp reflects the server's completion time rather than the local clock.
  • Updates markThreadVisited in the UI state store to avoid overwriting a stored timestamp with an earlier one, preventing regressions under clock skew.
  • Adds two unit tests in uiStateStore.test.ts covering the new timestamp storage and the clock skew guard.

Macroscope summarized ccafe71.


Note

Medium Risk
Changes the read/unread visit timestamp logic, which could affect badge/visited state across threads if timestamps are malformed or comparisons are incorrect, but the scope is small and covered by new tests.

Overview
Fixes thread visit tracking so the UI records the server-provided latestTurn.completedAt timestamp when a settled turn completes, instead of implicitly using the client wall clock.

Updates markThreadVisited to accept an explicit visitedAt and to no-op when the incoming timestamp is older than the stored one (guarding against clock skew), with new unit tests covering both behaviors.

Reviewed by Cursor Bugbot for commit ccafe71. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

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: 1bab22bc-8649-4f5c-b243-9b2812958741

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
  • Commit unit tests in branch codex/fix-clock-skew-visited

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

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Apr 29, 2026
@juliusmarminge juliusmarminge marked this pull request as ready for review April 30, 2026 00:00
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 30, 2026

Approvability

Verdict: Approved

Straightforward bug fix that passes a server-provided timestamp to avoid client clock skew issues. The change is minimal and well-tested, with no impact beyond the specific edge case being addressed.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge juliusmarminge merged commit 22b7d8c into main Apr 30, 2026
17 checks passed
@juliusmarminge juliusmarminge deleted the codex/fix-clock-skew-visited branch April 30, 2026 00:07
Morphexe pushed a commit to Morphexe/t3code that referenced this pull request May 4, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
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:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: React #185 crash after sending a message when client clock lags server

2 participants