Add block document reference support to schema form#4
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18b14dce7a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <BlockDocumentCreateForm | ||
| blockTypeId={blockType.id} | ||
| blockSchemaId={blockSchema.id} | ||
| blockSchemaFields={blockSchema.fields as unknown as PrefectSchemaObject} | ||
| onCreated={onCreated} |
There was a problem hiding this comment.
Remove forbidden
as unknown cast in schema fields
ui-v2/src/components/AGENTS.md explicitly says “NEVER use as unknown”; the cast blockSchema.fields as unknown as PrefectSchemaObject violates this rule and bypasses type safety. Please replace it with a safe conversion or a type guard so the schema is validated without unsafe casting.
Useful? React with 👍 / 👎.
| const filteredData = useMemo(() => { | ||
| return data.filter((blockDocument) => | ||
| blockDocument.name?.toLowerCase().includes(deferredSearch.toLowerCase()), | ||
| ); |
| const onSave = async (zodFormValues: BlockNameFormSchema) => { | ||
| try { | ||
| await validateForm({ schema: values }); | ||
| if (errors.length > 0) { | ||
| return; |
There was a problem hiding this comment.
Avoid relying on stale schema errors before create
After await validateForm(...), errors is still the pre-validation state because validateForm only schedules a React state update. That means createBlockDocument can run even when validation fails (e.g., required schema fields missing), or can be blocked even after errors are cleared. Consider returning a validation result from validateForm and branching on that instead of the stale errors array.
Useful? React with 👍 / 👎.
Benchmark PR from agentic-review-benchmarks#4