Skip to content

ENG-2140 Map source to an Obsidian relation on pull - #1411

Open
sid597 wants to merge 4 commits into
mainfrom
eng-2140-map-source-to-an-obsidian-relation-on-pull
Open

ENG-2140 Map source to an Obsidian relation on pull#1411
sid597 wants to merge 4 commits into
mainfrom
eng-2140-map-source-to-an-obsidian-relation-on-pull

Conversation

@sid597

@sid597 sid597 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator
eng-2140.mp4

Reviewer brief

Review focus: Source identity across spaces, accepted relation configuration, and partial import failures. Inline notes explain the decisions at each step.

Verification

Loom video

37-second feature demo above.

Scope check

  • Ran $scope-check against ENG-2140 and the final diff, with Sid's clarified scope.
  • Scope beyond Done When: None.

Local delegated full review

  • Full implementation diff reviewed in a subagent with fresh context. No findings.

@linear-code

linear-code Bot commented Sep 7, 2026

Copy link
Copy Markdown

ENG-2140

@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
discourse-graph Skipped Skipped Sep 7, 2026 11:30am UTC

Request Review

@supabase

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

@sid597
sid597 marked this pull request as ready for review September 7, 2026 10:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T10:40:39.598671Z 00ab1cf Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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 3 potential issues.

Devin Review

Comment thread apps/obsidian/src/utils/importNodes.ts
Comment thread apps/obsidian/src/utils/importNodes.ts
Comment thread apps/obsidian/src/utils/importNodes.ts
}

// The metadata cache can lag behind vault writes during a batch import.
importedFiles.set(importedFromRid, processedFile);

@sid597 sid597 Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The batch map keeps newly imported files available while Obsidian's metadata cache catches up. This prevents two Evidence nodes from importing the same Source twice.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00ab1cfbec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/obsidian/src/utils/importNodes.ts
Comment thread apps/obsidian/src/utils/importNodes.ts
@graphite-app

graphite-app Bot commented Sep 7, 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

@sid597

sid597 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Only importNodes.ts remains in this PR. Obsidian tests and test setup are kept in verification-only #1412.

@sid597 sid597 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer notes for the importer.


const { data: sources, error } = await client
.from("my_concepts")
.select("id, source_local_id, space_id")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceDocument contains a database concept ID. This lookup resolves it to a space and local ID before finding a vault file. The Source must be independently shared and visible to the importing user.

importedFiles.get(rid) ??
(source.space_id === localSpaceId
? queryEngine
.getFilesWithNodeTypeId({ excludeImported: true })

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A local ID is only unique within its space. Local Source lookup excludes imported notes; remote lookup uses the full origin RID. A same-ID note from another graph must not be reused here.

}
}
if (pendingSources.size > 0) {
await importNodes({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatic Source imports use the normal importer, including schema mapping, decorated titles, and assets. This lookup supplies identity; the importer fetches the title and content. Sources already found in the vault are reused without overwriting their content.


const localSpaceUri = getLocalSpaceUri(plugin.app);
const indexedFiles = queryEngine.getFilesWithNodeInstanceId();
const legacyEndpointsForFile = ({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually created relations may store bare IDs or this vault's RIDs. Those count as aliases only when the ID identifies this file uniquely. Otherwise, a relation between separate local notes could suppress the imported relation.

const sourceNodeType = plugin.settings.nodeTypes.find(
(type) => type.id === source.nodeTypeId,
);
if (sourceNodeType?.name.toLowerCase() !== "source") continue;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Source-named type matches Obsidian's push rule in #1381. Both the local triple and relation type must already be accepted. If either is missing or provisional, the notes import without creating a relation or new relation configuration.

const { frontmatter } = parseFrontmatter(
await plugin.app.vault.read(occupiedFile),
);
if (frontmatter.importedFromRid === importedFromRid) break;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two Sources can have the same title, so an occupied filename is reused only for the same origin RID. Other Sources get a suffix. The refresh path also recognizes its own suffixed file to avoid repeated renames.

nodeImportInfoByInstance,
importedFiles,
});
} catch (error) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source relations are added after the selected notes have been written. A Source lookup or relation failure must not turn those successful imports into failures. Keep the notes and report the incomplete Source step.

@sid597
sid597 requested review from maparent and mdroidian September 7, 2026 11:31
@mdroidian

Copy link
Copy Markdown
Member

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 59 minutes.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: bc68f4a5-c06d-4b1d-a7c1-66e199ccc234

📥 Commits

Reviewing files that changed from the base of the PR and between a8b8fee and aaa0416.

📒 Files selected for processing (1)
  • apps/obsidian/src/utils/importNodes.ts

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.

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