Skip to content

Conversation

@ENvironmentSet
Copy link
Collaborator

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: 3dc59ff

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

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added preloading and caching capability for structured activities defined outside the standard constructor, improving load times for lazy-loaded activity components.

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

Walkthrough

The changes implement a new preloading and caching system for structured activities. The getContentComponent function now returns both a Component and a preload function, replacing direct content() calls with standardized preload() pathways across loaders and preparation hooks. The preload function has been updated to handle both fulfilled and pending promises appropriately.

Changes

Cohort / File(s) Summary
Release metadata
\.changeset/yellow-geckos-warn\.md
New changeset documenting patch-level release describing preloading and caching capability for structured activities defined outside the standard constructor.
Core component type and utilities
integrations/react/src/__internal__/StructuredActivityComponentType\.tsx, integrations/react/src/__internal__/utils/PreloadableLazyComponent\.tsx, integrations/react/src/__internal__/PluginRenderer\.tsx
getContentComponent return type expanded from Content<{}>["component"] to { Component: Content<{}>["component"]; preload: () => Promise<void> }. Removed caching wrapper around content property. Updated preload function to check promise fulfillment state and conditionally return sync or async resolution. PluginRenderer now destructures { Component } from getContentComponent result.
Loaders and hooks
integrations/react/src/future/loader/loaderPlugin\.tsx, integrations/react/src/future/usePrepare\.ts
Both files updated to use getContentComponent(...).preload() instead of direct content() invocation. getContentComponent added to imports from StructuredActivityComponentType module. Preloading pathway now gated by structured activity component check.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
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.
Description check ❓ Inconclusive The pull request lacks a description; no information is provided to assess its relevance to the changeset. Add a pull request description explaining the motivation, implementation approach, and any breaking changes or migration guidance.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enabling preloading and caching of structured activities defined outside the standard constructor.
✨ Finishing touches
  • 📝 Generate docstrings

📜 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 57fd2da and 3dc59ff.

📒 Files selected for processing (6)
  • .changeset/yellow-geckos-warn.md
  • integrations/react/src/__internal__/PluginRenderer.tsx
  • integrations/react/src/__internal__/StructuredActivityComponentType.tsx
  • integrations/react/src/__internal__/utils/PreloadableLazyComponent.tsx
  • integrations/react/src/future/loader/loaderPlugin.tsx
  • integrations/react/src/future/usePrepare.ts
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

Include a Changeset entry for any user-facing package change

Files:

  • .changeset/yellow-geckos-warn.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write source in TypeScript with strict typing enabled across the codebase

Files:

  • integrations/react/src/__internal__/PluginRenderer.tsx
  • integrations/react/src/__internal__/utils/PreloadableLazyComponent.tsx
  • integrations/react/src/__internal__/StructuredActivityComponentType.tsx
  • integrations/react/src/future/usePrepare.ts
  • integrations/react/src/future/loader/loaderPlugin.tsx
integrations/react/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Use .tsx files for React components and JSX in the React integration package

Files:

  • integrations/react/src/__internal__/PluginRenderer.tsx
  • integrations/react/src/__internal__/utils/PreloadableLazyComponent.tsx
  • integrations/react/src/__internal__/StructuredActivityComponentType.tsx
  • integrations/react/src/future/loader/loaderPlugin.tsx
🧬 Code graph analysis (5)
integrations/react/src/__internal__/PluginRenderer.tsx (1)
integrations/react/src/__internal__/StructuredActivityComponentType.tsx (2)
  • getContentComponent (68-100)
  • structuredActivityComponent (27-41)
integrations/react/src/__internal__/utils/PreloadableLazyComponent.tsx (1)
integrations/react/src/__internal__/utils/SyncInspectablePromise.ts (4)
  • inspect (29-49)
  • PromiseStatus (9-13)
  • PromiseStatus (14-14)
  • resolve (80-91)
integrations/react/src/__internal__/StructuredActivityComponentType.tsx (1)
integrations/react/src/__internal__/utils/PreloadableLazyComponent.tsx (1)
  • preloadableLazyComponent (10-44)
integrations/react/src/future/usePrepare.ts (1)
integrations/react/src/__internal__/StructuredActivityComponentType.tsx (1)
  • getContentComponent (68-100)
integrations/react/src/future/loader/loaderPlugin.tsx (1)
integrations/react/src/__internal__/StructuredActivityComponentType.tsx (1)
  • getContentComponent (68-100)
⏰ 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 (9)
.changeset/yellow-geckos-warn.md (1)

1-5: LGTM!

The changeset correctly documents a patch-level release for @stackflow/react with a clear description of the new preloading and caching capability for structured activities.

integrations/react/src/__internal__/PluginRenderer.tsx (1)

90-92: LGTM!

The destructuring correctly adapts to the new { Component, preload } return type from getContentComponent, extracting only the Component property needed for rendering.

integrations/react/src/__internal__/utils/PreloadableLazyComponent.tsx (1)

34-42: LGTM!

The preload function implementation correctly handles both scenarios:

  • Returns an immediately resolved Promise<void> when the component is already loaded (efficient fast-path)
  • Returns a promise that resolves to undefined when still pending

This aligns well with the new preload-based API pattern.

integrations/react/src/future/loader/loaderPlugin.tsx (2)

7-10: LGTM!

The import is correctly updated to include getContentComponent alongside the existing isStructuredActivityComponent import.


117-125: LGTM!

The switch from direct content() invocation to getContentComponent(matchActivityComponent).preload() correctly implements the new centralized preloading pattern. The conditional check for function-based content remains appropriate to distinguish lazy-loadable content from eagerly-defined content.

integrations/react/src/__internal__/StructuredActivityComponentType.tsx (2)

63-66: LGTM!

The ContentComponentMap type correctly updated to store the new { Component, preload } shape, ensuring type safety for the caching mechanism.


68-99: LGTM!

The getContentComponent implementation is well-structured:

  • Proper cache-first lookup with the WeakMap
  • Handles both eager (Content<P>) and lazy (() => Promise<...>) content definitions
  • Correctly delegates to preloadableLazyComponent for unified preload behavior
  • Promise state handling covers fulfilled, rejected, and pending cases appropriately
integrations/react/src/future/usePrepare.ts (2)

7-10: LGTM!

The import correctly updated to include getContentComponent for the new preload API.


49-56: LGTM!

The refactoring from direct content() invocation to getContentComponent(...).preload() correctly aligns with the centralized preloading pattern. This ensures consistent caching behavior across both the loader plugin and the prepare hook.


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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 5, 2026

Deploying stackflow-demo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3dc59ff
Status: ✅  Deploy successful!
Preview URL: https://e4ddc8ac.stackflow-demo.pages.dev
Branch Preview URL: https://structured-activity-content.stackflow-demo.pages.dev

View logs

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 5, 2026

commit: 3dc59ff

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 5, 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 terminated
View logs
stackflow-docs 3dc59ff Commit Preview URL Jan 06 2026, 04:04 AM

@ENvironmentSet ENvironmentSet changed the title WIP feat(react): Make structured activities defined by other than the standard constructor can be preloaded and cached Jan 6, 2026
@ENvironmentSet ENvironmentSet marked this pull request as ready for review January 6, 2026 03:43
@ENvironmentSet ENvironmentSet merged commit 4b894ae into main Jan 6, 2026
8 of 9 checks passed
@ENvironmentSet ENvironmentSet deleted the structured-activity-content-cache-fix branch January 6, 2026 03:56
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