Code Review Bench PR #26801 - feat: add scope configuration for feature opt-in#14
Open
tomerqodo wants to merge 8 commits intobase_pr_26801_20260125_1768from
Open
Code Review Bench PR #26801 - feat: add scope configuration for feature opt-in#14tomerqodo wants to merge 8 commits intobase_pr_26801_20260125_1768from
tomerqodo wants to merge 8 commits intobase_pr_26801_20260125_1768from
Conversation
Add scope field to OptInFeatureConfig that allows features to be scoped to specific levels (org, team, user). This enables features to be shown only at certain settings pages rather than all three. Changes: - Add OptInFeatureScope type with values 'org', 'team', 'user' - Add optional scope field to OptInFeatureConfig interface - Add getOptInFeaturesForScope helper function to filter features by scope - Update FeatureOptInService to filter features based on scope - Update tRPC router to pass scope parameter for org/team endpoints Features without a scope field default to all scopes for backward compatibility. Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…tate - Add isFeatureAllowedForScope helper function to check if a feature is allowed for a scope - Update setUserFeatureState to reject if feature is not scoped to 'user' - Update setTeamFeatureState to accept scope parameter and reject if feature is not allowed - Update tRPC router to pass scope parameter for team and org endpoints - Fix unit test mock to include new config exports Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
- Replace raw Error with ErrorWithCode using ErrorCode.BadRequest - Add comprehensive tests for setUserFeatureState scope validation - Add comprehensive tests for setTeamFeatureState scope validation - Test both enabled/disabled and inherit state scenarios - Test error messages include feature ID and scope name Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
…on tests Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>
This was referenced Jan 25, 2026
Open
feat: add scope configuration for feature opt-in
agentic-review-benchmarks/cal.com-combined-codex#14
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code Review Bench PR calcom#26801
Original PR Title: feat: add scope configuration for feature opt-in
Original PR Description: ## What does this PR do?
Follow-up to calcom#25892 as discussed in this review comment.
Adds a
scopefield toOptInFeatureConfigthat allows features to be scoped to specific levels (org, team, user). This enables features to be shown only at certain settings pages rather than all three.Example configuration:
Changes
OptInFeatureScopetype with values"org","team","user"scopefield toOptInFeatureConfiginterfacegetOptInFeaturesForScope()helper function to filter features by scopeisFeatureAllowedForScope()helper function to validate scope accessFeatureOptInServiceto filter features based on scopesetUserFeatureStateandsetTeamFeatureStatenow reject requests withErrorWithCode(ErrorCode.BadRequest)if the feature is not allowed for the specified scopeHAS_USER_OPT_IN_FEATURES,HAS_TEAM_OPT_IN_FEATURES,HAS_ORG_OPT_IN_FEATURES) to only show when features exist for that scopeFeatures without a
scopefield default to all scopes for backward compatibility.Updates since last revision
ErrorwithErrorWithCodeusingErrorCode.BadRequestfor scope validation errorssetUserFeatureStateandsetTeamFeatureStateSettingsLayoutAppDirClient.tsxto use scope-specific constants instead of genericHAS_OPT_IN_FEATURES, so the Features menu item only appears when features are available for that specific scope (user/team/org)Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
OPT_IN_FEATURESis currently empty, the changes won't have visible effects until features are addedOPT_IN_FEATURESwithscope: ["user"]only/settings/my-account/featuresbut not on team/org settings pagesErrorWithCodewithBadRequestcodescope: ["org"]only/settings/organizations/featuresbut not on user/team settings pagesyarn type-check:ci --force --filter=@calcom/features --filter=@calcom/trpcTZ=UTC yarn test packages/features/feature-opt-in/services/FeatureOptInService.test.tsHuman Review Checklist
ErrorWithCodewithErrorCode.BadRequestis appropriate for scope validation failuresscopeshould appear in all scopes (backward compatible)"team"inlistFeaturesForTeamis appropriateHAS_USER_OPT_IN_FEATURES, etc.) are used correctly inSettingsLayoutAppDirClient.tsxChecklist
Link to Devin run: https://app.devin.ai/sessions/4d62343634ba4f44819cff9c8d0cb83a
Requested by: @eunjae-lee
Original PR URL: calcom#26801