ENG-2084 Add schema import UI for Obsidian - #1265
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
23c69c1 to
d417d43
Compare
11d1480 to
5f5edc0
Compare
d417d43 to
bc0e07d
Compare
5f5edc0 to
ce3af53
Compare
2db3e8e to
1fc3e89
Compare
bc0e07d to
34254ad
Compare
| onClose(); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| new Notice(`Failed to import schema: ${message}`, 6000); | ||
| } finally { | ||
| setIsApplyingImport(false); | ||
| } |
There was a problem hiding this comment.
React state update on unmounted component. When the import succeeds, onClose() is called at line 102, which closes the modal and unmounts the component. Then the finally block at line 107 attempts to call setIsApplyingImport(false) on an already unmounted component, causing a React error.
Fix: Move onClose() after the finally block or restructure the flow:
try {
const result = await applySchemaImportSelection({
plugin,
loadedSchemaFile,
selection: {
nodeTypeIds: selected.nodeTypeIds,
relationTypeIds: selected.relationTypeIds,
discourseRelationIds: selected.relationIds,
templateNames: selected.templateNames,
},
});
const { created } = result;
new Notice(
`Import complete: ${created.nodeTypes} node type(s), ${created.relationTypes} relation type(s), ${created.discourseRelations} relation triple(s), and ${created.templates} template(s) created.`,
7000,
);
if (result.warnings.length > 0) {
new Notice(
`Import completed with ${result.warnings.length} warning(s).`,
6000,
);
for (const warning of result.warnings) {
new Notice(warning, 6000);
}
}
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
new Notice(`Failed to import schema: ${message}`, 6000);
} finally {
setIsApplyingImport(false);
}
onClose(); // Move outside try/catch/finally| onClose(); | |
| } catch (error) { | |
| const message = error instanceof Error ? error.message : String(error); | |
| new Notice(`Failed to import schema: ${message}`, 6000); | |
| } finally { | |
| setIsApplyingImport(false); | |
| } | |
| } catch (error) { | |
| const message = error instanceof Error ? error.message : String(error); | |
| new Notice(`Failed to import schema: ${message}`, 6000); | |
| } finally { | |
| setIsApplyingImport(false); | |
| } | |
| onClose(); | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
…otModal abstraction)
…hemaPreviewSummary as sibling Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34254ad to
9073b20
Compare
1fc3e89 to
c731999
Compare
Summary
Adds the import modal UI and wires it into the command palette and settings.
ImportSchemaPreviewSummary.tsx— per-category new/existing counts shown before the user applies the importImportSpecsModal.tsx— two-screen modal: file picker screen → preview + selection screen (reusesSchemaSelectionModalBody+SchemaSelectionPanelfrom ENG-2083); delegates apply logic toapplySchemaImportSelectionfrom ENG-1977GeneralSettings.tsx— adds "Import discourse graph schema" entry to the settings UIregisterCommands.ts— registersimport-dg-schemacommand in the command paletteStack
PR 5 of 5 for FEE-840. Stacks on #1264.
Test plan
pnpm --filter @discourse-graphs/obsidian check-typespassesprovisional