-
Notifications
You must be signed in to change notification settings - Fork 4
[ENG-1332] Automatic node relationships #730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[ENG-1332] Automatic node relationships #730
Conversation
|
Cursor Agent can help with this pull request. Just |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 WalkthroughWalkthroughThe changes introduce relationship-aware node creation by adding currentFile context and relationship metadata (relationshipTypeId, relationshipTargetFile) throughout the modal, form, and node creation flows. New UI allows users to select relationships when creating nodes. Submission payloads are extended to carry relationship fields, and addRelationToFrontmatter is invoked when relationships are specified. Constants define a new Source node type and derivedFrom relation type. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Modal as ModifyNodeModal
participant Form as ModifyNodeForm
participant Flow as nodeCreationFlow
participant FM as addRelationToFrontmatter
User->>Modal: Opens modal (passes currentFile)
Modal->>Form: Passes currentFile, mode=create
Form->>Form: Derives availableRelationships from currentFile & selectedNodeType
User->>Form: Selects node type and relationship
Form->>Form: Updates selectedRelationshipTypeId state
User->>Form: Submits form
Form->>Modal: handleConfirm() with relationshipTypeId, relationshipTargetFile
Modal->>Flow: onSubmit() with all params including relationship fields
Flow->>Flow: Creates node via standard flow
alt relationshipTypeId provided
Flow->>FM: addRelationToFrontmatter(newFile, targetFile, relationshipTypeId)
FM->>FM: Updates frontmatter with relationship
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/obsidian/src/components/ModifyNodeModal.tsx`:
- Around line 321-323: In ModifyNodeModal (use the isEditMode boolean that
controls the header), fix the create-mode header string by replacing "Create
discourse nodeeeee" with the correct text "Create discourse node" so the <h2>
shows "Modify discourse node" when isEditMode is true and "Create discourse
node" when false.
🧹 Nitpick comments (2)
apps/obsidian/src/utils/registerCommands.ts (1)
24-58: Consider extracting duplicated relationship handling logic.The relationship handling logic (getting
currentFile, passing it to modal, and callingaddRelationToFrontmatter) is duplicated between both commands. Consider extracting a helper function.♻️ Suggested refactor
// Helper function to create the modal with relationship support const createNodeWithRelationship = async ({ plugin, editor, newFile, relationshipTypeId, relationshipTargetFile, }: { plugin: DiscourseGraphPlugin; editor: Editor; newFile: TFile | null; relationshipTypeId?: string; relationshipTargetFile?: TFile; }) => { if (newFile && relationshipTypeId && relationshipTargetFile) { await addRelationToFrontmatter({ app: plugin.app, plugin, sourceFile: newFile, targetFile: relationshipTargetFile, relationTypeId: relationshipTypeId, }); } };This helper could be used in both command callbacks to reduce duplication.
apps/obsidian/src/components/ModifyNodeModal.tsx (1)
190-195: Consider resettingselectedRelationshipTypeIdwhenavailableRelationshipschanges.The current logic only sets the initial value when
selectedRelationshipTypeIdis empty. If the user changes the node type andavailableRelationshipschanges to a different set, the previously selected relationship may no longer be valid.♻️ Suggested improvement
useEffect(() => { - if (!selectedRelationshipTypeId && availableRelationships[0]) { + // Reset selection when available relationships change + const isCurrentSelectionValid = availableRelationships.some( + (rel) => rel.relationTypeId === selectedRelationshipTypeId + ); + if (!isCurrentSelectionValid && availableRelationships[0]) { setSelectedRelationshipTypeId(availableRelationships[0].relationTypeId); + } else if (!isCurrentSelectionValid) { + setSelectedRelationshipTypeId(""); } - // eslint-disable-next-line react-hooks/exhaustive-deps -- only run when availableRelationships changes - }, [availableRelationships]); + }, [availableRelationships, selectedRelationshipTypeId]);
Co-authored-by: doantranghp2000 <doantranghp2000@gmail.com>
- Add relationship dropdown to ModifyNodeModal - Auto-detect current page context when creating nodes - Auto-suggest relationships based on node types - Create bidirectional relationships in frontmatter - Support relationships in tag handler and canvas node creation Co-authored-by: doantranghp2000 <doantranghp2000@gmail.com>
Co-authored-by: doantranghp2000 <doantranghp2000@gmail.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
3077985 to
964865e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.loom.com/share/e89289108cd14d529e1fc81573dceae2
Adds auto-linking for Evidence and Source nodes to automatically create relationships when nodes are created from a contextual page.
This PR enhances the
ModifyNodeModalto detect the current file's node type and the type of node being created, then suggests relevant relationships. Upon creation, the selected relationship is automatically added to the frontmatter of both linked nodes, streamlining the workflow for users creating related content.Linear Issue: ENG-1332
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.