Repository navigation
test(web): the shared-timeline test controls the clock it compares - #996
Conversation
The message's first-seen stamp and the moment the thread can be shared are both Date.now(). The hook treats a message as on screen before sharing only when its stamp is strictly earlier, so two renders in the same millisecond held the message back. The test now sets the clock for each render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Problem
sharedTimeline.browser.test.tsx› "keeps a message on screen when the thread becomes shared, and asks about it once" fails intermittently in CI withexpected [] to deeply equal [ 'entry-1' ]. It failed every time on macOS. Closes #941, closes #995.What changed
The cause is the wall clock, not async state. The hook stamps a message's first sighting and the moment the thread may be shared, both with
Date.now().sharedMessageAnsweredForcounts the message as already on screen only when its stamp is strictly earlier than the sharing stamp.The test renders, marks the thread shared, and re-renders, all synchronously. When both renders fall in the same millisecond, the two stamps are equal and the message is held back. Faster machines hit this more often, which is why it failed every time on macOS.
The test now controls the clock:
vi.spyOn(Date, "now")returns 10 for the first render and 11 for the re-render. That is the order the test means. There are no sleeps and no retries.Proof. With the clock pinned to the same value for both renders, the test fails with the CI assertion. With it advancing, the test passes.
Product code is unchanged. In the app, the two renders come from different events: the message arriving, then the read saying who reaches the thread. Even on a millisecond tie, the effect is brief. The message is held until the authors read answers, which the hook requests at once, and then it shows. That's a rare case, so I left it alone rather than add tie-breaking.
Checklist
Built by Claude Opus 5.5 in Claude Code, as builder-timeline in the mobile catch-up Crew.
🤖 Generated with Claude Code