Skip to content

test(web): the shared-timeline test controls the clock it compares - #996

Merged
Jacksondr5 merged 1 commit into
j5/mainfrom
j5code/shared-timeline-flake
Nov 9, 2026
Merged

Jacksondr5 merged 1 commit into
j5/mainfrom
j5code/shared-timeline-flake

Conversation

@Jacksondr5

Copy link
Copy Markdown
Owner

Problem

sharedTimeline.browser.test.tsx › "keeps a message on screen when the thread becomes shared, and asks about it once" fails intermittently in CI with expected [] 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(). sharedMessageAnsweredFor counts 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

  • One concern: the description has no "also"
  • Tests cover the changed behavior: the test itself, proved against the pinned clock
  • UI changes: none
  • Live testing: none; a test-only change
  • Upstream-owned files: none
  • Upstream product: none
  • Surfaces: test only
  • Docs: none

Built by Claude Opus 5.5 in Claude Code, as builder-timeline in the mobile catch-up Crew.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Nov 9, 2026 8:54am UTC

Request Review

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Nov 9, 2026
@github-actions github-actions Bot added the size:XS 0-9 effective changed lines (test files excluded in mixed PRs). label Nov 9, 2026
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The browser test now sets Date.now() to 10 for the initial render and to 11 after the thread becomes shared, before rerendering the probe.

Changes: Shared timeline test

Layer / File(s) Summary
Control timestamps in the sharing test
apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx
The test sets the initial timestamp to 10 and changes it to 11 after updating people with access, before rerendering.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: size:XS

Merge Risk: Minimal · up to e3eef

The test now controls timestamp ordering. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Linked issues #941 and #995 are direct, open, and coding-related. Their shared requirement: fix the intermittent failure of "keeps a message on screen when the thread becomes shared, and asks about it… Provide evidence for the open points:
(a) A real-clock trace from a failing run, or repeated real-clock runs, that shows whether the failing render pair had equal Date.now values, and that the test passes reliably with the change.
(b) Evide…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the change: the shared-timeline test now controls the clock it compares. The raw summary says the test pins Date.now() at 10 for the first render and advances it to 11 before the reren…
Description check Passed The description follows the template sections (Problem, What changed, Checklist). The Problem section states the symptom, the cause (equal Date.now() stamps), and links issues #941 and #995. The What …
Out of Scope Changes check Passed The whole-PR diff against the merge base changes one file: apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx, +4 lines. Both hunks sit inside the target test "keeps a message on screen when the …
Full details: Title check

Explanation

The title names the change: the shared-timeline test now controls the clock it compares. The raw summary says the test pins Date.now() at 10 for the first render and advances it to 11 before the rerender, which matches the title. The title is short, specific, and follows the test(web): convention.

Full details: Description check

Explanation

The description follows the template sections (Problem, What changed, Checklist). The Problem section states the symptom, the cause (equal Date.now() stamps), and links issues #941 and #995. The What changed section explains the clock pinning, the reasoning, and the proof. UI changes, Live testing, Upstream impact, and Docs are either marked none or covered by the checklist. Two gaps remain: the template's closing line asks for the model and harness that did the work, and the Live testing section is a checklist-only note rather than a template-style section. The description also still includes the 'Built by' and Claude Code attribution as the template requests. These gaps are minor, so the check passes.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes one file: apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx, +4 lines. Both hunks sit inside the target test "keeps a message on screen when the thread becomes shared, and asks about it once". One hunk adds a comment and pins Date.now to 10 before the first render. The other sets Date.now to 11 before the rerender. These lines directly support the flake objective of #941 and #995. No product code, documentation, or other tests changed.

Full details: Linked Issues check

Explanation

Linked issues #941 and #995 are direct, open, and coding-related. Their shared requirement: fix the intermittent failure of "keeps a message on screen when the thread becomes shared, and asks about it once" with a real fix, not a rerun or quarantine. #995 also asks to find unawaited state and wait on it with expect.element or vi.waitFor, not a sleep.

Reviewed head change: sharedTimeline.browser.test.tsx pins Date.now to 10 before the first render and sets it to 11 before the rerender. The change adds no sleep, retry, or quarantine. It removes wall-clock dependence from the test.

Supporting evidence: sharedTimeline.ts passes Date.now into observeSharedMessages, and the stamps feed sharedMessageAnsweredFor. This matches the PR's tie-timestamp mechanism. The PR's pinned-clock run (equal values fail, advancing values pass) supports that equal stamps can produce the reported assertion failure.

Unresolved points:

  1. The PR does not show that the CI or macOS failures had equal stamps. The evidence is a forced-input reproduction, not a real-clock trace.
  2. The #995 hypothesis (an unawaited async read at the share flip) is not ruled out. The test does not wait on the author read before the assertion.
  3. The PR states that a tie holds the message back only until the author read answers. The shared-conversation runtime module (@t3tools/client-runtime/j5/shared-conversation) was not readable within the inspection budget, so this product claim is unverified.
  4. The test no longer exercises the equal-stamp case. Product behavior on a tie stays untested.

The PR's proof claims were not re-run in this assessment.

Resolution

Provide evidence for the open points:
(a) A real-clock trace from a failing run, or repeated real-clock runs, that shows whether the failing render pair had equal Date.now values, and that the test passes reliably with the change.
(b) Evidence that no author read is pending at the assertion. This can be an awaited wait on the read state with expect.element or vi.waitFor, or a source reference showing the read completes before the rerender is observed.
(c) The source of sharedMessageAnsweredFor and observeSharedMessages from @t3tools/client-runtime/j5/shared-conversation, to confirm the held-back-then-shown behavior the PR describes.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 116940c and e3eefb1.

Files selected for processing: 1

  • apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

@Jacksondr5
Jacksondr5 merged commit d89e227 into j5/main Nov 9, 2026
31 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/shared-timeline-flake branch November 9, 2026 09:15

This branch was successfully deployed

1 active deployment
Preview — e3eefb13 Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

1 participant