feat: apply PRs #7498, #7494, #7493 - #3
Conversation
- refactor notification.open to use config object (refinedev#7498) - fix(react-hook-form): initialize useFieldArray via reset on first data load (refinedev#7494) - fix(cli): replace temp with native fs.mkdtempSync (refinedev#7493)
There was a problem hiding this comment.
3 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/react-hook-form/src/useForm/index.ts">
<violation number="1" location="packages/react-hook-form/src/useForm/index.ts:273">
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.</violation>
</file>
<file name="packages/antd/src/providers/notificationProvider/index.tsx">
<violation number="1" location="packages/antd/src/providers/notificationProvider/index.tsx:53">
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.</violation>
</file>
<file name="packages/cli/src/commands/add/sub-commands/resource/create-resources.ts">
<violation number="1" location="packages/cli/src/commands/add/sub-commands/resource/create-resources.ts:183">
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.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| queueMicrotask(applyQueryValues); | ||
| } else { | ||
| Promise.resolve().then(applyQueryValues); | ||
| if (initialLoadRef.current) { |
There was a problem hiding this comment.
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>
| : notification.open; | ||
|
|
||
| if (typeof method === "function") { | ||
| method(config); |
There was a problem hiding this comment.
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>
| const generateTempDir = (): string => { | ||
| temp.track(); | ||
| return temp.mkdirSync("resource"); | ||
| return mkdtempSync(join(tmpdir(), "resource-")); |
There was a problem hiding this comment.
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>
From refinedev/refine:\n- refinedev#7498 – Refactor notification.open to use config object\n- refinedev#7494 – fix(react-hook-form): initialize useFieldArray via reset on first data load\n- refinedev#7493 – fix(cli): replace temp with native fs.mkdtempSync
Summary by cubic
Improves notifications, form initialization, and CLI temp handling for better reliability and fewer dependencies. Notifications use a config-based API,
react-hook-formresets on first data load, and the CLI now uses native temp dirs.Bug Fixes
react-hook-form: Reset the form with server data on first query load to properly initializeuseFieldArray; keeps dirty values.tempwith nativefs.mkdtempSync+os.tmpdir()and remove manual cleanup.Refactors
antdnotification provider: Use a single config object and callnotification[type]when available, otherwise fallback tonotification.open.Written for commit 50ff772. Summary will update on new commits.