Skip to content

FEE-840 Add schema import for Obsidian#1164

Open
trangdoan982 wants to merge 2 commits into
fee-840-export-schemafrom
fee-840-import-schema
Open

FEE-840 Add schema import for Obsidian#1164
trangdoan982 wants to merge 2 commits into
fee-840-export-schemafrom
fee-840-import-schema

Conversation

@trangdoan982

@trangdoan982 trangdoan982 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds an Import discourse graph schema command and settings entry point
  • Users pick a dg-schema-*.json file via the Electron native open dialog
  • Preview step computes a match plan (id match, then name/label fallback) and shows per-category stats (new vs existing) for the full file before any changes are made
  • On apply, new items are created as provisional; existing matches are skipped (no destructive merges)
  • Relation triples, node types, and relation types in the selection panel enforce the same dependency constraints as export

Test plan

  • pnpm --filter @discourse-graphs/obsidian check-types
  • Open Import schema modal from command palette
  • Open Import schema modal from Settings
  • Pick an exported dg-schema-*.json file; verify preview stats are correct
  • Verify id-matched items show as existing; name/label-matched items show as existing
  • Import selected items; confirm new node types, relation types, triples created as provisional
  • Re-import the same file; confirm no duplicates created

Stack

Stacked on #1163 (export PR). Base branch: fee-840-export-schema.

Made with Cursor


Open in Devin Review

Adds an Import discourse graph schema command and settings entry point. Users
pick a dg-schema-*.json file via the Electron open dialog; the preview step
builds a match plan (id → name/label fallback) and shows per-category stats.
On apply, new items are created as provisional and existing matches are skipped.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jun 26, 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 Jun 26, 2026 7:51pm

Request Review

@linear-code

linear-code Bot commented Jun 26, 2026

Copy link
Copy Markdown

FEE-840

@graphite-app

graphite-app Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

PR size/scope check

This PR is over our review-size guideline.

  • Recommended: ~200 lines changed
  • Acceptable limit: up to 400 lines when well-scoped/self-contained
  • Preferred file count: fewer than 5 files

Please split this into smaller PRs unless there is a clear reason the changes need to land together.

If keeping it as one PR, please add a brief justification covering:

  • What single problem this PR solves
  • Why the files/changes are coupled

@supabase

supabase Bot commented Jun 26, 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 ↗︎.

@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 found 1 potential issue.

Open in Devin Review

Comment on lines +333 to +337
template:
importedNodeType.template &&
selectedTemplateNames.has(importedNodeType.template)
? importedNodeType.template
: undefined,

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.

🔴 Imported node types lose their template link when the template already exists locally

The template reference on newly imported node types is cleared (selectedTemplateNames.has(…) at apps/obsidian/src/utils/specImport.ts:335) when the user deselects an already-existing template, so imported node types lose their template even though it is present in the vault.

Impact: Users importing a schema into a vault that already has the same template files will get node types with no template association, silently breaking template-based workflows.

Mechanism: selectedTemplateNames check ignores already-existing templates

At apply time, applySchemaImportSelection correctly skips re-creating templates that already exist locally (matchPlan.existingTemplateNames.has(templateName) at apps/obsidian/src/utils/specImport.ts:279). However, when constructing the new node type at lines 333-337, the code only checks selectedTemplateNames — the set of templates the user explicitly selected for import. If a template already exists and the user deselected it (a natural action, since it doesn't need importing), the condition selectedTemplateNames.has(importedNodeType.template) returns false, and the template field is set to undefined.

The fix is to also check matchPlan.existingTemplateNames:

importedNodeType.template &&
(selectedTemplateNames.has(importedNodeType.template) ||
 matchPlan.existingTemplateNames.has(importedNodeType.template))
Suggested change
template:
importedNodeType.template &&
selectedTemplateNames.has(importedNodeType.template)
? importedNodeType.template
: undefined,
template:
importedNodeType.template &&
(selectedTemplateNames.has(importedNodeType.template) ||
matchPlan.existingTemplateNames.has(importedNodeType.template))
? importedNodeType.template
: undefined,
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant