Skip to content

Conversation

@sid597
Copy link
Collaborator

@sid597 sid597 commented Sep 4, 2025

image

Summary by CodeRabbit

  • Style
    • Tag badges in the node tag popup now display consistent colors derived from the tag’s canvas color.
    • Improved readability with added padding and rounded corners on tag badges.
    • More reliable color rendering through normalization for a uniform look across tags.

@linear
Copy link

linear bot commented Sep 4, 2025

@supabase
Copy link

supabase bot commented Sep 4, 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 ↗︎.

Copy link
Collaborator Author

sid597 commented Sep 4, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

@sid597 sid597 changed the title add background color to a nodetag ENG-798 add color to a nodetag Sep 4, 2025
@linear
Copy link

linear bot commented Sep 4, 2025

@sid597 sid597 marked this pull request as ready for review September 4, 2025 08:35
@sid597
Copy link
Collaborator Author

sid597 commented Sep 4, 2025

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

📝 Walkthrough

Walkthrough

Replaces per-tag membership Set with a tag-to-style map built during refresh, normalizing colors. The node tag popup observer now checks the map and, when present, renders the popup and applies inline styles (color, padding, borderRadius) to the tag span. Adds formatHexColor import. No public API changes.

Changes

Cohort / File(s) Summary
Tag style mapping and UI styling
apps/roam/src/utils/initializeObserversAndListeners.ts
Replaces discourseTagSet with discourseTagToStyle map built from discourseNodes; imports and uses formatHexColor; observer checks map presence to render tag popup and applies inline styles (color, padding, borderRadius) to tag span; no exported signatures changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App
  participant Init as initializeObserversAndListeners
  participant Refresh as Refresh Logic
  participant DOM as NodeTagPopupButtonObserver
  participant UI as renderNodeTagPopupButton

  rect rgb(240,248,255)
    note over Init: Initialization
    App->>Init: Initialize observers/listeners
  end

  rect rgb(235,250,240)
    note over Refresh: Build tag-to-style map
    Init->>Refresh: Refresh discourse data
    Refresh->>Refresh: Iterate discourseNodes
    Refresh->>Refresh: If node.tag and canvas color → formatHexColor
    Refresh->>Refresh: discourseTagToStyle[tag] = { color }
  end

  rect rgb(250,245,235)
    note over DOM: Observe tag spans and clicks
    DOM->>DOM: On tag element detected
    DOM->>Refresh: Lookup discourseTagToStyle[tag]
    alt Style exists
      DOM->>UI: renderNodeTagPopupButton(tag, ...)
      DOM->>DOM: Apply inline styles (color, padding, borderRadius)
    else No style
      DOM->>DOM: Skip popup/styling
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs


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 or @coderabbit 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: 1

🧹 Nitpick comments (2)
apps/roam/src/utils/initializeObserversAndListeners.ts (2)

47-47: Confirm formatHexColor guarantees a valid return (and non-throw).

If it can throw on malformed input, guard calls (see next comment’s diff) so a bad color on one node doesn’t break styling for all. Also verify this import path won’t create a circular dep at runtime.


128-134: Ensure color actually applies to the clickable link and add visible affordance.

Roam often colors the inner <a>; setting only the wrapper <span> may be overridden. Also, padding/borderRadius aren’t visible without a border/background.

-        const style = discourseTagToStyle[tag.toLowerCase()];
-        if (style) {
-          renderNodeTagPopupButton(s, discourseNodes, onloadArgs.extensionAPI);
-          s.style.color = style.color;
-          s.style.padding = "2px 4px";
-          s.style.borderRadius = "4px";
-        }
+        const style = discourseTagToStyle.get
+          ? discourseTagToStyle.get(tag.toLowerCase())
+          : (discourseTagToStyle as any)[tag.toLowerCase()];
+        if (style) {
+          renderNodeTagPopupButton(s, discourseNodes, onloadArgs.extensionAPI);
+          // ensure container and link both adopt the color
+          s.style.color = style.color;
+          const link = s.querySelector("a.rm-page-ref") as HTMLAnchorElement | null;
+          if (link) link.style.color = style.color;
+          // make the tag visually distinct
+          s.style.padding = "2px 4px";
+          s.style.borderRadius = "4px";
+          s.style.border = "1px solid currentColor";
+        }

Optional follow-up: to reflect color changes without navigation, after each refreshDiscourseNodeCache() call, re-style existing tags by iterating document.querySelectorAll('span.rm-page-ref--tag[data-tag]') and applying the same block.

📜 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 c797cb9 and 6ec6d76.

📒 Files selected for processing (1)
  • apps/roam/src/utils/initializeObserversAndListeners.ts (2 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). (8)
  • 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
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check

discourseNodes = getDiscourseNodes();
discourseTagSet = new Set(
discourseNodes.flatMap((n) => (n.tag ? [n.tag.toLowerCase()] : [])),
discourseTagToStyle = discourseNodes.reduce(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should reuse the existing refreshConfigTree. No need to re-invent the wheel 😀

const style = discourseTagToStyle[tag.toLowerCase()];
if (style) {
renderNodeTagPopupButton(s, discourseNodes, onloadArgs.extensionAPI);
s.style.color = style.color;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we put this color/style directly on the Blueprint button? That way it would all be in one place. Also, we could use tailwind/classes as much as possible so users could adjust the styles themselves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sorry which button? We have to add the color the node tag in the block right?

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, my bad. I was thinking of the popover.

@sid597 sid597 changed the base branch from eng-798-node-tags-breaks-color-highlighter to graphite-base/414 September 7, 2025 10:20
@sid597 sid597 deleted the branch graphite-base/414 September 7, 2025 10:25
@sid597 sid597 closed this Sep 7, 2025
@github-project-automation github-project-automation bot moved this to Done in General Sep 7, 2025
@mattakamatsu
Copy link
Contributor

Why are we not using the "button-like" CSS styling? I think it's much more appealing and makes clear you should hover mouse over:
image
css here: https://roamresearch.com/#/app/template-lab/page/X8V4gy32s

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