ENG-1461 Use full Rid instead of just spaceUri as marker of import#808
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
| } | ||
| }; | ||
|
|
||
| const migrateImportedFromFrontMatter = async (plugin: DiscourseGraphPlugin) => { |
There was a problem hiding this comment.
i don't think we need this function. because the first "actual" use case will be from Holehouse which has no initial data. This is only if you care about our testing data being migration but for production I don't think this is necessary.
| @@ -0,0 +1,29 @@ | |||
| export const spaceUriAndLocalIdToRid = ( | |||
There was a problem hiding this comment.
nit: maybe here is a good place to document the structure/ link to the RID structure https://github.com/BlockScience/rid-lib
6983308 to
5699c31
Compare
| ...[ | ||
| "nodeTypeId", | ||
| "importedFromSpaceUri", | ||
| "importedFromRid", |
There was a problem hiding this comment.
🟡 updateFrontmatterStyles doesn't hide legacy importedFromSpaceUri field
The updateFrontmatterStyles method hides importedFromRid from frontmatter display when showIdsInFrontmatter is false, but does not hide the legacy importedFromSpaceUri field. Before migration completes (or if migration fails for a node), the legacy field will be visible in the frontmatter UI.
Impact
This is a UI inconsistency: the old importedFromSpaceUri field will be visible in the Obsidian properties view for files that haven't been migrated yet, even when the user has configured frontmatter IDs to be hidden.
| "importedFromRid", | |
| "importedFromRid", | |
| "importedFromSpaceUri", |
Was this helpful? React with 👍 or 👎 to provide feedback.
| return; | ||
| } | ||
| const isImported = !!frontmatter.importedFromSpaceUri; | ||
| const isImported = !!frontmatter.importedFromRid; |
There was a problem hiding this comment.
🔴 DiscourseContextView isImported check misses legacy importedFromSpaceUri, showing Publish button for imported nodes
Both isImported checks in DiscourseContextView.tsx (lines 40 and 128) only check for importedFromRid, not the legacy importedFromSpaceUri. For previously imported files that haven't been migrated, isImported will be false.
Root Cause and Impact
At line 40:
const isImported = !!frontmatter.importedFromRid;And at line 128:
const isImported = !!frontmatter.importedFromRid;For legacy imported files, this means:
- The "Refresh" button will not be shown (since
isImportedis false) - The "Publish" button may be shown instead (since
canPublishchecks!isImported) - Source dates (created/modified in source) won't be displayed
Publishing an imported file could cause unintended data changes in the user's lab space.
| const isImported = !!frontmatter.importedFromRid; | |
| const isImported = !!frontmatter.importedFromRid || !!frontmatter.importedFromSpaceUri; | |
Was this helpful? React with 👍 or 👎 to provide feedback.
| const cache = plugin.app.metadataCache.getFileCache(file); | ||
| const frontmatter = cache?.frontmatter; | ||
| if (frontmatter?.importedFromSpaceUri && frontmatter?.nodeInstanceId) { | ||
| if (frontmatter?.importedFromRid && frontmatter?.nodeInstanceId) { |
There was a problem hiding this comment.
🔴 refreshAllImportedFiles skips legacy imported files that only have importedFromSpaceUri
The refreshAllImportedFiles function at importNodes.ts:1431 only finds files with importedFromRid in their frontmatter, silently skipping any legacy imported files that still have importedFromSpaceUri.
Root Cause and Impact
At line 1431:
if (frontmatter?.importedFromRid && frontmatter?.nodeInstanceId) {
importedFiles.push(file);
}Legacy files with only importedFromSpaceUri will be excluded. When the user triggers "refresh all imported files", these files will simply be skipped with no error or indication, leaving them stale.
Impact: Users who upgrade to this version and try to refresh all imported files will find that previously imported files are silently skipped. Those files will never get refreshed unless manually re-imported.
| if (frontmatter?.importedFromRid && frontmatter?.nodeInstanceId) { | |
| if ((frontmatter?.importedFromRid || frontmatter?.importedFromSpaceUri) && frontmatter?.nodeInstanceId) { | |
Was this helpful? React with 👍 or 👎 to provide feedback.
https://linear.app/discourse-graphs/issue/ENG-1461/use-full-rid-instead-of-just-spaceuri-as-marker-of-import
This PR migrates imported node frontmatter from using
importedFromSpaceUrito usingimportedFromRid, which contains both the original node's spaceUri and the original sourceLocalId, in the form of a koi-compliant Rid.(See Rid specs
Previously imported nodes are migrated accordingly.
Also, the sourceRid is added to the schema types, so we have provenance for schemas.
https://www.loom.com/share/b5dc1662b79e4b56a7ff0e3bf74b7039