ENG-1281: Port discourse node block panel#784
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThis PR introduces a new Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ 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. Comment |
aeb08bf to
97e6a54
Compare
ed4dfc0 to
60ea738
Compare
97e6a54 to
6f0eea0
Compare
60ea738 to
a9e061a
Compare
a9e061a to
6baa3dd
Compare
6f0eea0 to
cd22895
Compare
cd22895 to
22adbcc
Compare
6baa3dd to
05303b8
Compare
22adbcc to
5ff2835
Compare
59ba6a6 to
3c00e79
Compare
fad1443 to
1b467b4
Compare
ccde8ce to
13b1031
Compare
1b467b4 to
2d39338
Compare
602886e to
f7f988c
Compare
2d39338 to
30de848
Compare
| const el = containerRef.current; | ||
| if (!el || !uid) return; | ||
|
|
||
| const pattern = "[:block/string :block/order {:block/children ...}]"; |
There was a problem hiding this comment.
🟡 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 ...}]
| const pattern = "[:block/string :block/order {:block/children ...}]"; | |
| const pattern = "[:block/string :block/order :block/heading :block/open {:block/children ...}]"; |
Was this helpful? React with 👍 or 👎 to provide feedback.
cd7e227 to
6e6165a
Compare
mdroidian
left a comment
There was a problem hiding this comment.
A few comments and minor changes.
Specifically, why is the zodSchema being removed for templates?
apps/roam/src/components/settings/components/EphemeralBlocksPanel.tsx
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/components/EphemeralBlocksPanel.tsx
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/components/EphemeralBlocksPanel.tsx
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/components/EphemeralBlocksPanel.tsx
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/components/EphemeralBlocksPanel.tsx
Outdated
Show resolved
Hide resolved
| ); | ||
|
|
||
| export const SuggestiveRulesSchema = z.object({ | ||
| template: z.array(RoamNodeSchema).default([]), |
There was a problem hiding this comment.
why is this being removed? is it being replaced with something?
There was a problem hiding this comment.
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
6e6165a to
cc73405
Compare
24d516d to
6a8d9ef
Compare
cc73405 to
cfa9ba9
Compare
a9602ca to
ffdae8d
Compare
cfa9ba9 to
df9491f
Compare
df9491f to
a449e30
Compare
ffdae8d to
277aca6
Compare


https://www.loom.com/share/e4b407f50f4f47c49919a263c55ef729
Summary by CodeRabbit