FEE-840 Add schema import for Obsidian#1164
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
PR size/scope checkThis PR is over our review-size guideline.
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:
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
| template: | ||
| importedNodeType.template && | ||
| selectedTemplateNames.has(importedNodeType.template) | ||
| ? importedNodeType.template | ||
| : undefined, |
There was a problem hiding this comment.
🔴 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))
| 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, |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
dg-schema-*.jsonfile via the Electron native open dialogprovisional; existing matches are skipped (no destructive merges)Test plan
pnpm --filter @discourse-graphs/obsidian check-typesdg-schema-*.jsonfile; verify preview stats are correctprovisionalStack
Stacked on #1163 (export PR). Base branch:
fee-840-export-schema.Made with Cursor