Skip to content

feat: Topology view#3395

Open
shivamG640 wants to merge 1 commit into
KaotoIO:mainfrom
shivamG640:feat/topology_page
Open

feat: Topology view#3395
shivamG640 wants to merge 1 commit into
KaotoIO:mainfrom
shivamG640:feat/topology_page

Conversation

@shivamG640

@shivamG640 shivamG640 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Resolves #769
Try out and test this new feature here: https://shivamg640.github.io/kaoto/#/

Summary by CodeRabbit

  • New Features
    • Added a Topology page/view with new navigation entry and route.
    • Introduced dedicated topology visualization rendering (nodes/edges plus source/target anchors) and supporting endpoint-to-connection discovery.
    • Updated designer/topology visualization to drive the canvas using precomputed graph models.
  • Bug Fixes
    • Improved rendering behavior while the model resolves, including correct empty-state handling.
    • Prevented dragging on additional route elements.
  • Refactor
    • Updated canvas to consume precomputed nodes/edges and improved collapse-on-update handling.
  • Tests
    • Added/expanded unit tests for topology endpoints, topology diagram creation, controller baseline mapping, and anchor geometry.
  • Chores
    • Updated ignore rules to exclude the local Claude directory.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds a Topology route and page, introduces topology endpoint and diagram generation, refactors Canvas to consume precomputed nodes and edges, and wires new DesignerVisualization and TopologyVisualization components into the UI.

Changes

Topology View

Layer / File(s) Summary
Route registration and navigation
packages/ui/src/router/links.models.ts, packages/ui/src/router.tsx, packages/ui/src/layout/Navigation.tsx, packages/ui/src/pages/Topology/index.ts, packages/ui/src/pages/Topology/router-exports.tsx
Adds a Topology route constant, a lazy-loaded router entry, a navigation link, and page re-exports.
TopologyPage component and styles
packages/ui/src/pages/Topology/TopologyPage.tsx, packages/ui/src/pages/Topology/TopologyPage.scss
Renders TopologyVisualization with entities from EntitiesContext and applies flex-column full-height page styling.
Topology endpoint collection
packages/ui/src/components/Visualization/Topology/topology-endpoints.ts, packages/ui/src/components/Visualization/Topology/topology-endpoints.test.ts, packages/ui/src/utils/camel-uri-helper.ts, packages/ui/src/utils/camel-uri-helper.test.ts
Builds a registry mapping in-VM endpoints to consumers/producers by walking route steps, normalizing URIs, and adds CamelUriHelper.getEndpoint.
Topology diagram assembly
packages/ui/src/components/Visualization/Canvas/flow.service.ts, packages/ui/src/components/Visualization/Canvas/flow.service.test.ts
Adds getTopologyFlowDiagram, getTopologyNode, and getTopologyEdge to build topology nodes/edges from the endpoint registry.
Topology anchors, labels, nodes, edges and factory wiring
packages/ui/src/components/Visualization/Custom/topology-anchor.ts, packages/ui/src/components/Visualization/Custom/topology-anchor.test.ts, packages/ui/src/components/Visualization/Custom/Edge/TopologyEdge.tsx, packages/ui/src/components/Visualization/Custom/Node/TopologyNode.tsx, packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx, packages/ui/src/components/Visualization/Custom/Node/CustomNodeLabel.tsx, packages/ui/src/components/Visualization/Canvas/controller.service.ts, packages/ui/src/components/Visualization/Canvas/controller.service.test.ts
Adds layout-aware source/target anchors, extracted CustomNodeLabel, new TopologyNode/TopologyEdge renderers, and registers them in the controller factory.
Canvas nodes/edges model refactor
packages/ui/src/components/Visualization/Canvas/Canvas.tsx, packages/ui/src/components/Visualization/Canvas/Canvas.test.tsx, packages/ui-tests/stories/canvas/Canvas.stories.tsx
Canvas now accepts precomputed nodes/edges, visibleEntitiesCount, isModelResolving, and applyCollapseOnUpdate instead of raw vizNodes; tests and stories were updated accordingly.
Canvas model builders and visualization shell
packages/ui/src/components/Visualization/designer-canvas-model.ts, packages/ui/src/components/Visualization/topology-canvas-model.ts, packages/ui/src/components/Visualization/VisualizationShell.tsx, packages/ui/src/components/Visualization/DesignerVisualization.tsx, packages/ui/src/components/Visualization/DesignerVisualization.test.tsx, packages/ui/src/components/Visualization/TopologyVisualization.tsx, packages/ui/src/components/Visualization/index.ts
Adds buildDesignerCanvasModel/buildTopologyCanvasModel, a shared VisualizationShell, and DesignerVisualization/TopologyVisualization components wiring canvas models into Canvas.
Visualization consumers and drag restriction
packages/ui/src/external/RouteVisualization/RouteVisualization.tsx, packages/ui/src/pages/Design/DesignPage.tsx, packages/ui/src/components/Visualization/Visualization.tsx, packages/ui/src/models/visualization/flows/abstract-camel-visual-entity.ts
Switches consumers to DesignerVisualization, adds isTopologyView handling, and disallows dragging route root nodes.
Repository ignore rules
.gitignore
Ignores the .claude/ directory.

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

Sequence Diagram(s)

sequenceDiagram
  participant TopologyPage
  participant TopologyVisualization
  participant FlowService
  participant topology-endpoints
  participant Canvas

  TopologyPage->>TopologyVisualization: render(entities)
  TopologyVisualization->>FlowService: getTopologyFlowDiagram(vizNodes)
  FlowService->>topology-endpoints: collectTopologyEndpoints(vizNodes)
  topology-endpoints-->>FlowService: registry (consumers/producers)
  FlowService-->>TopologyVisualization: topology nodes/edges
  TopologyVisualization->>Canvas: render(nodes, edges, isModelResolving)
Loading

Possibly related PRs

  • KaotoIO/kaoto#2966: Both PRs modify the Canvas render/update flow to re-apply persisted collapse state via applyCollapseState(controller), with this PR gating it behind applyCollapseOnUpdate.
  • KaotoIO/kaoto#3092: Both PRs change packages/ui/src/components/Visualization/Canvas/Canvas.tsx’s exported CanvasProps contract.

Suggested reviewers: lordrip

Poem

A hop, a graph, a topology view,
Nodes and edges linking through and through 🐇
From direct to seda, the routes align,
Canvas now takes what's precomputed and fine.
Hop along the wires, route by route we go —
A rabbit's map of Camel flows, all in a row! 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The .gitignore update to ignore .claude/ is unrelated to the topology view feature. Remove the .claude/ ignore change or split it into a separate housekeeping PR.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly names the new topology view feature introduced by the PR.
Linked Issues check ✅ Passed The PR adds the topology page, route wiring, and topology-specific canvas rendering required by the linked issue.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@packages/ui/src/components/Visualization/Canvas/flow.service.ts`:
- Around line 11-12: The relationship tracking in FlowService is using
array-like overwrites instead of set semantics, which can drop shared consumers
and allow duplicate producer endpoints. Update the recording logic in the
FlowService methods that populate consumersByEndpoint and outgoingByEntity so
endpoint/entity IDs are accumulated uniquely rather than replaced or duplicated,
and make sure edge creation/lookup uses the deduplicated collections to avoid
repeated ${source} >>> ${target} entries.
- Around line 154-158: Reset the static topology relationship maps in
getTopologyFlowDiagram() before rebuilding the diagram: alongside nodes, edges,
and visitedNodes, also clear consumersByEndpoint and outgoingByEntity so stale
relationships from prior renders do not leak into the next topology view. Use
the getTopologyFlowDiagram method and the static maps
consumersByEndpoint/outgoingByEntity as the place to fix this initialization.

In `@packages/ui/src/pages/Topology/TopologyPage.tsx`:
- Line 12: The Topology page component is missing the `.topology-page` class
that `TopologyPage.scss` relies on for layout and topology-specific overrides.
Update `TopologyPage` so the `Visualization` render includes the topology page
class in addition to the existing `canvas-page` class, keeping both if needed,
so the styles scoped under `.topology-page` apply correctly.
🪄 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: CHILL

Plan: Pro

Run ID: b1f05f6e-fcb8-4149-8473-d0561387da9e

📥 Commits

Reviewing files that changed from the base of the PR and between 0fc9351 and 095a724.

⛔ Files ignored due to path filters (1)
  • packages/ui/src/layout/__snapshots__/Navigation.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (20)
  • .gitignore
  • packages/ui/src/components/Visualization/Canvas/Canvas.tsx
  • packages/ui/src/components/Visualization/Canvas/controller.service.test.ts
  • packages/ui/src/components/Visualization/Canvas/controller.service.ts
  • packages/ui/src/components/Visualization/Canvas/flow.service.ts
  • packages/ui/src/components/Visualization/Custom/Edge/TopologyEdge.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeLabels.tsx
  • packages/ui/src/components/Visualization/Custom/Node/TopologyNode.tsx
  • packages/ui/src/components/Visualization/Custom/topology-anchor.test.ts
  • packages/ui/src/components/Visualization/Custom/topology-anchor.ts
  • packages/ui/src/components/Visualization/Visualization.tsx
  • packages/ui/src/layout/Navigation.tsx
  • packages/ui/src/models/visualization/flows/abstract-camel-visual-entity.ts
  • packages/ui/src/pages/Topology/TopologyPage.scss
  • packages/ui/src/pages/Topology/TopologyPage.tsx
  • packages/ui/src/pages/Topology/index.ts
  • packages/ui/src/pages/Topology/router-exports.tsx
  • packages/ui/src/router.tsx
  • packages/ui/src/router/links.models.ts

Comment thread packages/ui/src/components/Visualization/Canvas/flow.service.ts Outdated
Comment thread packages/ui/src/components/Visualization/Canvas/flow.service.ts
Comment thread packages/ui/src/pages/Topology/TopologyPage.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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)
packages/ui/src/components/Visualization/Canvas/flow.service.ts (1)

194-204: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Inconsistent fallback for label vs id.

id falls back to vizNodeParam.id when getId() is undefined, but label does not, so a route without an explicit id would render with an undefined label.

🐛 Suggested fix
   private static getTopologyNode(vizNodeParam: IVisualizationNode): CanvasNode {
     return {
       id: vizNodeParam.getId() ?? vizNodeParam.id,
       type: 'topology-node',
-      label: vizNodeParam.getId(),
+      label: vizNodeParam.getId() ?? vizNodeParam.id,
       data: { vizNode: vizNodeParam },
🤖 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 `@packages/ui/src/components/Visualization/Canvas/flow.service.ts` around lines
194 - 204, The getTopologyNode method in flow.service.ts uses a fallback for id
but not for label, which can leave topology nodes unlabeled when getId() is
missing. Update getTopologyNode so the label uses the same fallback as id, based
on vizNodeParam.getId() ?? vizNodeParam.id, keeping the CanvasNode fields
consistent.
🧹 Nitpick comments (1)
packages/ui/src/utils/camel-uri-helper.ts (1)

269-290: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor duplication with getUriString.

getEndpoint re-implements the same string/uri-extraction checks already in getUriString before adding the parameters.name suffix logic. Could be expressed by delegating to getUriString first.

♻️ Optional refactor to reduce duplication
 static getEndpoint(value: unknown): string | undefined {
-    /** For string-based processor definitions, we can return the definition itself */
-    if (typeof value === 'string' && value !== '') {
-      return value;
-    }
-
-    const uriString = getValue(value, 'uri');
-
-    /** For object-based processor definitions, we can return the `uri` property if not empty */
-    if (typeof uriString === 'string' && uriString !== '') {
-      if (!uriString.includes(':')) {
+    const uriString = this.getUriString(value);
+    if (typeof uriString === 'string' && uriString !== '') {
+      if (!uriString.includes(':')) {
         const name = getValue(value, 'parameters.name');
         if (typeof name === 'string' && name.trim() !== '') {
           return `${uriString}:${name.trim()}`;
         }
       }
       return uriString;
     }
-
     return undefined;
   }
🤖 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 `@packages/ui/src/utils/camel-uri-helper.ts` around lines 269 - 290,
`getEndpoint` duplicates the same string and `uri` extraction logic already
present in `getUriString`; refactor it to delegate to `getUriString` first, then
apply only the `parameters.name` suffix handling when the returned URI does not
already contain a colon. Keep the existing behavior for plain string inputs and
empty/undefined values, but remove the repeated `getValue(value,
'uri')`/type-check branch from `getEndpoint` by reusing `getUriString`.
🤖 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 `@packages/ui/src/components/Visualization/Topology/topology-endpoints.ts`:
- Around line 4-6: Restore the missing topology coverage in topology-endpoints
by updating TOPOLOGY_PRODUCER_KEYS to include enrich and pollEnrich again, and
expanding IN_VM_ENDPOINT_PREFIXES to include vm: and direct-vm: alongside the
existing prefixes. Make the change in the topology-endpoints constants so any
topology-building logic that consumes these symbols continues to detect those
routes and endpoints.

---

Outside diff comments:
In `@packages/ui/src/components/Visualization/Canvas/flow.service.ts`:
- Around line 194-204: The getTopologyNode method in flow.service.ts uses a
fallback for id but not for label, which can leave topology nodes unlabeled when
getId() is missing. Update getTopologyNode so the label uses the same fallback
as id, based on vizNodeParam.getId() ?? vizNodeParam.id, keeping the CanvasNode
fields consistent.

---

Nitpick comments:
In `@packages/ui/src/utils/camel-uri-helper.ts`:
- Around line 269-290: `getEndpoint` duplicates the same string and `uri`
extraction logic already present in `getUriString`; refactor it to delegate to
`getUriString` first, then apply only the `parameters.name` suffix handling when
the returned URI does not already contain a colon. Keep the existing behavior
for plain string inputs and empty/undefined values, but remove the repeated
`getValue(value, 'uri')`/type-check branch from `getEndpoint` by reusing
`getUriString`.
🪄 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: CHILL

Plan: Pro

Run ID: 4d39344e-f1d0-44bc-8ed1-fda982253c69

📥 Commits

Reviewing files that changed from the base of the PR and between 095a724 and bd881b4.

📒 Files selected for processing (5)
  • packages/ui/src/components/Visualization/Canvas/flow.service.test.ts
  • packages/ui/src/components/Visualization/Canvas/flow.service.ts
  • packages/ui/src/components/Visualization/Topology/topology-endpoints.test.ts
  • packages/ui/src/components/Visualization/Topology/topology-endpoints.ts
  • packages/ui/src/utils/camel-uri-helper.ts

Comment thread packages/ui/src/components/Visualization/Canvas/Canvas.tsx Outdated
Comment thread packages/ui/src/components/Visualization/Canvas/flow.service.ts Outdated
Comment thread packages/ui/src/components/Visualization/Canvas/flow.service.ts Outdated
Comment thread packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx Outdated
Comment thread packages/ui/src/components/Visualization/Visualization.tsx Outdated
Comment thread packages/ui/src/pages/Topology/TopologyPage.tsx Outdated
Comment thread packages/ui/src/router/links.models.ts Outdated
return result;
}

static getEndpoint(value: unknown): string | undefined {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could it be possible that we have this logic somewhere already?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have several similar implementations already (including one in the same camel-uri-helper file), but none that solve this exact use case.

getUriString() simply returns the URI as it appears in the source. What we need here is the URI in a normalized format (e.g. direct:component-name), regardless of how the Direct component is defined in the source code.

This is necessary because we need to support all formats that users can provide on the Source Code page, for example:
uri: direct parameters: name: test-wiretap block: false
and
uri: direct:test-wiretap?block= false
Both should resolve to the same normalized URI format.

Please let me know if you think this can be handled differently.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
packages/ui/src/components/Visualization/Canvas/flow.service.ts (1)

194-199: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the same fallback for topology labels as topology IDs.

Line 198 can leave the node label undefined when getId() is absent, even though Line 196 still creates a valid id. That can render unlabeled topology nodes.

Proposed fix
 private static getTopologyNode(vizNodeParam: IVisualizationNode): CanvasNode {
+  const id = vizNodeParam.getId() ?? vizNodeParam.id;
+
   return {
-    id: vizNodeParam.getId() ?? vizNodeParam.id,
+    id,
     type: 'topology-node',
-    label: vizNodeParam.getId(),
+    label: id,
     data: { vizNode: vizNodeParam },
🤖 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 `@packages/ui/src/components/Visualization/Canvas/flow.service.ts` around lines
194 - 199, The getTopologyNode method in flow.service.ts is using getId() for
label without the same fallback used for id, which can leave topology nodes
unlabeled. Update the label assignment in getTopologyNode so it falls back to
vizNodeParam.id whenever getId() is unavailable, matching the existing id logic
and keeping topology nodes labeled consistently.
🧹 Nitpick comments (4)
packages/ui/src/components/Visualization/TopologyVisualization.tsx (3)

16-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing dedicated test coverage for TopologyVisualization.

Unlike DesignerVisualization, which has DesignerVisualization.test.tsx covering prop wiring to Canvas, there's no equivalent test file for TopologyVisualization in this cohort. Given the identical structure, mirroring the existing test suite (mocking ./topology-canvas-model and ./Canvas) should be straightforward.

🤖 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 `@packages/ui/src/components/Visualization/TopologyVisualization.tsx` around
lines 16 - 47, Add dedicated test coverage for TopologyVisualization by
mirroring the existing DesignerVisualization test pattern: create a
TopologyVisualization test that mocks useVisibleVizNodes,
buildTopologyCanvasModel, and ./Canvas, then verifies TopologyVisualization
wires className, fallback, contextToolbar, entitiesCount, visibleEntitiesCount,
nodes, edges, and isModelResolving correctly. Use the TopologyVisualization
component and its Canvas/model helpers as the main symbols to locate the code.

22-25: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Quadratic allFlowsVisible construction.

Building the map via reduce((acc, entity) => ({ ...acc, [entity.id]: true }), {}) spreads the accumulator on every iteration, making this O(n²) for n entities. Use Object.fromEntries (or a plain loop) for O(n) construction.

⚡ Proposed fix
-  const allFlowsVisible = useMemo(
-    () => entities.reduce<Record<string, boolean>>((acc, entity) => ({ ...acc, [entity.id]: true }), {}),
-    [entities],
-  );
+  const allFlowsVisible = useMemo(
+    () => Object.fromEntries(entities.map((entity) => [entity.id, true])),
+    [entities],
+  );
🤖 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 `@packages/ui/src/components/Visualization/TopologyVisualization.tsx` around
lines 22 - 25, The allFlowsVisible map in TopologyVisualization uses a reduce
spread pattern that recreates the accumulator on every entity, causing quadratic
construction time. Update the useMemo block that builds allFlowsVisible to use
an O(n) approach such as Object.fromEntries or a simple loop, while preserving
the same entity.id to true mapping.

26-33: 🚀 Performance & Scalability | 🔵 Trivial

Sequential resolution may not scale for topology view.

useVisibleVizNodes resolves vizNodes one at a time with await inside a for loop. Since TopologyVisualization now forces every entity to be "visible" (line 22-25), it will resolve strictly more entities than the Designer view typically does for a given user session, making this sequential bottleneck more likely to matter for large route sets. Worth keeping an eye on once real-world topology sizes are exercised; parallelizing with Promise.all in the hook would help if this becomes a bottleneck.

🤖 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 `@packages/ui/src/components/Visualization/TopologyVisualization.tsx` around
lines 26 - 33, The topology view now drives more entity resolution through
useVisibleVizNodes, and the current sequential await-in-loop approach can become
a bottleneck for large route sets. Update the hook’s resolution logic to fetch
the visible vizNodes in parallel instead of one-by-one, using Promise.all or an
equivalent batched pattern, while keeping the TopologyVisualization consumer
unchanged.
packages/ui/src/components/Visualization/DesignerVisualization.tsx (1)

17-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting shared logic with TopologyVisualization.

DesignerVisualization and TopologyVisualization share nearly identical structure: resolve viz nodes via useVisibleVizNodes, memoize a {nodes, edges} model while isResolving, then wrap Canvas in VisualizationShell. The only real differences are the flows source and the build*CanvasModel function/applyCollapseOnUpdate flag. Extracting a shared hook (e.g. useCanvasModel(entities, visibleFlows, buildFn)) would remove this duplication and keep both variants in sync as the model-building logic evolves.

♻️ Sketch of a shared hook
function useCanvasModel(
  entities: BaseVisualEntity[],
  visibleFlows: Record<string, boolean>,
  buildModel: (vizNodes: IVisualizationNode[]) => CanvasNodesAndEdges,
) {
  const { vizNodes, isResolving } = useVisibleVizNodes(entities, visibleFlows);
  const { nodes, edges } = useMemo(() => {
    if (isResolving) {
      return { nodes: [], edges: [] };
    }
    return buildModel(vizNodes);
  }, [vizNodes, isResolving, buildModel]);
  return { nodes, edges, vizNodes, isResolving };
}
🤖 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 `@packages/ui/src/components/Visualization/DesignerVisualization.tsx` around
lines 17 - 46, `DesignerVisualization` duplicates the same canvas-model flow as
`TopologyVisualization`, so extract the shared `useVisibleVizNodes` + `useMemo`
logic into a reusable hook such as `useCanvasModel` that accepts `entities`,
`visibleFlows`, and a build function. Update `DesignerVisualization` to consume
that hook and keep only the variant-specific pieces (`buildDesignerCanvasModel`,
`applyCollapseOnUpdate`, and the `Canvas` props). Also align the corresponding
`TopologyVisualization` implementation to use the same shared hook so both
components stay in sync.
🤖 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.

Outside diff comments:
In `@packages/ui/src/components/Visualization/Canvas/flow.service.ts`:
- Around line 194-199: The getTopologyNode method in flow.service.ts is using
getId() for label without the same fallback used for id, which can leave
topology nodes unlabeled. Update the label assignment in getTopologyNode so it
falls back to vizNodeParam.id whenever getId() is unavailable, matching the
existing id logic and keeping topology nodes labeled consistently.

---

Nitpick comments:
In `@packages/ui/src/components/Visualization/DesignerVisualization.tsx`:
- Around line 17-46: `DesignerVisualization` duplicates the same canvas-model
flow as `TopologyVisualization`, so extract the shared `useVisibleVizNodes` +
`useMemo` logic into a reusable hook such as `useCanvasModel` that accepts
`entities`, `visibleFlows`, and a build function. Update `DesignerVisualization`
to consume that hook and keep only the variant-specific pieces
(`buildDesignerCanvasModel`, `applyCollapseOnUpdate`, and the `Canvas` props).
Also align the corresponding `TopologyVisualization` implementation to use the
same shared hook so both components stay in sync.

In `@packages/ui/src/components/Visualization/TopologyVisualization.tsx`:
- Around line 16-47: Add dedicated test coverage for TopologyVisualization by
mirroring the existing DesignerVisualization test pattern: create a
TopologyVisualization test that mocks useVisibleVizNodes,
buildTopologyCanvasModel, and ./Canvas, then verifies TopologyVisualization
wires className, fallback, contextToolbar, entitiesCount, visibleEntitiesCount,
nodes, edges, and isModelResolving correctly. Use the TopologyVisualization
component and its Canvas/model helpers as the main symbols to locate the code.
- Around line 22-25: The allFlowsVisible map in TopologyVisualization uses a
reduce spread pattern that recreates the accumulator on every entity, causing
quadratic construction time. Update the useMemo block that builds
allFlowsVisible to use an O(n) approach such as Object.fromEntries or a simple
loop, while preserving the same entity.id to true mapping.
- Around line 26-33: The topology view now drives more entity resolution through
useVisibleVizNodes, and the current sequential await-in-loop approach can become
a bottleneck for large route sets. Update the hook’s resolution logic to fetch
the visible vizNodes in parallel instead of one-by-one, using Promise.all or an
equivalent batched pattern, while keeping the TopologyVisualization consumer
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fe3d62c2-ee5b-4535-a681-f2df8dbf75e4

📥 Commits

Reviewing files that changed from the base of the PR and between bd881b4 and 114c075.

📒 Files selected for processing (20)
  • packages/ui-tests/stories/canvas/Canvas.stories.tsx
  • packages/ui/src/components/Visualization/Canvas/Canvas.test.tsx
  • packages/ui/src/components/Visualization/Canvas/Canvas.tsx
  • packages/ui/src/components/Visualization/Canvas/flow.service.ts
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeLabel.tsx
  • packages/ui/src/components/Visualization/Custom/Node/TopologyNode.tsx
  • packages/ui/src/components/Visualization/DesignerVisualization.test.tsx
  • packages/ui/src/components/Visualization/DesignerVisualization.tsx
  • packages/ui/src/components/Visualization/TopologyVisualization.tsx
  • packages/ui/src/components/Visualization/Visualization.tsx
  • packages/ui/src/components/Visualization/VisualizationShell.tsx
  • packages/ui/src/components/Visualization/designer-canvas-model.ts
  • packages/ui/src/components/Visualization/index.ts
  • packages/ui/src/components/Visualization/topology-canvas-model.ts
  • packages/ui/src/external/RouteVisualization/RouteVisualization.tsx
  • packages/ui/src/pages/Design/DesignPage.tsx
  • packages/ui/src/pages/Topology/TopologyPage.scss
  • packages/ui/src/pages/Topology/TopologyPage.tsx
  • packages/ui/src/router/links.models.ts
💤 Files with no reviewable changes (2)
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeLabel.tsx
  • packages/ui/src/components/Visualization/Visualization.tsx
✅ Files skipped from review due to trivial changes (2)
  • packages/ui/src/pages/Design/DesignPage.tsx
  • packages/ui/src/router/links.models.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/ui/src/components/Visualization/Custom/Node/TopologyNode.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx

@shivamG640
shivamG640 requested a review from lordrip July 1, 2026 13:58
@shivamG640
shivamG640 force-pushed the feat/topology_page branch from ec964c6 to 19dbbc5 Compare July 1, 2026 15:42
@shivamG640
shivamG640 requested a review from a team July 1, 2026 15:42
@shivamG640
shivamG640 force-pushed the feat/topology_page branch from 19dbbc5 to b2a7e29 Compare July 1, 2026 15:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/ui/src/utils/camel-uri-helper.test.ts (1)

26-50: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test coverage looks correct; title format for object inputs is non-descriptive.

Verified all 21 cases against CamelUriHelper.getEndpoint's implementation — expectations match, including parameters.name whitespace trimming and invalid-input handling. Minor nit: the %s placeholders will stringify object inputs (e.g. { uri: {} }, { uri: 'direct', parameters: { name: 'foo' } }) to something like [object Object], producing indistinguishable/uninformative test names in the runner output for several cases. Consider using %j or a custom title function for clearer output.

♻️ Optional: improve test title readability
-    ])('should return `%s` for `%s`', (value, expected) => {
+    ])('should return `%j` for `%j`', (value, expected) => {
🤖 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 `@packages/ui/src/utils/camel-uri-helper.test.ts` around lines 26 - 50, The
test cases for CamelUriHelper.getEndpoint are correct, but the it.each title in
camel-uri-helper.test.ts uses %s, which makes object inputs render as unhelpful
[object Object] strings. Update the parameterized test title to use a
JSON-friendly or custom title format so the different object-shaped inputs are
distinguishable in runner output, while keeping the existing expectations
unchanged.
🤖 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.

Nitpick comments:
In `@packages/ui/src/utils/camel-uri-helper.test.ts`:
- Around line 26-50: The test cases for CamelUriHelper.getEndpoint are correct,
but the it.each title in camel-uri-helper.test.ts uses %s, which makes object
inputs render as unhelpful [object Object] strings. Update the parameterized
test title to use a JSON-friendly or custom title format so the different
object-shaped inputs are distinguishable in runner output, while keeping the
existing expectations unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dd61b8e2-8d17-46bf-b153-ea610fb5552f

📥 Commits

Reviewing files that changed from the base of the PR and between ec964c6 and b2a7e29.

⛔ Files ignored due to path filters (1)
  • packages/ui/src/layout/__snapshots__/Navigation.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (36)
  • .gitignore
  • packages/ui-tests/stories/canvas/Canvas.stories.tsx
  • packages/ui/src/components/Visualization/Canvas/Canvas.test.tsx
  • packages/ui/src/components/Visualization/Canvas/Canvas.tsx
  • packages/ui/src/components/Visualization/Canvas/controller.service.test.ts
  • packages/ui/src/components/Visualization/Canvas/controller.service.ts
  • packages/ui/src/components/Visualization/Canvas/flow.service.test.ts
  • packages/ui/src/components/Visualization/Canvas/flow.service.ts
  • packages/ui/src/components/Visualization/Custom/Edge/TopologyEdge.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeLabel.tsx
  • packages/ui/src/components/Visualization/Custom/Node/TopologyNode.tsx
  • packages/ui/src/components/Visualization/Custom/topology-anchor.test.ts
  • packages/ui/src/components/Visualization/Custom/topology-anchor.ts
  • packages/ui/src/components/Visualization/DesignerVisualization.test.tsx
  • packages/ui/src/components/Visualization/DesignerVisualization.tsx
  • packages/ui/src/components/Visualization/Topology/topology-endpoints.test.ts
  • packages/ui/src/components/Visualization/Topology/topology-endpoints.ts
  • packages/ui/src/components/Visualization/TopologyVisualization.tsx
  • packages/ui/src/components/Visualization/Visualization.tsx
  • packages/ui/src/components/Visualization/VisualizationShell.tsx
  • packages/ui/src/components/Visualization/designer-canvas-model.ts
  • packages/ui/src/components/Visualization/index.ts
  • packages/ui/src/components/Visualization/topology-canvas-model.ts
  • packages/ui/src/external/RouteVisualization/RouteVisualization.tsx
  • packages/ui/src/layout/Navigation.tsx
  • packages/ui/src/models/visualization/flows/abstract-camel-visual-entity.ts
  • packages/ui/src/pages/Design/DesignPage.tsx
  • packages/ui/src/pages/Topology/TopologyPage.scss
  • packages/ui/src/pages/Topology/TopologyPage.tsx
  • packages/ui/src/pages/Topology/index.ts
  • packages/ui/src/pages/Topology/router-exports.tsx
  • packages/ui/src/router.tsx
  • packages/ui/src/router/links.models.ts
  • packages/ui/src/utils/camel-uri-helper.test.ts
  • packages/ui/src/utils/camel-uri-helper.ts
💤 Files with no reviewable changes (1)
  • packages/ui/src/components/Visualization/Visualization.tsx
✅ Files skipped from review due to trivial changes (8)
  • packages/ui/src/pages/Topology/router-exports.tsx
  • packages/ui/src/router/links.models.ts
  • packages/ui/src/pages/Topology/TopologyPage.scss
  • packages/ui/src/pages/Topology/index.ts
  • packages/ui/src/components/Visualization/topology-canvas-model.ts
  • packages/ui/src/components/Visualization/Canvas/controller.service.test.ts
  • .gitignore
  • packages/ui/src/layout/Navigation.tsx
🚧 Files skipped from review as they are similar to previous changes (26)
  • packages/ui/src/components/Visualization/Custom/topology-anchor.ts
  • packages/ui/src/router.tsx
  • packages/ui/src/components/Visualization/index.ts
  • packages/ui/src/components/Visualization/Topology/topology-endpoints.test.ts
  • packages/ui/src/components/Visualization/VisualizationShell.tsx
  • packages/ui/src/components/Visualization/DesignerVisualization.tsx
  • packages/ui/src/external/RouteVisualization/RouteVisualization.tsx
  • packages/ui/src/pages/Design/DesignPage.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx
  • packages/ui/src/utils/camel-uri-helper.ts
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeLabel.tsx
  • packages/ui/src/components/Visualization/Custom/Edge/TopologyEdge.tsx
  • packages/ui/src/components/Visualization/Custom/topology-anchor.test.ts
  • packages/ui/src/components/Visualization/designer-canvas-model.ts
  • packages/ui/src/pages/Topology/TopologyPage.tsx
  • packages/ui/src/components/Visualization/Canvas/controller.service.ts
  • packages/ui/src/components/Visualization/Canvas/flow.service.test.ts
  • packages/ui/src/components/Visualization/DesignerVisualization.test.tsx
  • packages/ui/src/models/visualization/flows/abstract-camel-visual-entity.ts
  • packages/ui/src/components/Visualization/Canvas/flow.service.ts
  • packages/ui/src/components/Visualization/Custom/Node/TopologyNode.tsx
  • packages/ui/src/components/Visualization/TopologyVisualization.tsx
  • packages/ui/src/components/Visualization/Topology/topology-endpoints.ts
  • packages/ui-tests/stories/canvas/Canvas.stories.tsx
  • packages/ui/src/components/Visualization/Canvas/Canvas.test.tsx
  • packages/ui/src/components/Visualization/Canvas/Canvas.tsx

@lordrip
lordrip marked this pull request as draft July 8, 2026 08:53
@shivamG640
shivamG640 force-pushed the feat/topology_page branch 2 times, most recently from 5092f0c to 527dea3 Compare July 9, 2026 12:51
@shivamG640
shivamG640 marked this pull request as ready for review July 9, 2026 12:52
@shivamG640
shivamG640 force-pushed the feat/topology_page branch 4 times, most recently from 29599de to ef349fa Compare July 24, 2026 06:57
@shivamG640
shivamG640 force-pushed the feat/topology_page branch from ef349fa to 4ed6a3f Compare July 24, 2026 09:22
@sonarqubecloud

Copy link
Copy Markdown

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.

Offer an environment overview of used components

3 participants