Repository navigation
feat: migrate QR logo storage from D1 to R2 - #3
Conversation
|
Warning Review limit reached
Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughQR logos now use org-scoped R2 storage and serving URLs, with validation and lifecycle cleanup across worker routes and client upload controls. The application also centralizes organization, billing, member, loading, authentication, webhook, and landing-page behaviors. ChangesQR logo R2 integration
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
f12ff14 to
1bbd73c
Compare
BusyContent wraps a button label and transitions it to a spinner on busy: the text blurs (150ms), then shrinks and fades (150ms), while the spinner fades in with a 200ms delay. The label stays in the DOM during busy so the button never shrinks. Reduced motion falls back to a crossfade.
Applies BusyContent to every button that toggles between label text and a spinner on async operations. Each button now transitions smoothly instead of snapping between states. billing.tsx also gets per-button shake instances (each button shakes independently on error) and the upgrade buttons are laid out as two equal columns.
There was a problem hiding this comment.
Actionable comments posted: 8
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/components/qr.tsx (1)
285-290: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winExpose the upload state as disabled.
While busy, this remains tabbable and reports
aria-disabledas false even though activation does nothing. IncludebusyintabIndex,aria-disabled, and the hidden input'sdisabledvalue. Also callpreventDefault()for Space to avoid scrolling.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/components/qr.tsx` around lines 285 - 290, Update the upload control’s tabIndex, aria-disabled, and hidden input disabled state to treat both disabled and busy as inactive, using the existing disabled/busy symbols. In the onKeyDown handler, call preventDefault() when handling Enter or Space before opening the picker, while preserving the current activation guards.
🧹 Nitpick comments (1)
src/worker/routes/links.ts (1)
25-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for org-scoped QR validation.
Cover same-org URLs, foreign-org URLs, clearing a logo, and partial updates. This also addresses the reported high CRAP score for
validateInput.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/worker/routes/links.ts` around lines 25 - 40, Add focused tests for validateInput and validateQrFields covering same-org and foreign-org QR URLs, logo clearing, and partial updates. Assert both accepted and rejected validation outcomes, including omitted fields during partial updates, while reusing existing test fixtures and helpers to improve coverage without changing production behavior.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@AGENTS.md`:
- Around line 95-96: Update the upload-limit documentation near
QR_LOGO_MAX_BYTES to use a complete, plain sentence stating that paid plans can
upload logos up to 2 MB, while retaining the constant reference.
In `@src/app/components/qr.tsx`:
- Around line 270-272: Update the QR logo upload flow around uploadQrLogo and
its onLoad consumer so uploaded R2 objects are not finalized without a persisted
reference. Stage uploads until the organization/logo save succeeds, or track and
reliably delete the previous staged key when cancelled, replaced, or abandoned;
also remove the associated R2 object whenever the logo or organization link is
cleared or replaced.
In `@src/worker/routes/links.ts`:
- Around line 315-317: Prevent deletion of shared QR-logo objects by making
cleanup occur only after confirming the object has zero remaining references.
Update the replacement cleanup at src/worker/routes/links.ts:315-317, link
deletion at src/worker/routes/links.ts:333-333, and organization-default
replacement or clearing at src/worker/routes/orgs.ts:137-139; use shared
reference tracking or enforce a single-owner invariant consistently across all
three paths.
- Around line 315-317: Make R2 cleanup durable and retryable after successful D1
mutations: in src/worker/routes/links.ts lines 315-317, enqueue the old QR-logo
deletion through the durable cleanup mechanism after PATCH; in
src/worker/routes/links.ts line 333, apply the same retryable cleanup to link
deletion; in src/worker/routes/orgs.ts lines 143-149, update the teardown
comment to state that failed deletes leave live objects; and in
src/worker/routes/orgs.ts line 179, enqueue organization-prefix cleanup after D1
deletion. Reuse the existing cleanup mechanism and preserve the current cleanup
targets and conditions.
In `@src/worker/routes/qr-logos.ts`:
- Around line 63-65: Update the SVG response CSP in the route handling QR logos
to enforce a strict, self-contained policy: deny all resource types by default,
allow only the required inline SVG styling, and sandbox the document. Replace
the current script-only policy while preserving the existing cache and
content-type headers.
- Around line 55-60: Update the qrLogoRoutes GET("/:file") handler to enforce
the organization’s paid-plan requirement in addition to
requireOrgRole("member"). Reuse the same orgPlan(...).limits.qr gate and
established rejection behavior used by the QR logo upload route, while
preserving the existing filename validation and object lookup.
In `@src/worker/util.ts`:
- Around line 186-194: Update the QR logo validation around qrLogoUrl and
QR_LOGO_FILE_RE so it verifies the referenced R2 object exists before allowing
persistence. Use the available R2 binding’s head operation, or pass an existence
resolver into this validator, and reject missing objects while preserving the
existing organization-prefix and filename checks.
In `@wrangler.jsonc`:
- Line 17: Update the commented Wrangler setup command in wrangler.jsonc to
invoke Wrangler through Bun, preserving the existing bucket-creation arguments
and avoiding direct executable invocation.
---
Outside diff comments:
In `@src/app/components/qr.tsx`:
- Around line 285-290: Update the upload control’s tabIndex, aria-disabled, and
hidden input disabled state to treat both disabled and busy as inactive, using
the existing disabled/busy symbols. In the onKeyDown handler, call
preventDefault() when handling Enter or Space before opening the picker, while
preserving the current activation guards.
---
Nitpick comments:
In `@src/worker/routes/links.ts`:
- Around line 25-40: Add focused tests for validateInput and validateQrFields
covering same-org and foreign-org QR URLs, logo clearing, and partial updates.
Assert both accepted and rejected validation outcomes, including omitted fields
during partial updates, while reusing existing test fixtures and helpers to
improve coverage without changing production behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c1f5c02d-85d5-4b9a-8aa0-434c0bd7f599
📒 Files selected for processing (16)
AGENTS.mdmigrations/0010_qr_logo_r2.sqlsrc/app/components/link-editor.tsxsrc/app/components/qr-defaults-card.tsxsrc/app/components/qr.tsxsrc/app/lib/api.tssrc/shared/types.tssrc/worker/env.tssrc/worker/index.tssrc/worker/r2.tssrc/worker/routes/links.tssrc/worker/routes/orgs.tssrc/worker/routes/qr-logos.tssrc/worker/util.tstests/util.test.tswrangler.jsonc
| reference its own org's logos. Paid plans, ≤ 2 MB = | ||
| `QR_LOGO_MAX_BYTES` in `src/shared/types.ts`. Serving is immutable and |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use a complete sentence for the upload limit.
Replace this fragment with: “Paid plans can upload logos up to 2 MB (QR_LOGO_MAX_BYTES in src/shared/types.ts).”
As per coding guidelines, user-facing copy and documentation must use plain, short, direct language.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@AGENTS.md` around lines 95 - 96, Update the upload-limit documentation near
QR_LOGO_MAX_BYTES to use a complete, plain sentence stating that paid plans can
upload logos up to 2 MB, while retaining the constant reference.
Source: Coding guidelines
| setBusy(true); | ||
| try { | ||
| onLoad(await uploadQrLogo(org.id, file)); |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift
Prevent abandoned R2 objects from accumulating.
The upload becomes a final R2 object before either consumer persists its URL. Cancelling, navigating away, or choosing another file leaves an unreachable object, allowing repeated 2 MiB uploads to grow storage indefinitely. Stage uploads until save, or reliably delete and garbage-collect unattached keys.
As per coding guidelines, “Replacing, clearing, or deleting links or organizations must remove their associated R2 objects.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/components/qr.tsx` around lines 270 - 272, Update the QR logo upload
flow around uploadQrLogo and its onLoad consumer so uploaded R2 objects are not
finalized without a persisted reference. Stage uploads until the
organization/logo save succeeds, or track and reliably delete the previous
staged key when cancelled, replaced, or abandoned; also remove the associated R2
object whenever the logo or organization link is cleared or replaced.
Source: Coding guidelines
| // The old logo object is unreferenced once the row points at the new one. | ||
| if (body.qrLogo !== undefined && body.qrLogo !== existing.qrLogo) | ||
| await deleteQrLogo(c.env, existing.qrLogo); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Prevent deletion of shared QR-logo objects. The URL validator permits the same org-owned serving URL to be referenced by multiple D1 rows, so deletion must occur only after a safe zero-reference transition.
src/worker/routes/links.ts#L315-L317: guard replacement cleanup with reference tracking or enforce one owner per R2 object.src/worker/routes/links.ts#L333-L333: apply the same guard when deleting a link.src/worker/routes/orgs.ts#L137-L139: apply the same guard when replacing or clearing the organization default.
📍 Affects 2 files
src/worker/routes/links.ts#L315-L317(this comment)src/worker/routes/links.ts#L333-L333src/worker/routes/orgs.ts#L137-L139
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/worker/routes/links.ts` around lines 315 - 317, Prevent deletion of
shared QR-logo objects by making cleanup occur only after confirming the object
has zero remaining references. Update the replacement cleanup at
src/worker/routes/links.ts:315-317, link deletion at
src/worker/routes/links.ts:333-333, and organization-default replacement or
clearing at src/worker/routes/orgs.ts:137-139; use shared reference tracking or
enforce a single-owner invariant consistently across all three paths.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Make post-commit R2 cleanup durably retryable. D1 mutations complete before R2 cleanup, so transient R2 failures can return errors while leaving orphaned objects that normal retries cannot reach.
src/worker/routes/links.ts#L315-L317: retry old-logo deletion through a durable cleanup mechanism after PATCH commits.src/worker/routes/links.ts#L333-L333: make link-delete cleanup retryable after the row is removed.src/worker/routes/orgs.ts#L143-L149: update the teardown comment to reflect that failed deletes leave live objects, not harmless misses.src/worker/routes/orgs.ts#L179-L179: enqueue or otherwise durably retry organization-prefix cleanup after D1 deletion.
📍 Affects 2 files
src/worker/routes/links.ts#L315-L317(this comment)src/worker/routes/links.ts#L333-L333src/worker/routes/orgs.ts#L143-L149src/worker/routes/orgs.ts#L179-L179
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/worker/routes/links.ts` around lines 315 - 317, Make R2 cleanup durable
and retryable after successful D1 mutations: in src/worker/routes/links.ts lines
315-317, enqueue the old QR-logo deletion through the durable cleanup mechanism
after PATCH; in src/worker/routes/links.ts line 333, apply the same retryable
cleanup to link deletion; in src/worker/routes/orgs.ts lines 143-149, update the
teardown comment to state that failed deletes leave live objects; and in
src/worker/routes/orgs.ts line 179, enqueue organization-prefix cleanup after D1
deletion. Reuse the existing cleanup mechanism and preserve the current cleanup
targets and conditions.
Source: Coding guidelines
| qrLogoRoutes.get("/:file", requireOrgRole("member"), async (c) => { | ||
| const file = c.req.param("file"); | ||
| if (!QR_LOGO_FILE_RE.test(file)) | ||
| throw new HTTPException(404, { message: "Not found" }); | ||
| const obj = await c.env.QR_LOGOS.get(`${c.req.param("orgId")!}/${file}`); | ||
| if (!obj) throw new HTTPException(404, { message: "Not found" }); |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Enforce the paid-plan check when serving logos.
GET /:file checks membership only. Members of an organization downgraded to free can still use stored QR logo assets. Apply the same orgPlan(...).limits.qr gate as the upload route.
As per coding guidelines, QR logo upload and serving must require org membership and enforce paid plans.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/worker/routes/qr-logos.ts` around lines 55 - 60, Update the qrLogoRoutes
GET("/:file") handler to enforce the organization’s paid-plan requirement in
addition to requireOrgRole("member"). Reuse the same orgPlan(...).limits.qr gate
and established rejection behavior used by the QR logo upload route, while
preserving the existing filename validation and object lookup.
Source: Coding guidelines
| headers.set("cache-control", "private, max-age=31536000, immutable"); | ||
| headers.set("x-content-type-options", "nosniff"); | ||
| headers.set("content-security-policy", "script-src 'none'"); |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Use a strict CSP for uploaded SVGs.
script-src 'none' still permits other resource types. An uploaded SVG can declare remote images, styles, fonts, or fetches. Set a restrictive policy such as default-src 'none'; style-src 'unsafe-inline'; sandbox, or reject/sanitize SVG uploads.
As per coding guidelines, published pages must use a strict, self-contained CSP with no remote fonts, images, scripts, or fetches.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/worker/routes/qr-logos.ts` around lines 63 - 65, Update the SVG response
CSP in the route handling QR logos to enforce a strict, self-contained policy:
deny all resource types by default, allow only the required inline SVG styling,
and sandbox the document. Replace the current script-only policy while
preserving the existing cache and content-type headers.
Source: Coding guidelines
| if (fields.qrLogo) { | ||
| if (!fields.qrLogo.startsWith("data:image/")) | ||
| throw new HTTPException(400, { message: "Logo must be an image" }); | ||
| if (fields.qrLogo.length > MAX_QR_LOGO_BYTES * 1.37) | ||
| throw new HTTPException(400, { message: "Logo too large (max ~96 KB)" }); | ||
| // A logo may only be referenced by the org that uploaded it: match the | ||
| // org's own serving prefix, then check the file part is a real upload. | ||
| const prefix = qrLogoUrl(orgId, ""); | ||
| const file = fields.qrLogo.startsWith(prefix) | ||
| ? fields.qrLogo.slice(prefix.length) | ||
| : ""; | ||
| if (!QR_LOGO_FILE_RE.test(file)) | ||
| throw new HTTPException(400, { message: "Logo must be an uploaded image" }); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Verify that the referenced R2 object exists before persisting the URL.
This accepts any well-formed filename under the caller's org, including keys that were never uploaded. Check R2 with head at the persistence boundary, or pass an existence resolver into this validator, so D1 cannot store broken logo URLs.
As per coding guidelines, QR logo upload and serving must ensure rows reference only logos owned by the same organization.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/worker/util.ts` around lines 186 - 194, Update the QR logo validation
around qrLogoUrl and QR_LOGO_FILE_RE so it verifies the referenced R2 object
exists before allowing persistence. Use the available R2 binding’s head
operation, or pass an existence resolver into this validator, and reject missing
objects while preserving the existing organization-prefix and filename checks.
Source: Coding guidelines
| // Create the real resources with: | ||
| // wrangler kv namespace create LINKS | ||
| // wrangler d1 create rdyrct | ||
| // wrangler r2 bucket create rdyrct-qr-logos |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use Bun to invoke Wrangler.
This new setup command bypasses the repository's required executable tooling.
Proposed fix
-// wrangler r2 bucket create rdyrct-qr-logos
+// bunx wrangler r2 bucket create rdyrct-qr-logosAs per coding guidelines, “**/*: Use Bun for package installation, scripts, dependency management, and executable tooling. Never use npm or npx.”
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // wrangler r2 bucket create rdyrct-qr-logos | |
| // bunx wrangler r2 bucket create rdyrct-qr-logos |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@wrangler.jsonc` at line 17, Update the commented Wrangler setup command in
wrangler.jsonc to invoke Wrangler through Bun, preserving the existing
bucket-creation arguments and avoiding direct executable invocation.
Source: Coding guidelines
…onality - Simplified LinksPage by extracting link filtering logic into a custom hook. - Integrated organization limits and active domains directly into LinksPage. - Refactored MembersPage to use a custom hook for member management, enhancing readability and maintainability. - Consolidated subscription event handling in billing route to reduce redundancy and improve clarity.
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (3)
src/app/components/landing-mockup.tsx (1)
117-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff
LandingMockupstill trips the CRAP-score gate.Static analysis flags this component at CRAP 702 (cyclomatic 26, cognitive 29 over 250 lines), pre-existing and not worsened by this diff. Splitting the shorten-form, skeleton/result crossfade, and QR-logo crossfade into subcomponents would bring this down, but it's a large effort for a landing-page demo component, not a functional risk today.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/components/landing-mockup.tsx` around lines 117 - 118, Reduce the CRAP score of LandingMockup by extracting the shorten-form, skeleton/result crossfade, and QR-logo crossfade logic into focused subcomponents, leaving LandingMockup responsible for composition and shared state wiring while preserving the existing landing-page behavior.Source: Linters/SAST tools
src/app/routes/landing.tsx (1)
486-528: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
delaysis positionally coupled toresources.length, not derived from it.
delayshardcodes 13 slots split as 6 fixed + 5 resource rows + 2 trailing, matchinglinesonly becauseresourcescurrently has exactly 5 entries. Adding/removing a resource later will silently shift every delay after it out of alignment with no error, just wrong stagger timing.♻️ Derive resource-row delays from `resources.length`
-const delays = [ - 0.2, // prompt - 0.7, // build - 1.2, // upload - 1.7, // deploy - 2.2, // blank - 2.4, // header - 2.8, // kv - 3.2, // d1 - 3.6, // r2 - 4.0, // worker - 4.4, // saas - 4.8, // summary blank - 5.0, // summary -]; +const FIXED_DELAYS = [0.2, 0.7, 1.2, 1.7, 2.2, 2.4]; // prompt..header +const RESOURCE_STEP = 0.4; +const delays = [ + ...FIXED_DELAYS, + ...resources.map((_, i) => FIXED_DELAYS.at(-1)! + RESOURCE_STEP * (i + 1)), + FIXED_DELAYS.at(-1)! + RESOURCE_STEP * (resources.length + 1), // summary blank + FIXED_DELAYS.at(-1)! + RESOURCE_STEP * (resources.length + 1.5), // summary +];Also applies to: 556-573
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/routes/landing.tsx` around lines 486 - 528, Update the delay schedule used by the landing-page animation so resource-row delays are derived from resources.length rather than hardcoded positions. Adjust the corresponding lines construction and summary timing around the existing delays and resources definitions, preserving the fixed pre-resource and trailing delays while keeping each resource row aligned when resources are added or removed.src/app/routes/billing.tsx (1)
134-258: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftConsider splitting
useCheckoutFlowinto smaller, single-purpose hooks.Static analysis flags this hook at cognitive complexity 24 (threshold 15) and the
?plan=auto-upgrade effect at CRAP score 42 (threshold 30). The hook currently owns: checkout/portal mutation handlers, celebration/confetti, bfcache reset, checkout-return detection, confirmation polling, and URL-param auto-upgrade — six largely independent concerns in one 125-line function. Extracting e.g.useCheckoutConfirmation()(return-detection + polling + celebration) andusePlanParamAutoUpgrade()would reduce risk on this billing-critical path and make each piece independently testable.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/routes/billing.tsx` around lines 134 - 258, Split useCheckoutFlow into focused hooks, extracting checkout-return detection, confirmation polling, and celebration behavior into useCheckoutConfirmation, and the ?plan= handling into usePlanParamAutoUpgrade. Keep checkout/portal mutation handlers and bfcache reset behavior intact, pass the required user/query/mutation state into the extracted hooks, and preserve existing URL cleanup, polling, timeout, and upgrade behavior.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/components/link-editor.tsx`:
- Around line 241-259: Update the domain-change handling around MenuSelect and
setForm so switching an existing link to the shared domain resets or regenerates
its slug, not only when creating a link. Ensure the corresponding update path
does not fall back to existing.slug when the submitted body.slug is empty,
preventing custom-domain slugs from persisting in the shared namespace.
In `@src/app/components/qr-defaults-card.tsx`:
- Around line 22-32: Update useQrDefaultsForm to reset all QR field state and
savingQr when the selected org changes, using a useEffect keyed by orgId or the
org identity. Ensure the reset derives each value from the newly selected org,
and align the org parameter type with its usage by removing unnecessary optional
chaining or making the type nullable consistently.
In `@src/app/lib/org-store.ts`:
- Around line 14-18: Update setCurrentOrgId to normalize an empty ID to null
before assigning currentId or accessing localStorage, so both in-memory and
persisted organization state consistently clear the value.
In `@src/app/routes/auth.tsx`:
- Around line 16-18: Update the EMAIL_RE validation in auth.tsx to accept valid
punycode A-label domains such as example.xn--p1ai, matching the backend
domain-check behavior while retaining the existing rejection of malformed email
addresses. Ensure these addresses pass client validation and reach authClient.
In `@src/app/routes/dashboard.tsx`:
- Around line 52-57: Update the shared useOrgLimits hook used by the dashboard
to resolve the organization plan through orgPlan() before indexing PLAN_LIMITS,
rather than using org?.plan directly. Preserve the existing limits,
activeDomains, and orgQr outputs consumed by the dashboard.
In `@src/app/routes/landing.tsx`:
- Around line 563-570: Replace the literal em dash separator in the resource
rows rendered by the resources map with an approved punctuation mark such as a
colon, while preserving the existing spacing and resource name, ID, and
description output.
In `@src/worker/better-auth.ts`:
- Around line 12-47: Update domainHasMailRecords to distinguish an unverifiable
DNS check from a positively resolved domain with no mail-capable records.
Preserve rejection only when successful MX and A/AAAA lookups establish that no
mail records exist; return the caller-compatible allow-signup result when
fetches time out, return non-OK responses, or produce malformed/invalid DoH
data, including within the catch path.
---
Nitpick comments:
In `@src/app/components/landing-mockup.tsx`:
- Around line 117-118: Reduce the CRAP score of LandingMockup by extracting the
shorten-form, skeleton/result crossfade, and QR-logo crossfade logic into
focused subcomponents, leaving LandingMockup responsible for composition and
shared state wiring while preserving the existing landing-page behavior.
In `@src/app/routes/billing.tsx`:
- Around line 134-258: Split useCheckoutFlow into focused hooks, extracting
checkout-return detection, confirmation polling, and celebration behavior into
useCheckoutConfirmation, and the ?plan= handling into usePlanParamAutoUpgrade.
Keep checkout/portal mutation handlers and bfcache reset behavior intact, pass
the required user/query/mutation state into the extracted hooks, and preserve
existing URL cleanup, polling, timeout, and upgrade behavior.
In `@src/app/routes/landing.tsx`:
- Around line 486-528: Update the delay schedule used by the landing-page
animation so resource-row delays are derived from resources.length rather than
hardcoded positions. Adjust the corresponding lines construction and summary
timing around the existing delays and resources definitions, preserving the
fixed pre-resource and trailing delays while keeping each resource row aligned
when resources are added or removed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f63caf3d-166a-4487-b9a6-f6fc66e2ef87
⛔ Files ignored due to path filters (1)
public/cloudflare.svgis excluded by!**/*.svg
📒 Files selected for processing (23)
src/app/components/landing-mockup.tsxsrc/app/components/link-editor.tsxsrc/app/components/member-dialogs.tsxsrc/app/components/no-org.tsxsrc/app/components/qr-defaults-card.tsxsrc/app/lib/auth-form.tssrc/app/lib/current-org.tssrc/app/lib/org-limits.tssrc/app/lib/org-store.tssrc/app/routes/auth.tsxsrc/app/routes/billing.tsxsrc/app/routes/dashboard.tsxsrc/app/routes/domains.tsxsrc/app/routes/landing.tsxsrc/app/routes/links.tsxsrc/app/routes/members.tsxsrc/app/routes/reset-password.tsxsrc/app/routes/settings.tsxsrc/app/styles.csssrc/app/ui/spinner.tsxsrc/worker/better-auth.tssrc/worker/routes/billing.tssrc/worker/routes/qr-logos.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/worker/routes/qr-logos.ts
| {activeDomains.length > 0 && ( | ||
| <Field label="Domain"> | ||
| <MenuSelect | ||
| label="Domain" | ||
| value={form.domainId ?? ""} | ||
| onChange={(v) => | ||
| setForm({ | ||
| ...form, | ||
| domainId: v || null, | ||
| ...(!v && !editing ? { slug: "" } : {}), | ||
| }) | ||
| } | ||
| options={[ | ||
| { value: "", label: `shared: ${window.location.host}` }, | ||
| ...activeDomains.map((d) => ({ value: d.id, label: d.hostname })), | ||
| ]} | ||
| /> | ||
| </Field> | ||
| )} |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether the links update route enforces random slugs when domainId is cleared to shared.
fd -e ts links.ts src/worker/routes
rg -n "slug" -A8 -B8 src/worker/routes/links.tsRepository: baronunread/rdyrct
Length of output: 7734
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant client submit path and the server update logic in context.
sed -n '214,310p' src/app/components/link-editor.tsx
printf '\n---\n'
sed -n '250,320p' src/worker/routes/links.tsRepository: baronunread/rdyrct
Length of output: 5292
Re-randomize the slug when a link is moved to the shared domain. The patch path keeps existing.slug whenever body.slug is empty, so switching a custom-domain link back to shared can persist a chosen slug on the shared namespace. Clear or regenerate the slug on that update path, or block the domain change until the slug is reset.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/components/link-editor.tsx` around lines 241 - 259, Update the
domain-change handling around MenuSelect and setForm so switching an existing
link to the shared domain resets or regenerates its slug, not only when creating
a link. Ensure the corresponding update path does not fall back to existing.slug
when the submitted body.slug is empty, preventing custom-domain slugs from
persisting in the shared namespace.
Source: Coding guidelines
| function useQrDefaultsForm(orgId: string, org: NonNullable<ReturnType<typeof useCurrentOrg>["org"]>) { | ||
| const qc = useQueryClient(); | ||
| const toast = useToast(); | ||
| const isAdmin = me.data?.user.isAdmin || org?.role === "owner" || org?.role === "admin"; | ||
| const hasQr = org ? PLAN_LIMITS[org.plan].qr : false; | ||
|
|
||
| const [qrStyle, setQrStyle] = useState(org?.qrStyle ?? ""); | ||
| const [qrColor, setQrColor] = useState(org?.qrColor ?? ""); | ||
| const [qrLogo, setQrLogo] = useState(org?.qrLogo ?? ""); | ||
| const [qrCorner, setQrCorner] = useState(org?.qrCorner ?? ""); | ||
| const [qrBg, setQrBg] = useState(org?.qrBg ?? ""); | ||
| const [qrEyeColor, setQrEyeColor] = useState(org?.qrEyeColor ?? ""); | ||
| const [qrLogoSize, setQrLogoSize] = useState( | ||
| () => org?.qrLogoSize?.toString() ?? "", | ||
| ); | ||
| const [qrLogoSize, setQrLogoSize] = useState(() => org?.qrLogoSize?.toString() ?? ""); | ||
| const [savingQr, setSavingQr] = useState(false); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether QrDefaultsCard is keyed/remounted on org switch in settings.tsx.
rg -n "QrDefaultsCard" -A5 -B5 src/app/routes/settings.tsxRepository: baronunread/rdyrct
Length of output: 882
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the QR defaults card implementation around the hook and submit path.
file="src/app/components/qr-defaults-card.tsx"
wc -l "$file"
sed -n '1,260p' "$file"Repository: baronunread/rdyrct
Length of output: 7034
Reset the QR defaults when the selected org changes. QrDefaultsCard is rendered unkeyed, and useQrDefaultsForm seeds local state from org only once. Switching orgs on the same page can leave the previous org’s QR defaults in state and save them under the new orgId. Also make the org type and org?. usage agree.
🧰 Tools
🪛 GitHub Check: fallow
[failure] 22-22: High CRAP score (critical)
Function 'useQrDefaultsForm' has a CRAP score of 182 (threshold: 30).
• Severity: critical
• Cyclomatic: 13
• Cognitive: 16
• CRAP: 182 (threshold: 30)
• Lines: 36
CRAP combines complexity with coverage: high CRAP means changes here carry high risk.
Consider adding tests, simplifying the function, or both.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/components/qr-defaults-card.tsx` around lines 22 - 32, Update
useQrDefaultsForm to reset all QR field state and savingQr when the selected org
changes, using a useEffect keyed by orgId or the org identity. Ensure the reset
derives each value from the newly selected org, and align the org parameter type
with its usage by removing unnecessary optional chaining or making the type
nullable consistently.
| export function setCurrentOrgId(id: string | null) { | ||
| currentId = id; | ||
| try { | ||
| if (id) localStorage.setItem(KEY, id); | ||
| else localStorage.removeItem(KEY); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Normalize empty IDs before updating memory and storage.
setCurrentOrgId("") caches an empty string but removes the localStorage value, so in-memory and persisted organization state diverge.
Suggested fix
export function setCurrentOrgId(id: string | null) {
- currentId = id;
+ const nextId = id || null;
+ currentId = nextId;
try {
- if (id) localStorage.setItem(KEY, id);
+ if (nextId) localStorage.setItem(KEY, nextId);
else localStorage.removeItem(KEY);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function setCurrentOrgId(id: string | null) { | |
| currentId = id; | |
| try { | |
| if (id) localStorage.setItem(KEY, id); | |
| else localStorage.removeItem(KEY); | |
| export function setCurrentOrgId(id: string | null) { | |
| const nextId = id || null; | |
| currentId = nextId; | |
| try { | |
| if (nextId) localStorage.setItem(KEY, nextId); | |
| else localStorage.removeItem(KEY); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/lib/org-store.ts` around lines 14 - 18, Update setCurrentOrgId to
normalize an empty ID to null before assigning currentId or accessing
localStorage, so both in-memory and persisted organization state consistently
clear the value.
| // Stricter than the browser's type="email" check (which lets "a@b" through) | ||
| // and matches what the server's schema accepts, so bad emails never reach it. | ||
| const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/; | ||
| const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[A-Za-z]{2,}$/; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== auth route outline ==\n'
ast-grep outline src/app/routes/auth.tsx --view expanded || true
printf '\n== relevant email regex and submit logic ==\n'
rg -n "EMAIL_RE|submit\\(|authClient|email schema|zod|email" src/app/routes/auth.tsx src -g '!**/node_modules/**' || true
printf '\n== candidate shared/server email validation locations ==\n'
rg -n "email.*regex|regex.*email|z\\.string\\(\\)\\.email|\\.email\\(" src server packages shared -g '!**/node_modules/**' || true
printf '\n== list likely schema files mentioning email ==\n'
git ls-files | rg 'email|auth|schema|validation' || trueRepository: baronunread/rdyrct
Length of output: 17191
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the auth route around the regex and submit path.
sed -n '1,220p' src/app/routes/auth.tsxRepository: baronunread/rdyrct
Length of output: 6502
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== worker auth validation ==\n'
sed -n '140,220p' src/worker/better-auth.ts
printf '\n== worker auth route validation ==\n'
sed -n '1,120p' src/worker/routes/auth.ts
printf '\n== any shared email schema utilities ==\n'
rg -n "EMAIL_RE|email.*schema|schema.*email|zod.*email|\\.email\\(" src/worker src/app -g '!**/node_modules/**' || trueRepository: baronunread/rdyrct
Length of output: 6956
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== worker/routes/auth.ts around email validation ==\n'
sed -n '150,220p' src/worker/routes/auth.ts
printf '\n== worker/better-auth.ts around email plugin validation ==\n'
sed -n '1,140p' src/worker/better-auth.tsRepository: baronunread/rdyrct
Length of output: 5518
Allow punycode email domains
The TLD check rejects valid A-labels like user@example.xn--p1ai, so those users are blocked before authClient runs. Mirror the backend domain check here or relax the regex to accept IDN/punycode domains.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/routes/auth.tsx` around lines 16 - 18, Update the EMAIL_RE validation
in auth.tsx to accept valid punycode A-label domains such as example.xn--p1ai,
matching the backend domain-check behavior while retaining the existing
rejection of malformed email addresses. Ensure these addresses pass client
validation and reach authClient.
| const { org, orgId, limits, activeDomains, orgQr } = useOrgLimits(); | ||
| const stats = useStats(orgId); | ||
| const links = useLinks(orgId); | ||
| const members = useMembers(orgId); | ||
| const clicks = useRecentClicks(orgId); | ||
| const { create } = useLinkMutations(orgId); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Resolve dashboard limits from the owner’s plan.
useOrgLimits() now supplies the dashboard’s link and QR limits, but its provided implementation indexes PLAN_LIMITS by org?.plan. That can expose the wrong entitlements when billing is per user. Resolve the plan through orgPlan() in the shared hook before consuming limits here.
As per coding guidelines, billing is per user and organization limits must resolve from the owner’s plan through orgPlan().
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/routes/dashboard.tsx` around lines 52 - 57, Update the shared
useOrgLimits hook used by the dashboard to resolve the organization plan through
orgPlan() before indexing PLAN_LIMITS, rather than using org?.plan directly.
Preserve the existing limits, activeDomains, and orgQr outputs consumed by the
dashboard.
Source: Coding guidelines
| /* 6-10 */ ...resources.map((r) => ( | ||
| <span key={r.name}> | ||
| <span className="text-accent font-semibold">{r.name}</span> | ||
| <span className="text-muted/40"> {r.id}</span> | ||
| <span className="text-muted/20"> — </span> | ||
| <span className="text-muted">{r.desc}</span> | ||
| </span> | ||
| )), |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Em dash in user-visible terminal output.
The resource-row separator renders a literal em dash (—) to visitors. As per coding guidelines, "Do not use em dashes. Use a period, comma, colon, or parentheses instead."
✏️ Replace the em dash separator
- <span className="text-muted/20"> — </span>
+ <span className="text-muted/20"> · </span>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /* 6-10 */ ...resources.map((r) => ( | |
| <span key={r.name}> | |
| <span className="text-accent font-semibold">{r.name}</span> | |
| <span className="text-muted/40"> {r.id}</span> | |
| <span className="text-muted/20"> — </span> | |
| <span className="text-muted">{r.desc}</span> | |
| </span> | |
| )), | |
| /* 6-10 */ ...resources.map((r) => ( | |
| <span key={r.name}> | |
| <span className="text-accent font-semibold">{r.name}</span> | |
| <span className="text-muted/40"> {r.id}</span> | |
| <span className="text-muted/20"> · </span> | |
| <span className="text-muted">{r.desc}</span> | |
| </span> | |
| )), |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/app/routes/landing.tsx` around lines 563 - 570, Replace the literal em
dash separator in the resource rows rendered by the resources map with an
approved punctuation mark such as a colon, while preserving the existing spacing
and resource name, ID, and description output.
Source: Coding guidelines
| const DNS_CHECK_TIMEOUT = 3000; | ||
|
|
||
| async function domainHasMailRecords(domain: string): Promise<boolean> { | ||
| try { | ||
| const resp = await fetch( | ||
| `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=MX`, | ||
| { | ||
| headers: { accept: "application/dns-json" }, | ||
| signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT), | ||
| }, | ||
| ); | ||
| if (!resp.ok) return false; | ||
| const data = (await resp.json()) as { | ||
| Status: number; | ||
| Answer?: { type: number }[]; | ||
| }; | ||
| if (data.Status !== 0) return false; | ||
| if (data.Answer?.some((r) => r.type === 15)) return true; | ||
| // No MX records: RFC 5321 says fall back to A/AAAA records for mail delivery. | ||
| const aResp = await fetch( | ||
| `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=A`, | ||
| { | ||
| headers: { accept: "application/dns-json" }, | ||
| signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT), | ||
| }, | ||
| ); | ||
| if (!aResp.ok) return false; | ||
| const aData = (await aResp.json()) as { | ||
| Status: number; | ||
| Answer?: unknown[]; | ||
| }; | ||
| return aData.Status === 0 && (aData.Answer?.length ?? 0) > 0; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
DNS deliverability check fails closed and can block all signups.
Any hiccup talking to cloudflare-dns.com (timeout, non-OK response, malformed DoH payload) currently returns false from domainHasMailRecords, which the caller treats as "invalid domain" and rejects the signup with INVALID_EMAIL_DOMAIN. A DoH outage or slow response would then reject every signup, not just ones with real typo'd domains, and each request pays up to two sequential 3s timeouts before failing.
Consider failing open (allow signup) when the check itself couldn't be completed, and only reject when DNS positively resolved with zero mail-capable records.
🛡️ Fail open on unverifiable checks
async function domainHasMailRecords(domain: string): Promise<boolean> {
try {
const resp = await fetch(
`https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=MX`,
{
headers: { accept: "application/dns-json" },
signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT),
},
);
- if (!resp.ok) return false;
+ if (!resp.ok) return true; // couldn't verify: don't block signup
const data = (await resp.json()) as {
Status: number;
Answer?: { type: number }[];
};
- if (data.Status !== 0) return false;
+ if (data.Status !== 0) return true; // couldn't verify: don't block signup
if (data.Answer?.some((r) => r.type === 15)) return true;
// No MX records: RFC 5321 says fall back to A/AAAA records for mail delivery.
const aResp = await fetch(
`https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=A`,
{
headers: { accept: "application/dns-json" },
signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT),
},
);
- if (!aResp.ok) return false;
+ if (!aResp.ok) return true; // couldn't verify: don't block signup
const aData = (await aResp.json()) as {
Status: number;
Answer?: unknown[];
};
- return aData.Status === 0 && (aData.Answer?.length ?? 0) > 0;
+ if (aData.Status !== 0) return true; // couldn't verify: don't block signup
+ return (aData.Answer?.length ?? 0) > 0;
} catch {
- return false;
+ return true; // network error/timeout: don't block signup
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const DNS_CHECK_TIMEOUT = 3000; | |
| async function domainHasMailRecords(domain: string): Promise<boolean> { | |
| try { | |
| const resp = await fetch( | |
| `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=MX`, | |
| { | |
| headers: { accept: "application/dns-json" }, | |
| signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT), | |
| }, | |
| ); | |
| if (!resp.ok) return false; | |
| const data = (await resp.json()) as { | |
| Status: number; | |
| Answer?: { type: number }[]; | |
| }; | |
| if (data.Status !== 0) return false; | |
| if (data.Answer?.some((r) => r.type === 15)) return true; | |
| // No MX records: RFC 5321 says fall back to A/AAAA records for mail delivery. | |
| const aResp = await fetch( | |
| `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=A`, | |
| { | |
| headers: { accept: "application/dns-json" }, | |
| signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT), | |
| }, | |
| ); | |
| if (!aResp.ok) return false; | |
| const aData = (await aResp.json()) as { | |
| Status: number; | |
| Answer?: unknown[]; | |
| }; | |
| return aData.Status === 0 && (aData.Answer?.length ?? 0) > 0; | |
| } catch { | |
| return false; | |
| } | |
| } | |
| const DNS_CHECK_TIMEOUT = 3000; | |
| async function domainHasMailRecords(domain: string): Promise<boolean> { | |
| try { | |
| const resp = await fetch( | |
| `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=MX`, | |
| { | |
| headers: { accept: "application/dns-json" }, | |
| signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT), | |
| }, | |
| ); | |
| if (!resp.ok) return true; // couldn't verify: don't block signup | |
| const data = (await resp.json()) as { | |
| Status: number; | |
| Answer?: { type: number }[]; | |
| }; | |
| if (data.Status !== 0) return true; // couldn't verify: don't block signup | |
| if (data.Answer?.some((r) => r.type === 15)) return true; | |
| // No MX records: RFC 5321 says fall back to A/AAAA records for mail delivery. | |
| const aResp = await fetch( | |
| `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(domain)}&type=A`, | |
| { | |
| headers: { accept: "application/dns-json" }, | |
| signal: AbortSignal.timeout(DNS_CHECK_TIMEOUT), | |
| }, | |
| ); | |
| if (!aResp.ok) return true; // couldn't verify: don't block signup | |
| const aData = (await aResp.json()) as { | |
| Status: number; | |
| Answer?: unknown[]; | |
| }; | |
| if (aData.Status !== 0) return true; // couldn't verify: don't block signup | |
| return (aData.Answer?.length ?? 0) > 0; | |
| } catch { | |
| return true; // network error/timeout: don't block signup | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/worker/better-auth.ts` around lines 12 - 47, Update domainHasMailRecords
to distinguish an unverifiable DNS check from a positively resolved domain with
no mail-capable records. Preserve rejection only when successful MX and A/AAAA
lookups establish that no mail records exist; return the caller-compatible
allow-signup result when fetches time out, return non-OK responses, or produce
malformed/invalid DoH data, including within the catch path.
…476) ## Why Search Console has `/utm-builder` at #11 to #25 for its main queries ("google analytics utm builder", "utm tag maker", "utm builder analytics") and #3 for "utm links builder", a few weeks after it shipped. That is close enough that the tool itself is the lever. The two builders ranking above it, utmbuilder.net and utm.io, both do two things ours did not: build many links at once and keep a team's naming as templates. The title also never said "UTM generator" (3.6k searches a month) or "campaign URL builder" (1.6k, difficulty 19). ## What - **Many links** (a One link / Many links switch at the top of the builder): paste one address per line, pick channels (the five presets plus the source and medium of any saved template). One tagged link per address and channel, up to 500. With no channel picked, every link uses the typed source and medium; with some picked, a typed source is one more channel. **Copy all**, or **Download CSV** with each tag in its own column. Lines that are not addresses are named under the panel ("Line 3 is not a web address, so it was left out."). Nothing is shortened in this mode: the anonymous shortener makes one link per browser. - **Templates**: "Save as template" keeps all five tags in localStorage (parsed with valibot on read, junk dropped, at most 12). One click fills the fields again; the chip shows pressed while the fields match it; × removes it. Saving with no source marks Source ("Needed for a template") and focuses it rather than saving a template that would split from every link with a source. - **Wording**: title "UTM builder and generator for Google Analytics, free", a new description, the intro says "campaign URL builder", two new FAQs (bulk, and how it compares to Google's Campaign URL Builder), and the llms markdown covers both features. - Refactors that fell out of it: URL helpers to `lib/utm-tools.ts`, the coloured link to `components/utm-tagged-text.tsx` (both modes use it), and a `Textarea` in the field kit (same look as `Input`). - Three new `trackCta` placements (`utm_page_bulk_copy`, `utm_page_bulk_csv`, `utm_page_template`) so PostHog shows whether the new features get used. ## Deliberately not done - No `utm_id` field: unchanged, and the FAQ says so. - QR pages untouched. `/qr-code-generator` sits around #95 for its head terms with falling impressions, and the new WiFi/vCard/WhatsApp pages show no impressions yet; they need time and links, not code. ## Tests - `tests/utm-tools.test.ts`: address × channel product, typed-source rule, dedupe, bad lines, the 500 cap, template channels, CSV columns and quoting. - `tests/e2e/utm-builder.pw.ts`: two new scenarios, many links (refusal with nothing to copy, 2 addresses × 2 channels, the bad line named, Copy all to the clipboard, the CSV's name and rows) and templates (the source guard, save, survives a reload, apply, remove). Mutation-checked: removing the source guard fails the template scenario. - `bun run verify` and `bun run fallow` green locally; the UTM spec passes (6/6). Checked by hand at 1280 and 390 px, dark and light, with keyboard focus and the truncated-template tooltip. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **New Features** - Build tagged links for multiple URLs and selected channels, with validation, duplicate handling, and a limit of 500 links. - Copy all or individual links, or download results as a CSV. - Save, reuse, and remove UTM templates; templates are stored in the browser. - View tagged URL components in a more readable format. - Switch between single-link and bulk-link modes. - **Documentation** - Updated the UTM builder description and added guidance about bulk links and templates. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary by CodeRabbit
New Features
Bug Fixes
UI Improvements