-
Notifications
You must be signed in to change notification settings - Fork 0
feat: apply PRs #7498, #7494, #7493 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,8 +16,9 @@ import { | |
| import inquirer from "inquirer"; | ||
| import { join } from "path"; | ||
| import { plural } from "pluralize"; | ||
| import temp from "temp"; | ||
| import { getCommandRootDir } from "./get-command-root-dir"; | ||
| import { mkdtempSync } from "fs"; | ||
| import { tmpdir } from "os"; | ||
|
|
||
| export const defaultActions = ["list", "create", "edit", "show"]; | ||
|
|
||
|
|
@@ -134,9 +135,6 @@ export const createResources = async ( | |
| } | ||
| moveSync(tempDir, destinationResourcePath, moveSyncOptions); | ||
|
|
||
| // clear temp dir | ||
| temp.cleanupSync(); | ||
|
|
||
| // if use Next.js, generate page files. This makes easier to use the resource | ||
| if (isNextJs) { | ||
| generateNextJsPages( | ||
|
|
@@ -182,8 +180,7 @@ export const createResources = async ( | |
| }; | ||
|
|
||
| const generateTempDir = (): string => { | ||
| temp.track(); | ||
| return temp.mkdirSync("resource"); | ||
| return mkdtempSync(join(tmpdir(), "resource-")); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Leftover temp directories can accumulate on disk when errors occur during resource creation, because the removal of Prompt for AI agents |
||
| }; | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,6 +129,7 @@ export const useForm = < | |
| watch, | ||
| setValue, | ||
| getValues, | ||
| reset, | ||
| handleSubmit: handleSubmitReactHookForm, | ||
| setError, | ||
| formState: { dirtyFields }, | ||
|
|
@@ -253,39 +254,28 @@ export const useForm = < | |
| }); | ||
| }; | ||
|
|
||
| // On query load, attempt a first sync after registration effects run. | ||
| // On query load, reset the form with server data natively. | ||
| // This ensures useFieldArray and other RHF internals are properly initialized. | ||
| const initialLoadRef = React.useRef(true); | ||
| useEffect(() => { | ||
| const data = query?.data?.data; | ||
| if (!data) { | ||
| queryDataRef.current = undefined; | ||
| syncedFieldsRef.current = new Set(); | ||
| mountedFieldsRef.current = new Set(); | ||
| initialLoadRef.current = true; | ||
| return; | ||
| } | ||
|
|
||
| let isActive = true; | ||
|
|
||
| const applyQueryValues = () => { | ||
| if (!isActive) return; | ||
|
|
||
| applyValuesToFields(getRegisteredFields(), data, false); | ||
| }; | ||
|
|
||
| queryDataRef.current = data; | ||
| syncedFieldsRef.current = new Set(); | ||
| mountedFieldsRef.current = getMountedFields(); | ||
|
|
||
| // defer until after field registration effects | ||
| if (typeof queueMicrotask === "function") { | ||
| queueMicrotask(applyQueryValues); | ||
| } else { | ||
| Promise.resolve().then(applyQueryValues); | ||
| if (initialLoadRef.current) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: When a mounted edit form switches from one record to another, its inputs can remain populated with the previous record because this guard only resets on the first truthy query result. Tracking the loaded record/data identity and resetting when it changes would preserve the new record values while still allowing Prompt for AI agents |
||
| initialLoadRef.current = false; | ||
| syncedFieldsRef.current = new Set(); | ||
| reset(data as unknown as TVariables, { keepDirtyValues: true }); | ||
| } | ||
|
|
||
| return () => { | ||
| isActive = false; | ||
| }; | ||
| }, [query?.data, setValue, getValues]); | ||
| }, [query?.data, reset, getValues]); | ||
|
|
||
| // Re-sync when new fields register; do not override user edits. | ||
| useEffect(() => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The existing
packages/antdnotification-provider tests now fail because they spy onnotification.open, while this line dispatches success/error through separate convenience methods. Updating the tests to spy on the selected typed methods (and assert the type there) would keep the suite aligned with the changed behavior.Prompt for AI agents