Skip to content

feat(network): single Node Identity filter + selectable edge-colour modes#556

Merged
NotYuSheng merged 1 commit into
mainfrom
feature/network-diagram-identity-and-edge-colours
Jul 19, 2026
Merged

feat(network): single Node Identity filter + selectable edge-colour modes#556
NotYuSheng merged 1 commit into
mainfrom
feature/network-diagram-identity-and-edge-colours

Conversation

@NotYuSheng

@NotYuSheng NotYuSheng commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #537 ("Identity owns the verdict") plus edge-colour and UX fixes on the network diagram.

Node Identity filter (was two overlapping taxonomies)

The Node Types filter rendered nodeType and deviceType pills side by side, so Router / Web Server / DNS Server / Unknown each showed twice. Collapsed into one taxonomy keyed on the adjudicated identity:

  • New nodeIdentityKey()identityLabel → deviceType → L2_DEVICE → UNKNOWN.
  • Section renamed Node Identity; every filter site now uses a single id: key namespace (NetworkControls, NetworkDiagram, Compare, SnapshotDetailModal, NetworkIntelligence, networkService, report labels).
  • Mobile / IoT / Laptop now stay distinct (finer than the rendered nodeType, which collapses them to client).

Edge colour — user-selectable mode

The old Protocol / Volume toggle becomes Transport / Application / Volume in the same "Color edges by" dropdown:

  • Transport — base protocol (TCP/UDP/ICMP…), previous behaviour.
  • Application — the nDPI application (WhatsApp, YouTube…) via getAppColor, with a matching legend (buildAppLegend); un-identified flows fall to a grey "Other" bucket. Fixes edges reading as grey TCP when the identity lived only in appName.
  • Volume — unchanged.

UI fixes

  • Dark mode: contested "confirm" buttons (outline-primary on a warning alert) kept an unreadable purple — now a legible light foreground inside alerts.
  • Monitor: the snapshot-detail network diagram gains a fullscreen button matching the analysis diagram (over-modal z-index so it stacks above the dialog, Escape-to-exit, tab-change cleanup).

Testing

  • tsc -b clean; vitest 143 passing (new: nodeIdentityKey, buildAppLegend).
  • Verified live in-browser: dedup filter, WhatsApp edges colouring in Application mode, dark-mode button contrast, monitor fullscreen + Escape.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added fullscreen viewing for network diagrams, including an Escape-key exit option.
    • Added edge-coloring modes for transport, application, and traffic volume.
    • Added application-based graph legends.
    • Introduced unified node identity filters with improved labels and support for Layer 2 devices.
  • Bug Fixes
    • Improved dark-mode contrast for buttons displayed in alerts.
    • Refined node identity detection and filtering across network views.

…odes

Node Types filter (#499/#537 follow-up): the panel rendered two overlapping
taxonomies (nodeType + deviceType) side by side, so Router, Web Server, DNS
Server and Unknown each appeared twice. Collapse them into one taxonomy keyed
on the adjudicated identity via a new nodeIdentityKey() (identityLabel →
deviceType → L2_DEVICE → UNKNOWN), rename the section to "Node Identity", and
switch every filter site to a single id: key namespace. Mobile/IoT/Laptop now
stay distinct (finer than the rendered nodeType, which collapses them to
"client").

Edge colour: the old "Protocol"/"Volume" toggle becomes Transport /
Application / Volume in the same "Color edges by" dropdown.
- Transport: base protocol (TCP/UDP/ICMP…), the previous behaviour.
- Application: the nDPI application (WhatsApp, YouTube…) via getAppColor, with
  a matching legend (buildAppLegend); flows with no identified app fall to the
  grey "Other" bucket. This fixes edges reading as grey TCP when the identity
  lived only in appName.

UI fixes:
- Dark mode: contested "confirm" buttons (outline-primary on a warning alert)
  kept their unreadable purple; give outline-primary buttons inside alerts a
  legible light foreground in dark mode.
- Monitor: the snapshot-detail network diagram gains a fullscreen button like
  the analysis diagram, using an over-modal z-index variant so it stacks above
  the dialog, with Escape-to-exit and tab-change cleanup.

Tests: nodeIdentityKey resolution/dedup and buildAppLegend.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The frontend replaces separate node-type and device-type filters with canonical node identities, adds transport/application edge coloring, and introduces fullscreen diagram support in the monitor modal. Dark alert buttons receive additional contrast styling.

Changes

Network identity and filtering

Layer / File(s) Summary
Canonical identity taxonomy and display configuration
frontend/src/utils/deviceType.ts, frontend/src/utils/__tests__/deviceType.test.ts
Adds L2_DEVICE, exports nodeIdentityKey, and tests identity resolution, fallbacks, consolidation, and display mappings.
Identity-based filter integration
frontend/src/components/network/NetworkControls/*, frontend/src/features/network/constants.ts, frontend/src/features/network/services/*, frontend/src/pages/Compare/*, frontend/src/pages/NetworkDiagram/*, frontend/src/pages/NetworkIntelligence/*, frontend/src/components/monitor/SnapshotDetailModal/*
Replaces node-type/device-type filter sets with ordered id: identity filters and applies them through nodeIdentityKey.
Edge color modes and legends
frontend/src/components/network/NetworkGraph/*, frontend/src/features/network/constants.ts, frontend/src/features/network/__tests__/protocolLegend.test.ts, frontend/src/pages/NetworkDiagram/*, frontend/src/components/monitor/SnapshotDetailModal/*
Adds transport, application, and volume edge modes, application coloring and legends, repainting, and updated controls and tests.
Diagram fullscreen and dark alert styling
frontend/src/components/monitor/SnapshotDetailModal/*, frontend/src/components/network/NetworkGraph/NetworkGraph.css, frontend/src/assets/styles/sgds-overrides.css
Adds fullscreen toggling with Escape handling and over-modal layout rules, plus dark-mode alert button colors.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SnapshotDetailModal
  participant NetworkGraph
  participant NetworkControls
  participant networkService
  User->>SnapshotDetailModal: Select edge mode or identity filter
  SnapshotDetailModal->>NetworkGraph: Render diagram with selected mode
  SnapshotDetailModal->>NetworkControls: Provide presentIdentities
  NetworkControls->>networkService: Apply id-prefixed activeNodeFilters
  networkService->>NetworkGraph: Return filtered graph data
  User->>SnapshotDetailModal: Toggle diagram fullscreen
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main changes: unified Node Identity filtering and selectable edge-colour modes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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 consolidates the node filtering taxonomy from two separate dimensions (nodeType and deviceType) into a single canonical 'Node Identity' taxonomy, and introduces a new 'Application' edge-coloring mode alongside the existing 'Transport' and 'Volume' modes. Additionally, it adds a fullscreen toggle for the network diagram inside the snapshot detail modal and improves dark mode button styling within alerts. The review feedback suggests adding a defensive guard check to nodeIdentityKey to prevent potential runtime crashes, and casting string arguments to any in several places to resolve strict TypeScript compilation errors where DeviceType is expected.

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/utils/deviceType.ts
Comment thread frontend/src/features/network/constants.ts
Comment thread frontend/src/components/network/NetworkControls/NetworkControls.tsx
Comment thread frontend/src/components/network/NetworkControls/NetworkControls.tsx
@NotYuSheng
NotYuSheng merged commit 999f4ac into main Jul 19, 2026
2 of 3 checks passed
@NotYuSheng
NotYuSheng deleted the feature/network-diagram-identity-and-edge-colours branch July 19, 2026 03:23

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

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 (1)
frontend/src/components/network/NetworkControls/NetworkControls.tsx (1)

42-51: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

DEVICE_TYPES.includes(k) does not type-check here (frontend/src/components/network/NetworkControls/NetworkControls.tsx:122). DEVICE_TYPES is DeviceType[], while k is string, so this blocks strict TS compilation. Narrow k to DeviceType first or widen the array type if arbitrary strings are intended.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/network/NetworkControls/NetworkControls.tsx` around
lines 42 - 51, Update the identity-filter logic in NetworkControls to resolve
the DEVICE_TYPES.includes call’s string-versus-DeviceType type mismatch. Narrow
each key to DeviceType before calling includes, while preserving separate
handling for the L2_DEVICE identity and existing filter behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/monitor/SnapshotDetailModal/SnapshotDetailModal.tsx`:
- Around line 141-148: Update the Escape-key handler in SnapshotDetailModal to
prioritize closing showLabelModal, showFilterModal, and selectedPair before
handling isDiagramFullscreen. Only exit diagram fullscreen and stop propagation
when no modal or node-detail selection is active, matching the priority order
used by NetworkDiagramPage.

---

Outside diff comments:
In `@frontend/src/components/network/NetworkControls/NetworkControls.tsx`:
- Around line 42-51: Update the identity-filter logic in NetworkControls to
resolve the DEVICE_TYPES.includes call’s string-versus-DeviceType type mismatch.
Narrow each key to DeviceType before calling includes, while preserving separate
handling for the L2_DEVICE identity and existing filter behavior.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f018b2f0-e23d-47c9-a9d3-45135a2ff331

📥 Commits

Reviewing files that changed from the base of the PR and between 9dc3573 and d096b21.

📒 Files selected for processing (13)
  • frontend/src/assets/styles/sgds-overrides.css
  • frontend/src/components/monitor/SnapshotDetailModal/SnapshotDetailModal.tsx
  • frontend/src/components/network/NetworkControls/NetworkControls.tsx
  • frontend/src/components/network/NetworkGraph/NetworkGraph.css
  • frontend/src/components/network/NetworkGraph/NetworkGraph.tsx
  • frontend/src/features/network/__tests__/protocolLegend.test.ts
  • frontend/src/features/network/constants.ts
  • frontend/src/features/network/services/networkService.ts
  • frontend/src/pages/Compare/ComparePage.tsx
  • frontend/src/pages/NetworkDiagram/NetworkDiagramPage.tsx
  • frontend/src/pages/NetworkIntelligence/NetworkIntelligencePage.tsx
  • frontend/src/utils/__tests__/deviceType.test.ts
  • frontend/src/utils/deviceType.ts

Comment on lines 141 to 148
const [showFilterModal, setShowFilterModal] = useState(false);
const [showLabelModal, setShowLabelModal] = useState(false);
const isDark = useResolvedDark();
const [edgeColorMode, setEdgeColorMode] = useState<EdgeColorMode>('protocol');
const [edgeColorMode, setEdgeColorMode] = useState<EdgeColorMode>('transport');
const [isDiagramFullscreen, setIsDiagramFullscreen] = useState(false);
const [showHeatmap, setShowHeatmap] = useState(false);
const [isHeatmapFullscreen, setIsHeatmapFullscreen] = useState(false);
const [selectedPair, setSelectedPair] = useState<VolumePair | null>(null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Escape while diagram-fullscreen doesn't prioritize closing open modals/node-details first.

Unlike the analogous handler in NetworkDiagramPage.tsx (which checks showLabelModalshowFilterModalselectedNode before exiting fullscreen), this new isDiagramFullscreen branch exits fullscreen unconditionally and calls e.stopPropagation(). Since showFilterModal/showLabelModal remain openable while fullscreen (the Filters/tag buttons stay active), pressing Escape with one of those open will exit fullscreen and swallow the keypress that would otherwise close the modal — the modal is left open, requiring a second Escape press to dismiss it.

🐛 Proposed fix
       if (e.key === 'Escape' && isDiagramFullscreen) {
         e.preventDefault();
         e.stopPropagation();
+        if (showLabelModal) { setShowLabelModal(false); return; }
+        if (showFilterModal) { setShowFilterModal(false); return; }
+        if (selectedNode) { setSelectedNode(null); return; }
         setIsDiagramFullscreen(false);
         return;
       }

Also applies to: 269-301

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/monitor/SnapshotDetailModal/SnapshotDetailModal.tsx`
around lines 141 - 148, Update the Escape-key handler in SnapshotDetailModal to
prioritize closing showLabelModal, showFilterModal, and selectedPair before
handling isDiagramFullscreen. Only exit diagram fullscreen and stop propagation
when no modal or node-detail selection is active, matching the priority order
used by NetworkDiagramPage.

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