Skip to content

fix(network): correct IoT/Mobile node icon codepoints on graph canvas#544

Merged
NotYuSheng merged 2 commits into
mainfrom
feature/495-fix-graph-icon-mismatch
Jul 18, 2026
Merged

fix(network): correct IoT/Mobile node icon codepoints on graph canvas#544
NotYuSheng merged 2 commits into
mainfrom
feature/495-fix-graph-icon-mismatch

Conversation

@NotYuSheng

Copy link
Copy Markdown
Owner

Summary

  • NetworkGraph.tsx hardcoded raw Bootstrap Icon codepoints for Sigma's WebGL canvas, hand-copied from deviceTypeIcon()'s class names (the legend's source). Two had drifted: IOT drew bi-lightbulb instead of bi-cpu, MOBILE drew bi-patch-minus-fill instead of bi-phone.
  • Fixed both codepoints (IOT, MOBILE).
  • Extracted the icon tables (NODE_TYPE_ICONS, DEVICE_TYPE_ICONS, getNodeIcon, GENERIC_NODE_TYPES) out of NetworkGraph.tsx into a new nodeIcons.ts module, free of the sigma import — this lets them be unit-tested without pulling in Sigma's WebGL dependency (which crashes on import under jsdom).
  • Added __tests__/iconCodepoints.test.ts, which cross-checks every codepoint against the installed bootstrap-icons package (via bootstrap-icons/font/bootstrap-icons.json) and asserts DEVICE_TYPE_ICONS still agrees with deviceTypeIcon()'s class names, so the two tables can't silently drift again.

Closes #495

Test plan

  • npm run test — 106/106 passing (including 29 new tests)
  • tsc -b --noEmit — clean
  • Rebuilt nginx image, byte-inspected the built bundle: contains U+F4E7/U+F2D6 (correct), neither of the old wrong codepoints
  • Loaded a real capture's Network Topology Diagram in a browser (Playwright) — IoT Device nodes now render the CPU-chip glyph matching the legend (previously a lightbulb)
  • Mobile glyph not visually verified against a live node — none of the sample captures in this environment classify a host as MOBILE; verified via bundle codepoint inspection and the same code path confirmed working for IoT instead

🤖 Generated with Claude Code

…#495)

DEVICE_TYPE_ICONS in NetworkGraph.tsx had drifted from deviceTypeIcon()'s
class names (the legend's source): IOT drew bi-lightbulb instead of
bi-cpu, MOBILE drew bi-patch-minus-fill instead of bi-phone.

Extracts the icon codepoint tables into their own module (nodeIcons.ts,
free of the `sigma` import) and adds a regression test that cross-checks
every codepoint against the installed bootstrap-icons package and against
deviceTypeIcon(), so the two tables can't silently drift again.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@NotYuSheng, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 37cfd059-60e6-45a0-b32e-692a7c4b3e2e

📥 Commits

Reviewing files that changed from the base of the PR and between 51f3184 and 51eb5b2.

📒 Files selected for processing (3)
  • frontend/src/components/network/NetworkGraph/NetworkGraph.tsx
  • frontend/src/components/network/NetworkGraph/__tests__/iconCodepoints.test.ts
  • frontend/src/components/network/NetworkGraph/nodeIcons.ts

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the network graph icons by extracting icon codepoints, generic node types, and the getNodeIcon function from NetworkGraph.tsx into a separate nodeIcons.ts module. This allows unit testing of the codepoints without importing Sigma's WebGL dependencies. A new test suite iconCodepoints.test.ts is introduced to verify that the hardcoded codepoints match the Bootstrap Icon package. The reviewer feedback suggests several improvements to the tests, including: cross-checking NODE_TYPE_ICONS against NODE_TYPE_CONFIG to prevent drift, importing the necessary constants, updating the regex to correctly match the fallback icon (which ends with a semicolon), making the codepoint assertions case-insensitive, and including the fallback icon in the set of verified values.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread frontend/src/components/network/NetworkGraph/__tests__/iconCodepoints.test.ts Outdated
Comment thread frontend/src/components/network/NetworkGraph/__tests__/iconCodepoints.test.ts Outdated
Comment thread frontend/src/components/network/NetworkGraph/__tests__/iconCodepoints.test.ts Outdated
@NotYuSheng
NotYuSheng merged commit 181b974 into main Jul 18, 2026
3 checks passed
@NotYuSheng
NotYuSheng deleted the feature/495-fix-graph-icon-mismatch branch July 18, 2026 19:03
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.

[Bug] Graph node icons don't match the legend — IoT renders as a lightbulb, Mobile as patch-minus

1 participant