-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1197: fix personal settings migration, for all users insted of only the user who instantiated it #639
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
ENG-1197: fix personal settings migration, for all users insted of only the user who instantiated it #639
Conversation
…r who instantiated it
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughExtends the Left Sidebar settings utilities to support multi-user aggregation of personal sections. Introduces Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks✅ Passed checks (3 passed)
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 |
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.
Actionable comments posted: 0
🧹 Nitpick comments (4)
apps/roam/src/utils/migrateLeftSidebarSettings.ts (2)
54-73: Potential double migration of current user's personal sections.The existing logic at lines 54-60 migrates
leftSidebarSettings.personal.sections(current user's sections), and the new loop at lines 64-73 iterates overallPersonalSectionswhich includes all users—including the current user. This means the current user's sections may be migrated twice.While
migrateSectionChildrenappears idempotent (it skips items that are already UIDs viagetPageTitleByPageUidcheck at line 16), processing the same data twice is inefficient.Consider either:
- Removing the original personal sections migration (lines 54-60) since
allPersonalSectionsnow covers all users, or- Filtering out the current user from
allPersonalSectionsiteration.Option 1: Remove redundant original personal sections migration
- const personalSections = leftSidebarSettings.personal.sections; - for (const section of personalSections) { - const children = section.children || []; - if (children.length > 0) { - await migrateSectionChildren(children); - } - } - const allPersonalSections = leftSidebarSettings.allPersonalSections; for (const [_, userPersonalSection] of Object.entries(
39-39: Add explicit return type for the function.As per coding guidelines, functions should have explicit return types.
Proposed fix
-export const migrateLeftSidebarSettings = async () => { +export const migrateLeftSidebarSettings = async (): Promise<void> => {apps/roam/src/utils/getLeftSidebarSettings.ts (2)
185-201: Add blank line before function and explicit return type.Minor formatting and coding guidelines improvements:
- Add a blank line before the function declaration for better readability.
- Add explicit return type as per coding guidelines.
Proposed fix
+ export const getAllLeftSidebarPersonalSectionConfigs = ( leftSidebarChildren: RoamBasicNode[], -): AllUsersPersonalSections => { +): AllUsersPersonalSections => { const result: AllUsersPersonalSections = {};Note: The return type is already present, so only the blank line needs to be added before line 185.
212-214: Track the TODO for removal after migration.The TODO comment indicates
allPersonalSectionsshould be removed after migration is complete. Consider creating an issue to track this cleanup task to ensure it doesn't get forgotten.Would you like me to open an issue to track the removal of
allPersonalSectionsafter the migration is complete?
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/roam/src/utils/getLeftSidebarSettings.tsapps/roam/src/utils/migrateLeftSidebarSettings.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/main.mdc)
**/*.{ts,tsx}: Use Tailwind CSS for styling where possible
When refactoring inline styles, use tailwind classes
Prefertypeoverinterfacein TypeScript
Use explicit return types for functions
Avoidanytypes when possible
Prefer arrow functions over regular function declarations
Use named parameters (object destructuring) when a function has more than 2 parameters
Use PascalCase for components and types
Use camelCase for variables and functions
Use UPPERCASE for constants
Function names should describe their purpose clearly
Prefer early returns over nested conditionals for better readability
Files:
apps/roam/src/utils/migrateLeftSidebarSettings.tsapps/roam/src/utils/getLeftSidebarSettings.ts
apps/roam/**/*.{js,ts,tsx,jsx,json}
📄 CodeRabbit inference engine (.cursor/rules/roam.mdc)
Prefer existing dependencies from package.json when working on the Roam Research extension
Files:
apps/roam/src/utils/migrateLeftSidebarSettings.tsapps/roam/src/utils/getLeftSidebarSettings.ts
apps/roam/**/*.{ts,tsx,jsx,js,css,scss}
📄 CodeRabbit inference engine (.cursor/rules/roam.mdc)
Use BlueprintJS 3 components and Tailwind CSS for platform-native UI in the Roam Research extension
Files:
apps/roam/src/utils/migrateLeftSidebarSettings.tsapps/roam/src/utils/getLeftSidebarSettings.ts
apps/roam/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/roam.mdc)
apps/roam/**/*.{ts,tsx,js,jsx}: Use the roamAlphaApi docs from https://roamresearch.com/#/app/developer-documentation/page/tIaOPdXCj when implementing Roam functionality
Use Roam Depot/Extension API docs from https://roamresearch.com/#/app/developer-documentation/page/y31lhjIqU when implementing extension functionality
Files:
apps/roam/src/utils/migrateLeftSidebarSettings.tsapps/roam/src/utils/getLeftSidebarSettings.ts
apps/roam/**
📄 CodeRabbit inference engine (.cursor/rules/roam.mdc)
Implement the Discourse Graph protocol in the Roam Research extension
Files:
apps/roam/src/utils/migrateLeftSidebarSettings.tsapps/roam/src/utils/getLeftSidebarSettings.ts
🔇 Additional comments (3)
apps/roam/src/utils/getLeftSidebarSettings.ts (3)
129-134: LGTM!The type definition is clean, uses
typeoverinterfaceas per guidelines, and the index signature appropriately models the dynamic user UID keys.
136-144: LGTM!The optional
userUidparameter with nullish coalescing fallback to the current user maintains backward compatibility while enabling per-user section retrieval. Clean implementation.
223-230: LGTM!The integration of
allPersonalSectionsinto the return object is correct and type-safe, properly matching the updatedLeftSidebarConfigtype.

Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.