Skip to content

ENG-1479: Port suggestive mode settings to dual-read#845

Merged
sid597 merged 4 commits intomigration-block-init-staging-branchfrom
eng-1479-port-suggestive-mode-settings-to-dual-read-v1
Mar 3, 2026
Merged

ENG-1479: Port suggestive mode settings to dual-read#845
sid597 merged 4 commits intomigration-block-init-staging-branchfrom
eng-1479-port-suggestive-mode-settings-to-dual-read-v1

Conversation

@sid597
Copy link
Collaborator

@sid597 sid597 commented Mar 2, 2026

https://www.loom.com/share/6b740485161741e8b5ddd7d58b5f9891


Open with Devin

Summary by CodeRabbit

  • Refactor
    • Updated feature flag access to use a centralized mechanism with diagnostic support for configuration compatibility.
    • Streamlined how settings are retrieved across the admin panel and suggestive mode components.

Add dual-read routing to getFeatureFlag for flags with legacy counterparts.
FEATURE_FLAG_LEGACY_MAP maps "Suggestive mode enabled" and "Enable left
sidebar" to their config tree reads, gated by isNewSettingsStoreEnabled().
Flags without legacy entries go straight to block props (no behavior change).

Migrate value reads from getFormattedConfigTree() / extensionAPI.settings
to accessors:

- index.ts: getUidAndBooleanSetting → getFeatureFlag (accessor handles
  legacy fallback now)
- AdminPanel: suggestiveModeEnabled.value → getFeatureFlag in both
  FeatureFlagsTab and main component. Removed unused useMemo.
- SuggestiveModeSettings: includePageRelations state init →
  getGlobalSetting. Dropped initialValue from both GlobalFlagPanels.
- hyde.ts: orphan extensionAPI.settings.get() reads →
  getGlobalSetting. Fixes bug where sync config toggles had no
  runtime effect (keys were never written by any code).

Structural UIDs remain with getFormattedConfigTree().
pageGroups.groups NOT migrated — type mismatch (legacy PageGroup has
UIDs, Zod PageGroup does not). Deferred to ENG-1470.
@linear
Copy link

linear bot commented Mar 2, 2026

@supabase
Copy link

supabase bot commented Mar 2, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@sid597
Copy link
Collaborator Author

sid597 commented Mar 2, 2026

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

✅ Actions performed

Full review triggered.

devin-ai-integration[bot]

This comment was marked as resolved.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

This PR migrates feature flag access from legacy config-tree paths to a centralized mechanism via getFeatureFlag(). The new function provides dual-read support with fallback logic: it checks a legacy mapping first, then reads from block-props, and logs mismatches when both sources exist. Components across settings UI and initialization code are updated to use this new accessor instead of direct config tree reads.

Changes

Cohort / File(s) Summary
Feature Flag Accessor Layer
apps/roam/src/components/settings/utils/accessors.ts
Added new getFeatureFlag() function implementing dual-read logic with legacy-map fallback, mismatch diagnostics, and support for "Suggestive mode enabled" and "Enable left sidebar" flags.
Feature Flag Migrations
apps/roam/src/components/settings/AdminPanel.tsx, apps/roam/src/index.ts
Replaced direct settings.suggestiveModeEnabled.value and Roam config-tree reads with getFeatureFlag("Suggestive mode enabled") for centralized flag access.
Settings Accessor Migrations
apps/roam/src/components/settings/SuggestiveModeSettings.tsx, apps/roam/src/utils/hyde.ts
Updated to use getGlobalSetting() for retrieving boolean settings ("Include current page relations", "Include parent and child blocks") instead of legacy extension-API or direct initialValue reads.

Sequence Diagram

sequenceDiagram
    participant Component as Component<br/>(e.g., AdminPanel)
    participant getFeatureFlag as getFeatureFlag()<br/>Accessor
    participant LegacyMap as FEATURE_FLAG_LEGACY_MAP
    participant BlockProps as getFeatureFlags()<br/>(Block Props)
    participant LegacyConfig as getFormattedConfigTree()<br/>(Legacy Config)

    Component->>getFeatureFlag: getFeatureFlag(key)
    getFeatureFlag->>LegacyMap: Check if legacy reader exists
    alt Legacy reader found
        LegacyMap-->>getFeatureFlag: Legacy reader fn
        getFeatureFlag->>BlockProps: getFeatureFlags()
        BlockProps-->>getFeatureFlag: blockPropsValue
        alt New settings store enabled
            getFeatureFlag->>LegacyConfig: Call legacy reader fn
            LegacyConfig-->>getFeatureFlag: legacyValue
            alt Values mismatch
                getFeatureFlag->>getFeatureFlag: Log mismatch warning
            end
            getFeatureFlag-->>Component: Return blockPropsValue
        else Legacy settings only
            getFeatureFlag-->>Component: Return legacyValue
        end
    else No legacy reader
        getFeatureFlag->>BlockProps: getFeatureFlags()
        BlockProps-->>getFeatureFlag: value
        getFeatureFlag-->>Component: Return value
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main change: porting suggestive mode settings to a dual-read mechanism. It aligns with the PR's core objective of implementing dual-read logic for feature flags with legacy support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

coderabbitai[bot]

This comment was marked as resolved.

@sid597 sid597 requested a review from mdroidian March 2, 2026 17:04
@sid597 sid597 merged commit f44707f into migration-block-init-staging-branch Mar 3, 2026
9 checks passed
sid597 added a commit that referenced this pull request Mar 3, 2026
* ENG-1479: Port suggestive mode settings to dual-read

Add dual-read routing to getFeatureFlag for flags with legacy counterparts.
FEATURE_FLAG_LEGACY_MAP maps "Suggestive mode enabled" and "Enable left
sidebar" to their config tree reads, gated by isNewSettingsStoreEnabled().
Flags without legacy entries go straight to block props (no behavior change).

Migrate value reads from getFormattedConfigTree() / extensionAPI.settings
to accessors:

- index.ts: getUidAndBooleanSetting → getFeatureFlag (accessor handles
  legacy fallback now)
- AdminPanel: suggestiveModeEnabled.value → getFeatureFlag in both
  FeatureFlagsTab and main component. Removed unused useMemo.
- SuggestiveModeSettings: includePageRelations state init →
  getGlobalSetting. Dropped initialValue from both GlobalFlagPanels.
- hyde.ts: orphan extensionAPI.settings.get() reads →
  getGlobalSetting. Fixes bug where sync config toggles had no
  runtime effect (keys were never written by any code).

Structural UIDs remain with getFormattedConfigTree().
pageGroups.groups NOT migrated — type mismatch (legacy PageGroup has
UIDs, Zod PageGroup does not). Deferred to ENG-1470.

* Align hyde.ts fallback defaults with Zod schema

* Fix eslint naming-convention warnings in FEATURE_FLAG_LEGACY_MAP

* Add TODO(ENG-1484) for suggestive mode reactivity
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.

2 participants