Skip to content

Comments

ENG-1281: Port discourse node block panel#784

Merged
sid597 merged 5 commits intomainfrom
eng-1281-port-discourse-node-block-panel
Feb 24, 2026
Merged

ENG-1281: Port discourse node block panel#784
sid597 merged 5 commits intomainfrom
eng-1281-port-discourse-node-block-panel

Conversation

@sid597
Copy link
Collaborator

@sid597 sid597 commented Feb 15, 2026

https://www.loom.com/share/e4b407f50f4f47c49919a263c55ef729


Open with Devin

Summary by CodeRabbit

  • Refactor
    • Enhanced template settings configuration with improved synchronization mechanism ensuring more reliable updates and consistent data persistence across the system.
    • Modernized discourse node settings interface with refined configuration management capabilities for improved user control and settings management.
    • Updated settings structure and data handling architecture to provide enhanced real-time synchronization and better overall template configuration workflow performance.

@linear
Copy link

linear bot commented Feb 15, 2026

@supabase
Copy link

supabase bot commented Feb 15, 2026

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

@sid597 sid597 marked this pull request as ready for review February 15, 2026 08:59
devin-ai-integration[bot]

This comment was marked as resolved.

@sid597
Copy link
Collaborator Author

sid597 commented Feb 15, 2026

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new DualWriteBlocksPanel component for managing template settings in discourse node configurations. It replaces the existing BlocksPanel component usage across multiple settings files, removes the template field from SuggestiveRulesSchema, and exports the DiscourseNodeBaseProps type for broader use. The new component includes debounced change handling and Roam pull-watch integration for syncing block-based template data.

Changes

Cohort / File(s) Summary
Template Panel Replacement
apps/roam/src/components/settings/DiscourseNodeSuggestiveRules.tsx, apps/roam/src/components/settings/NodeConfig.tsx
Replaced BlocksPanel with DualWriteBlocksPanel in template settings, changing props from order, parentUid, defaultValue to nodeType, settingKeys, and uid.
New DualWriteBlocksPanel Component
apps/roam/src/components/settings/components/EphemeralBlocksPanel.tsx
Introduces new DualWriteBlocksPanel React component with debounced change handling, tree serialization, and Roam pull-watch integration for syncing block-based template configurations.
Type Exports
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Exported DiscourseNodeBaseProps type to make it available for use in other modules.
Schema Updates
apps/roam/src/components/settings/utils/zodSchema.ts, apps/roam/src/components/settings/utils/zodSchema.example.ts
Removed template field from SuggestiveRulesSchema and example configuration object, simplifying the schema structure.

Sequence Diagram

sequenceDiagram
    participant React Component as DualWriteBlocksPanel
    participant Roam API as Roam DB/API
    participant Debounce Handler as Debounced Handler
    participant Settings Store as Settings Store

    React Component->>Roam API: useEffect: addPullWatch(uid)
    Note over React Component: Mount and listen for changes
    
    React Component->>Roam API: Ensure block exists at uid
    Note over React Component: Create blank block if needed
    
    Roam API->>React Component: Block modified by user
    Note over React Component: Pull-watch detects change
    
    React Component->>Debounce Handler: Trigger debounced handleChange
    Note over Debounce Handler: Wait for debounce delay
    
    Debounce Handler->>Roam API: Read full block tree by uid
    Roam API-->>Debounce Handler: Return block tree
    
    Debounce Handler->>Debounce Handler: serializeBlockTree(tree)
    Note over Debounce Handler: Convert to RoamNodeType[]
    
    Debounce Handler->>Settings Store: setDiscourseNodeSetting(nodeType, settingKey, serialized)
    Settings Store-->>Debounce Handler: Persist changes
    
    React Component->>React Component: Unmount
    React Component->>Roam API: removePullWatch() + cleanup debounce
    Note over React Component: Cleanup lifecycle
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: porting a discourse node block panel component, which aligns with the primary modifications across multiple settings files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into eng-1290-port-discourse-node-config-panelsv0

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@sid597 sid597 requested a review from mdroidian February 15, 2026 16:11
@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from aeb08bf to 97e6a54 Compare February 15, 2026 18:24
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from ed4dfc0 to 60ea738 Compare February 15, 2026 18:24
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Contributor

@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.

Image

@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from 97e6a54 to 6f0eea0 Compare February 16, 2026 08:25
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from 60ea738 to a9e061a Compare February 16, 2026 08:25
devin-ai-integration[bot]

This comment was marked as resolved.

@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from a9e061a to 6baa3dd Compare February 17, 2026 05:16
@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from 6f0eea0 to cd22895 Compare February 17, 2026 05:16
@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from cd22895 to 22adbcc Compare February 17, 2026 15:07
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from 6baa3dd to 05303b8 Compare February 17, 2026 15:07
devin-ai-integration[bot]

This comment was marked as resolved.

@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from 22adbcc to 5ff2835 Compare February 17, 2026 15:37
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from 59ba6a6 to 3c00e79 Compare February 23, 2026 05:11
devin-ai-integration[bot]

This comment was marked as resolved.

@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from fad1443 to 1b467b4 Compare February 23, 2026 10:26
@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from ccde8ce to 13b1031 Compare February 23, 2026 10:26
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from 1b467b4 to 2d39338 Compare February 23, 2026 10:40
@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from 602886e to f7f988c Compare February 23, 2026 13:51
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from 2d39338 to 30de848 Compare February 23, 2026 13:51
@sid597 sid597 requested a review from mdroidian February 23, 2026 14:16
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 16 additional findings in Devin Review.

Open in Devin Review

const el = containerRef.current;
if (!el || !uid) return;

const pattern = "[:block/string :block/order {:block/children ...}]";
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 PullWatch pattern omits :block/heading and :block/open, so changes to those attributes never trigger a sync

The DualWriteBlocksPanel registers a Roam pull watch with pattern [:block/string :block/order {:block/children ...}] (EphemeralBlocksPanel.tsx:56), but the serializeBlockTree function at EphemeralBlocksPanel.tsx:18-28 reads and serializes child.heading and child.open into the output.

Root cause and impact

The pull watch pattern determines which Datomic attribute changes trigger the callback. Since :block/heading and :block/open are absent from the pattern, changing a block's heading level (e.g. normal → H1) or toggling its open/collapsed state will not fire the callback, so setDiscourseNodeSetting is never called for those edits.

However, serializeBlockTree does include these fields:

...(child.heading && { heading: child.heading as 0 | 1 | 2 | 3 }),
...(child.open === false && { open: false }),

This means heading/open changes made in isolation are silently dropped from the block-props settings store. They would only be picked up incidentally if the user also edits text or reorders blocks in the same session. The fix is to add :block/heading and :block/open to the pull pattern:

[:block/string :block/order :block/heading :block/open {:block/children ...}]
Suggested change
const pattern = "[:block/string :block/order {:block/children ...}]";
const pattern = "[:block/string :block/order :block/heading :block/open {:block/children ...}]";
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from cd7e227 to 6e6165a Compare February 23, 2026 16:40
Copy link
Contributor

@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.

A few comments and minor changes.

Specifically, why is the zodSchema being removed for templates?

);

export const SuggestiveRulesSchema = z.object({
template: z.array(RoamNodeSchema).default([]),
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this being removed? is it being replaced with something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have to store the template structure explicitly for suggestiveRulesSchema because

  • firstly suggestive mode shows the template not to edit it but to let the user copy a block uid from the template
  • and even if the user edits it we should be doing it in one place because there is no use for a different version of template, we use the canonical template from the nodes

@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from 6e6165a to cc73405 Compare February 24, 2026 05:46
@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch from 24d516d to 6a8d9ef Compare February 24, 2026 05:46
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from cc73405 to cfa9ba9 Compare February 24, 2026 05:48
@sid597 sid597 force-pushed the eng-1290-port-discourse-node-config-panelsv0 branch 2 times, most recently from a9602ca to ffdae8d Compare February 24, 2026 06:16
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from cfa9ba9 to df9491f Compare February 24, 2026 06:16
@sid597 sid597 changed the base branch from eng-1290-port-discourse-node-config-panelsv0 to graphite-base/784 February 24, 2026 06:29
@sid597 sid597 force-pushed the eng-1281-port-discourse-node-block-panel branch from df9491f to a449e30 Compare February 24, 2026 06:29
@sid597 sid597 changed the base branch from graphite-base/784 to main February 24, 2026 06:29
@sid597 sid597 merged commit 6a44f91 into main Feb 24, 2026
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants