Skip to content

ENG-1831: Convert native tldraw arrows to discourse relations (Obsidian)#1118

Open
trangdoan982 wants to merge 2 commits into
mainfrom
eng-1831-implement-ability-to-convert-a-tldraw-arrow-to-a-dg-relation
Open

ENG-1831: Convert native tldraw arrows to discourse relations (Obsidian)#1118
trangdoan982 wants to merge 2 commits into
mainfrom
eng-1831-implement-ability-to-convert-a-tldraw-arrow-to-a-dg-relation

Conversation

@trangdoan982

@trangdoan982 trangdoan982 commented Jun 9, 2026

Copy link
Copy Markdown
Member

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

Summary

  • Add a Relation context menu on native tldraw arrows that connect two discourse nodes, listing only schema-valid relation types for that node pair.
  • Convert arrows by creating a discourse-relation shape (preserving geometry and bindings) and deleting the native arrow, matching the create-and-delete pattern used for text/image → node conversion.
  • Persist to relations.json before the canvas swap so a failed save leaves the native arrow unchanged; shared persistence logic is extracted into persistRelationBetweenNodeShapes.

Test plan

  • Connect two discourse nodes (e.g. Evidence → Claim) with a native tldraw arrow, right-click → Relation → select a type (e.g. opposes)
  • Confirm the arrow becomes a labeled discourse relation with correct color and relations.json entry
  • Verify the relation appears in the Relations panel for both nodes
  • Right-click an arrow between non-discourse shapes → no Relation menu
image
  • Right-click an arrow between incompatible node types → no Relation menu
  • Simulate a persist failure (e.g. node without instance id) → native arrow remains, no misleading relation label
  • Undo/redo the conversion works cleanly

Made with Cursor


Open in Devin Review

…dian canvas.

Persist to relations.json before swapping the shape so failed saves leave the native arrow unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@linear-code

linear-code Bot commented Jun 9, 2026

Copy link
Copy Markdown

ENG-1831

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
discourse-graph Skipped Skipped Jun 9, 2026 9:10pm

Request Review

@supabase

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

@graphite-app

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

@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 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Also pass targetCanvasId on reifyRelation success toasts for consistency.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mdroidian

Copy link
Copy Markdown
Member

@codex review

@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: 117ecc79cd

ℹ️ 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 on lines +195 to +197
startNode,
endNode,
relationTypeId,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize reverse relations before persisting

When a native arrow is drawn in the reverse of an allowed schema edge (for example the default Claim → Evidence arrow for the Evidence supports Claim relation), getValidRelationTypesForNodePair still exposes that relation because it accepts reverse, and the converted shape is labeled with the complement, but this call persists startNode as the relation source and endNode as the destination. That writes relations.json as Claim supports Evidence instead of Evidence supports Claim, so the Relations panel shows the opposite label and publish code cannot match the schema triple for the saved relation. Swap the files/nodes when the selected relation is reverse-only before calling the persistence helper.

Useful? React with 👍 / 👎.

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