ENG-1465: Add "Use new settings store" feature flag #811
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThis PR introduces a new feature flag "Use new settings store" that enables reading accessor getters from block props instead of the old system. The flag is added to the schema, exposed in the admin UI, and the initialization flow is extended to set up pull-watchers on the settings page. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
d88de41 to
1d2ba62
Compare
3f08f30 to
0006f4d
Compare
1d2ba62 to
4634da5
Compare
23d75a0 to
9dddded
Compare
1b440fb to
586c385
Compare
9dddded to
41691df
Compare
41691df to
176d0d1
Compare
2f1d7d7 to
a8420de
Compare
176d0d1 to
86bbad9
Compare
a8420de to
307dd54
Compare
9ab2003 to
64767b4
Compare
97f27cd to
9d0b4f6
Compare
f87715d to
b18c761
Compare
f81fbc0 to
b34c8a3
Compare
081c714 to
57545ba
Compare
57545ba to
6a44f91
Compare
b34c8a3 to
22f4573
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/roam/src/components/settings/utils/accessors.ts (1)
288-291: Optional: simplify to expression body.The function body is a single
returnstatement; an expression arrow matches the style ofgetFeatureFlagdirectly above it.♻️ Proposed simplification
-export const isNewSettingsStoreEnabled = (): boolean => { - return getFeatureFlag("Use new settings store"); -}; +export const isNewSettingsStoreEnabled = (): boolean => + getFeatureFlag("Use new settings store");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/roam/src/components/settings/utils/accessors.ts` around lines 288 - 291, The function isNewSettingsStoreEnabled has a single return statement; simplify it to an expression-bodied arrow to match the surrounding style (like getFeatureFlag) by replacing the block body with a concise expression returning getFeatureFlag("Use new settings store"); keep the same function name isNewSettingsStoreEnabled and behavior.apps/roam/src/components/settings/AdminPanel.tsx (1)
468-473:getFeatureFlagcalled at render time causes unnecessary Roam API calls; confirm need for memoization.
getFeatureFlag("Use new settings store")is evaluated on every re-render ofFeatureFlagsTab(triggered by state changes likeisAlertOpen,isInstructionOpen), which invokesgetBlockUidByTextOnPageandgetBlockPropseach time. WhileBaseFlagPanelcorrectly usesuseState(() => initialValue ?? false)to initialize state only once, re-computing the initial value on every parent render is wasteful and causes unnecessary Roam API calls.The
RoamBlockSyncPropsfields (parentUid,uid,order) are all optional and do not need to be passed here.♻️ Optional refactor to memoize the feature flag value
const FeatureFlagsTab = (): React.ReactElement => { ... + const [isNewSettingsStoreEnabled] = useState(() => + getFeatureFlag("Use new settings store"), + ); ... <FeatureFlagPanel title="Use new settings store" description="When enabled, accessor getters read from block props instead of the old system. Surfaces dual-write gaps during development." featureKey="Use new settings store" - initialValue={getFeatureFlag("Use new settings store")} + initialValue={isNewSettingsStoreEnabled} />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/roam/src/components/settings/AdminPanel.tsx` around lines 468 - 473, The call to getFeatureFlag("Use new settings store") in FeatureFlagsTab causes Roam API calls on every render; change FeatureFlagPanel usage so the initialValue is memoized or computed once (e.g., compute value with useMemo or initialize a local state once) and pass that memoized/initialized boolean to FeatureFlagPanel instead of calling getFeatureFlag directly during render. Locate FeatureFlagsTab and replace the direct getFeatureFlag(...) call with a stable value (memoized or via useState(() => getFeatureFlag(...))) so BaseFlagPanel’s useState(() => initialValue ?? false) only runs once; also remove the unnecessary optional RoamBlockSyncProps (parentUid, uid, order) from the props passed to FeatureFlagPanel.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/roam/src/components/settings/AdminPanel.tsx`:
- Around line 468-473: The call to getFeatureFlag("Use new settings store") in
FeatureFlagsTab causes Roam API calls on every render; change FeatureFlagPanel
usage so the initialValue is memoized or computed once (e.g., compute value with
useMemo or initialize a local state once) and pass that memoized/initialized
boolean to FeatureFlagPanel instead of calling getFeatureFlag directly during
render. Locate FeatureFlagsTab and replace the direct getFeatureFlag(...) call
with a stable value (memoized or via useState(() => getFeatureFlag(...))) so
BaseFlagPanel’s useState(() => initialValue ?? false) only runs once; also
remove the unnecessary optional RoamBlockSyncProps (parentUid, uid, order) from
the props passed to FeatureFlagPanel.
In `@apps/roam/src/components/settings/utils/accessors.ts`:
- Around line 288-291: The function isNewSettingsStoreEnabled has a single
return statement; simplify it to an expression-bodied arrow to match the
surrounding style (like getFeatureFlag) by replacing the block body with a
concise expression returning getFeatureFlag("Use new settings store"); keep the
same function name isNewSettingsStoreEnabled and behavior.
ℹ️ Review info
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/roam/src/components/settings/AdminPanel.tsxapps/roam/src/components/settings/utils/accessors.tsapps/roam/src/components/settings/utils/zodSchema.example.tsapps/roam/src/components/settings/utils/zodSchema.tsapps/roam/src/index.ts
0ff501b to
017e4da
Compare
017e4da to
990543f
Compare
3ad8656 to
4f5eb59
Compare
990543f to
1491bbf
Compare

https://www.loom.com/share/ada47787b17b48c78d46ecbf1e44c0c6
add caller
Summary by CodeRabbit