Skip to content

ENG-1867 Import cross-app relations into Roam as tentative relations - #1302

Merged
maparent merged 9 commits into
mainfrom
eng-1867-Import-cross-app–relations-in-roam-as-tentative
Aug 28, 2026

Hidden character warning

The head ref may contain hidden characters: "eng-1867-Import-cross-app\u2013relations-in-roam-as-tentative"
Merged

ENG-1867 Import cross-app relations into Roam as tentative relations#1302
maparent merged 9 commits into
mainfrom
eng-1867-Import-cross-app–relations-in-roam-as-tentative

Conversation

@maparent

@maparent maparent commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

https://linear.app/discourse-graphs/issue/ENG-1867/import-cross-app-relations-into-roam-as-tentative-relations

Code walkthrough:
https://www.loom.com/share/e3cfe2ce63a34382a2b23200cb9e0b1e

Note: Since the code walkthrough I removed the RidToId in the discovery results.
Also added the correction to getDiscourseRelations, and code to delete an incorrect imported relation.

Simple demo:
https://www.loom.com/share/a0dd5ca98a194536a6d4350ec96b8bcb

Demo with type creation:
https://www.loom.com/share/bc8336651d7243f1b6f809ee6e886d9f

Quick note on templates
https://www.loom.com/share/5bfd0fffc27446af9d5d88383c7e276a

@linear-code

linear-code Bot commented Aug 17, 2026

Copy link
Copy Markdown

ENG-1867

@supabase

supabase Bot commented Aug 17, 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 ↗︎.

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
discourse-graph Skipped Skipped Aug 27, 2026 11:48pm

Request Review

@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 452cc49 to 1928997 Compare August 17, 2026 22:37
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 1928997 to 70f63a7 Compare August 19, 2026 13:37
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 70f63a7 to 5ce9525 Compare August 19, 2026 14:19
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 5ce9525 to 69aedbc Compare August 19, 2026 14:32
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 69aedbc to 9036ffd Compare August 19, 2026 14:56
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 9036ffd to f4ef064 Compare August 19, 2026 16:33
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from f4ef064 to c3e095b Compare August 20, 2026 01:09
@maparent
maparent marked this pull request as ready for review August 20, 2026 01:13
Comment thread apps/roam/src/utils/importSharedRelations.ts Outdated

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

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

View in Devin Review to see 7 additional findings.

Open in Devin Review

@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from c3e095b to b062e59 Compare August 20, 2026 01:22
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from b0d1031 to a360ea2 Compare August 22, 2026 16:03
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from a360ea2 to 5f45a0d Compare August 22, 2026 16:10
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 5f45a0d to 6699f70 Compare August 22, 2026 16:29
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 6699f70 to 84c96a5 Compare August 22, 2026 17:24
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 84c96a5 to d0dcb0f Compare August 22, 2026 17:25
@maparent

Copy link
Copy Markdown
Collaborator Author

Ok. Addressed most issues.
Some codex comments lost their anchor after the rebase, and before I processed them; so they are lost and might still apply, I would ask for another codex review. But all active comments were addressed.

@maparent
maparent requested a review from mdroidian August 22, 2026 17:29
@mdroidian

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0dcb0f2bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/roam/src/utils/importSharedRelations.ts
Comment thread apps/roam/src/utils/importSharedRelations.ts
Comment thread apps/roam/src/utils/createRelationSchema.ts
let templateTree: RoamBasicNode[] | undefined;
if (template !== undefined) {
const tree = getBasicTreeByParentUid(pageUid);
const templateUid = tree[3].uid;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tree[3] assumes Template is always the 4th child. That’s true for the tree you just built, but it isn’t a stable way to find the block.

If someone later adds, removes, or reorders a setting above Template, this still compiles and then writes markdown into the wrong parent. Easy to miss because the 3 is disconnected from the "Template" key.

Elsewhere we look these up by name with getSubTree. Same thing here:
const templateUid = getSubTree({ tree, key: "Template" }).uid;

label: string;
shortcut?: string;
format?: string;
template?: string;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like you are expecting a Markdown string here? Normally, in Roam, templates are RoamBasicNode[]. So this is going against the expected pattern. Let's explicitly called out as a comment on ln 1109, or a custom type, or even JSONDoc above the function.

It may be true that CrossApp* will generally expect Markdown, but this is currently in accessors.ts, so the context matters.

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.

Actually broadening the type.

Comment thread apps/roam/src/utils/createRelationSchema.ts
Comment thread apps/roam/src/utils/importSharedRelations.ts
Comment thread apps/roam/src/utils/importSharedRelations.ts
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from d0dcb0f to 2e6a60d Compare August 26, 2026 14:08
@maparent

Copy link
Copy Markdown
Collaborator Author

Made a few changes. I choose to allow relations with no condition vs creating an empty condition. I also broadened the input type.

@maparent
maparent requested a review from mdroidian August 26, 2026 14:13
@mdroidian

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e6a60d7cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

sourceUid,
destinationUid,
relationBlockUid,
tentative: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exclude tentative relations from accepted-relation queries

When stored relations are enabled, this imported relation is immediately treated as an accepted fact: registerDiscourseDatalogTranslators matches every reified block using only sourceUid, destinationUid, and hasSchema, and no Roam consumer filters the newly added tentative property. Consequently, merely importing shared nodes can change query, context, and canvas results before the user accepts the relation; exclude tentative records from normal relation paths until confirmation.

Useful? React with 👍 / 👎.

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.

This is valid, but I think it's a new scope.

Comment thread apps/roam/src/components/DiscoverSharedNodesDialog.tsx
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