ENG-2247 Copy a node's assets and rewrite its markdown for Roam - #1429
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
284bd2a to
8897117
Compare
8897117 to
e278641
Compare
e278641 to
6208fe4
Compare
6208fe4 to
d650f4b
Compare
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| export const importNodeAssets = async ({ | ||
| client, | ||
| sharedNode, | ||
| markdown, | ||
| }: { | ||
| client: DGSupabaseClient; | ||
| sharedNode: SharedNode; | ||
| markdown: string; | ||
| }): Promise<{ markdown: string; report: AssetImportReport }> => { |
There was a problem hiding this comment.
🔴 Asset import never reaches materialization
importNodeAssets has no production caller, so materialization writes unchanged asset locators. Obsidian assets become empty page references, and Roam assets remain origin-dependent.
Learn more
The new asset stage is only referenced by tests. After fetchFullMarkdown, materialization passes content.markdown directly to page creation or replacement. Therefore neither shared-storage downloads nor Roam uploads occur during an actual import, and rewriteAssetLinks never changes the markdown written to the page.
Example: Importing Obsidian markdown ![[attachments/diagram.png]] leaves that text unchanged. Roam interprets it as a page reference instead of displaying the published image. A Roam-origin Firebase URL still renders initially, but deleting the origin graph's blob later breaks the imported page.
Recommended fix: Call importNodeAssets({ client, sharedNode, markdown: content.markdown }) before createImportedPage or updateImportedPage, pass its returned markdown into materialization, and propagate its report to the import result or existing user-facing summary. Add materialization tests proving both create and update paths write rewritten markdown.
Was this helpful? React with 👍 or 👎 to provide feedback.
Reviewer brief
This creates a utility function, importAssetNodes, that ties together rewriteAssetLinks (ENG-2217) and mirrorAssetToRoamStorage (ENG-2218) to actually import the nodes detected in given markdown.
This also involves a refactoring of a repeated and defective utility function.
Finally, this includes some end-to-end tests (in a separate commit) that rely on importAssetNodes.
Verification
Includes unit tests.
Behaviour tests in #1401
Loom video
https://www.loom.com/share/f941f20853444597931d85d6b56ef68c
Scope check
$scope-checkagainst the ENG ticket and final diff.Done When: None. ENG-2247's criteria were written after the split, sothey describe this diff by construction. The list below measures against the original
ENG-2219
Done When, which is what was agreed before the split.Beyond the original ENG-2219 scope:
The tokenizer API.
rewriteAssetLinksexportslookupCandidatesand gainscollectAssetLocators, so the stage copies only references the rewriter can resolve.locator no longer appears in the fetched markdown once frontmatter and the title
heading are stripped. A Roam upload is a permanent charge on the user's storage, so
this is reachable the moment the stage ships. Deriving the spellings forward instead
does not work: a note writes
fig#1.pngasfig%231.png, andencodeURIleaves#alone.parseMatch, which this depends on, went to ENG-2217 as a pure refactor.getErrorMessageconsolidated intoapps/roam/src/utils/getErrorMessage.ts,replacing the copies in
materializeSharedNodeand inmirrorAssetToRoamStorage(anENG-2218 file), plus a branch for the
{ message }objects Supabase returns.importNodeAssetswould have satisfied theticket. This is cleanup, and it changes the error text of three existing callers. It
consolidates the two copies that had to share it; other inline copies elsewhere in
the codebase are untouched.
assetDegradation.test.tsasserts the degradation path across the publish andimport seam, calling ENG-1870's
publishNodeAssetsalongsideimportNodeAssets.cross-app-asset-referencesOpenSpecchange. The contract between the two halves cannot be asserted from either side
alone.
A doc comment in
mirrorAssetToRoamStoragerecording that nothing rolls an uploadback. Comment only, no behaviour change.
importNodeAssetsdepends on that constraint and it was uncaptured.Local delegated full review
$dg-delegated-full-reviewwhen no other full-review workflow is available.https://linear.app/discourse-graphs/issue/ENG-2247/copy-a-nodes-assets-and-rewrite-its-markdown-for-roam