Skip to content

Conversation

@trangdoan982
Copy link
Collaborator

@trangdoan982 trangdoan982 commented Nov 28, 2025

https://www.loom.com/share/c30a96008bff4252ac98c556d0815fe1

Summary by CodeRabbit

  • New Features

    • Added delete functionality with a new delete button (×) next to each linked file, enabling users to remove relationships directly from the interface with automatic updates across both files.
  • Style

    • Updated relationship item layout structure for improved visual presentation and usability.

✏️ Tip: You can customize this high-level summary in your review settings.

@linear
Copy link

linear bot commented Nov 28, 2025

@supabase
Copy link

supabase bot commented Nov 28, 2025

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 ↗︎.

@trangdoan982
Copy link
Collaborator Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

📝 Walkthrough

Walkthrough

Changes add a delete relationship feature to the Obsidian RelationshipSection component with a new delete button and deleteRelationship callback, while refactoring turbo.json task dependencies from "with" to "dependsOn" for roam#dev and website#dev tasks.

Changes

Cohort / File(s) Summary
Obsidian Relationship Management
apps/obsidian/src/components/RelationshipSection.tsx
Added deleteRelationship callback to remove relationships by updating frontmatter on both active and linked files with error handling; converted loadCurrentRelationships to memoized useCallback; updated UI to display flex-row layout with delete button (×) for each linked file item
Build Configuration
turbo.json
Changed task dependency declaration from "with" to "dependsOn" for roam#dev and website#dev tasks; updates how @repo/database#dev dependency is specified in the dependency graph

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Focus on deleteRelationship logic: verify frontmatter update operations on both files work correctly and error handling is appropriate
  • Confirm turbo.json dependency graph change doesn't alter intended build behavior

Possibly related PRs

  • discourse-graph#115: Introduces new RelationshipManager component for Obsidian relationship UI management, complementary to these relationship-handling enhancements.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding the ability to remove relations in the Obsidian Discourse Context Panel, which is reflected in the RelationshipSection.tsx modifications introducing the deleteRelationship function and delete button UI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/obsidian/src/components/RelationshipSection.tsx (3)

340-427: Align useEffect dependencies with loadCurrentRelationships and avoid lint warnings

The new loadCurrentRelationships useCallback looks good, but useEffect above now depends on it (direct call + inside onMetadataChange) without listing it in the dependency array. This will violate react-hooks/exhaustive-deps and is slightly indirect.

You can make the relationship explicit and a bit clearer by moving the callback above the effect and depending on it directly:

-  useEffect(() => {
-    loadCurrentRelationships();
-    const onMetadataChange = (file: TFile) => {
-      if (file && file.path === activeFile.path) {
-        loadCurrentRelationships();
-      }
-    };
-    plugin.app.metadataCache.on("changed", onMetadataChange);
-    return () => {
-      plugin.app.metadataCache.off(
-        "changed",
-        onMetadataChange as (...data: unknown[]) => unknown,
-      );
-    };
-  }, [activeFile, plugin]);
-
-  const loadCurrentRelationships = useCallback(async () => {
+  const loadCurrentRelationships = useCallback(async () => {
     const fileCache = plugin.app.metadataCache.getFileCache(activeFile);
     if (!fileCache?.frontmatter) return;
@@
-    setGroupedRelationships(Array.from(tempRelationships.values()));
-  }, [activeFile, plugin]);
+    setGroupedRelationships(Array.from(tempRelationships.values()));
+  }, [activeFile, plugin]);
+
+  useEffect(() => {
+    loadCurrentRelationships();
+
+    const onMetadataChange = (file: TFile) => {
+      if (file && file.path === activeFile.path) {
+        loadCurrentRelationships();
+      }
+    };
+
+    plugin.app.metadataCache.on("changed", onMetadataChange);
+
+    return () => {
+      plugin.app.metadataCache.off(
+        "changed",
+        onMetadataChange as (...data: unknown[]) => unknown,
+      );
+    };
+  }, [activeFile, plugin, loadCurrentRelationships]);

Behavior stays the same, but the hook dependencies become explicit and lint-friendly.


428-491: Delete logic is sound; consider minor cleanups and explicit typing (optional)

The deleteRelationship implementation correctly:

  • Locates the relationType by id.
  • Removes the appropriate wiki link from both activeFile and linkedFile frontmatter, handling scalar vs array values and deleting the key when empty.
  • Shows clear success/error notices and refreshes state via loadCurrentRelationships().

Two small, optional refinements you might consider:

  1. Parallelize frontmatter updates to reduce latency a bit:
-        // Remove link from active file
-        await removeLinkFromFrontmatter(
-          activeFile,
-          linkedFile.name,
-          relationTypeId,
-        );
-
-        // Remove reverse link from linked file
-        await removeLinkFromFrontmatter(
-          linkedFile,
-          activeFile.name,
-          relationTypeId,
-        );
+        await Promise.all([
+          removeLinkFromFrontmatter(activeFile, linkedFile.name, relationTypeId),
+          removeLinkFromFrontmatter(linkedFile, activeFile.name, relationTypeId),
+        ]);
  1. Add an explicit return type for clarity with TS guidelines, e.g.:
const deleteRelationship = useCallback(
  async (linkedFile: TFile, relationTypeId: string): Promise<void> => {
    // ...
  },
  [/* ... */],
);

Not required for correctness, but these keep the implementation a bit tighter and closer to the stated TS conventions.


513-536: New delete button works; consider small accessibility and icon tweaks

The new inline delete button per relationship (× with a tooltip) is functional and styled consistently with the rest of the panel.

To align more closely with accessibility and Obsidian icon conventions, you could optionally:

  • Add an aria-label for screen readers (title alone isn’t always sufficient).
  • Swap the raw "×" for a Lucide or Obsidian icon, per the Obsidian style guidance.

For example:

-                  <button
-                    className="!text-muted hover:!text-error cursor-pointer border-0 !bg-transparent p-1 text-sm"
-                    onClick={(e) => {
-                      e.preventDefault();
-                      deleteRelationship(file, group.relationTypeOptions.id);
-                    }}
-                    title="Delete relationship"
-                  >
-                    ×
-                  </button>
+                  <button
+                    className="!text-muted hover:!text-error cursor-pointer border-0 !bg-transparent p-1 text-sm"
+                    onClick={(e) => {
+                      e.preventDefault();
+                      deleteRelationship(file, group.relationTypeOptions.id);
+                    }}
+                    title="Delete relationship"
+                    aria-label="Delete relationship"
+                  >
+                    ×
+                  </button>

Functionally you’re good; this is just polish.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20199dc and ec13cff.

📒 Files selected for processing (2)
  • apps/obsidian/src/components/RelationshipSection.tsx (4 hunks)
  • turbo.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/main.mdc)

**/*.{ts,tsx}: Use Tailwind CSS for styling where possible
When refactoring inline styles, use tailwind classes
Prefer type over interface in TypeScript
Use explicit return types for functions
Avoid any types when possible
Prefer arrow functions over regular function declarations
Use named parameters (object destructuring) when a function has more than 2 parameters
Use PascalCase for components and types
Use camelCase for variables and functions
Use UPPERCASE for constants
Function names should describe their purpose clearly
Prefer early returns over nested conditionals for better readability

Files:

  • apps/obsidian/src/components/RelationshipSection.tsx
apps/obsidian/**

📄 CodeRabbit inference engine (.cursor/rules/obsidian.mdc)

apps/obsidian/**: Prefer existing dependencies from apps/obsidian/package.json when adding dependencies to the Obsidian plugin
Follow the Obsidian style guide from help.obsidian.md/style-guide and docs.obsidian.md/Developer+policies for UI and code styling
Use Lucide and custom Obsidian icons alongside detailed elements to provide visual representation of features in platform-native UI

Files:

  • apps/obsidian/src/components/RelationshipSection.tsx
🧠 Learnings (1)
📚 Learning: 2025-11-25T00:52:41.934Z
Learnt from: CR
Repo: DiscourseGraphs/discourse-graph PR: 0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-11-25T00:52:41.934Z
Learning: Applies to apps/roam/**/*.{js,ts,tsx,jsx,json} : Prefer existing dependencies from package.json when working on the Roam Research extension

Applied to files:

  • turbo.json
🔇 Additional comments (1)
turbo.json (1)

63-68: Switch to dependsOn is consistent with the rest of the Turbo config

Using "dependsOn": ["@repo/database#dev"] for both roam#dev and website#dev matches how other tasks (e.g., build, lint, deploy) express dependencies in this file and keeps the task graph explicit. No issues spotted with this change.

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