Skip to content

Hotfix/20250603#153

Merged
SvenVw merged 8 commits into
mainfrom
hotfix/20250603
Jun 3, 2025
Merged

Hotfix/20250603#153
SvenVw merged 8 commits into
mainfrom
hotfix/20250603

Conversation

@SvenVw
Copy link
Copy Markdown
Collaborator

@SvenVw SvenVw commented Jun 3, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Removed the nitrogen limit tooltip from the "Stikstof, totaal" card in fertilizer applications.
    • Improved handling of empty or invalid input for the fertilizer application form.
    • Fixed field form behavior to better reset and update with changing props.
    • Enhanced soil form validation with clearer error messages and better handling of empty numeric fields.
    • Fixed an exception when clicking to add a new field.
  • Chores

    • Updated package versions and changelogs across multiple modules.
    • Corrected typos in parameter names in fertilizer-related data types.

@SvenVw SvenVw self-assigned this Jun 3, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 3, 2025

🦋 Changeset detected

Latest commit: a452ac8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@svenvw/fdm-app Patch
@svenvw/fdm-data Patch
@svenvw/fdm-core Patch
@svenvw/fdm-calculator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2025

Walkthrough

This update includes patch releases across multiple packages, correcting a typo in a fertilizer property name (p_cl_cr to p_cl_rt) in both types and schemas. It also improves soil form validation, updates fertilizer application and field form logic, and documents these changes in changelogs. Package versions are incremented accordingly.

Changes

Files/Paths Change Summary
fdm-app/app/components/custom/fertilizer-applications/cards.tsx Removed nitrogen limit by setting limit to undefined for a specific card.
fdm-app/app/components/custom/fertilizer-applications/form.tsx Improved input handling for p_app_amount, adjusted form reset logic, and removed aria-required.
fdm-app/app/components/custom/field/form.tsx Centralized form state, removed redundant local state, updated form reset logic, and refined prop synchronization.
fdm-app/app/components/custom/soil/formschema.tsx Enhanced validation: improved error messages, handled empty string inputs for numbers, and made fields required unless explicitly optional.
fdm-data/src/fertilizers/d.ts
fdm-core/src/fertilizer.d.ts
Renamed property p_cl_cr to p_cl_rt in interfaces/types.
fdm-app/CHANGELOG.md
fdm-calculator/CHANGELOG.md
fdm-core/CHANGELOG.md
fdm-data/CHANGELOG.md
Added patch release entries describing bugfixes, validation improvements, and dependency updates.
fdm-app/package.json
fdm-calculator/package.json
fdm-core/package.json
fdm-data/package.json
Incremented package versions; updated dependencies as needed; reformatted "files" field in fdm-data.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FertilizerForm
    participant SoilForm
    participant FieldForm
    participant Types

    User->>FertilizerForm: Submit fertilizer application
    FertilizerForm->>FertilizerForm: Validate & process input (handle empty/NaN)
    FertilizerForm->>FertilizerForm: Reset form on success

    User->>SoilForm: Submit soil analysis
    SoilForm->>SoilForm: Validate fields (improved error messages, handle empty strings)
    SoilForm->>SoilForm: Enforce required fields

    User->>FieldForm: Open/add field dialog
    FieldForm->>FieldForm: Sync form state with props, reset on close

    FertilizerForm->>Types: Use updated property name p_cl_rt
    SoilForm->>Types: Use updated property name p_cl_rt
    FieldForm->>Types: Use updated property name p_cl_rt
Loading

Suggested labels

fdm-calculator

Suggested reviewers

  • gerardhros

Poem

A bunny hops from patch to patch,
Fixing typos, making a match.
Fields and forms now neat and bright,
Validation messages just right.
With every version hopped ahead,
The code grows strong—enough said!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a452ac8 and df6c56c.

📒 Files selected for processing (8)
  • fdm-app/CHANGELOG.md (1 hunks)
  • fdm-app/package.json (1 hunks)
  • fdm-calculator/CHANGELOG.md (1 hunks)
  • fdm-calculator/package.json (1 hunks)
  • fdm-core/CHANGELOG.md (1 hunks)
  • fdm-core/package.json (2 hunks)
  • fdm-data/CHANGELOG.md (1 hunks)
  • fdm-data/package.json (2 hunks)
✅ Files skipped from review due to trivial changes (8)
  • fdm-data/package.json
  • fdm-data/CHANGELOG.md
  • fdm-calculator/CHANGELOG.md
  • fdm-calculator/package.json
  • fdm-core/CHANGELOG.md
  • fdm-app/package.json
  • fdm-core/package.json
  • fdm-app/CHANGELOG.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.07%. Comparing base (94d18a6) to head (df6c56c).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #153   +/-   ##
=======================================
  Coverage   93.07%   93.07%           
=======================================
  Files          68       68           
  Lines        8061     8061           
  Branches      957      957           
=======================================
  Hits         7503     7503           
  Misses        556      556           
  Partials        2        2           
Flag Coverage Δ
fdm-calculator 94.69% <ø> (ø)
fdm-core 92.75% <ø> (ø)
fdm-data 92.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot added bug Something isn't working fdm-app fdm-data labels Jun 3, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
.changeset/tired-cloths-kneel.md (1)

5-5: Minor grammar improvement suggested.

The changeset description is clear, but could benefit from improved grammar for better readability.

Consider this minor grammar improvement:

-Fix exception when clicking on field to add a new field
+Fix exception when clicking on a field to add a new field
🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: You might be missing the article “a” here.
Context: ...tch --- Fix exception when clicking on field to add a new field

(AI_EN_LECTOR_MISSING_DETERMINER_A)

.changeset/khaki-snails-doubt.md (1)

5-5: Grammar improvement and clarity enhancement suggested.

The changeset description could benefit from better grammar and more specific details about the change.

Consider this improvement for clarity and grammar:

-Remove the incorrect limit value for nitrogen at fertilizer application cards
+Remove the incorrect limit value for nitrogen on fertilizer application cards

Alternatively, for even better clarity, consider:

-Remove the incorrect limit value for nitrogen at fertilizer application cards
+Remove the incorrect nitrogen limit value from fertilizer application cards
🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: The preposition “on” seems more likely in this position.
Context: ... the incorrect limit value for nitrogen at fertilizer application cards

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

.changeset/many-rats-check.md (1)

5-5: Fix grammatical and spelling errors in changeset description.

The changeset description contains grammatical and spelling errors that should be corrected for better documentation quality.

Apply this diff to fix the errors:

-Clear value for p_app_amount at fertilizer application form after succesfull submission
+Clear value for p_app_amount on fertilizer application form after successful submission
🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: The preposition “on” seems more likely in this position.
Context: ...patch --- Clear value for p_app_amount at fertilizer application form after succe...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94d18a6 and 3f5fd9a.

📒 Files selected for processing (8)
  • .changeset/khaki-snails-doubt.md (1 hunks)
  • .changeset/many-rats-check.md (1 hunks)
  • .changeset/rotten-camels-rest.md (1 hunks)
  • .changeset/tired-cloths-kneel.md (1 hunks)
  • fdm-app/app/components/custom/fertilizer-applications/cards.tsx (1 hunks)
  • fdm-app/app/components/custom/fertilizer-applications/form.tsx (2 hunks)
  • fdm-app/app/components/custom/field/form.tsx (3 hunks)
  • fdm-data/src/fertilizers/d.ts (1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/khaki-snails-doubt.md

[uncategorized] ~5-~5: The preposition “on” seems more likely in this position.
Context: ... the incorrect limit value for nitrogen at fertilizer application cards

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

.changeset/tired-cloths-kneel.md

[uncategorized] ~5-~5: You might be missing the article “a” here.
Context: ...tch --- Fix exception when clicking on field to add a new field

(AI_EN_LECTOR_MISSING_DETERMINER_A)

.changeset/many-rats-check.md

[uncategorized] ~5-~5: The preposition “on” seems more likely in this position.
Context: ...patch --- Clear value for p_app_amount at fertilizer application form after succe...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

🔇 Additional comments (8)
.changeset/rotten-camels-rest.md (1)

1-6: Well-documented changeset.

The changeset clearly describes the typo fix with specific details about the affected type and property name. This provides good traceability for the breaking change.

fdm-app/app/components/custom/fertilizer-applications/cards.tsx (1)

104-104: Correct implementation of nitrogen limit removal.

The change to set limit: undefined properly removes the incorrect nitrogen limit value. The component's conditional rendering logic (line 36) correctly handles this by hiding the limit-related UI elements when the limit is undefined.

fdm-app/app/components/custom/fertilizer-applications/form.tsx (2)

50-52: LGTM! Code style improvement.

Good addition of semicolons for consistency and proper formatting of the dependency array.


93-101: LGTM! Robust numeric input handling.

The updated input handling logic properly manages edge cases:

  • Displays empty string for undefined/null/NaN values instead of just zero
  • Converts empty input to undefined rather than leaving invalid state
  • Uses parseFloat for proper numeric conversion

This ensures the form state accurately reflects the input state and handles edge cases gracefully.

fdm-app/app/components/custom/field/form.tsx (4)

51-51: LGTM! Simplified initialization.

Setting the default value directly from the computed b_lu_catalogue eliminates the need for separate state synchronization.


60-63: LGTM! Improved form reset logic.

Adding form reset when the dialog closes (!open) prevents stale data from persisting when the dialog is reopened.


115-115: LGTM! Centralized state management.

Passing the entire form object to the Combobox component centralizes state management within the form hook, eliminating the need for separate local state handling.


65-71:

Details

❓ Verification inconclusive

Consider UX implications of props-based form reset.

While this ensures the form reflects updated props, resetting form values whenever fieldNameDefault or b_lu_catalogue changes could disrupt user input if these props change while the user is actively editing the form.

Consider whether these props can change during active form editing, and if so, whether a more selective reset strategy might be better (e.g., only reset when dialog opens).


🏁 Script executed:

#!/bin/bash
# Description: Check if fieldNameDefault or b_lu_catalogue can change during active form editing
# Look for parent components that might update these props dynamically

# Search for components that render FieldDetailsDialog
ast-grep --pattern 'FieldDetailsDialog'

# Look for dynamic prop updates
rg -A 5 -B 5 'fieldNameDefault|b_lu_catalogue' --type tsx --type ts

Length of output: 455


🏁 Script executed:

#!/bin/bash
# Search for definitions and updates of `fieldNameDefault` and `b_lu_catalogue` in the parent route
rg -n 'fieldNameDefault' fdm-app/app/routes/farm.*.tsx
rg -n 'b_lu_catalogue' fdm-app/app/routes/farm.*.tsx

# Inspect the context around the FieldDetailsDialog invocation to see how props are passed
sed -n '300,360p' fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx

Length of output: 23212


Verify props-driven form reset timing

The useEffect in fdm-app/app/components/custom/field/form.tsx resets the form any time fieldNameDefault or b_lu_catalogue changes:

useEffect(() => {
  form.reset({
    b_name: fieldNameDefault,
    b_lu_catalogue,
  });
}, [fieldNameDefault, b_lu_catalogue, form.reset]);

• These props originate from the loader in fdm-app/app/routes/.../field.new.tsx and, under typical Remix routing, don’t update while the dialog remains open.
• Please confirm that neither loaderData.fieldNameDefault nor loaderData.b_lu_catalogue can change during an active form session.

If there’s a chance they could change mid-edit, consider guarding the reset so it only runs when the dialog first opens, for example:

 useEffect(() => {
-  form.reset({ b_name: fieldNameDefault, b_lu_catalogue });
+  if (isOpen) {
+    form.reset({ b_name: fieldNameDefault, b_lu_catalogue });
+  }
 }, [isOpen, fieldNameDefault, b_lu_catalogue, form.reset]);

Comment thread fdm-data/src/fertilizers/d.ts
@coderabbitai coderabbitai Bot added the fdm-core label Jun 3, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/violet-readers-share.md (1)

5-5: Refine change description grammar.

Consider adding the definite article for clarity. For example:

  • “Fix the typo in the parameter name p_cl_rt in the Fertilizer type”
🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: You might be missing the article “the” here.
Context: ...venvw/fdm-core": patch --- Fix typo in parameter name p_cl_rt in the type Fertilizer

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f5fd9a and ce688ba.

📒 Files selected for processing (5)
  • .changeset/khaki-snails-doubt.md (1 hunks)
  • .changeset/many-rats-check.md (1 hunks)
  • .changeset/tired-cloths-kneel.md (1 hunks)
  • .changeset/violet-readers-share.md (1 hunks)
  • fdm-core/src/fertilizer.d.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • fdm-core/src/fertilizer.d.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • .changeset/khaki-snails-doubt.md
  • .changeset/many-rats-check.md
  • .changeset/tired-cloths-kneel.md
🧰 Additional context used
🪛 LanguageTool
.changeset/violet-readers-share.md

[uncategorized] ~5-~5: You might be missing the article “the” here.
Context: ...venvw/fdm-core": patch --- Fix typo in parameter name p_cl_rt in the type Fertilizer

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce688ba and a452ac8.

📒 Files selected for processing (2)
  • .changeset/clear-planets-read.md (1 hunks)
  • fdm-app/app/components/custom/soil/formschema.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/clear-planets-read.md
🔇 Additional comments (5)
fdm-app/app/components/custom/soil/formschema.tsx (5)

5-12: LGTM! String validation improvements look good.

The updates to the a_source field validation are well-implemented:

  • Clear, user-friendly error messages in Dutch
  • Updated refine logic to reject "nl-other-nmi" instead of "nmi"
  • Proper case-insensitive validation using toLowerCase()

13-16: Good addition of explicit error messages for date field.

The b_sampling_date field now has clear, descriptive error messages for both invalid type and required field scenarios.


34-305: Excellent systematic improvement to numeric field validation.

The consistent use of z.preprocess across all numeric fields provides several benefits:

  • Empty strings are properly converted to undefined for optional fields
  • Clear error messages improve user experience
  • Consistent validation ranges with appropriate min/max constraints
  • Proper handling of optional fields

310-325: Good cross-field validation logic.

The depth validation ensures logical consistency between upper and lower depth values, with appropriate error messaging and path specification.


309-309:

Details

✅ Verification successful

Verify the impact of making fields required by default.

Commenting out .partial() means all fields in the schema are now required unless explicitly marked as .optional(). This could be a breaking change if the form previously allowed partial submissions.

Verify that this change aligns with the intended form behavior:


🏁 Script executed:

#!/bin/bash
# Description: Check if there are any form components or tests that might be affected by making fields required
# Expected: Find usage patterns that might need updating

# Search for references to this FormSchema
rg -A 5 -B 5 "FormSchema" --type tsx --type ts

# Look for form submission or validation logic that might assume partial data
rg -A 10 "partial|optional" --type tsx --type ts | grep -i "soil\|form"

# Check for any existing tests that might fail with required fields
fd -e test.ts -e test.tsx -e spec.ts -e spec.tsx --exec rg -l "soil.*form\|FormSchema" {}

Length of output: 270


🏁 Script executed:

#!/bin/bash
# Improved search for FormSchema usages and optional fields in TS/TSX

# 1. Find all references to FormSchema in .ts and .tsx files
rg -g '*.ts' -g '*.tsx' -n -C5 "FormSchema"

# 2. Look for any .optional() calls that might indicate fields marked optional
rg -g '*.ts' -g '*.tsx' -n -C5 "\.optional\(\)"

# 3. Scan test/spec files for schema references or soil form usage
rg -g '*.test.ts' -g '*.test.tsx' -g '*.spec.ts' -g '*.spec.tsx' -n "FormSchema|soil"

Length of output: 72670


🏁 Script executed:

#!/bin/bash
# Inspect the soil FormSchema for .partial() and optional fields

# 1. Show the beginning of the soil formschema to see its shape
head -n 50 fdm-app/app/components/custom/soil/formschema.tsx

# 2. Search for any commented or active .partial() call
rg -n "partial" fdm-app/app/components/custom/soil/formschema.tsx

# 3. Check which fields are marked optional (if any)
rg -n "\.optional" fdm-app/app/components/custom/soil/formschema.tsx

# 4. Locate the a_id definition to see if it's required
rg -n "a_id" -n 1 fdm-app/app/components/custom/soil/formschema.tsx

Length of output: 3530


🏁 Script executed:

#!/bin/bash
# Inspect soil form default values and UI registrations

# 1. Find defaultValues assignment in form component
rg -n "defaultValues" -C5 fdm-app/app/components/custom/soil/form.tsx

# 2. Locate registration of a_source field
rg -n "register.*a_source" -C5 fdm-app/app/components/custom/soil/form.tsx

# 3. Locate registration of b_sampling_date field
rg -n "register.*b_sampling_date" -C5 fdm-app/app/components/custom/soil/form.tsx

Length of output: 1187


Confirmed removal of .partial() is safe and intentional.

I verified that the soil FormSchema now makes only these fields required (all others explicitly marked with .optional()):

  • a_source
  • b_sampling_date
  • a_depth_lower

Every other parameter in the schema is already .optional(), matching the defaultValues logic in the form (which supplies values or undefined). No tests or form consumers assume a truly “partial” schema, and all routes importing this schema handle missing values via .optional() or default fallbacks.

No follow-up changes are needed here.

Comment thread fdm-app/app/components/custom/soil/formschema.tsx
@SvenVw SvenVw merged commit 1b53e71 into main Jun 3, 2025
10 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant