ENG-1217: Port section component in left sidebar#804
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThe PR migrates left-sidebar settings components to new block-prop driven persistence approaches. Global settings now wire GlobalFlagPanel with setGlobalSetting for page operations (add/move/remove), while personal settings implement PersonalNumberPanel with a new sectionsToBlockProps synchronization layer and setPersonalSetting persistence. Zod schemas are updated to use UID-based identifiers and array-based structures. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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. Tip Issue Planner is now in beta. Read the docs and try it out! 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. Comment |
mdroidian
left a comment
There was a problem hiding this comment.
The audio in the loom is mostly inaudible. Please review the looms before submitting.
Also, a couple files are not formatted again.
There's a single comment asking to explain why caused the PersonalNumberPanel to break the pattern from the others. I think it would be worth exploring that deeper to see if there are alternative solutions prior to breaking the pattern.
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/LeftSidebarGlobalSettings.tsx
Outdated
Show resolved
Hide resolved
| export const PersonalNumberPanel = (props: NumberWrapperProps) => ( | ||
| <BaseNumberPanel {...props} {...personalAccessors.number} /> | ||
| export const PersonalNumberPanel = ({ setter, ...props }: NumberWrapperProps) => ( | ||
| <BaseNumberPanel {...props} setter={setter ?? personalAccessors.number.setter} /> |
There was a problem hiding this comment.
Why is this panel breaking the pattern with setter? What is the reason/need for this?
There was a problem hiding this comment.
usually the number panel setters are something that can be reached directly in the tree, but for this case we have an array and insde the array we have the key map. So to get to the numberPanel in this case we have to find the array for which we want to target, therefore we needed a custom setter for it. The standard setter can't target a specific array item so we needed this.
There was a problem hiding this comment.
This reminded me we also have an Alias Field in setting and we should be using a similar solution there so I checked, and I was using old flagpanel component so I ported that also with similar logic. Following is a loom video showing its working state (checked the audio and its working sorry for the one not working one)
Another change I did was move this to graphite stack because we needed a baseTextPanel which had debounce built in
b75a946 to
964b648
Compare
0006f4d to
1d2ba62
Compare
964b648 to
f41175c
Compare
4d1c4f3 to
4fd71df
Compare
1d2ba62 to
4634da5
Compare
4634da5 to
1b440fb
Compare
4fd71df to
56ec7bc
Compare
56ec7bc to
5a2778b
Compare
1b440fb to
586c385
Compare
307dd54 to
5bcf109
Compare
84b5f88 to
eb2aaa7
Compare
5bcf109 to
a679322
Compare
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ Pull watcher handler uses Object.keys() on array after schema change from record to array (apps/roam/src/components/settings/utils/pullWatchers.ts:128-145)
The "Left sidebar" handler in personalSettingsHandlers calls Object.keys(oldValue || {}) and Object.keys(newValue || {}) to compare sections. This was correct when LeftSidebarPersonalSettings was a record (Record<string, PersonalSection>), but the schema was changed in this PR to an array (PersonalSection[]).
Root Cause
With the new array-based schema (apps/roam/src/components/settings/utils/zodSchema.ts:222-224), PersonalSettings["Left sidebar"] is now PersonalSection[]. Calling Object.keys() on an array returns string indices (["0", "1", ...]) rather than section names.
For example, if the old value had 2 sections and the new value has 3 sections:
oldSections=["0", "1"]newSections=["0", "1", "2"]addedSections=["2"](an index, not a section name)
The comparisons at lines 137-138 (newSections.filter((s) => !oldSections.includes(s))) compare array indices instead of meaningful section identifiers, making the added/removed section detection incorrect.
Impact: The debug logging output for left sidebar personal section changes will show array indices instead of section names, making the pull watcher diagnostics misleading. Since this is currently only used for debug logging (the comment says "stub for testing"), the functional impact is limited.
View 14 additional findings in Devin Review.
a679322 to
79d4150
Compare
eb2aaa7 to
26619e2
Compare
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ Pull watcher handler uses Object.keys() on array after schema change from record to array (apps/roam/src/components/settings/utils/pullWatchers.ts:128-145)
The "Left sidebar" handler in personalSettingsHandlers calls Object.keys(oldValue || {}) and Object.keys(newValue || {}) to compare sections. This was correct when LeftSidebarPersonalSettings was a record (Record<string, PersonalSection>), but the schema was changed in this PR to an array (PersonalSection[]).
Root Cause
With the new array-based schema (apps/roam/src/components/settings/utils/zodSchema.ts:222-224), PersonalSettings["Left sidebar"] is now PersonalSection[]. Calling Object.keys() on an array returns string indices (["0", "1", ...]) rather than section names.
For example, if the old value had 2 sections and the new value has 3 sections:
oldSections=["0", "1"]newSections=["0", "1", "2"]addedSections=["2"](an index, not a section name)
The comparisons at lines 137-138 (newSections.filter((s) => !oldSections.includes(s))) compare array indices instead of meaningful section identifiers, making the added/removed section detection incorrect.
Impact: The debug logging output for left sidebar personal section changes will show array indices instead of section names, making the pull watcher diagnostics misleading. Since this is currently only used for debug logging (the comment says "stub for testing"), the functional impact is limited.
View 14 additional findings in Devin Review.
79d4150 to
f87715d
Compare
26619e2 to
ef60df6
Compare
f87715d to
b18c761
Compare
ef60df6 to
5d03b39
Compare
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ Pull watcher handler uses Object.keys() on array after schema change from record to array (apps/roam/src/components/settings/utils/pullWatchers.ts:128-145)
The "Left sidebar" handler in personalSettingsHandlers calls Object.keys(oldValue || {}) and Object.keys(newValue || {}) to compare sections. This was correct when LeftSidebarPersonalSettings was a record (Record<string, PersonalSection>), but the schema was changed in this PR to an array (PersonalSection[]).
Root Cause
With the new array-based schema (apps/roam/src/components/settings/utils/zodSchema.ts:222-224), PersonalSettings["Left sidebar"] is now PersonalSection[]. Calling Object.keys() on an array returns string indices (["0", "1", ...]) rather than section names.
For example, if the old value had 2 sections and the new value has 3 sections:
oldSections=["0", "1"]newSections=["0", "1", "2"]addedSections=["2"](an index, not a section name)
The comparisons at lines 137-138 (newSections.filter((s) => !oldSections.includes(s))) compare array indices instead of meaningful section identifiers, making the added/removed section detection incorrect.
Impact: The debug logging output for left sidebar personal section changes will show array indices instead of section names, making the pull watcher diagnostics misleading. Since this is currently only used for debug logging (the comment says "stub for testing"), the functional impact is limited.
View 14 additional findings in Devin Review.
b595bdc
into
eng-1328-port-small-blueprint-based-misc-settings-into-props-based
specification, config panel) The initial recovery commit claimed to include these but only contained Chain 2 (#793, #794, #805, #804). Chain 1 lives on separate branches that weren't in the merge source. Applied using `gh pr diff` for each PR in order (#764 → #765 → #769). init.ts required manual merge — #765 and #769 both modified it from the same base. Kept #765's safeParse checks inside #769's restructured initializeSettingsBlockProps. - #764 ENG-1280: Port query builder and editor component for block props - #765 ENG-1291: Port discourse node specification - #769 ENG-1290: Port discourse node config panel
…#826) * Land orphaned Graphite stack PRs (#764, #765, #769, #793, #794, #805) These PRs were squash-merged into parent branches instead of main due to a Graphite stack merge race condition. Their changes never landed on main despite showing as merged in Graphite. Includes: - #764 ENG-1280: Port query builder/editor for block props - #765 ENG-1291: Port discourse node specification (dual-write) - #769 ENG-1290: Port discourse node config panel - #793 ENG-1440: Port page groups settings in suggestive mode - #794 ENG-1438: Port keyboard shortcut keys/triggers - #805 ENG-1328: Port small blueprint misc settings * Add #804 ENG-1217: Port section component in left sidebar * Add #764, #765, #769 (Chain 1 orphaned PRs: query builder, specification, config panel) The initial recovery commit claimed to include these but only contained Chain 2 (#793, #794, #805, #804). Chain 1 lives on separate branches that weren't in the merge source. Applied using `gh pr diff` for each PR in order (#764 → #765 → #769). init.ts required manual merge — #765 and #769 both modified it from the same base. Kept #765's safeParse checks inside #769's restructured initializeSettingsBlockProps. - #764 ENG-1280: Port query builder and editor component for block props - #765 ENG-1291: Port discourse node specification - #769 ENG-1290: Port discourse node config panel * fix lint * prettier

https://www.loom.com/share/f375f9fab2864d4ab06cd020eeafeaea
Summary by CodeRabbit
Bug Fixes
Improvements