-
Notifications
You must be signed in to change notification settings - Fork 4
Eng 1616 add getconfigtree equivalent for block pros on init #944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sid597
merged 7 commits into
eng-1470-test-dual-read-with-flag-on-and-fix-gapsv2
from
eng-1616-add-getconfigtree-equivalent-for-block-pros-on-init
Apr 15, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
343dc11
ENG-1616: Bulk-read settings + thread snapshot (with timing logs)
sid597 4d5c720
ENG-1616: Remove plugin-load timing logs
sid597 b13d401
ENG-1616: Address review — typed indexing, restore dgDualReadLog, opt…
sid597 4140f5c
ENG-1616: Log total plugin load time
sid597 aea086d
ENG-1616: Tighten init-only leaves to required snapshot, AGENTS.md co…
sid597 24e521b
ENG-1616: Address review — rename snapshot vars, flag-gate bulkRead, …
sid597 b15b0ab
Fix legacy bulk settings fallback
sid597 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -863,8 +863,10 @@ export const setGlobalSetting = (keys: string[], value: json): void => { | |
| }); | ||
| }; | ||
|
|
||
| export const getAllRelations = (): DiscourseRelation[] => { | ||
| const settings = getGlobalSettings(); | ||
| export const getAllRelations = ( | ||
| snapshot?: SettingsSnapshot, | ||
| ): DiscourseRelation[] => { | ||
| const settings = snapshot ? snapshot.globalSettings : getGlobalSettings(); | ||
|
|
||
| return Object.entries(settings.Relations).flatMap(([id, relation]) => | ||
| relation.ifConditions.map((ifCondition) => ({ | ||
|
|
@@ -909,6 +911,61 @@ export const getPersonalSetting = <T = unknown>( | |
| return blockPropsValue as T | undefined; | ||
| }; | ||
|
|
||
| export type SettingsSnapshot = { | ||
| featureFlags: FeatureFlags; | ||
| globalSettings: GlobalSettings; | ||
| personalSettings: PersonalSettings; | ||
| }; | ||
|
|
||
| export const bulkReadSettings = (): SettingsSnapshot => { | ||
| const pageResult = window.roamAlphaAPI.pull( | ||
| "[{:block/children [:block/string :block/props]}]", | ||
| [":node/title", DG_BLOCK_PROP_SETTINGS_PAGE_TITLE], | ||
| ) as Record<string, json> | null; | ||
|
|
||
| const children = (pageResult?.[":block/children"] ?? []) as Record< | ||
| string, | ||
| json | ||
| >[]; | ||
| const personalKey = getPersonalSettingsKey(); | ||
| let featureFlagsProps: json = {}; | ||
| let globalProps: json = {}; | ||
| let personalProps: json = {}; | ||
|
|
||
| for (const child of children) { | ||
| const text = child[":block/string"]; | ||
| if (typeof text !== "string") continue; | ||
| const rawBlockProps = child[":block/props"]; | ||
| const blockProps = | ||
| rawBlockProps && typeof rawBlockProps === "object" | ||
| ? normalizeProps(rawBlockProps) | ||
| : {}; | ||
| if (text === TOP_LEVEL_BLOCK_PROP_KEYS.featureFlags) { | ||
| featureFlagsProps = blockProps; | ||
| } else if (text === TOP_LEVEL_BLOCK_PROP_KEYS.global) { | ||
| globalProps = blockProps; | ||
| } else if (text === personalKey) { | ||
| personalProps = blockProps; | ||
| } | ||
| } | ||
|
|
||
| const featureFlags = FeatureFlagsSchema.parse(featureFlagsProps || {}); | ||
|
|
||
| if (!featureFlags["Use new settings store"]) { | ||
| return { | ||
| featureFlags, | ||
| globalSettings: readAllLegacyGlobalSettings() as GlobalSettings, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| personalSettings: readAllLegacyPersonalSettings() as PersonalSettings, | ||
| }; | ||
|
sid597 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| return { | ||
| featureFlags, | ||
| globalSettings: GlobalSettingsSchema.parse(globalProps || {}), | ||
| personalSettings: PersonalSettingsSchema.parse(personalProps || {}), | ||
| }; | ||
| }; | ||
|
|
||
| export const setPersonalSetting = (keys: string[], value: json): void => { | ||
| if (keys.length === 0) { | ||
| internalError({ | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe
getPersonalSettingwas checking ifisNewSettingsStoreEnabled, but it doesn't look likebulkReadSettingsis doing this anymore.Specifically example would be:
const disallowDiagnostics = settingsSnapshot.personalSettings[PERSONAL_KEYS.disableProductDiagnostics];If the new store settings aren't enabled, would the migration have happened yet?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the check, I missed it.