Skip to content

Conversation

@trangdoan982
Copy link
Collaborator

@trangdoan982 trangdoan982 commented Oct 10, 2025

https://www.loom.com/share/0865fab1de364937a0df36a0d07dbcd4

Summary by CodeRabbit

  • New Features
    • SHIFT+Click a Discourse Node on canvas to open its linked Obsidian file.
    • Opens in the right or vertical split for side-by-side viewing.
    • Prevents accidental double-opens with built-in debounce.
    • Provides clear toast messages for missing block references, read errors, or failed openings.
    • Clears selection after opening to streamline navigation.

@supabase
Copy link

supabase bot commented Oct 10, 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 trangdoan982 marked this pull request as ready for review October 10, 2025 01:48
Copy link
Collaborator Author

trangdoan982 commented Oct 10, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@trangdoan982 trangdoan982 changed the title shift click to open file on the right split [ENG-928] Shift click to open file on the right split Oct 10, 2025
@linear
Copy link

linear bot commented Oct 10, 2025

@trangdoan982
Copy link
Collaborator Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Adds SHIFT+click handling in TldrawViewComponent to open a linked Obsidian file from a Discourse Node. Implements debounce, detects single selected discourse-node under pointer, extracts block ref, resolves linked file, opens it in a split, clears selection, and shows toasts on missing refs/errors.

Changes

Cohort / File(s) Summary of Changes
Canvas shift-click open Linked File
apps/obsidian/src/components/canvas/TldrawViewComponent.tsx
Added SHIFT+click handler with debounce; detects discourse-node under pointer and validates single selection; extracts block ref; resolves linked file via resolveLinkedTFileByBlockRef; opens file in right/vertical split; clears selection; integrates toast-based feedback and error handling; added related imports/types/constants.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant C as TldrawViewComponent
  participant E as Tldraw Editor
  participant X as BlockRef Extractor
  participant R as Linked File Resolver
  participant O as Obsidian App
  participant T as Toast

  U->>C: SHIFT+Click on canvas
  C->>C: Debounce guard (skip if recent)
  alt Debounced
    C->>T: showToast("Please wait")
  else Proceed
    C->>E: get shape under pointer
    E-->>C: discourse-node?
    alt Not a discourse-node or multiple selection
      C->>C: Exit (no action)
    else Single discourse-node
      C->>X: extract block ref
      alt No block ref
        C->>T: showToast("Missing block reference")
      else Has block ref
        C->>R: resolveLinkedTFileByBlockRef(ref)
        alt Resolve error or not found
          C->>T: showToast("Unable to resolve/open")
        else Resolved TFile
          C->>O: open file in right/vertical split
          alt Open failed
            C->>T: showToast("Open failed")
          else Opened
            C->>E: clear selection
          end
        end
      end
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

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 succinctly describes the core feature change by indicating that a shift-click action will open a file in the right split, directly reflecting the main functionality added in the code. It is concise, clear, and fully related to the implementation of shift-click handling for opening linked files.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

🧹 Nitpick comments (1)
apps/obsidian/src/components/canvas/TldrawViewComponent.tsx (1)

226-226: Remove redundant null coalescing.

shape.props.src ?? undefined is redundant since the nullish coalescing operator already returns undefined when the left operand is null or undefined.

-        const blockRefId = extractBlockRefId(shape.props.src ?? undefined);
+        const blockRefId = extractBlockRefId(shape.props.src);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1d15d0 and c649cf4.

📒 Files selected for processing (1)
  • apps/obsidian/src/components/canvas/TldrawViewComponent.tsx (4 hunks)
🔇 Additional comments (7)
apps/obsidian/src/components/canvas/TldrawViewComponent.tsx (7)

33-41: LGTM! Clean imports for the new functionality.

The new imports are well-organized and all are utilized in the shift-click handler implementation.

Also applies to: 53-53


71-72: LGTM! Good debounce implementation.

The 300ms debounce window is reasonable for preventing accidental double-clicks while remaining responsive.


203-210: LGTM! Effective debounce logic.

The timestamp-based debounce correctly prevents rapid successive shift-clicks within 300ms.


277-277: LGTM! Good UX touch.

Clearing the editor selection after opening the file prevents confusion and keeps the UI clean.


228-286: LGTM! Comprehensive error handling with user feedback.

The implementation provides clear user feedback through toast notifications for all error cases (missing block ref, file read error, file not found, failed open) and includes proper error logging.


217-224: Verify shift-click requires selected node
Current guard only checks selectedShapes.length, so if Node A is selected and you shift-click unselected Node B, it still opens B. Should the clicked node be required to be in selectedShapes?


246-286: Confirm workspace.rightSplit is a valid API
I couldn’t find rightSplit in the Obsidian type definitions—verify it’s exposed in your target Obsidian version or replace with splitActiveLeaf/alternative split APIs.

@trangdoan982 trangdoan982 force-pushed the 10-09-shift_click_to_open_file_on_the_right_split branch from c649cf4 to d16c9a3 Compare October 10, 2025 15:38
Copy link
Contributor

@mdroidian mdroidian left a comment

Choose a reason for hiding this comment

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

I believe I misunderstood our last conversation where you mentioned this. I assumed the behavior was going to be opening the file in the workspace in another vertical tab beside the existing tab.

Seems like an odd behavior, to open a file in the sidebar. This goes against the plugins default behavior (shift click opens in current tab). This will also lead to some odd UX like if the canvas is in it's own window, for example. And closing a sidebar leaf isn't as clear as it is in the main window.

But, if you are sure this is what was requested, I won't block on it. I just couldn't find the original request in the ticket. I'd like to investigate the discussion and bring this up.


EDIT - I tested shift click on a property, shift click on a regular link does nothing

As long as we are matching Obsidian in the future:

  • Ctrl - open in new tab in current leaf
  • Alt+Ctrl - open in new leaf

and creating some affordance to open the node in the current tab, I'm happy.

@trangdoan982
Copy link
Collaborator Author

I'll note this behavior down in this ticket: https://linear.app/discourse-graphs/issue/ENG-874/open-dn-file

@trangdoan982 trangdoan982 merged commit 1a01259 into tldraw-obsidian Oct 13, 2025
5 checks passed
@trangdoan982 trangdoan982 deleted the 10-09-shift_click_to_open_file_on_the_right_split branch October 13, 2025 15:57
@github-project-automation github-project-automation bot moved this to Done in General Oct 13, 2025
trangdoan982 added a commit that referenced this pull request Oct 16, 2025
* [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>
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.

3 participants