Skip to content

Conversation

@trangdoan982
Copy link
Collaborator

@trangdoan982 trangdoan982 commented Jan 15, 2026

Summary by CodeRabbit

Release Notes

  • Refactor
    • Enhanced data synchronization for discourse graphs with improved conversion and upsertion of node and relation information.
    • Streamlined cloud synchronization workflow with better handling of schema configurations and data structures.

✏️ Tip: You can customize this high-level summary in your review settings.

@linear
Copy link

linear bot commented Jan 15, 2026

@supabase
Copy link

supabase bot commented Jan 15, 2026

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

@trangdoan982
Copy link
Collaborator Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This PR introduces relation-type and relation-schema conversion helpers for building LocalConceptDataInput, updates node conversion to include full node data in literal_content, and refactors the Supabase sync pipeline to accept plugin parameters, build schema lookups, and implement a two-step upsert process for nodes and relation concepts.

Changes

Cohort / File(s) Summary
Relation data conversion helpers
apps/obsidian/src/utils/conceptConversion.ts
Added two new exported functions: discourseRelationTypeToLocalConcept() and discourseRelationSchemaToLocalConcept() to transform Discourse relation and relation-type data into LocalConceptDataInput format. Updated discourseNodeSchemaToLocalConcept() to populate literal_content with full node data instead of placeholder comment.
Supabase sync pipeline refactoring
apps/obsidian/src/utils/syncDgNodesToSupabase.ts
Extended convertDgToSupabaseConcepts(), syncChangedNodesToSupabase(), and createOrUpdateDiscourseEmbedding() to accept plugin parameter. Introduced plugin-driven schema handling to build node-types, relation-types, and discourse-relations lookups from plugin.settings. Replaced previous single-step upsert with two-step flow: upsert node content/embeddings first, then upsert related concepts via upsert_concepts RPC.

Sequence Diagram

sequenceDiagram
    participant Plugin as Obsidian Plugin
    participant SyncFn as syncChangedNodesToSupabase
    participant ConvertFn as convertDgToSupabaseConcepts
    participant SupabaseAPI as Supabase RPC API
    
    Plugin->>SyncFn: plugin, context, changedNodeIds
    SyncFn->>SyncFn: upsertNodesToSupabaseAsContentWithEmbeddings
    SyncFn->>SupabaseAPI: upsert node content + embeddings
    SupabaseAPI-->>SyncFn: nodes upserted
    
    SyncFn->>ConvertFn: plugin, changed nodes
    ConvertFn->>ConvertFn: build nodeTypesById, relationTypesById lookups
    ConvertFn->>ConvertFn: discourseNodeSchemaToLocalConcept (nodes)
    ConvertFn->>ConvertFn: discourseRelationTypeToLocalConcept (relation types)
    ConvertFn->>ConvertFn: discourseRelationSchemaToLocalConcept (relations)
    ConvertFn-->>SyncFn: LocalConceptDataInput array
    
    SyncFn->>SupabaseAPI: upsert_concepts (ordered set)
    SupabaseAPI-->>SyncFn: concepts upserted
    SyncFn-->>Plugin: sync complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and specifically references syncing node relation definitions, which aligns with the core changes: adding new helpers for relation data transformation and modifying sync workflows to handle discourse relations and relation types.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@trangdoan982 trangdoan982 changed the title [ENG-1181] Sync noderelation definitions [ENG-1181] Sync node relation definitions Jan 15, 2026
@trangdoan982 trangdoan982 requested a review from maparent January 15, 2026 20:13
@trangdoan982 trangdoan982 force-pushed the eng-1178-f9-automatic-local-remote-sync-nodes-relations branch from 97b3983 to 777b079 Compare January 20, 2026 17:21
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