Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/antd/src/providers/notificationProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,21 @@ export const useNotificationProvider = (): NotificationProvider => {
closeIcon: <></>,
});
} else {
notification.open({
const config = {
key,
description: message,
message: description ?? null,
type,
});
};
const method =
type && type !== "progress"
? notification[type as "success" | "error" | "warning" | "info"]
: notification.open;

if (typeof method === "function") {
method(config);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The existing packages/antd notification-provider tests now fail because they spy on notification.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
Check if this issue is valid — if so, understand the root cause and fix it. At packages/antd/src/providers/notificationProvider/index.tsx, line 53:

<comment>The existing `packages/antd` notification-provider tests now fail because they spy on `notification.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.</comment>

<file context>
@@ -39,12 +39,21 @@ export const useNotificationProvider = (): NotificationProvider => {
+            : notification.open;
+        
+        if (typeof method === "function") {
+          method(config);
+        } else {
+          notification.open(config);
</file context>

} else {
notification.open(config);
}
}
},
close: (key) => notification.destroy(key),
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"prettier": "^2.7.1",
"semver": "7.5.2",
"semver-diff": "^3.1.1",
"temp": "^0.9.4",
"tslib": "^2.6.2"
},
"devDependencies": {
Expand All @@ -90,7 +89,6 @@
"@types/pluralize": "^0.0.29",
"@types/prettier": "^2.7.3",
"@types/semver": "^7.5.8",
"@types/temp": "^0.9.1",
"@vitest/ui": "^2.1.8",
"tsup": "^6.7.0",
"typescript": "^5.8.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -182,8 +180,7 @@ export const createResources = async (
};

const generateTempDir = (): string => {
temp.track();
return temp.mkdirSync("resource");
return mkdtempSync(join(tmpdir(), "resource-"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 temp.track() and temp.cleanupSync() eliminated the cleanup mechanism without replacement. The old temp package automatically cleaned tracked temp dirs on process exit; the new fs.mkdtempSync has no equivalent. Consider either adding a try-catch with rmSync cleanup, or registering a one-shot cleanup using process.once('exit', ...) to restore the safety net for error paths.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/src/commands/add/sub-commands/resource/create-resources.ts, line 183:

<comment>Leftover temp directories can accumulate on disk when errors occur during resource creation, because the removal of `temp.track()` and `temp.cleanupSync()` eliminated the cleanup mechanism without replacement. The old `temp` package automatically cleaned tracked temp dirs on process exit; the new `fs.mkdtempSync` has no equivalent. Consider either adding a try-catch with `rmSync` cleanup, or registering a one-shot cleanup using `process.once('exit', ...)` to restore the safety net for error paths.</comment>

<file context>
@@ -182,8 +180,7 @@ export const createResources = async (
 const generateTempDir = (): string => {
-  temp.track();
-  return temp.mkdirSync("resource");
+  return mkdtempSync(join(tmpdir(), "resource-"));
 };
 
</file context>

};

/**
Expand Down
30 changes: 10 additions & 20 deletions packages/react-hook-form/src/useForm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const useForm = <
watch,
setValue,
getValues,
reset,
handleSubmit: handleSubmitReactHookForm,
setError,
formState: { dirtyFields },
Expand Down Expand Up @@ -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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 keepDirtyValues to protect edits.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/react-hook-form/src/useForm/index.ts, line 273:

<comment>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 `keepDirtyValues` to protect edits.</comment>

<file context>
@@ -253,39 +254,28 @@ export const useForm = <
-      queueMicrotask(applyQueryValues);
-    } else {
-      Promise.resolve().then(applyQueryValues);
+    if (initialLoadRef.current) {
+      initialLoadRef.current = false;
+      syncedFieldsRef.current = new Set();
</file context>

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(() => {
Expand Down
Loading