Skip to content

Conversation

@trangdoan982
Copy link
Collaborator

@trangdoan982 trangdoan982 commented Apr 26, 2025

https://www.loom.com/share/16c24a6cc7ad4ca6aef6624ffc097bae

Summary by CodeRabbit

  • New Features
    • Introduced a searchable popover menu for inserting discourse nodes by typing "@" in a block, with keyboard and mouse navigation.
    • Selecting a node automatically inserts a page reference into the block.
  • Chores
    • Added new keyboard event listeners to support the discourse node search functionality.

@linear
Copy link

linear bot commented Apr 26, 2025

@vercel
Copy link

vercel bot commented Apr 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
discourse-graph ⬜️ Skipped (Inspect) May 12, 2025 3:57pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 26, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

A new feature has been introduced that allows users to trigger and interact with a searchable popover menu for inserting discourse nodes into a Roam Research block by typing "@". This involves the creation of a new React component for the menu, the addition of a keyboard event listener to detect the trigger, and updates to the initialization and teardown of event listeners. The menu supports keyboard and mouse interactions, updates block content upon selection, and tracks analytics events.

Changes

File(s) Change Summary
apps/roam/src/components/DiscourseNodeSearchMenu.tsx Introduced NodeSearchMenu React component for a searchable popover menu; added helper function renderDiscourseNodeSearchMenu to mount and clean up the menu; manages input, selection, and insertion of discourse nodes.
apps/roam/src/index.ts Registered and unregistered a new discourseNodeSearchTriggerListener for the keydown event in the extension's initialization and unload routines.
apps/roam/src/utils/initializeObserversAndListeners.ts Added discourseNodeSearchTriggerListener to detect "@" keypress in block input textareas and trigger the discourse node search menu; included this listener in the observer/listener initialization and teardown logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Textarea
    participant discourseNodeSearchTriggerListener
    participant NodeSearchMenu
    participant ExtensionAPI

    User->>Textarea: Types "@"
    Textarea->>discourseNodeSearchTriggerListener: keydown event
    discourseNodeSearchTriggerListener->>NodeSearchMenu: renderDiscourseNodeSearchMenu()
    User->>NodeSearchMenu: Types search term / navigates / selects item
    NodeSearchMenu->>ExtensionAPI: Update block content with selected node
    NodeSearchMenu->>NodeSearchMenu: Track selection event
    NodeSearchMenu-->>User: Menu closes, block updated
Loading

Poem

In the garden of Roam where ideas grow free,
A new "@" menu pops up as quick as can be!
With a hop and a skip, I search and I find,
Discourse nodes aplenty, so neatly aligned.
With a twitch of my nose and a tap of my paw,
The block fills with wisdom—oh, what I saw!
🐇✨


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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@trangdoan982
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (1)
apps/roam/src/components/DiscourseNodeSearchMenu.tsx (1)

170-174: Global keydown listener should be scoped

Attaching to document captures every keystroke while the menu is open.
Instead, attach the listener to the menu container or use Popover’s onKeyDown prop to keep the handler local and avoid unintended side-effects.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8b8915 and e499488.

📒 Files selected for processing (3)
  • apps/roam/src/components/DiscourseNodeSearchMenu.tsx (1 hunks)
  • apps/roam/src/index.ts (2 hunks)
  • apps/roam/src/utils/initializeObserversAndListeners.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/roam/src/utils/initializeObserversAndListeners.ts (1)
apps/roam/src/components/DiscourseNodeSearchMenu.tsx (1)
  • renderDiscourseNodeSearchMenu (234-252)

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.

Generally good stuff!

A couple use cases we should handle before merging

  • insert node and keep typing (don't create a new block on enter)
  • dealing with text after @
  • remove node menu when @ is gone

https://www.loom.com/share/8210d0012149414aae284bd0f31b1d64

Copy link
Contributor

How goes the progress on this?

@trangdoan982
Copy link
Collaborator Author

I'm still working on this. there's some cursor position bug I still can't figure out yet.

@trangdoan982
Copy link
Collaborator Author

@mdroidian https://www.loom.com/share/1582b3a10eb44abdbd955c16536caa98 new checkbox for filtering node types during search and a few test cases

Copy link
Contributor

Good stuff. But what happens to the UI when a graph has 9 or 10 nodes? Could you test this on plugin-testing-megacoglab?

@trangdoan982
Copy link
Collaborator Author

@mdroidian i set the popover menu to fixed height will scrollable y so it will look the same and users just need to scroll down to see the results:

scroll.search.menu.mov

@mdroidian
Copy link
Contributor

Having to scroll each time is probably something we want to avoid. Likely we'll want to widen the entire popover and have the check boxes limited to one or two rows, then scroll horizontal. Or remove the grouping and hide the filters until the user wants them. We can consider this out of scope for the current PR and ask Johnny his opinion.

@trangdoan982
Copy link
Collaborator Author

i did start with responsive sizing for the menu, but it somehow created a bug that mess with the popover's position. So i'd go with overflow-x-auto for the filters.
But I think this filter might need more thoughts on UI (when it appears, how it appears), or saving the selected options so it persists somewhere instead of renewing the state everytime it opens.
We already have this ticket to confirm UI with John: https://linear.app/discourse-graphs/issue/ENG-277/confirm-on-ui-design-of-dg-summoning-menu. I will follow up with him here and we might scope a separate PR for the filters

@jsmorabito
Copy link
Collaborator

this is fantastic! I see the utility of having filters given a user might want to only see a particular set of nodes and exclude others from the search. My intuition though is that the filtering action will a less frequent operation and could be relegated to the dg settings menu so that users have the option to customize node search to their needs, but the menu itself will not be cluttered with the filter options.

I'd be content with that solution and then if users request to have filter settings more easily accessible we can explore designs such as these below:
image

For now I'm content with having filter options in the settings menu and not in the node search menu.

@trangdoan982
Copy link
Collaborator Author

trangdoan982 commented May 7, 2025

@jsmorabito my instinct is that user might want to change up the filter type when they query quite often. I'm imagining a flow where users would switch the type up as they type down their paper outline.
I would love to implement a "node type X only" feature, like in Google Flights they have options for you to choose 1 stop only or Non-stop only. With graphs that has lots of lists this would be really helpful. Can you develop a mockup for that as well?

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.

🔥 A few minor changes requested.

Also, I don't believe we should be merging this to main as is. If we want an anchor I'll create a eng-235-create-dg-summoning-menu to merge to.

}
});

// Analytics
Copy link
Contributor

Choose a reason for hiding this comment

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

.

@trangdoan982 trangdoan982 changed the base branch from main to eng-235-create-dg-summoning-menu May 7, 2025 20:06
@jsmorabito
Copy link
Collaborator

@jsmorabito my instinct is that user might want to change up the filter type when they query quite often. I'm imagining a flow where users would switch the type up as they type down their paper outline. I would love to implement a "node type X only" feature, like in Google Flights they have options for you to choose 1 stop only or Non-stop only. With graphs that has lots of lists this would be really helpful. Can you develop a mockup for that as well?

would this be something similar to a search with advanced options like we see in obsidians search widget?
image

I can definitely see a use for having some advanced search that let's you have a more specific query which can persist in the sidebar while your outline is in the main window

@trangdoan982
Copy link
Collaborator Author

@jsmorabito i was referring to this:
image

if there's an UI pattern that can be clean and allow people to chose only 1 node type (i imagine it useful if there are many node types). But that's more a nice-to-have. I don't think we need to overkill this with an advanced filter option for now.

@jsmorabito
Copy link
Collaborator

Gotcha! I made a project in Linear where we can continue to expand on this idea: https://linear.app/discourse-graphs/project/advanced-search-4b947899da16/overview

Feel free to add more notes there. Also added a ticket for mockup up this functionality: https://linear.app/discourse-graphs/issue/DES-49/mock-up-advanced-search

@jsmorabito
Copy link
Collaborator

But yea, for now this node search menu is good without the filters (in the menu itself at least)

@trangdoan982
Copy link
Collaborator Author

@mdroidian addressed your PR comments. I also implemented the filter toggle that Johnny mocked. I made sure the focus remains even when you interact with the filter menu.

test.filter.mov

@trangdoan982 trangdoan982 requested a review from mdroidian May 9, 2025 17: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.

Good stuff!

One thing we should add in the future is capturing clicks and preventing the default so they don't remove focus. (use case: user wants to click the filter button or a checkbox but misses)

https://www.loom.com/share/6a852a8007464f709700f41571c0646c

None of this is blocking.

@trangdoan982 trangdoan982 merged commit 962f5ae into eng-235-create-dg-summoning-menu May 12, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this to Done in General May 12, 2025
@mdroidian mdroidian deleted the eng-259-observer branch May 13, 2025 16:34
mdroidian pushed a commit that referenced this pull request May 27, 2025
* [ENG-259] Create Observer and UI pattern (#138)

* create event listener for @ key

* fix ui

* address PR comments

* cur progress

* current progress

* tested yayyy

* add the checkbox UI

* fix focus issue

* rm logs

* address PR comments

* address PR comments

* [ENG-261] Query function for DG summoning menu (#150)

* cur progress

* current progress

* rm logs

* address PR comments

* address PR comments

* query works

* address PR comments

* address PR comments

* sm change

* [ENG-299] Trigger setting for DG summoning menu (#162)

* setting menu done

* trigger works correctly

* clean up

* address PR comment

* optimize getFocusedBlock()

* address nit comments

* fix bug (#166)

* address PR comments
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.

4 participants