Skip to content

Conversation

@mdroidian
Copy link
Contributor

@mdroidian mdroidian commented Oct 16, 2025

image

Summary by CodeRabbit

  • New Features

    • "Open in Sidebar" button added to discourse nodes for quicker navigation.
    • Overlay supports mutually exclusive tag or uid targeting.
  • Style

    • Customizable icon and text colors with controllable opacity (default 100) for overlays.
    • Icons and score/refs text now render with consistent color and opacity handling.

@linear
Copy link

linear bot commented Oct 16, 2025

@supabase
Copy link

supabase bot commented Oct 16, 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
Contributor Author

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

@coderabbitai full review

* Introduced opacity and color props to DiscourseContextOverlay for better customization.
* Added an "Open in Sidebar" button in DiscourseNodeUtil to improve user interaction.
* Updated styles to reflect new props and ensure consistent UI behavior.
@mdroidian
Copy link
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

📝 Walkthrough

Walkthrough

Adds opacity and color props and a discriminated-union prop type to DiscourseContextOverlay, wires those props into icon/text rendering, and adds an "Open in Sidebar" button to canvas nodes while passing opacity/textColor/iconColor from DiscourseNodeUtil into the overlay.

Changes

Cohort / File(s) Change Summary
DiscourseContextOverlay type and styling system
apps/roam/src/components/DiscourseContextOverlay.tsx
Adds OPACITY_VALUES and OpacityValue types; introduces DiscourseContextOverlayBaseProps and replaces the previous prop union with `DiscourseContextOverlayProps = Base & ({ tag; uid?: never }
Canvas node overlay & sidebar integration
apps/roam/src/components/canvas/DiscourseNodeUtil.tsx
Adds a BlueprintJS "Open in Sidebar" button to node UI that calls openBlockInSidebar(shape.props.uid) (stopping propagation); shifts overlay position (right-0 top-0right-1 top-1); passes opacity, textColor, and iconColor into DiscourseContextOverlay; imports BlueprintJS components and openBlockInSidebar.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant NodeUI as DiscourseNode (canvas)
  participant Overlay as DiscourseContextOverlay
  participant Sidebar as Sidebar/OpenBlock

  User->>NodeUI: hover / view node
  NodeUI->>Overlay: render(props: opacity, textColor, iconColor)
  Note right of Overlay: Icons/text rendered\nwith provided color & opacity
  User->>NodeUI: click "Open in Sidebar" button
  NodeUI->>NodeUI: stopPropagation (click / pointerdown)
  NodeUI->>Sidebar: openBlockInSidebar(uid)
  Sidebar-->>User: sidebar opens with block
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Rationale: multiple related type changes and new discriminated-union props, UI behavior additions (button + event handling), and styling propagation across components; requires verifying type safety, event handling edge cases, and consistent styling application.

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 "ENG-969 Add open node in sidebar button to canvas nodes" directly describes the primary feature addition in this changeset: a new button that allows users to open nodes in the sidebar from canvas nodes. The title is specific, concise, and accurately reflects the main change evident in the DiscourseNodeUtil.tsx modifications where an "Open in Sidebar" button is wired into the node rendering. While the PR also includes supporting changes to styling and opacity handling in DiscourseContextOverlay.tsx, these appear to be secondary enhancements that enable the button feature rather than the primary objective. The title would be immediately understandable to a teammate reviewing the commit history.
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: 0

🧹 Nitpick comments (2)
apps/roam/src/components/canvas/DiscourseNodeUtil.tsx (1)

523-540: Add an accessible label to the sidebar button.

Icon-only controls need an explicit accessible name; a title alone won’t be announced by screen readers. Please add an aria-label (or visible text) so the new shortcut remains usable for assistive tech.

           <Button
             className="absolute left-1 top-1 z-10"
             minimal
             small
+            aria-label="Open in sidebar"
             icon={
               <Icon
                 icon="panel-stats"
apps/roam/src/components/DiscourseContextOverlay.tsx (1)

175-190: Mirror opacity styling on the text spans.

Icons use inline opacity, but the text relies on opacity-${opacity} classes, which can disappear in Tailwind’s purge/JIT path and leave the text at full opacity. Please apply the same inline opacity math to the spans so the visual treatment is consistent and purge‑proof.

-            <span
-              className={`mr-1 leading-none opacity-${opacity}`}
-              style={{ color: textColor }}
-            >
+            <span
+              className="mr-1 leading-none"
+              style={{
+                color: textColor,
+                opacity: Number(opacity) / 100,
+              }}
+            >
               {loading ? "-" : score}
             </span>
             <Icon
               icon={"link"}
               color={iconColor}
               style={{ opacity: `${Number(opacity) / 100}` }}
             />
-            <span
-              className={`leading-none opacity-${opacity}`}
-              style={{ color: textColor }}
-            >
+            <span
+              className="leading-none"
+              style={{
+                color: textColor,
+                opacity: Number(opacity) / 100,
+              }}
+            >
               {loading ? "-" : refs}
             </span>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9204ce9 and 42546cc.

📒 Files selected for processing (2)
  • apps/roam/src/components/DiscourseContextOverlay.tsx (2 hunks)
  • apps/roam/src/components/canvas/DiscourseNodeUtil.tsx (3 hunks)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

✅ Actions performed

Full review triggered.

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/roam/src/components/canvas/DiscourseNodeUtil.tsx (1)

562-571: Consider making overlay opacity configurable.

The overlay position adjustment (line 562) is appropriate. However, the opacity is hardcoded to "50" (line 568). Consider whether this should be:

  1. Configurable via discourse node canvas settings
  2. Matched to the button's opacity for consistency
  3. Left as-is if 50% is the intended design

If configurability is desired, you could derive it from canvas settings similar to how color is handled:

const {
  canvasSettings: { 
    alias = "", 
    "key-image": isKeyImage = "",
    overlayOpacity = "50"  // Add to canvas settings
  } = {},
} = discourseContext.nodes[shape.type] || {};

Then pass it to the overlay:

               <DiscourseContextOverlay
                 uid={shape.props.uid}
                 id={`${shape.id}-overlay`}
-                opacity="50"
+                opacity={overlayOpacity}
                 textColor={textColor}
                 iconColor={textColor}
               />
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9204ce9 and 42546cc.

📒 Files selected for processing (2)
  • apps/roam/src/components/DiscourseContextOverlay.tsx (2 hunks)
  • apps/roam/src/components/canvas/DiscourseNodeUtil.tsx (3 hunks)
🔇 Additional comments (4)
apps/roam/src/components/DiscourseContextOverlay.tsx (2)

61-84: LGTM! Well-structured opacity type definition.

The const array with as const assertion and derived type using typeof is idiomatic TypeScript. This provides both runtime values and compile-time type safety.


86-95: LGTM! Discriminated union correctly enforces tag XOR uid.

The type definition ensures either tag or uid is provided (but not both), which prevents invalid prop combinations at compile time.

apps/roam/src/components/canvas/DiscourseNodeUtil.tsx (2)

30-31: LGTM! Correct imports for new functionality.

The imports for openBlockInSidebar and Blueprint components are properly added.


522-540: LGTM! Button implementation follows best practices.

The "Open in Sidebar" button correctly:

  • Stops event propagation to prevent canvas interactions
  • Uses void for the async call since errors are handled by openBlockInSidebar
  • Applies semi-transparent styling for subtle UI presence
  • Provides a descriptive tooltip

@mdroidian mdroidian merged commit 2232736 into main Oct 16, 2025
5 checks passed
@mdroidian mdroidian deleted the eng-969-roam-open-node-button-in-sidebar-for-canvas-nodes branch October 16, 2025 08:08
@github-project-automation github-project-automation bot moved this to Done in General Oct 16, 2025
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