Skip to content

Replace selection methods with config-driven highlighting and outlining#217

Open
Stukova wants to merge 7 commits intomainfrom
feat/config-driven-highlighting
Open

Replace selection methods with config-driven highlighting and outlining#217
Stukova wants to merge 7 commits intomainfrom
feat/config-driven-highlighting

Conversation

@Stukova
Copy link
Copy Markdown
Member

@Stukova Stukova commented Mar 26, 2026

Replace the imperative selection API with config-driven properties for controlling point and link visual states. Point and link highlighting are now independent — greying out points does not automatically grey out links.

Key semantics: [] activates highlighting with everything greyed out; undefined clears highlighting entirely.

Removed methods

Removed Replacement
selectPointByIndex() / selectPointsByIndices() setConfigPartial({ highlightedPointIndices })
selectPointsInRect() findPointsInRect() + setConfigPartial({ highlightedPointIndices })
selectPointsInPolygon() findPointsInPolygon() + setConfigPartial({ highlightedPointIndices })
unselectPoints() setConfigPartial({ highlightedPointIndices: undefined, highlightedLinkIndices: undefined })
getSelectedIndices() Track highlighted indices in your own state

Renamed methods (signatures changed)

Before After Notes
getAdjacentIndices(index) getNeighboringPointIndices(pointIndices) Now accepts number | number[]
getPointsInRect(selection) findPointsInRect(rect) Returns number[] instead of Float32Array
getPointsInPolygon(polygonPath) findPointsInPolygon(polygonPath) Returns number[] instead of Float32Array

New config properties

Property Type Default Description
highlightedPointIndices number[] | undefined undefined Points to highlight; others greyed out
outlinedPointIndices number[] | undefined undefined Points to render with an outline ring
outlinedPointRingColor string | RGBA 'white' Outline ring color
highlightedLinkIndices number[] | undefined undefined Links to highlight; others greyed out
focusedLinkIndex number | undefined undefined Single link rendered wider
focusedLinkWidthIncrease number 5 Extra pixels on focused link width

New methods

Method Returns Description
getConnectedLinkIndices(pointIndices) number[] Links where both endpoints are within the provided point set
getConnectedPointIndices(linkIndices) number[] Point indices at the endpoints of the provided links

Hover event ordering fix

Hover detection now uses a two-phase approach: state is updated first for both points and links, then callbacks fire in the correct order — mouseout always fires before mouseover when transitioning between element types (e.g. link → point). Previously, moving from a link to a point would fire onPointMouseOver before onLinkMouseOut.

Callback changes

Callback Change
onPointMouseOver 4th param isSelectedisHighlighted; new 5th param isOutlined

Summary by CodeRabbit

Release Notes

  • New Features

    • Added configuration-driven highlighting and outlining: highlightedPointIndices, outlinedPointIndices, outlinedPointRingColor, highlightedLinkIndices, focusedLinkIndex, focusedLinkWidthIncrease.
    • Added query APIs: findPointsInRect(), findPointsInPolygon(), getNeighboringPointIndices(), getConnectedLinkIndices(), getConnectedPointIndices().
  • Breaking Changes

    • Removed selection APIs: selectPointByIndex(), selectPointsByIndices(), unselectPoints(), getSelectedIndices(), getPointsInRect(), selectPointsInRect(), getPointsInPolygon(), selectPointsInPolygon().
    • Updated onPointMouseOver callback: isSelected parameter replaced with isHighlighted and isOutlined.
  • Documentation

    • Updated guides and examples to reflect new configuration-driven approach.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

This PR transitions from an imperative selection-based API to a configuration-driven highlighting model. Core changes include replacing point/link selection methods with stateless "find" query methods, introducing new config properties for highlighting and outline state, refactoring shader infrastructure to support multi-channel status textures, and updating hover detection to trigger config updates rather than direct mutations.

Changes

Cohort / File(s) Summary
Documentation & Migration Guides
README.md, migration-notes.md, src/stories/1. welcome.mdx, src/stories/2. configuration.mdx, src/stories/3. api-reference.mdx
Updated documentation to reflect API transition from selection-based to config-driven highlighting; added migration guidance for new rect/polygon "find" query methods and new highlight/outline config properties; changed example links from BasicSetUp to Actions story.
Configuration & Type Definitions
src/config.ts, src/variables.ts
Added new config properties: highlightedPointIndices, outlinedPointIndices, outlinedPointRingColor (points) and highlightedLinkIndices, focusedLinkIndex, focusedLinkWidthIncrease (links); updated documentation for pointGreyoutOpacity, linkGreyoutOpacity, and onPointMouseOver callback to reference highlighting instead of selection; modified callback signature to include isHighlighted and isOutlined parameters.
Core Graph API & Data Structures
src/index.ts, src/helper.ts, src/modules/GraphData/index.ts, src/modules/Store/index.ts
Replaced selection mutation methods with stateless "find" queries (findPointsInRect, findPointsInPolygon); added relationship queries (getNeighboringPointIndices, getConnectedLinkIndices, getConnectedPointIndices); refactored hover detection into deferred two-phase callback execution; introduced extractIndicesFromPixels helper for FBO queries; updated Store to manage highlighted/outlined point sets and outlined ring color instead of selected indices.
Point Rendering Infrastructure
src/modules/Points/draw-points.vert, src/modules/Points/draw-points.frag, src/modules/Points/draw-highlighted.vert, src/modules/Points/find-hovered-point.vert, src/modules/Points/find-points-in-rect.frag, src/modules/Points/find-points-in-polygon.frag, src/modules/Points/index.ts
Renamed status texture from pointGreyoutStatus to pointStatus with multi-channel support (greyed/outlined); refactored updateGreyoutStatus() to updatePointStatus() for config-driven highlighting; added outline ring rendering via fragment shader; renamed search operations from "selection" to "find" and rect/polygon FBO from selectedFbo/selectedTexture to searchFbo/searchTexture; updated skip uniforms from skipSelected/skipUnselected to skipHighlighted/skipGreyed.
Link Rendering Infrastructure
src/modules/Lines/draw-curve-line.vert, src/modules/Lines/index.ts
Added link status texture (linkStatusTexture) for config-driven link highlighting; introduced updateLinkStatus() method to manage per-link greyed/highlighted state; swapped greyout sampling from point endpoints to link-indexed texture lookup; added link focus uniforms (focusedLinkIndex, focusedLinkWidthIncrease, isLinkHighlightingActive).
Interactive Stories & Examples
src/stories/beginners.stories.ts, src/stories/beginners/actions/index.ts, src/stories/beginners/explore-connections/index.ts, src/stories/beginners/explore-connections/data-gen.ts, src/stories/beginners/explore-connections/style.css, src/stories/shapes/image-example/index.ts, src/stories/clusters/polygon-selection/index.ts
Renamed BasicSetUp story to Actions; refactored story interaction logic from point selection to point/link highlighting via setConfigPartial; added new ExploreConnections interactive story with hierarchical sunburst data generator, hover/click state management with outlined neighborhoods and highlight previews, and focused link rendering.

Sequence Diagram

sequenceDiagram
    participant User
    participant Graph as Graph (index.ts)
    participant Hover as Hover Detection
    participant Config as Config Update
    participant Renderer as GPU Renderer
    participant Store

    User->>User: Move/Click Interaction
    User->>Graph: Hover over Point

    Graph->>Hover: findHoveredPoint()
    Hover->>Renderer: Sample from hover FBO
    Hover-->>Graph: Return { mouseover, mouseout }
    
    Graph->>Graph: Collect callbacks (mouseout first, then mouseover)
    Graph->>Config: setConfigPartial({ highlightedPointIndices })
    Config->>Store: Update highlightedPointSet
    Store->>Renderer: Trigger updatePointStatus()
    Renderer->>Renderer: Regenerate multi-channel status texture
    
    Graph->>Graph: Execute deferred onPointMouseOver callback
    Graph-->>User: Callback fires with isHighlighted, isOutlined flags

    User->>User: Click Point
    User->>Graph: Click handler
    Graph->>Graph: Compute getNeighboringPointIndices()
    Graph->>Graph: Compute getConnectedLinkIndices()
    Graph->>Config: setConfigPartial({ highlightedPointIndices, highlightedLinkIndices })
    Config->>Store: Update highlighted point/link sets
    Store->>Renderer: Trigger updatePointStatus() + updateLinkStatus()
    Renderer->>Renderer: Regenerate status textures & render with highlighting
    Renderer-->>User: Render updated visual state
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • rokotyan

Poem

🐰 Selections became configs, and selection faded away,
Find-queries whisper indices in a highlighting way,
No more imperative picking, just config-driven delight,
Multi-channel status textures make rendering right!
From sunburst explorations to focused link rings so bright,

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and accurately summarizes the main objective: replacing imperative selection methods with a config-driven highlighting and outlining approach.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/config-driven-highlighting

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
Copy Markdown

@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

Caution

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

⚠️ Outside diff range comments (2)
README.md (1)

34-50: ⚠️ Potential issue | 🟡 Minor

TypeScript quick-start snippet should avoid nullable/implicit types.

Line 37 (querySelector) is nullable and needs validation before use. Line 49 has an implicit callback parameter type that should be explicitly annotated.

✏️ Suggested doc fix
-const div = document.querySelector('div')
+const div = document.querySelector('div')
+if (!(div instanceof HTMLDivElement)) {
+  throw new Error('Expected a target <div> element')
+}
 const config = {
@@
-  onClick: (pointIndex) => { console.log('Clicked point index: ', pointIndex) },
+  onClick: (pointIndex: number | undefined) => { console.log('Clicked point index: ', pointIndex) },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 34 - 50, The README snippet uses
document.querySelector('div') which returns nullable; update the code that
initializes and uses div (the variable from document.querySelector) to validate
it before use (e.g., check for null and handle or throw) or obtain a non-null
element safely so Graph is only instantiated when div is present; also
explicitly annotate the onClick callback parameter in the config (the onClick
function in the config object) with its type (e.g., pointIndex: number) instead
of relying on an implicit any/implicit type.
src/modules/Lines/draw-curve-line.vert (1)

187-199: ⚠️ Potential issue | 🟠 Major

Include focused width in the picking pass.

Line 187 only applies the fixed 5px hover padding during index-buffer rendering. If focusedLinkWidthIncrease is set above 5, the focused link renders wider than its hover/click geometry, so interacting with the visible stroke can miss.

💡 Possible fix
   if (renderMode > 0.0) {
     // Add 5 pixels padding for better hover detection
     linkWidthPx += 5.0 / transformationMatrix[0][0];
+    if (focusedLinkIndex == linkIndex) {
+      linkWidthPx += focusedLinkWidthIncrease / transformationMatrix[0][0];
+    }
   } else {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/Lines/draw-curve-line.vert` around lines 187 - 199, The
picking-pass branch (renderMode > 0.0) only adds a fixed 5px padding to
linkWidthPx, so focused links that use focusedLinkWidthIncrease can be visually
wider than their pickable area; modify the renderMode > 0.0 block to also add
the same focused and hovered width increases (dividing by
transformationMatrix[0][0]) when hoveredLinkIndex == linkIndex and when
focusedLinkIndex == linkIndex so linkWidthPx matches what's used in the visible
pass (use the same symbols: renderMode, linkWidthPx, transformationMatrix,
hoveredLinkIndex, focusedLinkIndex, hoveredLinkWidthIncrease,
focusedLinkWidthIncrease, linkIndex).
🧹 Nitpick comments (3)
src/stories/shapes/image-example/index.ts (1)

199-201: Deduplicate highlighted points before applying config (optional).

If getNeighboringPointIndices() includes the clicked point, duplicates may be passed downstream unnecessarily.

♻️ Suggested refinement
-        const highlightedPointIndices = [pointIndex, ...neighboringPoints]
+        const highlightedPointIndices = [...new Set([pointIndex, ...neighboringPoints])]
         const highlightedLinkIndices = graph.getConnectedLinkIndices(highlightedPointIndices)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/stories/shapes/image-example/index.ts` around lines 199 - 201, The
highlightedPointIndices array may contain duplicates if
getNeighboringPointIndices() returns the clicked point; before calling
graph.getConnectedLinkIndices and graph.setConfigPartial, deduplicate the
highlightedPointIndices (e.g., create a Set from [pointIndex,
...neighboringPoints] and convert back to an array) so
graph.getConnectedLinkIndices(highlightedPointIndices) and
graph.setConfigPartial({ highlightedPointIndices, highlightedLinkIndices })
receive unique point IDs; keep the same variable names highlightedPointIndices
and highlightedLinkIndices so downstream calls remain unchanged.
src/stories/clusters/polygon-selection/index.ts (1)

28-29: Guard polygon query until graph is ready.

To avoid edge-case calls before initialization completes, add a readiness check before findPointsInPolygon().

🛡️ Suggested guard
   const polygonSelection = new PolygonSelection(div, (polygonPoints) => {
+    if (!graph.isReady) return
     const indices = graph.findPointsInPolygon(polygonPoints)
     graph.setConfigPartial({ highlightedPointIndices: indices })
   })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/stories/clusters/polygon-selection/index.ts` around lines 28 - 29, Guard
the polygon query so we don't call graph.findPointsInPolygon before the graph is
initialized: before calling graph.findPointsInPolygon(polygonPoints) check a
readiness flag or method on the graph (e.g., graph.isReady(), graph.ready, or
graph.initialized) and only call findPointsInPolygon and then
graph.setConfigPartial({ highlightedPointIndices: indices }) when that readiness
check passes; if the graph isn't ready, either no-op or subscribe to the graph's
ready event and run the same code then.
src/modules/Points/find-hovered-point.vert (1)

71-72: Minor naming inconsistency for clarity.

The local variable greyoutStatus samples from texture pointStatus, which now contains both greyout (R) and outlined (G) channels. Consider renaming to status for consistency with draw-points.vert:

-  vec4 greyoutStatus = texture(pointStatus, (pointIndices + 0.5) / pointsTextureSize);
-  float isHighlighted = (greyoutStatus.r == 0.0) ? 1.0 : 0.0;
+  vec4 status = texture(pointStatus, (pointIndices + 0.5) / pointsTextureSize);
+  float isHighlighted = (status.r == 0.0) ? 1.0 : 0.0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/Points/find-hovered-point.vert` around lines 71 - 72, Rename the
local GLSL variable greyoutStatus to a more general name like status in the
vertex shader so it reflects that pointStatus texture contains multiple channels
(R=greyout, G=outlined) and to match naming in draw-points.vert; update the
subsequent usage of isHighlighted (and any other references) to read from status
instead of greyoutStatus while keeping the texture lookup using pointStatus and
pointsTextureSize unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/index.ts`:
- Around line 941-949: findPointsInRect relies on GPU resources (searchFbo,
program/uniform setup) produced by Points.initPrograms() and
Points.updatePositions(), so calling graph.ready alone can return stale/empty
results; add a preparation step before using this.points.searchFbo to ensure
those GPU resources and pending updates are created/flushed (mirror the
preparation used in findPointsInPolygon). Concretely, add/Call a method like
this.points.prepareForSearch() (implement it to call/await
Points.initPrograms(), Points.updatePositions(), and flush any pending
render/update commands) at the start of findPointsInRect (and symmetrically in
findPointsInPolygon) so searchFbo and related uniforms are valid before
readPixels/extractIndicesFromPixels are invoked.

---

Outside diff comments:
In `@README.md`:
- Around line 34-50: The README snippet uses document.querySelector('div') which
returns nullable; update the code that initializes and uses div (the variable
from document.querySelector) to validate it before use (e.g., check for null and
handle or throw) or obtain a non-null element safely so Graph is only
instantiated when div is present; also explicitly annotate the onClick callback
parameter in the config (the onClick function in the config object) with its
type (e.g., pointIndex: number) instead of relying on an implicit any/implicit
type.

In `@src/modules/Lines/draw-curve-line.vert`:
- Around line 187-199: The picking-pass branch (renderMode > 0.0) only adds a
fixed 5px padding to linkWidthPx, so focused links that use
focusedLinkWidthIncrease can be visually wider than their pickable area; modify
the renderMode > 0.0 block to also add the same focused and hovered width
increases (dividing by transformationMatrix[0][0]) when hoveredLinkIndex ==
linkIndex and when focusedLinkIndex == linkIndex so linkWidthPx matches what's
used in the visible pass (use the same symbols: renderMode, linkWidthPx,
transformationMatrix, hoveredLinkIndex, focusedLinkIndex,
hoveredLinkWidthIncrease, focusedLinkWidthIncrease, linkIndex).

---

Nitpick comments:
In `@src/modules/Points/find-hovered-point.vert`:
- Around line 71-72: Rename the local GLSL variable greyoutStatus to a more
general name like status in the vertex shader so it reflects that pointStatus
texture contains multiple channels (R=greyout, G=outlined) and to match naming
in draw-points.vert; update the subsequent usage of isHighlighted (and any other
references) to read from status instead of greyoutStatus while keeping the
texture lookup using pointStatus and pointsTextureSize unchanged.

In `@src/stories/clusters/polygon-selection/index.ts`:
- Around line 28-29: Guard the polygon query so we don't call
graph.findPointsInPolygon before the graph is initialized: before calling
graph.findPointsInPolygon(polygonPoints) check a readiness flag or method on the
graph (e.g., graph.isReady(), graph.ready, or graph.initialized) and only call
findPointsInPolygon and then graph.setConfigPartial({ highlightedPointIndices:
indices }) when that readiness check passes; if the graph isn't ready, either
no-op or subscribe to the graph's ready event and run the same code then.

In `@src/stories/shapes/image-example/index.ts`:
- Around line 199-201: The highlightedPointIndices array may contain duplicates
if getNeighboringPointIndices() returns the clicked point; before calling
graph.getConnectedLinkIndices and graph.setConfigPartial, deduplicate the
highlightedPointIndices (e.g., create a Set from [pointIndex,
...neighboringPoints] and convert back to an array) so
graph.getConnectedLinkIndices(highlightedPointIndices) and
graph.setConfigPartial({ highlightedPointIndices, highlightedLinkIndices })
receive unique point IDs; keep the same variable names highlightedPointIndices
and highlightedLinkIndices so downstream calls remain unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 13995ac2-494d-473e-89a8-3731ccae4f60

📥 Commits

Reviewing files that changed from the base of the PR and between 66653e3 and b978157.

📒 Files selected for processing (22)
  • README.md
  • migration-notes.md
  • src/config.ts
  • src/helper.ts
  • src/index.ts
  • src/modules/GraphData/index.ts
  • src/modules/Lines/draw-curve-line.vert
  • src/modules/Lines/index.ts
  • src/modules/Points/draw-highlighted.vert
  • src/modules/Points/draw-points.frag
  • src/modules/Points/draw-points.vert
  • src/modules/Points/find-hovered-point.vert
  • src/modules/Points/find-points-in-polygon.frag
  • src/modules/Points/find-points-in-rect.frag
  • src/modules/Points/index.ts
  • src/modules/Store/index.ts
  • src/stories/2. configuration.mdx
  • src/stories/3. api-reference.mdx
  • src/stories/beginners/basic-set-up/index.ts
  • src/stories/clusters/polygon-selection/index.ts
  • src/stories/shapes/image-example/index.ts
  • src/variables.ts

@Stukova Stukova requested a review from rokotyan March 26, 2026 09:50
Stukova added 2 commits March 30, 2026 16:43
…g, outlining, and focusing

Signed-off-by: Stukova Olya <stukova.o@gmail.com>
Signed-off-by: Stukova Olya <stukova.o@gmail.com>
@Stukova Stukova force-pushed the feat/config-driven-highlighting branch from c61f036 to a08cbe6 Compare March 30, 2026 11:44
Copy link
Copy Markdown

@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: 2

🧹 Nitpick comments (1)
src/modules/Store/index.ts (1)

41-41: Type searchArea as a fixed 2-point tuple.

This is currently inferred as number[][], so malformed shapes can still compile and only fail deeper in the rect-search path. Pinning it to [[number, number], [number, number]] keeps the new search contract checked at compile time.

♻️ Suggested change
-  public searchArea = [[0, 0], [0, 0]]
+  public searchArea: [[number, number], [number, number]] = [[0, 0], [0, 0]]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/Store/index.ts` at line 41, The public field searchArea is
currently inferred as number[][] allowing malformed shapes; change its
declaration to have the fixed tuple type [[number, number], [number, number]]
and keep the same initial value so the compiler enforces two 2-number points.
Update the Store class's public searchArea declaration to use the explicit tuple
type [[number, number], [number, number]] wherever it's declared and adjust any
assignments/usages to satisfy that shape.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/modules/Lines/index.ts`:
- Around line 685-699: When link highlighting is cleared or there are no links,
release the old GPU texture to avoid pinned memory: in the branches handling
!linksNumber and highlightedLinkIndices === undefined (where linkStatusTexture
and ensureLinkStatusPlaceholder are referenced), call the texture
destructor/release on this.linkStatusTexture, set this.linkStatusTexture to
null/undefined, and set this.linkStatusTextureSize = 0; keep the existing
ensureLinkStatusPlaceholder behavior for creating a 1×1 placeholder when needed.

In `@src/modules/Points/index.ts`:
- Around line 1664-1668: findPointsInPolygon currently proceeds for 1- or
2-point inputs; add an early check at the top of the findPointsInPolygon method
to reject degenerate polygons by returning false when the polygon vertex count
is < 3 (i.e., inspect the polygon vertex array used by this method — e.g. the
polygon vertex buffer/array or the property that backs polygonPathTexture — and
if its length/vertexCount < 3 return false before any GPU resources or commands
are used). Ensure the check runs before referencing
this.findPointsInPolygonCommand, this.searchFbo, this.currentPositionTexture, or
this.polygonPathTexture so the GPU pass is never launched for invalid polygons.

---

Nitpick comments:
In `@src/modules/Store/index.ts`:
- Line 41: The public field searchArea is currently inferred as number[][]
allowing malformed shapes; change its declaration to have the fixed tuple type
[[number, number], [number, number]] and keep the same initial value so the
compiler enforces two 2-number points. Update the Store class's public
searchArea declaration to use the explicit tuple type [[number, number],
[number, number]] wherever it's declared and adjust any assignments/usages to
satisfy that shape.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 195e7150-d22c-43e3-b892-8603e2824121

📥 Commits

Reviewing files that changed from the base of the PR and between c61f036 and a08cbe6.

📒 Files selected for processing (22)
  • README.md
  • migration-notes.md
  • src/config.ts
  • src/helper.ts
  • src/index.ts
  • src/modules/GraphData/index.ts
  • src/modules/Lines/draw-curve-line.vert
  • src/modules/Lines/index.ts
  • src/modules/Points/draw-highlighted.vert
  • src/modules/Points/draw-points.frag
  • src/modules/Points/draw-points.vert
  • src/modules/Points/find-hovered-point.vert
  • src/modules/Points/find-points-in-polygon.frag
  • src/modules/Points/find-points-in-rect.frag
  • src/modules/Points/index.ts
  • src/modules/Store/index.ts
  • src/stories/2. configuration.mdx
  • src/stories/3. api-reference.mdx
  • src/stories/beginners/basic-set-up/index.ts
  • src/stories/clusters/polygon-selection/index.ts
  • src/stories/shapes/image-example/index.ts
  • src/variables.ts
✅ Files skipped from review due to trivial changes (4)
  • src/variables.ts
  • src/modules/Points/find-points-in-polygon.frag
  • README.md
  • src/index.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/stories/clusters/polygon-selection/index.ts
  • src/helper.ts
  • src/modules/Points/draw-highlighted.vert
  • src/stories/shapes/image-example/index.ts
  • src/modules/Points/find-points-in-rect.frag
  • src/modules/Points/draw-points.frag
  • src/modules/GraphData/index.ts
  • src/stories/beginners/basic-set-up/index.ts
  • migration-notes.md
  • src/stories/2. configuration.mdx

… methods

Signed-off-by: Stukova Olya <stukova.o@gmail.com>
Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/modules/GraphData/index.ts`:
- Around line 387-399: In getConnectedPointIndices, validate that each supplied
linkIndex is an integer before using it to index this.links: for the
single-number and array cases reject or skip any non-integer (use
Number.isInteger(linkIndex) or equivalent) in addition to the existing range
check (linksNumber) so fractional values like 1.5 are ignored; keep the existing
checks for this.links undefined and the source/target extraction
(this.links[linkIndex * 2], this.links[linkIndex * 2 + 1]) intact and only
execute them for indices that pass both the integer and range guards.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa23d2e7-82a4-487d-9705-d940c2587e4b

📥 Commits

Reviewing files that changed from the base of the PR and between a08cbe6 and aa2227d.

📒 Files selected for processing (1)
  • src/modules/GraphData/index.ts

Stukova added 2 commits April 1, 2026 12:56
Signed-off-by: Stukova Olya <stukova.o@gmail.com>
…g, and focusing

Signed-off-by: Stukova Olya <stukova.o@gmail.com>
Copy link
Copy Markdown

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

🧹 Nitpick comments (2)
src/index.ts (1)

968-970: Avoid warning on every incomplete polygon preview.

findPointsInPolygon() is a likely building block for interactive lasso/polygon selection, so callers may invoke it repeatedly while the path still has 1–2 vertices. Returning [] is already enough here; the warning will just spam the console.

💡 Possible fix
-    if (polygonPath.length < 3) {
-      console.warn('Polygon path requires at least 3 points to form a polygon.')
-      return []
-    }
+    if (polygonPath.length < 3) return []
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/index.ts` around lines 968 - 970, The console.warn in findPointsInPolygon
that triggers when polygonPath.length < 3 should be removed to avoid spamming
during interactive lasso/polygon construction; simply return [] as is. Locate
the check in findPointsInPolygon referencing polygonPath.length and delete the
warning call (console.warn('Polygon path requires at least 3 points to form a
polygon.')), leaving the early return intact so callers get an empty array
without noisy logs.
src/stories/beginners/explore-connections/index.ts (1)

165-173: graph.zoom(0.9) is likely temporary here.

render() still runs the init-fit path when initialZoomLevel is unset, so this zoom call is likely to be overwritten on first paint. If the goal is a looser initial fit, prefer fitViewPadding; if the goal is a fixed starting scale, use initialZoomLevel or disable fitViewOnInit.

Based on learnings, Cosmos Graph initializes by fitting the view, which triggers an onZoom event on load.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/stories/beginners/explore-connections/index.ts` around lines 165 - 173,
The explicit graph.zoom(0.9) call is being overwritten by Graph.render()'s
init-fit behavior; instead, update the Graph construction/config (the config
passed to new Graph(...)) to either set initialZoomLevel to fix the starting
scale, set fitViewPadding to achieve a looser initial fit, or set
fitViewOnInit:false to prevent the automatic fit — remove the temporary
graph.zoom(0.9) line and adjust the config (initialZoomLevel, fitViewPadding, or
fitViewOnInit) so the desired initial zoom is applied before/at render().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/index.ts`:
- Around line 968-970: The console.warn in findPointsInPolygon that triggers
when polygonPath.length < 3 should be removed to avoid spamming during
interactive lasso/polygon construction; simply return [] as is. Locate the check
in findPointsInPolygon referencing polygonPath.length and delete the warning
call (console.warn('Polygon path requires at least 3 points to form a
polygon.')), leaving the early return intact so callers get an empty array
without noisy logs.

In `@src/stories/beginners/explore-connections/index.ts`:
- Around line 165-173: The explicit graph.zoom(0.9) call is being overwritten by
Graph.render()'s init-fit behavior; instead, update the Graph
construction/config (the config passed to new Graph(...)) to either set
initialZoomLevel to fix the starting scale, set fitViewPadding to achieve a
looser initial fit, or set fitViewOnInit:false to prevent the automatic fit —
remove the temporary graph.zoom(0.9) line and adjust the config
(initialZoomLevel, fitViewPadding, or fitViewOnInit) so the desired initial zoom
is applied before/at render().

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 384d26e8-1fbf-4a4e-bd40-127a7a68e123

📥 Commits

Reviewing files that changed from the base of the PR and between aa2227d and 176c5c5.

📒 Files selected for processing (5)
  • src/index.ts
  • src/stories/beginners.stories.ts
  • src/stories/beginners/explore-connections/data-gen.ts
  • src/stories/beginners/explore-connections/index.ts
  • src/stories/beginners/explore-connections/style.css
✅ Files skipped from review due to trivial changes (1)
  • src/stories/beginners/explore-connections/style.css

Stukova added 2 commits April 1, 2026 16:34
Signed-off-by: Stukova Olya <stukova.o@gmail.com>
Signed-off-by: Stukova Olya <stukova.o@gmail.com>
Copy link
Copy Markdown

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

🧹 Nitpick comments (1)
src/stories/beginners.stories.ts (1)

53-62: Minor inconsistency in sourceCode naming conventions.

The Actions story uses 'data-gen' (line 59) without the .ts extension, while ExploreConnections uses 'data-gen.ts' (line 169) with the extension. Other existing stories in this file also use .ts extensions (e.g., 'data.ts', 'config.ts').

Consider aligning to the existing convention with .ts extensions for consistency in the displayed source code tabs.

✨ Suggested fix for consistency
 export const Actions: Story = {
   ...createStory(actions),
   parameters: {
     sourceCode: [
       { name: 'Story', code: actionsStoryRaw },
       { name: 'style.css', code: actionsStoryCssRaw },
-      { name: 'data-gen', code: actionsStoryDataGenRaw },
+      { name: 'data-gen.ts', code: actionsStoryDataGenRaw },
     ],
   },
 }

Also applies to: 163-173

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/stories/beginners.stories.ts` around lines 53 - 62, The sourceCode tab
names are inconsistent: update the parameters.sourceCode entries for the Actions
story (export const Actions) to use the '.ts' extension (change the 'data-gen'
name to 'data-gen.ts') so it matches the convention used elsewhere (e.g.,
ExploreConnections and other stories); also make the same change for the other
story block mentioned (the data-gen entry around ExploreConnections) by renaming
its sourceCode name from 'data-gen' to 'data-gen.ts' to keep tab naming
consistent across stories.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/stories/beginners.stories.ts`:
- Around line 53-62: The sourceCode tab names are inconsistent: update the
parameters.sourceCode entries for the Actions story (export const Actions) to
use the '.ts' extension (change the 'data-gen' name to 'data-gen.ts') so it
matches the convention used elsewhere (e.g., ExploreConnections and other
stories); also make the same change for the other story block mentioned (the
data-gen entry around ExploreConnections) by renaming its sourceCode name from
'data-gen' to 'data-gen.ts' to keep tab naming consistent across stories.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 02db85fa-50c1-4ec2-8942-b145145efe13

📥 Commits

Reviewing files that changed from the base of the PR and between 74ca702 and bcb32f1.

📒 Files selected for processing (6)
  • README.md
  • src/stories/1. welcome.mdx
  • src/stories/beginners.stories.ts
  • src/stories/beginners/actions/data-gen.ts
  • src/stories/beginners/actions/index.ts
  • src/stories/beginners/actions/style.css
✅ Files skipped from review due to trivial changes (1)
  • src/stories/1. welcome.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant