Skip to content

Feat/built in feature flag - #17

Merged
arxja merged 8 commits into
mainfrom
feat/built-in-feature-flag
Jul 25, 2026
Merged

Feat/built in feature flag#17
arxja merged 8 commits into
mainfrom
feat/built-in-feature-flag

Conversation

@arxja

@arxja arxja commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added feature-flag support for controlling application functionality through configuration.
    • Added support for a client-configured demo mode.
    • Added safeguards to prevent client-side access to server-only feature settings.
    • Added consistent handling for checking whether features are enabled and retrieving configured values.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@arxja, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 23 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fa52bc8-15e6-4599-bc57-c23ab5062ce9

📥 Commits

Reviewing files that changed from the base of the PR and between caf4091 and ed27721.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • docs/guides/feature-flag.md
  • hooks/useFeatureflags.ts
  • lib/config/config-client.ts
  • lib/config/index.ts
  • lib/feature-flags.ts
📝 Walkthrough

Walkthrough

Adds typed feature-flag utilities with client/server access rules, requires NEXT_PUBLIC_DEMO_MODE in client configuration, and exposes demo mode through a memoized client-side React hook.

Changes

Feature flag configuration

Layer / File(s) Summary
Flag registry and configuration contracts
lib/feature-flags.ts, lib/config/index.ts, lib/email/index.ts
Defines supported feature flags, adds the required NEXT_PUBLIC_DEMO_MODE client setting, and updates the commented email enablement reference.
Flag access utilities
lib/feature-flags.ts
Adds override-aware enablement checks and configuration value access with client-side restrictions and development warnings.
Client feature flag hook
hooks/useFeatureflags.ts
Adds a client-only hook that memoizes the demoMode flag and an empty UI configuration object.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding built-in feature-flag support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/built-in-feature-flag

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 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 `@hooks/useFeatureflags.ts`:
- Around line 16-18: Update the demoMode value in useFeatureflags to normalize
clientConfig.NEXT_PUBLIC_DEMO_MODE to a boolean by reusing the shared enablement
helper or checking equality with "true"; ensure the hook’s result type exposes
demoMode as boolean so the string "false" cannot enable demo behavior.
- Line 3: Update the client-facing hooks/useFeatureflags.ts import so it no
longer references the server-inclusive `@/lib/config` module. Split or use the
existing client-safe configuration module, ensuring clientConfig remains
available without importing serverConfig or invoking getServerConfig() in the
"use client" module graph.

In `@lib/config/index.ts`:
- Line 35: Update the NEXT_PUBLIC_DEMO_MODE schema and configuration boundary to
accept only "true" or "false" and normalize the value to a boolean. Ensure
useFeatureFlags() exposes the same boolean result used by
isEnable("NEXT_PUBLIC_DEMO_MODE"), preserving consistent component conditionals.

In `@lib/feature-flags.ts`:
- Around line 38-56: Update isEnable so the client/server restriction is
evaluated before the overrides branch: on the client, only flags starting with
"NEXT_PUBLIC_" may use overrides, while server-only flags must return false.
Preserve override priority for server-side calls and the existing client-safe
configuration behavior.
- Around line 13-18: Align the FEATURE_FLAGS entry
NEXT_PUBLIC_FEATURE_NEW_DASHBOARD with the clientConfig validation by adding the
corresponding field to clientSchema, including the appropriate type and
optionality used for client feature flags. Alternatively, remove the flag from
FEATURE_FLAGS until schema support is wired, ensuring isEnable() cannot
reference an unvalidated configuration key.
🪄 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 Plus

Run ID: e8f014f4-590e-48aa-8eb0-7751249c8c0b

📥 Commits

Reviewing files that changed from the base of the PR and between eadccfb and caf4091.

📒 Files selected for processing (4)
  • hooks/useFeatureflags.ts
  • lib/config/index.ts
  • lib/email/index.ts
  • lib/feature-flags.ts

Comment thread hooks/useFeatureflags.ts Outdated
Comment thread hooks/useFeatureflags.ts Outdated
Comment thread lib/config/index.ts Outdated
Comment thread lib/feature-flags.ts Outdated
Comment thread lib/feature-flags.ts Outdated
@arxja
arxja merged commit 4584ecf into main Jul 25, 2026
3 checks passed
@arxja
arxja deleted the feat/built-in-feature-flag branch July 25, 2026 07:19
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.

1 participant