Repository navigation
feat: non-blocking post-signup email-verification nudge with resend - #13891
mattmillerai wants to merge 24 commits into
Conversation
Add a cloud-only, feature-flagged (default off) email-verification nudge for authenticated password-provider users whose email is unverified. - useEmailVerification composable: needsEmailVerification (password provider + emailVerified false), resend() with a 60s client cooldown and too-many-requests handling, refresh() that reloads the firebase user and force-refreshes the token so the backend can lazily persist verification. Runs on window refocus and after resend. - EmailVerificationNudge topbar banner: dismissible (dismissal persisted to localStorage, re-prompted at most once per session), gated on isCloud + the feature flag. Never gates a route, dialog, or feature. - Surfaces the same nudge with credit-specific copy when the cloud subscription status reports free_tier_grant_state=verification_required (shown in non-dismissed form). - email_verification_nudge_enabled feature flag, default off.
📦 Bundle: 12.4 MB gzip 🔴 +1.4 kBDetailsSummary
Category Glance App Entry Points — 7.1 kB (baseline 7.1 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 3.7 MB (baseline 3.7 MB) • 🔴 +5.48 kBGraph editor runtime, canvas, workflow orchestration
Status: 4 added / 4 removed / 1 unchanged Views & Navigation — 150 kB (baseline 150 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 15 added / 15 removed / 3 unchanged Panels & Settings — 899 kB (baseline 899 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 14 added / 14 removed / 21 unchanged User & Accounts — 108 kB (baseline 108 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 11 added / 11 removed / 7 unchanged Editors & Dialogs — 502 kB (baseline 502 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 13 added / 13 removed / 6 unchanged UI Components — 369 kB (baseline 369 kB) • ⚪ 0 BReusable component library chunks
Status: 13 added / 13 removed / 21 unchanged Data & Services — 2.02 MB (baseline 2.02 MB) • ⚪ 0 BStores, services, APIs, and repositories
Status: 42 added / 42 removed / 5 unchanged Utilities & Hooks — 1.42 MB (baseline 1.42 MB) • 🔴 +273 BHelpers, composables, and utility bundles
Status: 50 added / 50 removed / 36 unchanged Vendor & Third-Party — 9.7 MB (baseline 9.7 MB) • 🔴 +1.25 kBExternal libraries and shared vendor chunks
Status: 1 added / 1 removed / 15 unchanged Other — 36.6 MB (baseline 36.6 MB) • 🔴 +493 BBundles that do not match a named category
Status: 118 added / 118 removed / 648 unchanged ⚡ Performance: ⏳ Performance tests in progress…🎭 Playwright: ✅ 3290 passed, 0 failed · 3 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure
Findings and check detailsExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight The matrix runs on same-repository version-bump PRs with relevant changes, main-branch pushes, and manual dispatches. This candidate does not qualify, so every expensive stage was skipped. Full docs: scripts/registry-census/README.md Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
🌾 Fallow: ✅ PassedFindings and check detailsFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Full docs: ADR-DEVEX-LINT-0015 Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 0fe5c75024781beac00da782c10c6e3661407a5d
🏛️ Architecture: ✅ PassedFindings and check detailsWarnings (512)
Full docs: Frontend domain catalog Reproduce locallypnpm architecture:check |
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
Found 7 finding(s).
| Severity | Count |
|---|---|
| 🟠 High | 1 |
| 🟡 Medium | 2 |
| 🟢 Low | 4 |
Panel: 8/8 reviewers contributed findings.
- Guard localStorage reads/writes so blocked storage (sandboxed iframe, privacy mode) no longer crashes topbar rendering or the dismiss handler - Re-enable resend immediately on non-rate-limit failures and clear the pending cooldown timer so a transient error doesn't lock the button 60s - Gate the focus refresh on needsEmailVerification (not nudge visibility) so a dismissed nudge still picks up verification done in another tab - Add an in-flight guard to refresh() to avoid overlapping reload requests - Stub EmailVerificationNudge in LinearView.test.ts (real component mounted without stores and broke 6 tests)
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #13891 +/- ##
=========================================
Coverage 87.86% 87.87%
=========================================
Files 3050 3052 +2
Lines 165573 165693 +120
Branches 44348 46631 +2283
=========================================
+ Hits 145479 145599 +120
Misses 19287 19287
Partials 807 807
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 13 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…rification-nudge # Conflicts: # src/composables/useFeatureFlags.ts
…rification-nudge # Conflicts: # src/composables/useFeatureFlags.ts
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 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/components/topbar/EmailVerificationNudge.test.ts`:
- Around line 51-89: Update the tests in the nudge rendering cases to select the
container with getByRole('status') and the resend and dismiss controls by their
accessible button names instead of data-testid attributes. In the cooldown test,
assert the resend control with toBeDisabled() while preserving the existing
generic, credit-specific, and no-nudge behavior checks.
In `@src/composables/auth/useEmailVerification.test.ts`:
- Around line 52-56: Update the test helper loadComposable to create
useEmailVerification inside a Vue effectScope, retain the scope for the current
test, and stop it in afterEach(). Ensure each test disposes its scoped
composable and its useEventListener focus listener before vi.resetModules() is
used again.
- Around line 280-297: The refresh tests only cover a single manual call; extend
the refresh suite around loadComposable to dispatch focus after verification
dismissal and assert the nudge remains hidden, then invoke refresh concurrently
and assert user.reload is called once. Preserve the existing token-refresh and
needsEmailVerification assertions while covering the focus listener and
isRefreshing guard.
- Line 30: Remove the '`@/i18n`' mock from the useEmailVerification tests and
install the real createI18n plugin or established i18n test helper in the test
setup. Preserve assertions against translation keys or consumer payloads while
exercising the configured translation path.
- Around line 179-277: Enable fake timers for the entire resend test suite
before its tests run, and ensure each test clears pending timers before
restoring real timers during cleanup. Update the existing cooldown test to reuse
the suite-level fake-timer setup rather than enabling timers locally, while
preserving its 60-second cooldown assertions.
In `@src/composables/useFeatureFlags.ts`:
- Around line 241-247: Add direct tests for the emailVerificationNudgeEnabled
getter in useFeatureFlags.test.ts, covering the remote-config value, server
feature-flag fallback, and false default. Reuse the existing test setup and
assertions for neighboring feature flags to verify each resolution path.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 158dbbcd-5126-4904-b42a-c53d82c57005
📒 Files selected for processing (10)
src/components/graph/GraphCanvas.vuesrc/components/topbar/EmailVerificationNudge.test.tssrc/components/topbar/EmailVerificationNudge.vuesrc/composables/auth/useEmailVerification.test.tssrc/composables/auth/useEmailVerification.tssrc/composables/useFeatureFlags.tssrc/locales/en/main.jsonsrc/platform/remoteConfig/types.tssrc/views/LinearView.test.tssrc/views/LinearView.vue
- Select the nudge and its controls by role/accessible name instead of data-testid, and assert cooldown with toBeDisabled(). - Drop the @/i18n mock so the composable tests exercise real translation key resolution. - Run the shared composable inside an effectScope stopped after each test so its window focus listener does not leak across tests. - Use fake timers for the whole resend suite and clear pending timers on teardown. - Cover the focus-triggered refresh after dismissal and the concurrent refresh guard. - Cover emailVerificationNudgeEnabled resolution in useFeatureFlags. Also drop the retired team_workspaces_enabled key from the workspace auth E2E fixture: #14613 removed it from RemoteConfig after #12940 was written, so typecheck:browser fails on main and on every PR that merges it.
|
Heads-up on one file in this diff that is not part of the feature:
That is a semantic conflict already on Fix here is the minimal one: drop the retired key so the fixture is an empty |
…rification-nudge # Conflicts: # browser_tests/fixtures/data/workspaceAuthFixtures.ts
…rification-nudge # Conflicts: # src/views/LinearView.vue
- Narrow the free_tier_grant_state read to a local type instead of relying on it existing on the generated BillingStatusResponse, which doesn't have that field yet; behavior is unchanged (still undefined until the ingest API and its generated types add it). - Drop vi.clearAllMocks/clearAllTimers/useRealTimers calls that are now redundant with restoreMocks and the global timer teardown, per the comfy(no-redundant-vitest-cleanup) rule added on main.
The focus listener called refresh() (and so user.reload()) for any unverified password user, even outside cloud or with the flag off.
|
@coderabbitai review |
✅ Action performedReview finished.
|
DrJKL
left a comment
There was a problem hiding this comment.
The nudge implementation and tests bypass generated and mock contracts with assertions.
|
|
||
| const freeTierVerificationRequired = computed( | ||
| () => | ||
| (subscriptionStatus.value as WithFreeTierGrantState | null) |
There was a problem hiding this comment.
This cast invents a field that the generated subscription contract does not expose. Remove the free-tier branch until the backend schema generates that state, or update the authoritative API schema first and consume the generated type.
There was a problem hiding this comment.
Agreed — removed the free-tier branch (1e4cf16).
Checked before removing: subscriptionStatus is ref<BillingStatusResponse | null> and is only ever filled from workspaceApi.getBillingStatus(), and the generated ingest BillingStatusResponse has no free_tier_grant_state. The only generated type that does expose it is the registry GetCloudSubscriptionStatus response, which has no call site in src/. So the credits variant was unreachable, not just untyped.
nudgeVariant therefore collapses to an isNudgeVisible boolean; creditsMessage and the useSubscription dependency are gone. Left a note for re-adding the credit-specific copy once the billing-status schema actually generates the field.
| import type { EffectScope } from 'vue' | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| authStore: { currentUser: null as unknown }, |
There was a problem hiding this comment.
These as unknown initializers erase the mock contracts. Use explicitly typed mutable holders for the user and subscription values, or extract the nudge-state calculation into a pure typed function and test it directly.
There was a problem hiding this comment.
Fixed in 1e4cf16. The subscription holder is gone entirely (the free-tier branch it fed was removed), and the user holder is now explicitly typed: authStore: { currentUser: null as FakeUser | null }. No as unknown left in the file.
There was a problem hiding this comment.
Follow-up in 8ecc059: the test no longer mocks the auth or toast stores at all (main now forbids that via comfy/use-global-pinia). The user is set on the real useAuthStore() through fromPartial<User>(...), and toast outcomes are asserted from useToast().toasts. Still no as unknown in the file.
`free_tier_grant_state` is not on the generated `BillingStatusResponse` that types `subscriptionStatus`, so the credits variant could never fire. Collapse `nudgeVariant` to an `isNudgeVisible` boolean and type the test mock holders instead of erasing them with `as unknown`.
|
🤖 The reviews loop filed Linear follow-up ticket(s) for review thread(s) deferred as out of scope for this PR:
The following carry
|
…rification-nudge # Conflicts: # src/components/graph/GraphCanvas.vue # src/composables/useFeatureFlags.ts # src/views/LinearView.vue
Main moved TopbarBadges into WorkflowTabs, replaced the toast store with the design-system useToast, moved ServerFeatureFlag to its own module and required a reportError surface. Mount the nudge in WorkflowTabs, switch to useToast, drive the composable test through the global testing Pinia, and satisfy the type-aware lint rules main now enforces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rification-nudge # Conflicts: # src/composables/useFeatureFlags.test.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rification-nudge Main extracted the topbar actions into TopbarActions.vue, so the nudge now mounts there; Button moved to the design-system package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dante01yoon
left a comment
There was a problem hiding this comment.
Thanks for keeping this behind a default-off flag and making it non-blocking. The cloud/flag gating, the in-flight guard on refresh(), and the cooldown reset on non-rate-limit errors all look right, and DrJKL's earlier points about the free-tier cast and the as unknown mocks appear to be addressed.
Requesting changes for two repo-rule items:
- the added inline comments in
useEmailVerification.ts - the
errorTypeslug, which doesn't follow the naming convention
The rest are suggestions plus one question about the banner copy.
Gate 3: email_verification_nudge_enabled?: boolean is a thin addition on top of the generated GetFeaturesResponses, following the existing signup_turnstile pattern, so that's fine. Gate 2: the visibility check uses the Firebase user's own emailVerified and provider. That's presentation-only and gates nothing.
Not run locally: I reviewed the diff only (no worktree install).
| const toast = useToast() | ||
|
|
||
| // Bumped after an in-place `User.reload()` so computeds that read the mutated | ||
| // firebase user object (whose reference does not change) re-evaluate. |
There was a problem hiding this comment.
issue: Repo rule: new code should not add comments other than a 1–2 line JSDoc on exported API. This file adds several (lines 17–21, 30, 50–51, 94–95, 111–112, 140–141, 163–164). The reasoning is useful, so it could go in the PR description or commit message, or into names, e.g. reloadTick → userReloadedTick. Please remove the inline comments and the JSDoc on the non-exported SESSION_START_MS.
There was a problem hiding this comment.
Done in 5293b9a: removed all the inline comments and the SESSION_START_MS JSDoc, renamed reloadTick → userReloadedTick, and replaced the long JSDoc on the internal function with a one-line JSDoc on the exported useEmailVerification.
| } | ||
| } catch (error) { | ||
| reportError(error, { | ||
| errorType: 'email_verification_refresh_failure', |
There was a problem hiding this comment.
issue: errorType should follow the <category>_<operation>_<subject> convention in src/AGENTS.md (category first, then a present participle). Existing types in this family use that shape, e.g. error_refreshing_billing_after_invite. Something like error_refreshing_email_verification would sort with the other refresh failures. Since this is a new telemetry contract, it's cheap to fix now.
There was a problem hiding this comment.
Renamed to error_refreshing_email_verification in 5293b9a (test updated too). No other references to the old slug existed.
| description: t('auth.emailVerification.resentSuccessDetail'), | ||
| duration: 5000 | ||
| }) | ||
| await refresh() |
There was a problem hiding this comment.
suggestion: refresh() here runs right after the email is sent, when the user can't have clicked the link yet, so reload() will almost never flip emailVerified. The focus listener already covers the real case (the user verifies in another tab and comes back). Dropping this call removes one network round trip per resend, plus the test that covers this path.
There was a problem hiding this comment.
Agreed. Dropped the post-send refresh() and its test in 5293b9a. The focus listener still picks up a verification done in another tab.
| } | ||
| })) | ||
| vi.mock(import('firebase/auth'), { spy: true }) | ||
| vi.mock(import('@/platform/telemetry/reportError'), () => ({ |
There was a problem hiding this comment.
suggestion: Once this is rebased onto main (#22018), vitest.setup.ts mocks reportError by default. This local vi.mock can then go, and the assertions can use vi.mocked(reportError). That also brings the suite back under three module mocks.
There was a problem hiding this comment.
Merged main (includes #22018) and removed the local reportError mock in 5293b9a. Because the suite calls vi.resetModules() before each load, the assertion re-imports reportError after loading the composable so it checks the same mock instance the composable got. That brings it to three module mocks.
| /> | ||
| <span class="text-xs whitespace-nowrap text-foreground"> | ||
| {{ t('auth.emailVerification.genericMessage') }} | ||
| </span> |
There was a problem hiding this comment.
question: "Verify your email to unlock account benefits": what does verification actually unlock today? The credits variant was dropped because the billing contract doesn't expose that state, so the client can't know which benefit applies. If nothing is gated on verification yet, neutral copy (e.g. "Please verify your email address") would avoid promising something the server doesn't grant. If something is gated, the server should be the one telling the client about it.
There was a problem hiding this comment.
Nothing is gated on verification client-side today, so I switched to neutral copy: "Please verify your email address" (5293b9a). If a benefit gets gated later, the server should expose it, and the copy can follow from that.
- remove inline comments; rename reloadTick to userReloadedTick - rename telemetry slug to error_refreshing_email_verification - drop the post-resend refresh (focus listener covers verification) - use the shared reportError mock from vitest setup - neutral nudge copy that promises no specific benefit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dante01yoon
left a comment
There was a problem hiding this comment.
Re-reviewed through e1d21683. Everything from my last review is addressed:
- The inline comments and the
SESSION_START_MSJSDoc are gone.reloadTickis renamed touserReloadedTick, and only a one-line JSDoc remains on the exported composable. errorTypeis nowerror_refreshing_email_verification.- The post-send
refresh()and its test are dropped. The focus listener still covers verifying in another tab. - The local
reportErrormock is gone (the suite is at three module mocks), and it uses the packaged@comfyorg/telemetry/reportError. - The banner copy is now neutral ("Please verify your email address"), so it doesn't promise a benefit the server doesn't grant.
Dropping size-4 on the new icon matches AGENTS.md, since Iconify icons default to size-4.
Gates: Gate 2 is fine because visibility comes from the Firebase user's own emailVerified and provider and gates nothing. Gate 3 is fine because email_verification_nudge_enabled?: boolean is a thin addition on top of the generated GetFeaturesResponses.
Ran locally at this head: useEmailVerification.test.ts, EmailVerificationNudge.test.ts and useFeatureFlags.test.ts, 145 passed. preflight, perf-tests and pr-risk were still running when I posted, so please make sure they go green before merging.
One non-blocking nit is inline.
| import EmailVerificationNudge from './EmailVerificationNudge.vue' | ||
|
|
||
| const h = vi.hoisted(() => ({ | ||
| composable: null as { |
There was a problem hiding this comment.
nit-pick (non-blocking): This hand-types the composable shape (ReturnType<typeof vi.fn>, { value: boolean }) and then needs h.composable! in every test plus fromPartial to get it back to the real type. Typing the holder from ReturnType<typeof useEmailVerification> (for example with vi.mockObject, as __mocks__/useBillingDialogs.ts does) would drop the non-null assertions and keep the mock in sync if the composable's return shape changes.
There was a problem hiding this comment.
Agreed, typing the holder from ReturnType<typeof useEmailVerification> via vi.mockObject (like __mocks__/useBillingDialogs.ts) is cleaner and would drop the h.composable! assertions. I left it out of this round because a push to this branch dismisses your approval (the ruleset has dismiss_stale_reviews_on_push), and this is a test-only nit you marked non-blocking. If you would like it in this PR anyway, reply here and I will push it.
There was a problem hiding this comment.
Done in ec1cb33. The branch had to be pushed anyway to merge main (a main.json conflict), so I folded this in. The holder is now typed as ReturnType<typeof useEmailVerification> with typed vi.fn<...>() members, so there are no h.composable! assertions and no fromPartial left. I used a plain typed object instead of vi.mockObject, because the return value includes refs/computeds and plain refs keep them reactive.
…rification-nudge # Conflicts: # src/locales/en/main.json
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ELI5
When you sign up with an email and password, nobody ever checks that the email is really yours. This adds a small, friendly banner in the top bar that asks you to verify your email and gives you a button to resend the verification link. It never blocks you from using the app — you can dismiss it, and it only shows up for cloud users once we turn the feature on.
Summary
Adds a non-blocking, cloud-only, feature-flagged (default off) email-verification nudge for authenticated password-provider users whose email is unverified, plus a resend action. Entirely client-side Firebase; no backend changes.
Changes
useEmailVerificationcomposable (src/composables/auth/):needsEmailVerification— authenticated,emailVerified === false, and sign-in provider ispassword(Google/GitHub SSO users carryemailVerified=trueand never see it).resend()—sendEmailVerification(user, { url: origin }), success toast, mapsauth/too-many-requeststo a friendly cooldown message, and a 60s client-side cooldown to avoid hammering.refresh()—user.reload()then, if verification flipped,getIdToken(true)so subsequent API calls carry theemail_verified=trueclaim (lets the backend lazily persist it). Runs on window refocus (while the flag is on and the user is still unverified, including after dismissal so a verification done in another tab is picked up); hides the nudge once verified. Reload failures go toreportError(error_refreshing_email_verification).EmailVerificationNudgetopbar banner — dismissible (dismissal persisted tolocalStorage, re-prompted at most once per session), gated onisCloud+ the feature flag, mounted next toTopbarBadges/TopbarSubscribeButtoninsideTopbarActions(both the integrated tab bar and the legacy layout), so it appears wherever the workflow tabs render. Never gates a route, dialog, or feature.email_verification_nudge_enabledfeature flag (default off) via the existinguseFeatureFlagsmechanism (and reported through feature-flag evaluation telemetry), so rollout/funnel impact is measurable before broad enable.auth.emailVerification.*; the banner uses neutral copy ("Please verify your email address") since nothing is gated on verification yet.Review Focus
User.reload()mutatesemailVerifiedin place without changing the object reference, so the composable bumps an internal tick to re-evaluate the derived state.Tests
google.com), flag/cloud gating, dismissal + cross-session re-prompt + blocked storage, resend success /too-many-requests/ generic error, cooldown re-enable, refresh flip hiding the nudge, focus refresh after dismissal and skipped while the flag is off, reload failures reported to telemetry, overlapping refreshes collapsed. Runs against the global testing Pinia (real auth and toast stores).Judgment calls
TopbarActions(rendered byWorkflowTabs) next to the subscribe chip, which is where that chip now lives for both the canvas and linear views; not added to any modal/settings surface.free_tier_grant_statewas dropped: the billing-status contract this client reads does not expose that field, so the branch was unreachable.Provenance
main(resolved asrc/locales/en/main.jsonconflict, keeping bothsignInToUsePartnerNodesand theemailVerificationblock)vitest runonuseEmailVerification,EmailVerificationNudgeanduseFeatureFlags: 3 files, 149 tests passpnpm typecheck,pnpm knip,oxlintandoxfmtclean on the headuseToast()instead of the retired PrimeVue toast store