ENG-1867 Import cross-app relations into Roam as tentative relations - #1302
Hidden character warning
ENG-1867 Import cross-app relations into Roam as tentative relations#1302maparent wants to merge 7 commits into
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
452cc49 to
1928997
Compare
1928997 to
70f63a7
Compare
70f63a7 to
5ce9525
Compare
5ce9525 to
69aedbc
Compare
69aedbc to
9036ffd
Compare
9036ffd to
f4ef064
Compare
f4ef064 to
c3e095b
Compare
c3e095b to
b062e59
Compare
f30f065 to
5276db1
Compare
03b13ed to
e8b609b
Compare
b0d1031 to
a360ea2
Compare
a360ea2 to
5f45a0d
Compare
5f45a0d to
6699f70
Compare
6699f70 to
84c96a5
Compare
84c96a5 to
d0dcb0f
Compare
|
Ok. Addressed most issues. |
|
@codex review |
There was a problem hiding this comment.
💡 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".
| const node = await createDiscourseNodeType({ | ||
| label: schema.label, | ||
| template: schema.template, | ||
| // TODO: colour, other metadata? | ||
| }); | ||
| blockUid = node.type; |
There was a problem hiding this comment.
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 👍 / 👎.
| blockUid = await createRelationSchema({ | ||
| label, | ||
| complement, | ||
| source, | ||
| destination, | ||
| }); |
There was a problem hiding this comment.
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: [], |
There was a problem hiding this comment.
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 👍 / 👎.
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