Skip to content

Conversation

@gideongrinberg
Copy link

@gideongrinberg gideongrinberg commented Jan 30, 2026

This PR closes #815 by adding an organization-wide toggle to control who sees the upgrade toast. When the toggle is enabled, the toast is shown to all users. Otherwise, the toast is only shown to the owner. The toggle is displayed on the access control page. For backward compatibility, the toggle is enabled by default.

I have tested the feature locally by changing the version in version.ts.

Summary by CodeRabbit

Release Notes

  • New Features
    • Organizations can now configure upgrade toast visibility. Owners can toggle notifications on or off in settings, controlling whether these messages appear to team members. Upgrade toasts remain enabled by default.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Walkthrough

This PR adds organization-level control for upgrade toast visibility. It introduces a new database column, server-side getter/setter functions, and UI components to toggle the setting. The upgrade toast display is now conditional, showing only when enabled OR when the user has owner role.

Changes

Cohort / File(s) Summary
Database Schema
packages/db/prisma/migrations/20260129233909_add_upgrade_toast_enabled/migration.sql, packages/db/prisma/schema.prisma
Added upgradeToastEnabled boolean column to Org table with default value true and NOT NULL constraint.
Server-Side Logic
packages/web/src/actions.ts, packages/web/src/types.ts
Implemented getUpgradeToastEnabled and setUpgradeToastEnabled functions with authentication/authorization; added upgradeToastEnabled field to orgMetadataSchema.
Client-Side UI
packages/web/src/app/[domain]/layout.tsx, packages/web/src/app/components/upgradeToastToggle.tsx, packages/web/src/app/components/organizationAccessSettings.tsx
Added conditional rendering of UpgradeToast based on setting or owner role; created UpgradeToastToggle component with toggle functionality; integrated toggle into organization access settings.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client<br/>(Browser)
    participant ServerAction as Server Action<br/>(getUpgradeToastEnabled)
    participant DB as Database<br/>(Org)
    participant Component as UpgradeToast<br/>Component

    Client->>ServerAction: layout.tsx requests setting<br/>(on page load)
    ServerAction->>DB: fetch Org by domain
    DB-->>ServerAction: Org record with<br/>upgradeToastEnabled flag
    ServerAction-->>Client: return boolean or<br/>ServiceError
    Client->>Component: render conditionally if<br/>setting enabled OR user.role=OWNER
    alt Setting Enabled OR Owner Role
        Component-->>Client: display UpgradeToast
    else
        Component-->>Client: hide UpgradeToast
    end
Loading
sequenceDiagram
    participant User as User<br/>(Owner)
    participant UI as UpgradeToastToggle<br/>Component
    participant ServerAction as Server Action<br/>(setUpgradeToastEnabled)
    participant Auth as Auth Check<br/>(withAuth/withOrgMembership)
    participant DB as Database<br/>(Org)

    User->>UI: clicks toggle switch
    UI->>UI: set isLoading=true<br/>(disable switch)
    UI->>ServerAction: call setUpgradeToastEnabled<br/>(domain, enabled)
    ServerAction->>Auth: verify user authenticated<br/>and is org owner
    Auth-->>ServerAction: validated
    ServerAction->>DB: update Org.metadata<br/>with upgradeToastEnabled
    DB-->>ServerAction: update successful
    ServerAction-->>UI: return true
    UI->>UI: update local state<br/>show success toast
    UI->>UI: set isLoading=false<br/>(enable switch)
    UI-->>User: display confirmation
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses the issue requirement. While it adds a toggle for controlling upgrade toast visibility and shows toast only to owners by default, the toggle allows re-enabling it for all users, which contradicts the strict requirement that the upgrade prompt should ONLY be shown to owners. Reconsider the design: either remove the toggle to ensure owners-only display per #815, or clarify with stakeholders if an organization-wide override is acceptable despite the original requirement.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a toggle control for the upgrade notification feature.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the upgrade toast toggle feature scoped in #815; no unrelated modifications were introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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

🤖 Fix all issues with AI agents
In `@packages/db/prisma/schema.prisma`:
- Around line 277-278: The schema added a top-level Org.upgradeToastEnabled
column but actions.ts still reads/writes the value from metadata JSON; update
the implementation to use the new column directly: replace uses of
getOrgMetadata(...).upgradeToastEnabled with reading org.upgradeToastEnabled
(defaulting to true if null) and change updates that build mergedMetadata/
prisma.org.update({ data: { metadata: ... } }) to instead call
prisma.org.update({ data: { upgradeToastEnabled: enabled } }) in the functions
around lines where prisma.org.update and getOrgMetadata are used; also remove
upgradeToastEnabled from orgMetadataSchema in types.ts so the field is not
duplicated in metadata.
🧹 Nitpick comments (1)
packages/web/src/actions.ts (1)

1813-1837: Consider adding authentication to getUpgradeToastEnabled.

Unlike getAnonymousAccessStatus which legitimately needs to be called before authentication (to determine if anonymous access is allowed), getUpgradeToastEnabled is only called in authenticated contexts (layout.tsx after session check). Consider wrapping with withAuth for consistency, or document why public access is intentional.

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.

[FR] Upgrade pop-up should only be shown to current owner, not users

1 participant