Skip to content

[7418] plugin - serializers/retrievers/validators - #8882

Open
jvega190 wants to merge 5 commits into
craftersoftware:developfrom
jvega190:7418-plugin-retrievers-serializers-validators
Open

[7418] plugin - serializers/retrievers/validators#8882
jvega190 wants to merge 5 commits into
craftersoftware:developfrom
jvega190:7418-plugin-retrievers-serializers-validators

Conversation

@jvega190

@jvega190 jvega190 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

#7418

Summary by CodeRabbit

  • New Features
    • Added plugin support for custom value retrieval, serialization, and field validation.
    • Forms now preload required control plugins before initializing create, edit, and embedded forms.
    • Exposed field rendering and plugin control integration through the Forms Engine.
  • Bug Fixes
    • Improved plugin loading cleanup, preload failure handling, and embedded-form cleanup.
    • Preserved configured rich-text styles, including inline and dark-mode behavior.
  • Documentation
    • Updated Forms Engine and plugin integration guidance with the new capabilities.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

FE2 control plugins now support value retrieval, serialization, and validation hooks. Forms Engine preloads referenced plugins before embedded, create, and edit form initialization. The controls host exposes hook lookups and FormsEngineField. Built-in mappings retain precedence.

Changes

FE2 control plugin lifecycle

Layer / File(s) Summary
Plugin contracts and registration
studio-ui/ui/app/src/models/PluginDescriptor.ts, studio-ui/ui/app/src/services/plugin.ts, studio-ui/ui/app/src/components/FormsEngine/controls/registry.ts, studio-ui/ui/app/src/components/FormsEngine/lib/controlValueTypes.ts
Plugin contributions accept optional retriever, serializer, and validator hooks. Registration validates and stores these hooks. The registry refreshes hooks during same-owner re-registration and exposes lookup functions.
Value and validation resolution
studio-ui/ui/app/src/components/FormsEngine/lib/valueRetrievers.ts, studio-ui/ui/app/src/components/FormsEngine/lib/valueSerializers.ts, studio-ui/ui/app/src/components/FormsEngine/lib/validators.ts, studio-ui/ui/app/src/components/FormsEngine/dataSources/host.ts, studio-ui/ui/app/src/components/FormsEngine/components/TableOfContents.tsx
Built-in mappings take precedence. Plugin hooks handle unknown control types. The controls host exposes hook lookups and FormsEngineField. Validator lookup is shared by validation and table-of-contents rendering.
Plugin preload and form initialization
studio-ui/ui/app/src/components/FormsEngine/lib/controlPluginLoader.ts, studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx
Nested fields are scanned for unique plugin locators. Plugins load before embedded, create, and edit values are parsed. Failed loads are removed from cache, and asynchronous initialization stops after disposal.
Host UI contract and documentation
studio-ui/docs/type-builder-forms-engine.md, studio-ui/docs/type-builder-forms-engine-plugins.md, studio-ui/ui/app/src/components/FormsEngine/lib/rteUtils.ts
Documentation describes bare plugin controls, validation chrome, hook precedence, and preload behavior. TinyMCE content stylesheet fallback behavior is updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Plugin
  participant registerPlugin
  participant registry
  participant FormsEngine
  participant controlPluginLoader

  Plugin->>registerPlugin: provide control hooks
  registerPlugin->>registry: register contribution
  FormsEngine->>controlPluginLoader: preload plugins for form fields
  controlPluginLoader-->>FormsEngine: resolve loaded plugins
  FormsEngine->>registry: resolve retriever, serializer, or validator
  registry-->>FormsEngine: return registered hook
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 65.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the plugin serializer, retriever, and validator changes covered by the pull request.
Description check ✅ Passed The description provides the required ticket reference through the linked issue URL.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@studio-ui/docs/type-builder-forms-engine.md`:
- Around line 667-670: Synchronize the Progress and Open decisions sections in
the Forms Engine documentation with the completed control cleanup: remove or
mark resolved the entries for retired IDs link-input, link-textarea,
linked-dropdown and the remapped disabled/internal-name aliases, ensuring no
unresolved null-map-slot item remains.

In `@studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx`:
- Around line 539-543: In
studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx:539-543, update the
preload promise handling around initCreateForm to set the preparation error and
prevent initCreateForm from running when preloadControlPluginsForFields fails.
Apply the same behavior in
studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx:586-621: set the
preparation error and do not call createParsedValuesObject after preload
failure; retain the existing success paths.
- Around line 539-546: Update the embedded-component initialization flow around
prepareEmbeddedItemForm and invokePrepareFn so the embedded content type’s
fields are preloaded before invokePrepareFn parses or validates values. Reuse
the existing preloadControlPluginsForFields mechanism, awaiting or chaining it
before invokePrepareFn, while preserving the current parent-field preload and
initCreateForm behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 98e61389-0047-4be3-bb0d-ac26f0c1ae00

📥 Commits

Reviewing files that changed from the base of the PR and between cdfede1 and 60a6f0a.

📒 Files selected for processing (14)
  • studio-ui/docs/type-builder-forms-engine-plugins.md
  • studio-ui/docs/type-builder-forms-engine.md
  • studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx
  • studio-ui/ui/app/src/components/FormsEngine/components/TableOfContents.tsx
  • studio-ui/ui/app/src/components/FormsEngine/controls/registry.ts
  • studio-ui/ui/app/src/components/FormsEngine/dataSources/host.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/controlPluginLoader.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/controlValueTypes.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/rteUtils.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/validators.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/valueRetrievers.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/valueSerializers.ts
  • studio-ui/ui/app/src/models/PluginDescriptor.ts
  • studio-ui/ui/app/src/services/plugin.ts

Comment thread studio-ui/docs/type-builder-forms-engine.md
Comment thread studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx Outdated
Comment thread studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx Outdated
@jvega190

Copy link
Copy Markdown
Contributor Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@jvega190 I will perform a final review of PR #8882 before the human review handover.

⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 7 minutes.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Your plan includes PR reviews subject to rate limits. Reviews are available now.

@jvega190

Copy link
Copy Markdown
Contributor Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@jvega190 I will perform a final review of PR #8882 before the human review handover.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jvega190

Copy link
Copy Markdown
Contributor Author

@coderabbitai how does this work look to be merged? Any issues you can point out?

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@jvega190 I will run a complete final review of #8882. I will report any merge-blocking issues and other findings after the review completes.

✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@studio-ui/ui/app/src/components/FormsEngine/lib/controlPluginLoader.ts`:
- Around line 92-116: Update the preload flow around the Promise.all call in the
control plugin loader to wait for every import to settle before returning,
rather than rejecting immediately on the first failure. Preserve the existing
controlPluginCache cleanup, console.error logging, and rejection/continue
behavior for failed imports while ensuring successful plugin imports finish
before callers proceed.
- Around line 69-70: Extend the recursive preload traversal alongside the
field.fields handling in the loader to inspect node-selector item.component
values, resolve each embedded content type, and walk its fields before
createParsedValueForField parses values. Reuse the existing plugin-discovery and
content-type resolution logic so embedded controls are registered before
parsing.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 46eb676d-e67b-410a-bc6b-ddc58c6be044

📥 Commits

Reviewing files that changed from the base of the PR and between cdfede1 and 49c75ba.

📒 Files selected for processing (14)
  • studio-ui/docs/type-builder-forms-engine-plugins.md
  • studio-ui/docs/type-builder-forms-engine.md
  • studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx
  • studio-ui/ui/app/src/components/FormsEngine/components/TableOfContents.tsx
  • studio-ui/ui/app/src/components/FormsEngine/controls/registry.ts
  • studio-ui/ui/app/src/components/FormsEngine/dataSources/host.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/controlPluginLoader.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/controlValueTypes.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/rteUtils.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/validators.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/valueRetrievers.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/valueSerializers.ts
  • studio-ui/ui/app/src/models/PluginDescriptor.ts
  • studio-ui/ui/app/src/services/plugin.ts

Comment thread studio-ui/ui/app/src/components/FormsEngine/lib/controlPluginLoader.ts Outdated
Comment thread studio-ui/ui/app/src/components/FormsEngine/lib/controlPluginLoader.ts Outdated
@jvega190

Copy link
Copy Markdown
Contributor Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

@jvega190 I will run a final full review of #8882 before human review. I will report any findings after the review completes.

✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
studio-ui/ui/app/src/components/FormsEngine/lib/rteUtils.ts (1)

119-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Update the content_css fallback comment.

Line 286 still says that missing content_css always selects dark/default styles. The new branch selects [] for inline editors. Update the comment to describe both paths.

As per coding guidelines, “Do not remove comments unless they are no longer applicable to the code they describe”; keep Line 286 accurate.

Proposed comment update
-						'content_css' // Handled above, if no content_css is found it will use dark/default styles.
+						'content_css' // Handled above: inline editors use [] when no content_css is configured; non-inline editors use dark/default styles.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@studio-ui/ui/app/src/components/FormsEngine/lib/rteUtils.ts` around lines 119
- 126, Update the fallback comment associated with content_css in the TinyMCE
options logic to accurately describe both behaviors: inline editors use an empty
stylesheet array and non-inline editors select dark or default styles based on
the preferred color scheme. Keep the comment in place and aligned with the
conditional branches.

Source: Coding guidelines

studio-ui/docs/type-builder-forms-engine-plugins.md (1)

285-288: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the non-blocking preload failure path.

The hook contract documents preload timing but not failure handling. If preloadControlPluginsForFields rejects for one locator, Forms Engine logs the failure and continues initialization. Hooks for that plugin can be unavailable. Add this behavior to the preload documentation.

Based on learnings, this is the expected host behavior. As per path instructions, record this durable behavior in studio-ui/docs/type-builder-forms-engine.md's Progress and Open decisions sections.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@studio-ui/docs/type-builder-forms-engine-plugins.md` around lines 285 - 288,
Update the preload documentation around preloadControlPluginsForFields to state
that a rejection for one locator is logged, does not block Forms Engine
initialization, and may leave that plugin’s hooks unavailable. Also record this
established host behavior in the Progress and Open decisions sections of the
Forms Engine documentation.

Sources: Path instructions, Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@studio-ui/docs/type-builder-forms-engine-plugins.md`:
- Around line 285-288: Update the preload documentation around
preloadControlPluginsForFields to state that a rejection for one locator is
logged, does not block Forms Engine initialization, and may leave that plugin’s
hooks unavailable. Also record this established host behavior in the Progress
and Open decisions sections of the Forms Engine documentation.

In `@studio-ui/ui/app/src/components/FormsEngine/lib/rteUtils.ts`:
- Around line 119-126: Update the fallback comment associated with content_css
in the TinyMCE options logic to accurately describe both behaviors: inline
editors use an empty stylesheet array and non-inline editors select dark or
default styles based on the preferred color scheme. Keep the comment in place
and aligned with the conditional branches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd6da48b-58a7-41b4-8af1-4cfecc9d721b

📥 Commits

Reviewing files that changed from the base of the PR and between cdfede1 and e513766.

📒 Files selected for processing (14)
  • studio-ui/docs/type-builder-forms-engine-plugins.md
  • studio-ui/docs/type-builder-forms-engine.md
  • studio-ui/ui/app/src/components/FormsEngine/FormsEngine.tsx
  • studio-ui/ui/app/src/components/FormsEngine/components/TableOfContents.tsx
  • studio-ui/ui/app/src/components/FormsEngine/controls/registry.ts
  • studio-ui/ui/app/src/components/FormsEngine/dataSources/host.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/controlPluginLoader.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/controlValueTypes.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/rteUtils.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/validators.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/valueRetrievers.ts
  • studio-ui/ui/app/src/components/FormsEngine/lib/valueSerializers.ts
  • studio-ui/ui/app/src/models/PluginDescriptor.ts
  • studio-ui/ui/app/src/services/plugin.ts

@jvega190
jvega190 marked this pull request as ready for review August 12, 2026 14:36
@jvega190
jvega190 requested a review from rart August 12, 2026 14:39
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.

1 participant