Skip to content

Conversation

@mdroidian
Copy link
Contributor

@mdroidian mdroidian commented Aug 24, 2025

https://www.loom.com/share/954b7fce269d41aea8d6e1600236de23

Summary by CodeRabbit

  • New Features
    • Added a “Auto Canvas Relations” toggle in Personal Settings to control automatic creation of discourse relations on the canvas when adding or editing nodes. Default is off.
    • When enabled, relations are auto-created after creating shapes and after editing node labels, preserving previous behavior.
    • Clear in-app description explains the effect of the setting.

@supabase
Copy link

supabase bot commented Aug 24, 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 ↗︎.

@mdroidian
Copy link
Contributor Author

@CodeRabbit full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 24, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 24, 2025

📝 Walkthrough

Walkthrough

Adds a user-configurable setting (AUTO_CANVAS_RELATIONS_KEY) to control automatic creation of canvas discourse relations. Integrates the setting in canvas node creation/edit flows to conditionally call createExistingRelations. Exposes a new toggle in personal settings and defines the setting key in userSettings.

Changes

Cohort / File(s) Summary
Setting key definition
apps/roam/src/data/userSettings.ts
Exported AUTO_CANVAS_RELATIONS_KEY = "auto-canvas-relations".
Settings UI
apps/roam/src/components/settings/HomePersonalSettings.tsx
Added “Auto Canvas Relations” checkbox bound to extensionAPI.settings using AUTO_CANVAS_RELATIONS_KEY; persists on change.
Canvas relation gating
apps/roam/src/components/canvas/DiscourseNodeUtil.tsx, apps/roam/src/components/canvas/Tldraw.tsx
Imported AUTO_CANVAS_RELATIONS_KEY and getSetting. Replaced unconditional createExistingRelations with conditional calls based on getSetting(AUTO_CANVAS_RELATIONS_KEY, false) in node edit and after-create handlers.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Settings as Settings UI
  participant Ext as extensionAPI.settings
  participant Canvas as Canvas (Tldraw/DiscourseNodeUtil)
  participant Util as getSetting
  participant Rel as createExistingRelations

  User->>Settings: Toggle "Auto Canvas Relations"
  Settings->>Ext: set(AUTO_CANVAS_RELATIONS_KEY, true/false)

  rect rgb(240,245,255)
  note right of Canvas: On shape create or label edit
  Canvas->>Util: getSetting(AUTO_CANVAS_RELATIONS_KEY, false)
  alt Auto enabled
    Util-->>Canvas: true
    Canvas->>Rel: createExistingRelations(...)
    Rel-->>Canvas: done
  else Auto disabled
    Util-->>Canvas: false
    note right of Canvas: Skip relation creation
  end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mdroidian
Copy link
Contributor Author

@CodeRabbit full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 24, 2025

✅ Actions performed

Full review triggered.

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: 2

🧹 Nitpick comments (2)
apps/roam/src/data/userSettings.ts (1)

6-6: Add brief JSDoc and confirm intended default/back-compat behavior

Nice addition. Two quick items:

  • Add a short comment to describe the key’s purpose.
  • Today’s call sites use getSetting(AUTO_CANVAS_RELATIONS_KEY, false), which flips a previously-always-on behavior to OFF by default. If that’s unintended, switch those defaults to true for backward compatibility.

Apply this doc tweak:

+// Controls whether discourse relations are auto-created on the canvas when nodes are added/edited.
 export const AUTO_CANVAS_RELATIONS_KEY = "auto-canvas-relations";

If we want to preserve the prior default behavior (auto-creation ON), I’ve proposed diffs in the other files to default to true.

apps/roam/src/components/settings/HomePersonalSettings.tsx (1)

147-168: Clarify label/scope, align default for back-compat, and keep style consistent

  • Label/description: The toggle also affects relation creation on edit flows, not just “when a node is added.” Clarify the copy.
  • Default: If we intend to preserve the previous behavior (auto-create ON by default), prefer !== false as used elsewhere for “on by default” switches.
  • Style: Other checkboxes don’t use void before extensionAPI.settings.set; drop it for consistency.
       <Checkbox
-        defaultChecked={
-          extensionAPI.settings.get(AUTO_CANVAS_RELATIONS_KEY) === true
-        }
+        defaultChecked={
+          extensionAPI.settings.get(AUTO_CANVAS_RELATIONS_KEY) !== false
+        }
         onChange={(e) => {
           const target = e.target as HTMLInputElement;
-          void extensionAPI.settings.set(
+          extensionAPI.settings.set(
             AUTO_CANVAS_RELATIONS_KEY,
             target.checked,
           );
         }}
         labelElement={
           <>
-            Auto Canvas Relations
+            Auto-create Canvas Relations
             <Description
               description={
-                "Automatically add discourse relations to canvas when a node is added"
+                "Automatically create discourse relations on the canvas when a node is added or edited."
               }
             />
           </>
         }
       />

If the new behavior should be OFF by default, keep the current === true check, but please still update the label/description.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 96544bc and 52a1bd8.

📒 Files selected for processing (4)
  • apps/roam/src/components/canvas/DiscourseNodeUtil.tsx (2 hunks)
  • apps/roam/src/components/canvas/Tldraw.tsx (2 hunks)
  • apps/roam/src/components/settings/HomePersonalSettings.tsx (2 hunks)
  • apps/roam/src/data/userSettings.ts (1 hunks)
🔇 Additional comments (3)
apps/roam/src/components/settings/HomePersonalSettings.tsx (1)

16-16: Import looks good

Importing the setting key from a single source of truth is the right call.

apps/roam/src/components/canvas/Tldraw.tsx (1)

85-87: LGTM

Centralizing the key and using getSetting here keeps the canvas logic decoupled from the settings UI.

apps/roam/src/components/canvas/DiscourseNodeUtil.tsx (1)

41-43: LGTM

Importing the key and getSetting here aligns the node util with the canvas handler.

@mdroidian mdroidian merged commit 40b63ec into main Aug 24, 2025
5 checks passed
…elations are deleted before creating existing relations when auto canvas relations are enabled.
@mdroidian mdroidian deleted the eng-636-add-toggle-to-roam-dg-settings-menu-allowing-user-to-enable branch August 24, 2025 09:19
@github-project-automation github-project-automation bot moved this to Done in General Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants