Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
82e3f74 to
c022156
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Outdated
Show resolved
Hide resolved
📝 WalkthroughWalkthroughUpdates 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
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 | 🟡 MinorAdd 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.Elementto 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 ofgetShallowTreeByParentUidon each render.The initializer expression in
useRef(...)is evaluated every time the component renders, even though React only uses the result once. SincegetShallowTreeByParentUidqueries the Roam API, this causes unnecessary work on each render.Use lazy initialization with
useStateto 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);
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Outdated
Show resolved
Hide resolved
c022156 to
87c2e08
Compare
|
To test, update the update your |
87c2e08 to
1e8fcd2
Compare
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Outdated
Show resolved
Hide resolved
1e8fcd2 to
cf56730
Compare
9095d0b to
304f5f9
Compare
cf56730 to
0723252
Compare
mdroidian
left a comment
There was a problem hiding this comment.
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
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/components/BlockPropSettingPanels.tsx
Outdated
Show resolved
Hide resolved
| const newValue = e.target.value; | ||
| setValue(newValue); | ||
| setter(settingKeys, newValue); | ||
| syncToBlock?.(newValue); |
There was a problem hiding this comment.
to test:
- add the following code to
index.ts(just above the `
const { blockUids, nodePageUids } = await initSchema();
const cleanupSettingsWatchers = setupPullWatchOnSettingsPage(blockUids);
const cleanupNodeWatchers = setupPullWatchDiscourseNodes(nodePageUids);
- add the following timeout here
setTimeout(() => {
console.log(`[TextPanel] "${title}" blockProp:`, getter(settingKeys));
}, 500);
Do same thing to other base panels.
- 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}
/>
0723252 to
d42b423
Compare
304f5f9 to
7769e02
Compare

https://www.loom.com/share/fcc05f0564e84a88baf41f535272523a
Summary by CodeRabbit
New Features
Improvements