Skip to content

ENG-1549: Add convert existing page to discourse node command#987

Merged
sid597 merged 12 commits into
mainfrom
eng-1549-convert-existing-page-to-node-roam
May 20, 2026
Merged

ENG-1549: Add convert existing page to discourse node command#987
sid597 merged 12 commits into
mainfrom
eng-1549-convert-existing-page-to-node-roam

Conversation

@sid597

@sid597 sid597 commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

@linear-code

linear-code Bot commented Apr 30, 2026

Copy link
Copy Markdown

@supabase

supabase Bot commented Apr 30, 2026

Copy link
Copy Markdown

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

devin-ai-integration[bot]

This comment was marked as resolved.

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

Copy link
Copy Markdown
Contributor

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 5 additional findings in Devin Review.

Open in Devin Review

Comment thread apps/roam/src/utils/registerCommandPaletteCommands.ts Outdated
@sid597 sid597 requested a review from mdroidian May 2, 2026 06:52
Comment thread apps/roam/src/components/ModifyNodeDialog.tsx Outdated
Comment thread apps/roam/src/components/ModifyNodeDialog.tsx Outdated
Comment thread apps/roam/src/utils/registerCommandPaletteCommands.ts Outdated
sid597 added 3 commits May 12, 2026 11:15
Address review comments on PR #987:
- DRY the SmartBlocks template-handling logic by extracting
  insertTemplateBlocks into createDiscourseNode.ts and reusing it
  from convertPageToNodeFromCommand.
- Tighten createOverride return type from Promise<string | void> to
  Promise<string> so the dialog can collapse the override fallback
  into a single const.
Image insertion belongs with template insertion (matches the
original pre-refactor coupling). Extract handleImageCreation to
a module-level insertCanvasKeyImage and call it from the helper
after template work. createDiscourseNode no longer needs a
separate image step; convert flow's image branch is a no-op via
undefined imageUrl.
Pure extraction — the function body is identical to the original
closure. The signature now takes pageUid, discourseNodes,
configPageUid, imageUrl, extensionAPI, and text as params instead
of picking them up via closure. createDiscourseNode passes its
already-computed discourseNodes through (no duplicate fetch).
return false;
};

const handleImageCreation = async ({

@sid597 sid597 May 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Pulled out function from line 53, nothing changed in the implementation of this.

sid597 added 3 commits May 12, 2026 15:51
Step back from the insertTemplateBlocks orchestrator. The PR is
just two function extractions:
- hasSmartBlockSyntax and createBlocksFromTemplate are exported
  from createDiscourseNode.ts at module scope.
- handleImageCreation stays at module scope (used only by
  createDiscourseNode).

createDiscourseNode keeps its original if/else SmartBlocks
orchestration; convertPageToNodeFromCommand keeps its inline
orchestration too. Both sites now call the shared helpers.
const results = await runQuery({
extensionAPI,
parentUid,
// eslint-disable-next-line @typescript-eslint/naming-convention

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

extra line to fix lint

}) => {
const createBlocksFromTemplate = async () => {
await Promise.all(
stripUid(templateNode.children).map((node, templateOrder) =>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

  1. Removed the uid from the place we pulled this from (line 153).

Because: stripUid(...) already removes uid, so the destructuring was redundant and caused an unused uid lint warning

  1. Updated from order to templateOrder, defaults to 0. We need to add template to last block if we convert a page using the command palette command

});
await createBlocksFromTemplate();
} else if (useSmartBlocks && window.roamjs?.extension?.smartblocks) {
void window.roamjs.extension.smartblocks?.triggerSmartblock({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

void That is only to mark the promise as intentionally not awaited. Runtime intent is the same

@sid597 sid597 requested a review from mdroidian May 12, 2026 11:35
sid597 added 3 commits May 15, 2026 17:33
…ting-page-to-node-roam

# Conflicts:
#	apps/roam/src/utils/createDiscourseNode.ts
…ting-page-to-node-roam

# Conflicts:
#	apps/roam/src/utils/createDiscourseNode.ts
@sid597 sid597 merged commit 6a7bca8 into main May 20, 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