Skip to content

Conversation

@ENvironmentSet
Copy link
Collaborator

@ENvironmentSet ENvironmentSet commented Dec 17, 2025

Marking activity preparation tasks as passive effects, stackflow now prioritize ongoing rendering works than activity preparation tasks requested by activities currently being rendered. This patch prevents script evaluation tasks for anticipated next activities from blocking ongoing transition updates.

(an example of the issue)
스크린샷 2025-12-17 오후 4 05 06

@changeset-bot
Copy link

changeset-bot bot commented Dec 17, 2025

🦋 Changeset detected

Latest commit: 127ff5f

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

This PR includes changesets to release 1 package
Name Type
@stackflow/react Minor

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 17, 2025

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 127ff5f Commit Preview URL Dec 17 2025, 08:47 AM

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Improved scheduling of Activity preparation so tasks run after render, reducing UI contention and improving responsiveness.
    • Stabilized preparation calls across renders to reduce redundant work and improve performance.
  • Chores

    • Added a release changeset noting a minor version bump and the preparation scheduling improvement.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Defers Activity preparation from synchronous render to passive React effects and memoizes the prepare function with React.useCallback. Adds a changeset declaring a minor release for @stackflow/react. No exported/public signatures were changed.

Changes

Cohort / File(s) Summary
Release declaration
\.changeset/solid-pillows-laugh\.md
New changeset file marking a minor release for @stackflow/react and noting that Activity preparation tasks are now scheduled as passive effects.
Activity preparation -> effect
integrations/react/src/future/useActivityPreparation.ts
Replaces synchronous preparation loop during render with a useEffect that defers calling prepare for each activity; adds useEffect import and depends on [activities, prepare].
Prepare function memoization
integrations/react/src/future/usePrepare.ts
Wraps the returned prepare function in React.useCallback (stable dependency array [config, loadData, activityComponentMap]); no signature changes, internal logic preserved.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Changes affect two hook implementations and a release metadata file.
  • Areas to focus on:
    • Race conditions or ordering changes from deferring prepare to effect in useActivityPreparation.ts.
    • Correctness of dependency arrays and stability of the memoized prepare in usePrepare.ts.
    • Any consumer assumptions about synchronous preparation timing.

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: prioritizing ongoing rendering works over activity preparation tasks, which directly aligns with the changeset's focus on marking activity preparation as passive effects.
Description check ✅ Passed The description is directly related to the changeset, explaining the rationale behind marking activity preparation tasks as passive effects and the performance benefit of preventing blocking of transition updates.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lazy-use-activity-preparation

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ee931b3 and 127ff5f.

📒 Files selected for processing (2)
  • integrations/react/src/future/useActivityPreparation.ts (1 hunks)
  • integrations/react/src/future/usePrepare.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write source in TypeScript with strict typing enabled across the codebase

Files:

  • integrations/react/src/future/usePrepare.ts
  • integrations/react/src/future/useActivityPreparation.ts
🧬 Code graph analysis (2)
integrations/react/src/future/usePrepare.ts (3)
config/src/RegisteredActivityName.ts (1)
  • RegisteredActivityName (3-6)
config/src/InferActivityParams.ts (1)
  • InferActivityParams (5-8)
integrations/react/src/__internal__/StructuredActivityComponentType.tsx (1)
  • isStructuredActivityComponent (61-69)
integrations/react/src/future/useActivityPreparation.ts (2)
config/src/RegisteredActivityName.ts (1)
  • RegisteredActivityName (3-6)
integrations/react/src/future/usePrepare.ts (1)
  • usePrepare (16-57)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Workers Builds: stackflow-docs
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
integrations/react/src/future/useActivityPreparation.ts (1)

2-2: LGTM!

The import addition is necessary and correctly placed for the useEffect usage below.

integrations/react/src/future/usePrepare.ts (2)

5-5: LGTM!

The import addition is necessary for the useCallback wrapper and correctly placed.


21-56: Excellent memoization implementation!

The useCallback wrapper correctly stabilizes the prepare function reference across renders. The dependency array [config, loadData, activityComponentMap] includes all external dependencies used within the callback, ensuring correctness while preventing unnecessary re-creation.

This change aligns well with the PR objective to defer activity preparation as passive effects, as it prevents the useEffect in useActivityPreparation.ts from re-running unnecessarily due to a changing prepare reference.


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

pkg-pr-new bot commented Dec 17, 2025

commit: 127ff5f

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 002aebc and ee931b3.

📒 Files selected for processing (2)
  • .changeset/solid-pillows-laugh.md (1 hunks)
  • integrations/react/src/future/useActivityPreparation.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write source in TypeScript with strict typing enabled across the codebase

Files:

  • integrations/react/src/future/useActivityPreparation.ts
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

Include a Changeset entry for any user-facing package change

Files:

  • .changeset/solid-pillows-laugh.md
🧬 Code graph analysis (1)
integrations/react/src/future/useActivityPreparation.ts (2)
config/src/RegisteredActivityName.ts (1)
  • RegisteredActivityName (3-6)
integrations/react/src/future/usePrepare.ts (1)
  • usePrepare (15-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Workers Builds: stackflow-docs
🔇 Additional comments (2)
integrations/react/src/future/useActivityPreparation.ts (1)

2-2: LGTM!

The useEffect import is necessary for the new deferred execution approach.

.changeset/solid-pillows-laugh.md (1)

1-5: LGTM!

The changeset correctly declares a minor version bump for @stackflow/react with an appropriate description of the scheduling improvement. This follows the coding guideline requirement to include a changeset entry for user-facing package changes.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 17, 2025

Deploying stackflow-demo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 127ff5f
Status: ✅  Deploy successful!
Preview URL: https://9dc15847.stackflow-demo.pages.dev
Branch Preview URL: https://lazy-use-activity-preparatio.stackflow-demo.pages.dev

View logs

@ENvironmentSet ENvironmentSet merged commit 57fd2da into main Dec 17, 2025
9 checks passed
@ENvironmentSet ENvironmentSet deleted the lazy-use-activity-preparation branch December 17, 2025 09:20
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.

3 participants