-
Notifications
You must be signed in to change notification settings - Fork 3
ENG-605: Add new relation flow #411
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
ENG-605: Add new relation flow #411
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
Caution Review failedAn error occurred during the review process. Please try again 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. 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: 2
🧹 Nitpick comments (9)
apps/obsidian/src/components/canvas/DiscourseRelationTool.ts (4)
157-161: Remove unreachable branch after earlier null/Type guard
targetis already asserted non-null and type-checked above; thisif (!target) ... elseblock can’t hit the!targetpath. Simplify to just set hinting.Apply this diff:
- if (!target) { - this.createArrowShape(); - } else { - this.editor.setHintingShapes([target.id]); - } + this.editor.setHintingShapes([target.id]);
80-111: Deduplicate and centralize relation compatibility logic
getCompatibleNodeTypesfilters the same array twice and reimplements logic that likely belongs in a shared util. Consider moving this to a utility (e.g.,relationUtils) and pre-indexing relations by type to avoid O(2n) scans on every pointer start.I can extract this into a helper and add simple caching if helpful.
16-22: Global tool context can bleed across editors/views
relationToolContextis module-scoped. If multiple canvases/editors are open, context can be overwritten or cleared unexpectedly by another instance. Prefer storing context in the editor’s instance state or a store keyed by editor id.I can wire this to
editor.setInstanceStateor a jotai/atom keyed byeditor.instanceIdif you want.
119-123: Avoid noisy notices when no relation type is setShowing a Notice on any click with the tool active but no selected relation type can be distracting. Consider early-returning without a Notice and highlighting the panel to prompt selection.
apps/obsidian/src/components/canvas/TldrawViewComponent.tsx (2)
205-212: Tool override OK; consider defaulting context on selectOverriding the
"discourse-relation"tool is fine. Optional: if no relation type is focused, default-select the first available relation type to avoid “No relation type selected” warnings on first use.
233-252: Add a toolbar button for the relation toolThe panel covers selection, but parity in the toolbar improves discoverability and flow.
Apply this diff:
Toolbar: (props) => { const tools = useTools(); const isDiscourseNodeSelected = useIsToolSelected( tools["discourse-node"], ); + const isDiscourseRelationSelected = useIsToolSelected( + tools["discourse-relation"], + ); return ( <DefaultToolbar {...props}> <TldrawUiMenuItem id="discourse-node" icon="discourseNodeIcon" label="Discourse Node" onSelect={() => { if (editorRef.current) { editorRef.current.setCurrentTool("discourse-node"); } }} isSelected={isDiscourseNodeSelected} /> + <TldrawUiMenuItem + id="discourse-relation" + icon="tool-arrow" + label="Discourse Relation" + onSelect={() => { + if (editorRef.current) { + editorRef.current.setCurrentTool("discourse-relation"); + } + }} + isSelected={isDiscourseRelationSelected} + /> <DefaultToolbarContent /> </DefaultToolbar> ); },apps/obsidian/src/components/canvas/DiscourseToolPanel.tsx (3)
220-227: Cursor should also reflect relation focusCursor changes only when a node type is focused. Apply the same UX when a relation is focused.
Apply this diff:
- useEffect(() => { - const cursor = focusedNodeTypeId ? "cross" : "default"; + useEffect(() => { + const hasAnyFocus = !!focusedNodeTypeId || !!focusedRelationTypeId; + const cursor = hasAnyFocus ? "cross" : "default"; editor.setCursor({ type: cursor }); return () => { editor.setCursor({ type: "default" }); }; - }, [focusedNodeTypeId, editor]); + }, [focusedNodeTypeId, focusedRelationTypeId, editor]);
304-304: Remove redundant key on inner button
keyshould be on the mapped component, not the inner DOM element. It’s ignored here and can be dropped.Apply this diff:
- <button - key={nodeType.id} + <button
350-362: Avoid hard-coding CDN icon versionThe mask URL pins
2.3.0; future TLDraw updates may break icons. Prefer a local asset or the editor’s icon system.I can wire this to use
assetUrls.iconsor a local SVG import.
📜 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.
📒 Files selected for processing (3)
apps/obsidian/src/components/canvas/DiscourseRelationTool.ts(1 hunks)apps/obsidian/src/components/canvas/DiscourseToolPanel.tsx(8 hunks)apps/obsidian/src/components/canvas/TldrawViewComponent.tsx(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Graphite / mergeability_check
- GitHub Check: Graphite / mergeability_check
- GitHub Check: Graphite / mergeability_check
- GitHub Check: Graphite / mergeability_check
- GitHub Check: Graphite / mergeability_check
🔇 Additional comments (4)
apps/obsidian/src/components/canvas/DiscourseRelationTool.ts (1)
182-187: Verify DiscourseRelationShape defines “end” handle
Search shows nogetShapeHandlesoverride or static handle list inDiscourseRelationShape.tsx. Ensure the shape (or its util) actually declares a handle with
• id:"end"
• type:vertex
• index:"a3"
before using it, or dragging behavior will be incorrect.apps/obsidian/src/components/canvas/TldrawViewComponent.tsx (2)
73-74: LGTM: tools registrationRegistering both
DiscourseNodeToolandDiscourseRelationToolintoolsis correct.
217-231: LGTM: conditional StylePanel integrationSwitching to
DiscourseToolPanelwhen either discourse tool is selected works as intended.apps/obsidian/src/components/canvas/DiscourseToolPanel.tsx (1)
242-251: Nice: relation tool handoff is wiredClicking a relation type sets the context and switches the tool. Smooth flow.
6676abd to
6a00de7
Compare
226d5b2 to
d90bba4
Compare
65b4a9c to
82a3329
Compare
d90bba4 to
10ba459
Compare
82a3329 to
f8fec7f
Compare
ec8785c to
4011a3b
Compare
f8fec7f to
2117973
Compare
4011a3b to
73a9bdf
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.
Could you please add a loom video walking through the UI/UX changes then re-tag me? Thank you.
73a9bdf to
89ff480
Compare
2117973 to
382d101
Compare
|
oh yes my bad. here's the Loom link: https://www.loom.com/share/b1d6d2bc9261479287ed9a486326c93f |
mdroidian
left a 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.
Found a couple bugs
https://www.loom.com/share/2d2056ae7c6e4a0db5b6d20d77119bf9
The one described in the video (relation tool being unselected) and also the relation arrow label line breaking. For the relation arrow line breaking, we had a similar issue in roam, you could look there in the css, might have the same solution.
apps/obsidian/src/components/canvas/shapes/DiscourseRelationBinding.tsx
Outdated
Show resolved
Hide resolved
|
@trangdoan982 another thing that we need to change is: relations need to be added on " |
89ff480 to
a72671b
Compare
|
@mdroidian can you clarify what you mean by the mouse events? I think the flow for creating the relations in the app for Roam are quite different from Obsidian. For Roam, I noticed that the relation is created on "pointer_up" event and the function |
|
@trangdoan982 Yeah it was like this in Roam too for the initial upgrade , but changed. https://linear.app/discourse-graphs/issue/ENG-688/bind-on-mouse-up (I think it was changed before merging to main, so there's no PR to reference) The binding gets created right when the handle is over a bindable shape. This causes a problematic UX. So we have to change when the relation is created to when the user releases the mouse. This way we know the intent of the user. |
fda8850 to
cc8556b
Compare
|
@mdroidian yes I see. It created the wrong relation even. I pushed up the latest changes, which address this comment. Now the relation is only created on the pointer_up event, following similar pattern to Roam |
mdroidian
left a 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.
A few bugs I noticed. None blocking, can be done later. Some not related to this PR.
https://www.loom.com/share/a839dd03460c4ca2866a03461d763d54
Let's make sure we host the .svg on vercel, nix the console.logs, and use named params on addRelationToFrontmatter, then feel free to merge
apps/obsidian/src/components/canvas/shapes/DiscourseRelationBinding.tsx
Outdated
Show resolved
Hide resolved
cc8556b to
895292b
Compare
* [ENG-495] Tldraw obsidian setup (#285) * cleaned * sm * address PR comments * [ENG-598] Data persistence for tldraw (#303) * data persistence to the file * error handling * address PR comments * address some PR comments * address other PR comments * address PR comments * [ENG-624] TLDraw Obsidian asset store (#326) * current state * works now * clean up * address PR comments * address PR reviews * cleanup * fix styling issues * address PR comments * correct styles * [ENG-599] Discourse node shape (#341) * current state * works now * clean up * address PR comments * address PR reviews * fix styling issues * latest progress * update new shape * shape defined * address PR comments * sm address PR review * current progress * reorg * address other PR comments * clean * simplify flow * address PR comments * [ENG-604] Create node flow (#387) * eng-604: create node flow * pwd * [ENG-658] Add existing node flow (#389) * eng-658-add-existing-nodes-flow * address PR comments * small changes * [ENG-601] Create settings for canvas and attachment default folder (#338) * add new settings * small add * ENG-600: Discourse Relation shape definition (#408) * ENG-605: Add new relation flow (#411) * [ENG-603] Add existing relations (#412) https://www.loom.com/share/3641f2a642714b0d849262344e8c6ee5?sid=0614c657-e541-4bfd-92df-9b1aa60945b6 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Added a Relations overlay on the canvas that shows a “Relations” button when a discourse node is selected. - Introduced a Relations panel to view and manage relations for the selected node, including adding or removing links, with clear loading/error states. - Overlay appears above the canvas without disrupting existing tools. - Chores - Consolidated relation-type lookup into shared utilities and updated imports. No user-facing changes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> * [ENG-844] Add color setting for relation types (#429) * add color setting * address PR reviews * address PR commens * fix icons * ENG-812 Update of database cli tools (#401) * eng-812 : Update database cli tools: supabase, vercel, cucumber. * newer cucumber constrains node * [ENG-495] Tldraw obsidian setup (#285) * cleaned * sm * address PR comments * [ENG-598] Data persistence for tldraw (#303) * data persistence to the file * error handling * address PR comments * address some PR comments * address other PR comments * address PR comments * switch to pnpm * delete wrong rebase file * fix pnpm lock * fix type checks * address all the PR comments * delete redundant files * fix types * shift click to open file on the right split (#485) * address PR comments * final lint cleanup --------- Co-authored-by: Marc-Antoine Parent <maparent@acm.org>


Summary by CodeRabbit
New Features
UI/UX