Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@devkiran
Copy link
Collaborator

@devkiran devkiran commented Jun 10, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new component for configuring program referral link domains and destination URLs, featuring domain selection, verification status, tooltips, and referral link preview.
  • Refactor

    • Simplified forms by consolidating domain and URL input management into the new configuration component, removing previous domain verification and referral link preview logic.
    • Enhanced error messages in settings to display server error details when available.
  • Chores

    • Updated internal logic for program onboarding to use a direct property check instead of a database query.
    • Removed unnecessary field watching in rewards form for cleaner state management.

@vercel
Copy link
Contributor

vercel bot commented Jun 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
dub ✅ Ready (Inspect) Visit Preview Jun 10, 2025 8:28pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

The changes introduce a new ProgramLinkConfiguration component to centralize the configuration of referral link domains and destination URLs. Existing forms are refactored to delegate domain and URL management to this component, removing previous domain verification and preview logic. Additional minor adjustments include altering form field watchers and simplifying program onboarding conditions.

Changes

File(s) Change Summary
apps/web/ui/partners/program-link-configuration.tsx Introduced new ProgramLinkConfiguration component for domain and URL configuration.
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx Refactored form to use ProgramLinkConfiguration; removed domain verification and preview logic.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx Replaced manual domain/URL inputs with ProgramLinkConfiguration; improved error handling.
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx Removed "maxDuration" from watched form fields.
apps/web/lib/actions/partners/onboard-program.ts Simplified onboarding condition to check defaultProgramId instead of counting programs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Form
    participant ProgramLinkConfiguration
    participant DomainVerificationService
    participant WorkspaceContext

    User->>Form: Interacts with form (create/update program)
    Form->>ProgramLinkConfiguration: Renders with domain/url props
    ProgramLinkConfiguration->>WorkspaceContext: Fetch workspace info
    ProgramLinkConfiguration->>DomainVerificationService: Fetch domain status (SWR)
    User->>ProgramLinkConfiguration: Selects domain / enters URL
    ProgramLinkConfiguration->>Form: Calls onDomainChange/onUrlChange handlers
    Form->>Form: Updates form state accordingly
Loading

Poem

In the warren of code, a new path appears,
Domains and URLs now handled with cheers.
No more scattered fields, no more preview fuss,
One shiny component does all this for us!
With hops and with leaps, the forms feel so light—
A rabbit’s delight, everything just right! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 10, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2510:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@devkiran devkiran marked this pull request as ready for review June 10, 2025 13:59
Copy link
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 (1)
apps/web/ui/partners/program-link-configuration.tsx (1)

142-155: Null-safe access is fine, but a guard would remove the optional chain

linkStructureOptions?.[0].example is safe but still renders undefined if the util returns an empty array. If that can happen, consider short-circuiting to avoid a blank line in the UI.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6e2a174 and 876f02c.

📒 Files selected for processing (5)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (2 hunks)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (4 hunks)
  • apps/web/lib/actions/partners/onboard-program.ts (1 hunks)
  • apps/web/ui/partners/program-link-configuration.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
  • ProgramLinkConfiguration (19-163)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
  • ProgramLinkConfiguration (19-163)
apps/web/ui/partners/program-link-configuration.tsx (2)
apps/web/lib/types.ts (1)
  • DomainVerificationStatusProps (196-202)
apps/web/ui/domains/domain-configuration.tsx (1)
  • DomainConfiguration (6-123)
🔇 Additional comments (4)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx (1)

80-84: maxDuration removed from the watch list – confirm no downstream dependency

maxDuration is no longer watched. A quick scan shows it is not used in this component (it lives inside NewProgramForm), so this looks safe.
Please double-check that no validation / side-effect elsewhere relied on the parent form re-rendering when maxDuration changed.

apps/web/lib/actions/partners/onboard-program.ts (1)

16-19: Logic change may allow multiple programs when defaultProgramId is null but other programs exist

Switching from “count any program” to “check defaultProgramId” means a workspace that already created additional programs (but never set a default) could now create yet another one.
Verify that this behavioural change is intentional and that no invariant elsewhere assumes exactly one program per workspace.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (1)

90-100: Good use of the new ProgramLinkConfiguration component

Integrating the shared component removes a lot of duplicated logic and keeps the form succinct. The watch → setValue callbacks are wired correctly and dirty-state is preserved.
Nice refactor!

apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)

159-166: 👍 Clean hand-off to the shared link configuration component

This drops a sizeable amount of bespoke domain logic and centralises it behind ProgramLinkConfiguration, improving maintainability. Props are correctly typed and setValue marks the field dirty. Looks solid.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 10, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2510:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@devkiran
Copy link
Collaborator Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

✅ Actions performed

Full review triggered.

@devkiran devkiran requested a review from steven-tey June 10, 2025 19:10
Copy link
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

♻️ Duplicate comments (1)
apps/web/ui/partners/program-link-configuration.tsx (1)

33-35: ⚠️ Potential issue

Encode domain when constructing the verification URL

This security issue (path-injection / SSRF) was flagged in an earlier review but is still present. Use encodeURIComponent before interpolating domain into the path:

-      ? `/api/domains/${domain}/verify?workspaceId=${workspaceId}`
+      ? `/api/domains/${encodeURIComponent(domain)}/verify?workspaceId=${workspaceId}`
🧹 Nitpick comments (4)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (1)

72-101: Watch → re-render dependency is safe but a bit expensive

const [domain, url] = watch(["domain", "url"]); subscribes the component to every change inside the form; this means the parent form will re-render even when unrelated fields mutate.
A lightweight alternative is to subscribe only to the specific fields via useWatch:

-import { useForm, useWatch } from "react-hook-form";
...
-const [domain, url] = watch(["domain", "url"]);
+const domain = useWatch({ control, name: "domain" });
+const url    = useWatch({ control, name: "url" });

This avoids unnecessary re-renders when large forms grow.

apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)

159-166: Pass null not undefined to child props

watch returns undefined for untouched fields, yet ProgramLinkConfiguration’s prop types expect string | null.
Consider normalising the values to keep the prop contract explicit:

- domain={domain}
- url={url}
+ domain={domain ?? null}
+ url={url ?? null}
apps/web/ui/partners/program-link-configuration.tsx (2)

39-43: Memoise linkStructureOptions

getLinkStructureOptions could be computationally heavy. Wrap it in useMemo to avoid recomputation on every keystroke:

- const linkStructureOptions = getLinkStructureOptions({ domain, url });
+ const linkStructureOptions = useMemo(
+   () => getLinkStructureOptions({ domain, url }),
+   [domain, url],
+ );

95-104: Validate destination URL before propagating

Currently any string that passes the browser’s <input type="url"> filter is accepted.
Consider basic runtime validation (e.g. https?://) and display inline feedback to avoid bad data entering the DB.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6e2a174 and 8da8d80.

📒 Files selected for processing (5)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (2 hunks)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/links/links-settings.tsx (4 hunks)
  • apps/web/lib/actions/partners/onboard-program.ts (1 hunks)
  • apps/web/ui/partners/program-link-configuration.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/form.tsx (1)
apps/web/ui/partners/program-link-configuration.tsx (1)
  • ProgramLinkConfiguration (20-165)
apps/web/ui/partners/program-link-configuration.tsx (2)
apps/web/lib/types.ts (1)
  • DomainVerificationStatusProps (196-202)
apps/web/ui/domains/domain-configuration.tsx (1)
  • DomainConfiguration (6-123)
🔇 Additional comments (1)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx (1)

80-84: Confirm removal of maxDuration from the top–level watcher

maxDuration is now watched only inside NewProgramForm, which is fine as long as no logic outside that component relies on immediate updates of that field. Please double-check callers (e.g. button disabling, validation) to ensure no regressions slipped in after this change.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 10, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2510:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 10, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2510:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@steven-tey steven-tey merged commit 6cda42f into main Jun 10, 2025
8 checks passed
@steven-tey steven-tey deleted the program-link-config branch June 10, 2025 21:17
@coderabbitai coderabbitai bot mentioned this pull request Oct 15, 2025
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