Skip to content

Conversation

@Oksamies
Copy link
Contributor

@Oksamies Oksamies commented Dec 3, 2025

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Added a Validator type and a validators option to useStrongForm, and exposed a computed isReady boolean that checks required fields are present. Updated three form components (Teams, MemberAddForm, ServiceAccounts) to declare required-field validators and to gate submit buttons and submission checks on strongForm.isReady instead of ad-hoc/local validation logic.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No description was provided by the author, so this cannot be evaluated against the changeset. Add a brief description explaining the validator feature and its motivation, even a single sentence would help future reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a validator option to useStrongForm and applying it across multiple components.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 12-03-add_validator_option_for_usestrongfrom_and_use_it_in_few_places

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor Author

Oksamies commented Dec 3, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Oksamies Oksamies requested a review from anttimaki December 3, 2025 12:31
Copy link

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/cyberstorm-remix/cyberstorm/utils/StrongForm/useStrongForm.ts (1)

138-176: submit() returns a stale/undefined value instead of the latest output

Inside submit, you await the submitor chain, but then return submitOutput, which is a React state value:

await props
  .submitor(submissionData)
  .then((output) => {
    setSubmitOutput(output);
    if (props.onSubmitSuccess) {
      props.onSubmitSuccess(output);
    }
  })
  .catch(/* ... */);
return submitOutput;

Because setSubmitOutput is async, submitOutput still holds the previous value when you return, so callers of await strongForm.submit() don't reliably get the latest output (undefined on first call, stale on subsequent calls).

You can keep the existing error handling while returning the fresh output:

-    setSubmitting(true);
-    try {
-      await props
-        .submitor(submissionData)
-        .then((output) => {
-          setSubmitOutput(output);
-          if (props.onSubmitSuccess) {
-            props.onSubmitSuccess(output);
-          }
-        })
-        .catch((error) => {
+    setSubmitting(true);
+    try {
+      const output = await props
+        .submitor(submissionData)
+        .then((output) => {
+          setSubmitOutput(output);
+          if (props.onSubmitSuccess) {
+            props.onSubmitSuccess(output);
+          }
+          return output;
+        })
+        .catch((error) => {
           if (error instanceof RequestBodyParseError) {
             setSubmitError(
               new Error(
                 "Some of the field values are invalid"
               ) as SubmissionError
             );
             setInputErrors(error.error.formErrors as InputErrors);
           } else if (error instanceof RequestQueryParamsParseError) {
@@
           } else if (error instanceof ParseError) {
             setSubmitError(
               new Error(
                 "Request succeeded, but the response was invalid"
               ) as SubmissionError
             );
             setInputErrors(error.error.formErrors as InputErrors);
             throw error;
           } else {
             throw error;
           }
-        });
-      return submitOutput;
+        });
+      return output;

This preserves the existing error mapping and callbacks but makes submit()'s return value reliable.

🧹 Nitpick comments (2)
apps/cyberstorm-remix/app/settings/teams/team/tabs/ServiceAccounts/ServiceAccounts.tsx (1)

140-155: Service account form wiring looks good; consider simplifying submit hook‑up

Using validators: { nickname: { required: true } } plus strongForm.isReady in both the onSubmit handler and the disabled state gives a consistent required-field check and avoids the old ad‑hoc validation. Functionally solid.

You can simplify by letting the button submit the form instead of calling strongForm.submit directly:

-          <form
-            className="service-accounts__form"
-            onSubmit={(e) => {
-              e.preventDefault();
-              if (strongForm.isReady) {
-                strongForm.submit();
-              }
-            }}
-          >
+          <form
+            className="service-accounts__form"
+            onSubmit={(e) => {
+              e.preventDefault();
+              if (strongForm.isReady) {
+                strongForm.submit();
+              }
+            }}
+          >
@@
-      {serviceAccountAdded ? null : (
-        <Modal.Footer>
-          <NewButton onClick={strongForm.submit} disabled={!strongForm.isReady}>
-            Add Service Account
-          </NewButton>
-        </Modal.Footer>
-      )}
+      {serviceAccountAdded ? null : (
+        <Modal.Footer>
+          <NewButton type="submit" disabled={!strongForm.isReady}>
+            Add Service Account
+          </NewButton>
+        </Modal.Footer>
+      )}

This keeps all submission logic in the form submit handler and avoids duplicate pathways.

Also applies to: 200-208, 235-238

apps/cyberstorm-remix/cyberstorm/utils/StrongForm/useStrongForm.ts (1)

8-10: Validator/isReady design is fine; tighten dependencies and typing for future‑proofing

The Validator shape + validators prop and isReady memo are straightforward and easy to extend. A couple of small robustness improvements:

  1. Include validators in the useMemo deps

isReady uses both props.inputs and props.validators, but only props.inputs is in the dependency array. If someone ever passes dynamic validators, isReady could become stale.

-  const isReady = useMemo(() => {
+  const isReady = useMemo(() => {
     if (!props.validators) return true;
@@
-    return true;
-  }, [props.inputs]);
+    return true;
+  }, [props.inputs, props.validators]);
  1. Improve key typing inside the validator loop (optional)

Using for (const key in props.validators) gives you a string key and props.inputs[key] is only loosely typed. You could make this a bit safer:

const isReady = useMemo(() => {
  if (!props.validators) return true;

  (Object.keys(props.validators) as (keyof Inputs)[]).forEach((key) => {
    const validator = props.validators?.[key];
    const value = props.inputs[key];
    if (validator?.required) {
      if (typeof value === "string" && value.trim() === "") return false;
      if (value === undefined || value === null) return false;
    }
  });

  return true;
}, [props.inputs, props.validators]);

Not mandatory today, but it helps if more validators are added later.

Also applies to: 20-28, 61-73

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41f5dbe and 2471673.

📒 Files selected for processing (4)
  • apps/cyberstorm-remix/app/settings/teams/Teams.tsx (2 hunks)
  • apps/cyberstorm-remix/app/settings/teams/team/tabs/Members/MemberAddForm.tsx (2 hunks)
  • apps/cyberstorm-remix/app/settings/teams/team/tabs/ServiceAccounts/ServiceAccounts.tsx (3 hunks)
  • apps/cyberstorm-remix/cyberstorm/utils/StrongForm/useStrongForm.ts (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Generate visual diffs

@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.81%. Comparing base (41f5dbe) to head (2843cbc).

Files with missing lines Patch % Lines
...remix/cyberstorm/utils/StrongForm/useStrongForm.ts 0.00% 14 Missing ⚠️
...settings/teams/team/tabs/Members/MemberAddForm.tsx 0.00% 6 Missing ⚠️
apps/cyberstorm-remix/app/settings/teams/Teams.tsx 0.00% 3 Missing ⚠️
...eams/team/tabs/ServiceAccounts/ServiceAccounts.tsx 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1651      +/-   ##
==========================================
- Coverage   10.82%   10.81%   -0.01%     
==========================================
  Files         315      315              
  Lines       22684    22704      +20     
  Branches      463      463              
==========================================
  Hits         2455     2455              
- Misses      20229    20249      +20     

☔ 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.

@Oksamies Oksamies force-pushed the 12-03-add_validator_option_for_usestrongfrom_and_use_it_in_few_places branch from 2471673 to 2843cbc Compare December 3, 2025 13:49
Copy link

@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)
apps/cyberstorm-remix/app/settings/teams/team/tabs/ServiceAccounts/ServiceAccounts.tsx (1)

132-155: Validator wiring and isReady gating look solid

validators: { nickname: { required: true } } plus checking strongForm.isReady in both the form onSubmit and the footer button disabled state gives you a consistent, centralized readiness check and avoids firing submitor for obviously invalid input. This integrates cleanly with the new useStrongForm API and keeps the Enter‑to‑submit path aligned with the button click path.

Only small nit (optional): if your required validator does not already trim, and you care about rejecting whitespace‑only nicknames, consider either normalizing formInputs.nickname on change or configuring the validator to trim, instead of relying on data.nickname.trim() solely in submitor.

Also applies to: 200-208, 235-238

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2471673 and 2843cbc.

📒 Files selected for processing (4)
  • apps/cyberstorm-remix/app/settings/teams/Teams.tsx (2 hunks)
  • apps/cyberstorm-remix/app/settings/teams/team/tabs/Members/MemberAddForm.tsx (2 hunks)
  • apps/cyberstorm-remix/app/settings/teams/team/tabs/ServiceAccounts/ServiceAccounts.tsx (3 hunks)
  • apps/cyberstorm-remix/cyberstorm/utils/StrongForm/useStrongForm.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/cyberstorm-remix/cyberstorm/utils/StrongForm/useStrongForm.ts
  • apps/cyberstorm-remix/app/settings/teams/team/tabs/Members/MemberAddForm.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Generate visual diffs
🔇 Additional comments (1)
apps/cyberstorm-remix/app/settings/teams/Teams.tsx (1)

157-184: Create Team form now correctly uses centralized validation

Adding validators: { name: { required: true } } and wiring the Create button as disabled={!strongForm.isReady} while still calling strongForm.submit().then(() => setOpen(false)) gives you a clean, unified readiness check and restores proper submission behavior. This is consistent with the new useStrongForm pattern used elsewhere.

No further issues from my side here.

Also applies to: 225-235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants