Skip to content

ENG-1047 Repair setBlockProps#542

Merged
maparent merged 1 commit intomainfrom
eng-1047-repair-setblockprops
Nov 16, 2025
Merged

ENG-1047 Repair setBlockProps#542
maparent merged 1 commit intomainfrom
eng-1047-repair-setblockprops

Conversation

@maparent
Copy link
Copy Markdown
Collaborator

@maparent maparent commented Nov 11, 2025

https://linear.app/discourse-graphs/issue/ENG-1047/repair-setblockprops
Problem: If I setBlockProp repeatedly, the old values get repeated with increased : nesting.
Eg: (Having put getBlockProps and setBlockProps in the index)

window.roamjs.extension.queryBuilder.getBlockProps('DFPKL0i51')
-> {}
window.roamjs.extension.queryBuilder.setBlockProps('DFPKL0i51', {a:1})
-> {a: 1}
window.roamjs.extension.queryBuilder.setBlockProps('DFPKL0i51', {a:2})
-> {:a: 1, a: 2}
window.roamjs.extension.queryBuilder.setBlockProps('DFPKL0i51', {a:3})
-> {::a: 1, :a: 2, a: 3}
window.roamjs.extension.queryBuilder.getBlockProps('DFPKL0i51')
-> {a: 3}

The way getBlockProps is programmed makes this invisible, but it is visible when pulling the props.
Solution: In the not-denormalized case, make sure to normalize the incoming old props before updating.

Summary by CodeRabbit

  • Bug Fixes
    • Improved block property handling with conditional normalization logic to ensure consistent and correct behavior when setting block properties.

@linear
Copy link
Copy Markdown

linear bot commented Nov 11, 2025

@supabase
Copy link
Copy Markdown

supabase bot commented Nov 11, 2025

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 ↗︎.

@maparent
Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 11, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 11, 2025

📝 Walkthrough

Walkthrough

Modified setBlockProps.ts to add conditional normalization of block properties. The function now retrieves raw properties and conditionally applies normalizeProps() based on a denormalize flag, whereas previously base properties were retrieved without a normalization step.

Changes

Cohort / File(s) Change Summary
Property normalization logic
apps/roam/src/utils/setBlockProps.ts
Added import of normalizeProps and introduced conditional normalization: baseProps is now computed as normalizeProps(rawBaseProps) unless denormalize is explicitly true; previously baseProps was directly retrieved via getRawBlockProps(uid).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that the denormalize flag is properly propagated and handled throughout the function and in all call sites
  • Confirm that conditional normalization logic produces expected behavior for both true and false cases

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ENG-1047 Repair setBlockProps' clearly identifies the specific bug fix (setBlockProps function repair) referenced in the PR objectives, directly matching the main change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de69756 and 403d823.

📒 Files selected for processing (1)
  • apps/roam/src/utils/setBlockProps.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/main.mdc)

**/*.{ts,tsx}: Prefer type over interface
Use explicit return types for functions
Avoid any types when possible

Files:

  • apps/roam/src/utils/setBlockProps.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/main.mdc)

**/*.{ts,tsx,js,jsx}: Prefer arrow functions over regular function declarations
Use named parameters (object destructuring) when a function has more than 2 parameters
Use Prettier with the project's configuration
Maintain consistent naming conventions: PascalCase for components and types
Maintain consistent naming conventions: camelCase for variables and functions
Maintain consistent naming conventions: UPPERCASE for constants

Files:

  • apps/roam/src/utils/setBlockProps.ts
apps/roam/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/roam.mdc)

apps/roam/**/*.{js,jsx,ts,tsx}: Use BlueprintJS 3 components and Tailwind CSS for platform-native UI in the Roam Research extension
Use the roamAlphaApi documentation from https://roamresearch.com/#/app/developer-documentation/page/tIaOPdXCj when working with the Roam API
Use Roam Depot/Extension API documentation from https://roamresearch.com/#/app/developer-documentation/page/y31lhjIqU when working with the Roam Extension API

Files:

  • apps/roam/src/utils/setBlockProps.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: maparent
Repo: DiscourseGraphs/discourse-graph PR: 0
File: :0-0
Timestamp: 2025-11-06T13:48:35.007Z
Learning: In apps/roam/src/utils/createReifiedBlock.ts, the `setBlockProps` function does not need await as it is synchronous or fire-and-forget.
📚 Learning: 2025-11-06T13:48:35.007Z
Learnt from: maparent
Repo: DiscourseGraphs/discourse-graph PR: 0
File: :0-0
Timestamp: 2025-11-06T13:48:35.007Z
Learning: In apps/roam/src/utils/createReifiedBlock.ts, the `setBlockProps` function does not need await as it is synchronous or fire-and-forget.

Applied to files:

  • apps/roam/src/utils/setBlockProps.ts
🔇 Additional comments (1)
apps/roam/src/utils/setBlockProps.ts (1)

27-28: Normalization fix looks good

Pulling the raw props once and normalizing them when denormalize is false prevents the runaway :a, ::a, … key duplication while leaving the denormalized path untouched. Nice targeted fix.


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.

@maparent maparent requested a review from mdroidian November 11, 2025 21:21
Copy link
Copy Markdown
Member

@mdroidian mdroidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@maparent maparent merged commit a8d9f88 into main Nov 16, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this to Done in General Nov 16, 2025
@maparent maparent deleted the eng-1047-repair-setblockprops branch November 16, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants