Skip to content

Commit f17cf3e

Browse files
committed
ENG-1756: Preserve existing feature flag block-prop values during legacy migration
readAllLegacyFeatureFlags only sources Enable left sidebar from legacy config. The migration wrote the full FeatureFlags object (with Zod defaults filling the unsourced keys as false) via setBlockProps, which clobbered any pre-existing true values for Duplicate node alert enabled and Suggestive mode overlay enabled. Expose LEGACY_SOURCED_FEATURE_FLAG_KEYS to identify which keys the legacy reader actually sources. The migration now overlays only those keys onto the existing block-prop values, leaving everything else untouched.
1 parent 6d66a6b commit f17cf3e

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

apps/roam/src/components/settings/utils/accessors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ export const isNewSettingsStoreEnabled = (): boolean => {
716716
return getFeatureFlag("Use new settings store");
717717
};
718718

719+
export const LEGACY_SOURCED_FEATURE_FLAG_KEYS = Object.keys(
720+
FEATURE_FLAG_LEGACY_MAP,
721+
) as Array<keyof FeatureFlags>;
722+
719723
export const readAllLegacyFeatureFlags = (): Partial<FeatureFlags> => {
720724
const flags: Partial<FeatureFlags> = {};
721725
for (const [key, reader] of Object.entries(FEATURE_FLAG_LEGACY_MAP)) {

apps/roam/src/components/settings/utils/migrateLegacyToBlockProps.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { createBlock } from "roamjs-components/writes";
66
import { getSetting, setSetting } from "~/utils/extensionSettings";
77
import internalError from "~/utils/internalError";
88
import {
9+
LEGACY_SOURCED_FEATURE_FLAG_KEYS,
910
readAllLegacyFeatureFlags,
1011
readAllLegacyGlobalSettings,
1112
readAllLegacyPersonalSettings,
@@ -199,12 +200,21 @@ export const migrateGraphLevel = async (
199200
failures++;
200201
} else {
201202
const legacyFlags = readAllLegacyFeatureFlags();
203+
const mergedFlags: Record<string, json> = {
204+
...getBlockProps(featureFlagUid),
205+
};
206+
for (const key of LEGACY_SOURCED_FEATURE_FLAG_KEYS) {
207+
const value = legacyFlags[key];
208+
if (value !== undefined) {
209+
mergedFlags[key] = value;
210+
}
211+
}
202212
if (
203213
!migrateSection({
204214
label: "Feature Flags",
205215
blockUid: featureFlagUid,
206216
schema: FeatureFlagsSchema,
207-
legacyData: legacyFlags as Record<string, unknown>,
217+
legacyData: mergedFlags,
208218
})
209219
) {
210220
failures++;

0 commit comments

Comments
 (0)