Skip to content

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

Open
maparent wants to merge 7 commits into
mainfrom
eng-1867-Import-cross-app–relations-in-roam-as-tentative

Hidden character warning

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

ENG-1867 Import cross-app relations into Roam as tentative relations#1302
maparent wants to merge 7 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 22, 2026 5:26pm

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 f30f065 to 5276db1 Compare August 21, 2026 13:05
@maparent
maparent force-pushed the eng-1867-Import-cross-app–relations-in-roam-as-tentative branch from 03b13ed to e8b609b Compare August 22, 2026 00:37
Comment thread apps/roam/src/utils/importSharedRelations.ts Outdated
@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 on lines +60 to +65
const node = await createDiscourseNodeType({
label: schema.label,
template: schema.template,
// TODO: colour, other metadata?
});
blockUid = node.type;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse node schemas created earlier in the import

When one discovery batch contains previously unknown node schemas from multiple spaces with the same label, localNodeSchemasByLabel remains the snapshot taken before this loop. After creating the first schema, the next schema with that label enters this branch again and attempts to create the same discourse-graph/nodes/<label> page; because Roam page titles are unique, that transaction rejects and aborts relation importing. Add each newly created schema to the per-batch label lookup.

Useful? React with 👍 / 👎.

Comment on lines +144 to +149
blockUid = await createRelationSchema({
label,
complement,
source,
destination,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse relation schemas created earlier in the import

When two remote triple schemas in the same batch resolve to the same label, source, and destination, relationSchemas still contains only the pre-import snapshot, so both take the creation path and produce duplicate local relation schemas. On the next import, both duplicates match the predicate above and trigger the multiple matches error, preventing the relation batch from being processed. Track newly created schemas in the per-batch lookup as well.

Useful? React with 👍 / 👎.

source,
destination,
complement,
ifConditions: [],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep stored-only schemas visible in the new settings store

When Use new settings store is enabled, this stores the imported relation with no conditions, but getAllRelations flat-maps relation.ifConditions, so the schema immediately disappears from getDiscourseRelations even though the tentative relation was created with its UID. Fresh evidence beyond the earlier comment is that the new dual-write is present, but its empty array still emits zero relations; store an empty stored-relation condition or add the same stored-relations fallback used by the legacy reader.

Useful? React with 👍 / 👎.

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