Skip to content

Conversation

@sid597
Copy link
Collaborator

@sid597 sid597 commented Aug 25, 2025

https://www.loom.com/share/7aaa1d3cb17b4d25ba58451d21c2ed4a?sid=8d65c3d8-861f-44e4-b3c5-92b4a000a5c1

Summary by CodeRabbit

  • Bug Fixes
    • Ensures tags are consistently normalized: a single leading “#” is displayed, stored, and used in menus and popups.
    • Tag matching is case-insensitive and ignores an initial “#”, improving accuracy when suggesting or creating tags.
  • Style
    • Tag input placeholder now shows a normalized suggestion (e.g., “#example”) using lowercase.
    • Create button label in the tag popup displays the normalized tag with a single “#” for clarity.

@supabase
Copy link

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

@linear
Copy link

linear bot commented Aug 25, 2025

@sid597
Copy link
Collaborator Author

sid597 commented Aug 25, 2025

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

📝 Walkthrough

Walkthrough

This PR standardizes tag handling across Roam UI components: it normalizes user-entered tags by stripping a leading “#” and lowercasing for comparisons, ensures a single “#” when displaying/inserting tags, and updates the tag input placeholder format.

Changes

Cohort / File(s) Summary
Menu tag normalization and display
apps/roam/src/components/DiscourseNodeMenu.tsx
Strip leading “#” from tags before prefixing with a single “#” when inserting and displaying; store data-tag without leading “#”.
Tag input placeholder
apps/roam/src/components/settings/NodeConfig.tsx
Change placeholder to include leading “#” and lowercase: #${node.text.toLowerCase()}.
Popup tag normalization and creation flow
apps/roam/src/utils/renderNodeTagPopup.tsx
Normalize tags by stripping leading “#” and lowercasing for set membership and matching; update Create button text to “Create #tag”.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant M as DiscourseNodeMenu
  participant D as Document

  U->>M: Select tag to insert
  M->>M: normalize(tag): strip leading "#" once
  M->>D: Insert text "#"+tag+" "
Loading
sequenceDiagram
  autonumber
  actor U as User
  participant P as renderNodeTagPopup
  participant S as Tag Set
  participant N as Node Store

  U->>P: Type tag (e.g., "#Tag")
  P->>P: norm = strip leading "#" + toLowerCase()
  P->>S: Check contains(norm)
  alt exists
    S-->>P: match found
    P->>U: Show matched node
  else not exists
    P->>U: Show "Create #"+norm
    U->>P: Click Create
    P->>N: Create node with tag norm
  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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/roam/src/components/settings/NodeConfig.tsx (1)

158-166: Fix regex group usage to correctly extract tag names (current logic misses #tag and over-captures [[...]]).

match[1] || match[2] is wrong for the current alternation. For #tag, the captured group is match[3]; for [[...]], match[2] is the inner page title while match[1] is the whole #?[[...]] fragment. As written, the validation will fail to detect #tag conflicts and will compare the entire bracket expression instead of the inner title for [[...]].

Apply this diff to capture only tag titles and handle both forms:

-    const roamTagRegex = /#?\[\[(.*?)\]\]|#(\S+)/g;
+    const roamTagRegex = /#?\[\[([^\]]+)\]\]|#([^\s#]+)/g;
     const matches = format.matchAll(roamTagRegex);
     const formatTags: string[] = [];
     for (const match of matches) {
-      const tagName = match[1] || match[2];
+      const tagName = (match[1] ?? match[2] ?? "").trim();
       if (tagName) {
         formatTags.push(tagName.toUpperCase());
       }
     }
🧹 Nitpick comments (4)
apps/roam/src/components/settings/NodeConfig.tsx (1)

232-232: Placeholder casing: consider not forcing lowercase for display.

The placeholder now lowercases the example tag. Elsewhere, tag displays are sometimes shown with original casing (e.g., Node Menu). For a consistent UX and to avoid oddities with proper nouns (“iOS”, “GraphQL”), consider keeping the original case in the placeholder.

-                placeholder={`#${node.text.toLowerCase()}`}
+                placeholder={`#${node.text}`}
apps/roam/src/components/DiscourseNodeMenu.tsx (1)

113-127: Optional: avoid unconditional trailing space insertion.

When inserting, you always append a trailing space. This is convenient, but can introduce double spaces or unwanted spacing mid-word. Consider inserting a space only if the next character isn’t whitespace or punctuation.

-          const newText = `${currentText.substring(
-            0,
-            cursorPos,
-          )}${textToInsert}${currentText.substring(cursorPos)}`;
+          const needsSpace =
+            !currentText[cursorPos] || !/\s|[)\],.;:!?]/.test(currentText[cursorPos]);
+          const newText = `${currentText.substring(0, cursorPos)}${textToInsert}${needsSpace ? "" : ""}${currentText.substring(cursorPos)}`;

Note: Alternatively compute textToInsert without trailing space and decide space contextually.

apps/roam/src/utils/renderNodeTagPopup.tsx (2)

74-74: Display consistency: consider preserving original case in the “Create” label.

Elsewhere (Node Menu), the rendered tag keeps its original case. Here it’s forced to lowercase. Decide on one convention for display; for comparisons, keep normalization under the hood.

-          text={`Create #${matchedNode.tag?.replace(/^#/, "").toLowerCase()}`}
+          text={`Create #${matchedNode.tag?.replace(/^#+/, "")}`}

36-43: Optional: centralize tag normalization to avoid duplication.

Normalization is repeated across files with slight variations. Introduce a small utility to reduce drift.

Example (new file apps/roam/src/utils/tagUtils.ts):

export const normalizeForCompare = (s?: string) =>
  (s ?? "").replace(/^#+/, "").trim().toLowerCase();

export const formatForDisplay = (s?: string) => {
  const core = (s ?? "").replace(/^#+/, "").trim();
  return core ? `#${core}` : "";
};

Then use:

// comparisons
normalizeForCompare(n.tag) === normalizeForCompare(input);

// display
formatForDisplay(item.tag)
📜 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 6c63455 and 2abe0f9.

📒 Files selected for processing (3)
  • apps/roam/src/components/DiscourseNodeMenu.tsx (2 hunks)
  • apps/roam/src/components/settings/NodeConfig.tsx (1 hunks)
  • apps/roam/src/utils/renderNodeTagPopup.tsx (2 hunks)
🔇 Additional comments (1)
apps/roam/src/components/DiscourseNodeMenu.tsx (1)

124-126: Analytics consistency: confirm whether tag should include #.

You’re capturing tag without the hash here, while other parts of the app may include it. Align the event property format for easier analysis downstream.

Would you like me to scan the repo for posthog.capture usages that include a tag property and summarize the formats used?

@sid597 sid597 requested a review from mdroidian September 1, 2025 07:55
@sid597
Copy link
Collaborator Author

sid597 commented Sep 5, 2025

#418 carried over using graphite

@sid597 sid597 closed this Sep 5, 2025
@github-project-automation github-project-automation bot moved this to Done in General Sep 5, 2025
@sid597 sid597 deleted the eng-693-handle-in-tags branch September 5, 2025 19:26
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