Skip to content

ENG-1345: Modify existing RoamJS component onChange to also change props#745

Merged
sid597 merged 2 commits intomainfrom
eng-1345-modify-existing-roamjs-component-onchange-to-also-change
Feb 6, 2026
Merged

ENG-1345: Modify existing RoamJS component onChange to also change props#745
sid597 merged 2 commits intomainfrom
eng-1345-modify-existing-roamjs-component-onchange-to-also-change

Conversation

@sid597
Copy link
Collaborator

@sid597 sid597 commented Feb 3, 2026

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


Open with Devin

Summary by CodeRabbit

  • New Features

    • Settings panels now support synchronization with Roam blocks, enabling persistent configuration storage and management across your workspace.
  • Improvements

    • Refactored export settings interface with updated panel organization, clearer titles, and improved configuration options.
    • Enhanced all settings panels with block-based synchronization capabilities.

@linear
Copy link

linear bot commented Feb 3, 2026

@supabase
Copy link

supabase bot commented Feb 3, 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 changed the title Save to both roam block and block props ENG-1345: Modify existing RoamJS component onChange to also change props Feb 3, 2026
@sid597 sid597 marked this pull request as ready for review February 3, 2026 16:52
Copy link

@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: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional flags.

Open in Devin Review

@sid597 sid597 force-pushed the eng-1345-modify-existing-roamjs-component-onchange-to-also-change branch from 82e3f74 to c022156 Compare February 3, 2026 17:58
@sid597
Copy link
Collaborator Author

sid597 commented Feb 3, 2026

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

✅ Actions performed

Full review triggered.

Copy link

@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 issue and 7 additional flags in Devin Review.

Open in Devin Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

Updates settings panels in ExportSettings to use Global variants with block synchronization support. Extends all Base*Panel types with RoamBlockSyncProps to enable Roam block syncing across settings panels. Reinstates schema watcher initialization in the onload flow at two points.

Changes

Cohort / File(s) Summary
Settings Panel Migration
apps/roam/src/components/settings/ExportSettings.tsx
Replaced FlagPanel, NumberPanel, MultiTextPanel, and SelectPanel with Global variants. Removed value props, introduced settingKeys and defaultValue props. Updated component function signature to remove unused destructured parameter. Changed import source to local BlockPropSettingPanels module.
Block Synchronization Infrastructure
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Added RoamBlockSyncProps type (parentUid, uid, order). Extended all five Base*PanelProps types (Text, Flag, Number, Select, MultiText) with block sync props. Implemented block synchronization logic in each panel: computes hasBlockSync state, uses useSingleChildValue utility, triggers sync functions on value changes, manages parent/child block creation and deletion for MultiText panels, and adds debug logging throughout.
Schema Watcher Initialization
apps/roam/src/index.ts
Reinstated schema watcher setup blocks at two points in the onload flow, each creating separate blockUids and nodePageUids cleanup handles via setupPullWatchOnSettingsPage and setupPullWatchDiscourseNodes utilities.

Sequence Diagram

sequenceDiagram
    participant User as User (UI)
    participant Panel as Global*Panel<br/>(Base Panel Component)
    participant Roam as Roam Block<br/>(Storage)
    
    User->>Panel: Change setting value
    Panel->>Panel: Detect change event
    alt hasBlockSync is true
        Panel->>Panel: Prepare block sync operation
        Panel->>Roam: Create/Update/Delete block<br/>(via syncToBlock or syncFlagToBlock)
        Roam-->>Panel: Block operation complete
    else hasBlockSync is false
        Panel->>Panel: No block sync needed
    end
    Panel->>User: Update UI with new value
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title references modifying RoamJS component onChange to update props, which partially aligns with the changes (adding block sync props), but obscures the main change: replacing panels with Global variants and adding Roam block synchronization across multiple files. Consider a more descriptive title that captures the primary changes: replacing panel components with Global variants and introducing block synchronization, e.g., 'Replace ConfigPanels with Global variants and add block synchronization'.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx (1)

96-107: ⚠️ Potential issue | 🟡 Minor

Add explicit return types to all panel components.
All Base* and wrapper panels (BaseTextPanel, BaseFlagPanel, BaseNumberPanel, BaseSelectPanel, BaseMultiTextPanel, and their exported Global*/Personal* wrappers) lack explicit return type annotations. Add : JSX.Element to align with the TypeScript guideline requiring explicit return types for functions.

♻️ Example fix (apply to all panels)
-const BaseTextPanel = ({
+const BaseTextPanel = ({
   title,
   description,
   settingKeys,
   getter,
   setter,
   defaultValue = "",
   placeholder,
   parentUid,
   uid,
   order,
-}: BaseTextPanelProps) => {
+}: BaseTextPanelProps): JSX.Element => {
🤖 Fix all issues with AI agents
In `@apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx`:
- Around line 127-130: Remove the temporary debug setTimeout/console.log
statements in BlockPropSettingPanels.tsx (the blocks invoking setTimeout(() => {
console.log(`[TextPanel] "${title}" blockProp:`, getter(settingKeys)); }, 500))
and identical calls at the other locations (lines referencing title, getter, and
settingKeys); either delete these statements or wrap them behind a centralized
debug flag/ENV check (e.g., isDebugLogging) so logs only run when explicitly
enabled.

In `@apps/roam/src/index.ts`:
- Around line 163-166: The TODO comment saying "REMOVE stub call after testing"
is ambiguous and risks accidental removal of required startup logic; either
update the comment to state that initSchema(),
setupPullWatchOnSettingsPage(blockUids) and
setupPullWatchDiscourseNodes(nodePageUids) are required for block-sync or wrap
these calls behind a clear feature flag (e.g., ENABLE_BLOCK_SYNC) checked at
startup so they remain opt‑in during testing; implement the flag by reading an
env/config value and only invoking initSchema and the two setup* functions when
the flag is true, or alternatively change the TODO text to a permanent
explanatory note clarifying their necessity for block-sync.
🧹 Nitpick comments (1)
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx (1)

335-341: Prevent unnecessary re-evaluation of getShallowTreeByParentUid on each render.

The initializer expression in useRef(...) is evaluated every time the component renders, even though React only uses the result once. Since getShallowTreeByParentUid queries the Roam API, this causes unnecessary work on each render.

Use lazy initialization with useState to compute the child UIDs once:

♻️ Lazy initialization pattern
-  const childUidsRef = useRef<string[]>(
-    initialBlockUid
-      ? getShallowTreeByParentUid(initialBlockUid).map(
-          (c: { uid: string }) => c.uid,
-        )
-      : [],
-  );
+  const [initialChildUids] = useState<string[]>(() =>
+    initialBlockUid
+      ? getShallowTreeByParentUid(initialBlockUid).map(
+          (c: { uid: string }) => c.uid,
+        )
+      : [],
+  );
+  const childUidsRef = useRef<string[]>(initialChildUids);

@sid597 sid597 force-pushed the eng-1345-modify-existing-roamjs-component-onchange-to-also-change branch from c022156 to 87c2e08 Compare February 4, 2026 17:17
Copy link

@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 issue and 9 additional flags in Devin Review.

Open in Devin Review

@sid597
Copy link
Collaborator Author

sid597 commented Feb 4, 2026

To test,

update the blockProp... BaseXYZPanels with:

setTimeout(() => {
      console.log(`[TextPanel] "${title}" blockProp:`, getter(settingKeys));
    }, 500);

update your ExportSettings.tsx with


       <GlobalFlagPanel
          title="Append Referenced Node"
          description="If a referenced node is defined in a node's format, it will be appended to the discourse context"
          settingKeys={["Export", "Append Referenced Node"]}
          defaultValue={false}
          order={6}
          uid={exportSettings.appendRefNodeContext.uid}
          parentUid={parentUid}
        />
      </div>
      <div className="link-type-select-wrapper">
        <GlobalSelectPanel
          title="Link Type"
          description="How to format links that appear in your export."
          settingKeys={["Export", "Link Type"]}
          options={["alias", "wikilinks", "roam url"]}
          defaultValue="alias"
          order={5}
          uid={exportSettings.linkType.uid}
          parentUid={parentUid}
        />
      </div>
      <GlobalNumberPanel
        title="Max Filename Length"
        description="Set the maximum name length for markdown file exports"
        settingKeys={["Export", "Max Filename Length"]}
        defaultValue={64}
        order={0}
        uid={exportSettings.maxFilenameLength.uid}
        parentUid={parentUid}
      />
      <GlobalMultiTextPanel
        title="Frontmatter"
        description="Specify all the lines that should go to the Frontmatter of the markdown file"
        settingKeys={["Export", "Frontmatter"]}
        defaultValue={[]}
        order={2}
        uid={exportSettings.frontmatter.uid}
        parentUid={parentUid}
      />
      
      ```
      
      and in `index.ts` (just above the `<return>
      
      
      ```
       const { blockUids, nodePageUids } = await initSchema();
  const cleanupSettingsWatchers = setupPullWatchOnSettingsPage(blockUids);
  const cleanupNodeWatchers = setupPullWatchDiscourseNodes(nodePageUids);

@sid597 sid597 force-pushed the eng-1345-modify-existing-roamjs-component-onchange-to-also-change branch from 87c2e08 to 1e8fcd2 Compare February 4, 2026 17:48
Copy link

@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 issue and 8 additional flags in Devin Review.

Open in Devin Review

@sid597 sid597 force-pushed the eng-1345-modify-existing-roamjs-component-onchange-to-also-change branch from 1e8fcd2 to cf56730 Compare February 4, 2026 17:56
@sid597 sid597 force-pushed the eng-1190-replace-existing-roam-js-components-with-blockprop-based branch from 9095d0b to 304f5f9 Compare February 4, 2026 17:56
Copy link

@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 issue and 10 additional flags in Devin Review.

Open in Devin Review

@sid597 sid597 force-pushed the eng-1345-modify-existing-roamjs-component-onchange-to-also-change branch from cf56730 to 0723252 Compare February 4, 2026 18:05
@sid597 sid597 requested a review from mdroidian February 4, 2026 18:05
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.

Generally looks good, a few minor suggestions.
We'll just have to be sure to test this extensively together before it goes affects production.

Make sure to change these before merging:

  • use the new api: data.block.create
  • use ~ instead of ..
  • delete the empty line change

@sid597 sid597 changed the base branch from eng-1190-replace-existing-roam-js-components-with-blockprop-based to graphite-base/745 February 6, 2026 13:23
const newValue = e.target.value;
setValue(newValue);
setter(settingKeys, newValue);
syncToBlock?.(newValue);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to test:

  1. add the following code to index.ts (just above the `
       const { blockUids, nodePageUids } = await initSchema();
  const cleanupSettingsWatchers = setupPullWatchOnSettingsPage(blockUids);
  const cleanupNodeWatchers = setupPullWatchDiscourseNodes(nodePageUids);
  1. add the following timeout here
setTimeout(() => {
      console.log(`[TextPanel] "${title}" blockProp:`, getter(settingKeys));
    }, 500);

Do same thing to other base panels.

  1. then goto ExportSettings.tsx

and update its panels with the new components

  <GlobalFlagPanel
          title="Append Referenced Node"
          description="If a referenced node is defined in a node's format, it will be appended to the discourse context"
          settingKeys={["Export", "Append Referenced Node"]}
          defaultValue={false}
          order={6}
          uid={exportSettings.appendRefNodeContext.uid}
          parentUid={parentUid}
        />
      </div>
      <div className="link-type-select-wrapper">
        <GlobalSelectPanel
          title="Link Type"
          description="How to format links that appear in your export."
          settingKeys={["Export", "Link Type"]}
          options={["alias", "wikilinks", "roam url"]}
          defaultValue="alias"
          order={5}
          uid={exportSettings.linkType.uid}
          parentUid={parentUid}
        />
      </div>
      <GlobalNumberPanel
        title="Max Filename Length"
        description="Set the maximum name length for markdown file exports"
        settingKeys={["Export", "Max Filename Length"]}
        defaultValue={64}
        order={0}
        uid={exportSettings.maxFilenameLength.uid}
        parentUid={parentUid}
      />
      <GlobalMultiTextPanel
        title="Frontmatter"
        description="Specify all the lines that should go to the Frontmatter of the markdown file"
        settingKeys={["Export", "Frontmatter"]}
        defaultValue={[]}
        order={2}
        uid={exportSettings.frontmatter.uid}
        parentUid={parentUid}
      />

@sid597 sid597 force-pushed the eng-1345-modify-existing-roamjs-component-onchange-to-also-change branch from 0723252 to d42b423 Compare February 6, 2026 14:21
@sid597 sid597 force-pushed the graphite-base/745 branch from 304f5f9 to 7769e02 Compare February 6, 2026 14:21
@sid597 sid597 changed the base branch from graphite-base/745 to main February 6, 2026 14:21
@sid597 sid597 merged commit 2ac769a into main Feb 6, 2026
8 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