Skip to content

fix(core): prevent incorrect transition state when transitionDuration is 0#691

Merged
ENvironmentSet merged 3 commits intomainfrom
fix/transition-duration-zero-jitter
Apr 3, 2026
Merged

fix(core): prevent incorrect transition state when transitionDuration is 0#691
ENvironmentSet merged 3 commits intomainfrom
fix/transition-duration-zero-jitter

Conversation

@ENvironmentSet
Copy link
Copy Markdown
Collaborator

@ENvironmentSet ENvironmentSet commented Apr 2, 2026

Closes FECO-90

Summary

  • transitionDuration: 0 설정 시 간헐적으로 transition state가 enter-done 대신 enter-active로 잘못 설정되는 이슈를 수정합니다.
  • dispatchEvent에서 aggregate() 호출 시 Math.max(newEvent.eventDate, Date.now())를 사용하여 now >= eventDate를 보장합니다.

Root Cause

core/src/utils/time.tstime() 함수는 이벤트 정렬을 위해 같은 밀리초 내 중복 호출 시 sub-millisecond 오프셋을 추가합니다 (e.g., 1000000.001). dispatchEvent에서 aggregate(events, Date.now())를 호출할 때, Date.now()가 같은 밀리초를 반환하면 now < eventDate가 되어 now - eventDate >= transitionDuration(0) 판정이 실패합니다.

이로 인해 activity가 enter-done 대신 enter-active 상태로 진입하게 됩니다.

Test plan

  • yarn workspace @stackflow/core test — 84개 테스트 모두 통과
  • Demo 앱에서 transitionDuration: 0으로 반복 네비게이션 시 정상 동작 확인
  • Demo 앱에서 transitionDuration: 270 (기본값)으로 전환 애니메이션 정상 작동 확인

🤖 Generated with Claude Code

…heme

The `time()` utility adds sub-millisecond offsets to ensure unique event
timestamps. When `dispatchEvent` calls `aggregate()` with `Date.now()`,
there is a race condition where `Date.now() < eventDate` (by a fraction
of a millisecond), causing `now - eventDate < 0`. With transitionDuration
set to 0, this makes the `>= transitionDuration` check fail, briefly
putting the activity in `enter-active` instead of `enter-done`.

Combined with `useLazy`'s 2-frame delay and the android theme's default
`opacity: 0` style, this produces a visible flicker ("jitter") during
page transitions.

Use `Math.max(newEvent.eventDate, Date.now())` to guarantee
`now >= eventDate`, ensuring the transition state resolves correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: da242aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stackflow/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b000d55c-8535-4b02-96ae-4de618e0a354

📥 Commits

Reviewing files that changed from the base of the PR and between 862e9c6 and da242aa.

📒 Files selected for processing (2)
  • .changeset/fix-transition-duration-zero-jitter.md
  • core/src/makeCoreStore.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed intermittent incorrect transition state when transition duration is set to zero.

Walkthrough

This PR fixes an intermittent state aggregation bug in @stackflow/core when transitionDuration is 0. The fix modifies dispatchEvent to pass the maximum of the event's date and current time to the aggregate function, ensuring correct timing during initial state calculation.

Changes

Cohort / File(s) Summary
Changelog Entry
.changeset/fix-transition-duration-zero-jitter.md
Adds patch release note documenting the fix for incorrect transition state when transitionDuration is 0.
Core Logic
core/src/makeCoreStore.ts
Updates dispatchEvent to pass Math.max(newEvent.eventDate, Date.now()) to aggregate instead of just Date.now(), ensuring the timestamp is at least the new event's date.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: preventing incorrect transition state when transitionDuration is 0, which directly aligns with the primary change in the changeset.
Description check ✅ Passed The description provides detailed context about the fix, including root cause analysis, the specific problem, and the solution, all of which directly relate to the changes in the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/transition-duration-zero-jitter

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 and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

@stackflow/core

yarn add https://pkg.pr.new/@stackflow/core@691.tgz

@stackflow/compat-await-push

yarn add https://pkg.pr.new/@stackflow/compat-await-push@691.tgz

@stackflow/link

yarn add https://pkg.pr.new/@stackflow/link@691.tgz

@stackflow/plugin-basic-ui

yarn add https://pkg.pr.new/@stackflow/plugin-basic-ui@691.tgz

@stackflow/plugin-blocker

yarn add https://pkg.pr.new/@stackflow/plugin-blocker@691.tgz

@stackflow/plugin-devtools

yarn add https://pkg.pr.new/@stackflow/plugin-devtools@691.tgz

@stackflow/plugin-google-analytics-4

yarn add https://pkg.pr.new/@stackflow/plugin-google-analytics-4@691.tgz

@stackflow/plugin-history-sync

yarn add https://pkg.pr.new/@stackflow/plugin-history-sync@691.tgz

@stackflow/plugin-map-initial-activity

yarn add https://pkg.pr.new/@stackflow/plugin-map-initial-activity@691.tgz

@stackflow/plugin-preload

yarn add https://pkg.pr.new/@stackflow/plugin-preload@691.tgz

@stackflow/plugin-renderer-basic

yarn add https://pkg.pr.new/@stackflow/plugin-renderer-basic@691.tgz

@stackflow/plugin-renderer-web

yarn add https://pkg.pr.new/@stackflow/plugin-renderer-web@691.tgz

@stackflow/plugin-sentry

yarn add https://pkg.pr.new/@stackflow/plugin-sentry@691.tgz

@stackflow/plugin-stack-depth-change

yarn add https://pkg.pr.new/@stackflow/plugin-stack-depth-change@691.tgz

@stackflow/react-ui-core

yarn add https://pkg.pr.new/@stackflow/react-ui-core@691.tgz

@stackflow/react

yarn add https://pkg.pr.new/@stackflow/react@691.tgz

commit: da242aa

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 2, 2026

Deploying stackflow-demo with  Cloudflare Pages  Cloudflare Pages

Latest commit: da242aa
Status: ✅  Deploy successful!
Preview URL: https://5f384c0f.stackflow-demo.pages.dev
Branch Preview URL: https://fix-transition-duration-zero.stackflow-demo.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 2, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
stackflow-docs da242aa Commit Preview URL Apr 03 2026, 02:33 AM

@ENvironmentSet ENvironmentSet marked this pull request as ready for review April 3, 2026 02:21
@ENvironmentSet ENvironmentSet force-pushed the fix/transition-duration-zero-jitter branch from 4e1077d to 4987887 Compare April 3, 2026 02:25
@ENvironmentSet ENvironmentSet changed the title fix(core): prevent jitter when transitionDuration is 0 with android theme fix(core): prevent incorrect transition state when transitionDuration is 0 Apr 3, 2026
@ENvironmentSet ENvironmentSet requested a review from orionmiz April 3, 2026 02:27
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ENvironmentSet ENvironmentSet force-pushed the fix/transition-duration-zero-jitter branch from 4987887 to da242aa Compare April 3, 2026 02:28
@ENvironmentSet ENvironmentSet merged commit 0160f82 into main Apr 3, 2026
9 checks passed
@ENvironmentSet ENvironmentSet deleted the fix/transition-duration-zero-jitter branch April 3, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants