Skip to content

[DT-3584] Migrate Nexus form to Superforms with validation#3158

Merged
andrewzamojc merged 19 commits intomainfrom
DT-3584-nexus-form-superforms
Feb 23, 2026
Merged

[DT-3584] Migrate Nexus form to Superforms with validation#3158
andrewzamojc merged 19 commits intomainfrom
DT-3584-nexus-form-superforms

Conversation

@andrewzamojc
Copy link
Copy Markdown
Contributor

@andrewzamojc andrewzamojc commented Feb 12, 2026

Summary

Migrates the Nexus endpoint form to use Superforms with Zod validation, following the established Superforms pattern used throughout the application.

To test it yourself, run it locally and go to nexus. Try saving without filling out the form, or adding invalid data.

The form is also imported into cloud-ui. You can test that on here https://cloud-ui-git-test-ui-bef7a7fd.preview.thundergun.io/nexus

Before - on load before clicking submit

Screenshot 2026-02-17 at 5 01 18 PM

Before - fixing name

Screenshot 2026-02-17 at 5 02 27 PM

After

Screenshot 2026-02-17 at 4 56 11 PM

Clicked save without filling it out

Screenshot 2026-02-17 at 4 56 18 PM

invalid name

Screenshot 2026-02-17 at 4 56 37 PM

fixed it

Screenshot 2026-02-17 at 4 56 41 PM

here's the edit form, same validation but has a delete button

Screenshot 2026-02-17 at 4 57 02 PM

Changes

  • nexus-form.svelte: Refactored to use Superforms with proper validation

    • Replaced manual state management with Superforms $form, $errors, and $enhance
    • Added Zod schema validation for form fields
    • Improved error handling and user feedback
  • nexus-create-endpoint.svelte & nexus-edit-endpoint.svelte: Updated to work with new Superforms pattern

  • Page components: Updated to pass data correctly to Superforms-enabled components

Benefits

  • Type-safe validation: Zod schema ensures runtime type safety
  • Consistent UX: Matches validation patterns used in other forms (capacity, groups, auth settings)
  • Better error handling: Clearer error messages and validation feedback
  • Maintainability: Follows established Superforms factory pattern

Testing

  • Tested Nexus endpoint creation flow
  • Tested Nexus endpoint edit flow
  • Verified validation errors display correctly
  • Confirmed form submission handling works as expected

@andrewzamojc andrewzamojc requested a review from a team as a code owner February 12, 2026 19:53
@andrewzamojc andrewzamojc requested review from GiantRobots and removed request for a team February 12, 2026 19:53
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
holocene Ready Ready Preview, Comment Feb 23, 2026 6:24pm

Request Review

- Replace writable store pattern with Superforms
- Add Zod schema for form validation
- Fix error display: only show after user interaction
- Remove `endpointForm` store export
- Use bind:this pattern to expose form methods
- Update parent components to use new API
- Ensure errors don't show on initial load or empty state
- Add optional chaining for formComponent in  block
- Add null checks for endpoint.id in update and delete handlers
This resolves the 'used before being assigned' error by acknowledging
that formComponent is undefined until the component mounts and bind:this executes.
- Add toNexusEndpoint() utility to convert flat form data to nested API structure
- Update create/edit pages to use transformation helper
- Standardize nameHintText prop flow: base form has default, wrappers pass through
- Remove inline transformations in favor of reusable utility

This supports the Superforms migration by providing a shared transformation
helper that both ui and cloud-ui can use to convert the new flat form structure
to the nested NexusEndpoint structure required by the API.
- Change onSubmit prop type to return Promise<void>
- Update onCreate and onUpdate wrapper callbacks to Promise<void>
- Ensures SuperForms properly awaits async operations including navigation
- Matches pattern used in other forms (projects, etc)
- Shows spinner during API call and navigation
- Better visual feedback for users
- Add tainted state tracking from SuperForms
- Button disabled when form hasn't been modified (edit forms only)
- Prevents 'Nothing to change' API error
- Matches pattern used in namespace settings forms
- Button re-enables/disables as user makes/reverts changes
- Remove custom error state in favor of SuperForms message store
- Add onError callback to display actual API error messages instead of generic fallbacks
- Remove descriptionString from toNexusEndpoint helper (handled separately via encodePayloads)
- Make allowedCallerNamespaces conditional to support OSS (omit when empty)
- Await goto() calls to fix navigation timing and prevent loading state flash
@temporal-cicd
Copy link
Copy Markdown
Contributor

temporal-cicd Bot commented Feb 19, 2026

Warnings
⚠️

📊 Strict Mode: 1 error in 1 file (0.1% of 1114 total)

src/lib/pages/nexus-form.svelte (1)
  • L106:8: Type '{}' is not assignable to type 'string'.

Generated by 🚫 dangerJS against fca5668

Copy link
Copy Markdown
Collaborator

@rossnelson rossnelson left a comment

Choose a reason for hiding this comment

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

Looks good overall — clean migration to Superforms. One thing to clean up before merge:

The onError handler in nexus-form.svelte has debug console.log statements that should be removed:

console.log('SuperForms error object:', error);
console.log('Error keys:', error && typeof error === 'object' ? Object.keys(error) : 'N/A');

Otherwise LGTM — approving.

? errorObj.statusText
: undefined;
const body = errorObj.body;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • ⚠️ Type '{}' is not assignable to type 'string'.

@andrewzamojc andrewzamojc merged commit 1f2900c into main Feb 23, 2026
20 of 22 checks passed
@andrewzamojc andrewzamojc deleted the DT-3584-nexus-form-superforms branch February 23, 2026 19:17
temporal-cicd Bot pushed a commit that referenced this pull request Feb 24, 2026
Auto-generated version bump from 2.45.4 to 2.46.0

Bump type: minor

Changes included:
- [`1acf17c0`](1acf17c) docs: Add AUTHENTICATION.md referenced by README (#3157)
- [`7d2368a2`](7d2368a) Corrected location of output directory (#3155)
- [`1f2900c0`](1f2900c) [DT-3584] Migrate Nexus form to Superforms with validation (#3158)
- [`f60fe1bf`](f60fe1b) feat(workflow): split Event History into Timeline and Event History tabs (#3109)
- [`4801f8dc`](4801f8d) fix(workflow): remove extra vertical padding from history toolbar (#3179)
- [`4ba52557`](4ba5255) Fix some minor bugs in the Standalone Activities UI (#3177)
rossedfort added a commit that referenced this pull request Feb 24, 2026
Auto-generated version bump from 2.45.4 to 2.46.0

Bump type: minor

Changes included:
- [`1acf17c0`](1acf17c) docs: Add AUTHENTICATION.md referenced by README (#3157)
- [`7d2368a2`](7d2368a) Corrected location of output directory (#3155)
- [`1f2900c0`](1f2900c) [DT-3584] Migrate Nexus form to Superforms with validation (#3158)
- [`f60fe1bf`](f60fe1b) feat(workflow): split Event History into Timeline and Event History tabs (#3109)
- [`4801f8dc`](4801f8d) fix(workflow): remove extra vertical padding from history toolbar (#3179)
- [`4ba52557`](4ba5255) Fix some minor bugs in the Standalone Activities UI (#3177)

Co-authored-by: rossedfort <11775628+rossedfort@users.noreply.github.com>
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