Skip to content

FIX: Default Notification Emails to Current User and Add Validation#58

Merged
wicky-zipstack merged 4 commits intomainfrom
fix/notification-emails-default-and-validation
Apr 15, 2026
Merged

FIX: Default Notification Emails to Current User and Add Validation#58
wicky-zipstack merged 4 commits intomainfrom
fix/notification-emails-default-and-validation

Conversation

@tahierhussain
Copy link
Copy Markdown
Contributor

What

  • Pre-populate the notification emails field with the current user's email when creating a new job
  • Add email validation to reject invalid email formats
  • Update tooltip text from "Comma-separated email addresses" to "Enter email addresses"

Why

  • Users typically want to be notified about their own jobs, so defaulting to their email improves UX
  • Without validation, users could enter invalid email addresses that would fail silently when notifications are sent
  • The tooltip was misleading since the field uses a tag-based input, not comma-separated text

How

  • Imported useSessionStore to access the current user's session details
  • Extracted userEmail from sessionDetails.email
  • Set notification_emails initial value to [userEmail] when available (empty array otherwise)
  • Added a custom validator in the Form.Item rules that:
    • Validates each email against a standard email regex (/^[^\s@]+@[^\s@]+\.[^\s@]+$/)
    • Shows an error message listing invalid emails if any are found
    • Allows empty arrays (field is optional)

Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)

  • No, this PR cannot break existing features because:
    • The default email only applies to new job creation; editing existing jobs still loads saved notification emails
    • Validation only adds a check on form submission; it doesn't modify any existing data flow
    • The pattern for accessing sessionDetails.email is already used throughout the codebase (WelcomeBanner.jsx, UserDropdown.jsx)
    • Changes are isolated to a single component (JobDeploy.jsx)

Database Migrations

  • None

Env Config

  • None

Relevant Docs

  • None

Related Issues or PRs

  • None

Dependencies Versions

  • None

Notes on Testing

  • Create a new job and verify the notification emails field is pre-populated with the current user's email
  • Edit an existing job and verify the saved notification emails are loaded correctly (not overwritten)
  • Try entering an invalid email (e.g., "notanemail") and verify the error message appears
  • Try entering a valid email and verify it's accepted without errors
  • Verify the form cannot be submitted with invalid emails in the notification emails field

Screenshots

Pre-populated current user's email address by default
image

Added email address validation
image

Checklist

I have read and understood the Contribution Guidelines.

- Pre-populate notification_emails field with current user's email
- Add email validation to reject invalid email formats
- Update tooltip text

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 13, 2026

Greptile Summary

This PR pre-populates the notification emails field with the current user's email on new job creation, adds an email regex validator to the tag-based input, and updates the tooltip to match the tag-based UI. Edit mode is unaffected — form.setFieldsValue in the load effect overwrites initialValues, so saved emails are correctly restored.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style suggestions.

Changes are isolated to a single component. Create/edit mode boundary is handled correctly. The only open finding is a whitespace-trimming gap in the validator, which is a non-blocking usability improvement.

No files require special attention.

Important Files Changed

Filename Overview
frontend/src/ide/scheduler/JobDeploy.jsx Added session-based email pre-population and tag-input email validation; edit-mode flow is unaffected (setFieldsValue overrides initialValues); one minor UX gap around untrimmed whitespace in comma-pasted tag values.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[JobDeploy opens] --> B{isEditMode?}
    B -- Yes --> C[setLoading true\nfetch job data]
    C --> D[form.setFieldsValue\nnotification_emails: job.notification_emails]
    B -- No --> E[Form renders with initialValues\nnotification_emails: userEmail or empty]
    D --> F[Form ready for edit]
    E --> F2[Form ready for create]
    F --> G[User submits]
    F2 --> G
    G --> H[Validator runs on notification_emails]
    H --> I{value empty?}
    I -- Yes --> J[Promise.resolve — field is optional]
    I -- No --> K[Filter emails against EMAIL_REGEX]
    K --> L{Invalid found?}
    L -- Yes --> M[Promise.reject with list of invalid addresses]
    L -- No --> N[Promise.resolve — submit proceeds]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: frontend/src/ide/scheduler/JobDeploy.jsx
Line: 683-685

Comment:
**Tag values are not trimmed before validation**

The Select has `tokenSeparators` set to comma, so when a user pastes a comma-separated address list the tokens may include leading whitespace. That whitespace causes the regex test to fail on what visually appears to be a valid address, producing a confusing error message. Trimming each entry before testing would fix this, and the submitted payload should also be normalised to avoid space-padded addresses reaching the backend.

```suggestion
                              const invalid = value.filter(
                                (e) => !EMAIL_REGEX.test(String(e).trim())
                              );
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (4): Last reviewed commit: "refactor: move email regex to constant o..." | Re-trigger Greptile

tahierhussain and others added 2 commits April 13, 2026 21:40
Update email regex to require 2+ character TLD and restrict allowed
characters to prevent invalid addresses from passing validation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@wicky-zipstack wicky-zipstack left a comment

Choose a reason for hiding this comment

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

@tahierhussain
LGTM.

One minor nit: the email regex (/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) is defined inline inside the validator and gets recreated on every validation call. Consider moving it outside the component as a constant — but not a blocker.

@tahierhussain tahierhussain self-assigned this Apr 15, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@tahierhussain
Copy link
Copy Markdown
Contributor Author

@tahierhussain LGTM.

One minor nit: the email regex (/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) is defined inline inside the validator and gets recreated on every validation call. Consider moving it outside the component as a constant — but not a blocker.

@wicky-zipstack Done. I have moved the variable outside the component. Thanks for the suggestion!

Copy link
Copy Markdown
Contributor

@abhizipstack abhizipstack left a comment

Choose a reason for hiding this comment

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

LGTM

@wicky-zipstack wicky-zipstack merged commit c55380f into main Apr 15, 2026
8 checks passed
@wicky-zipstack wicky-zipstack deleted the fix/notification-emails-default-and-validation branch April 15, 2026 06:57
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.

3 participants