Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented Jul 15, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a collapsible tree visualization for exploring resource relationships and dependencies.
    • Added a sidebar layout that displays detailed system information alongside the relationships diagram.
    • Implemented expand/collapse controls for resource nodes within the visualization.
    • Displayed system job statuses directly within resource nodes.
  • Refactor

    • Simplified and unified the relationships diagram logic to rely on shared context and providers.
    • Streamlined the page layout by consolidating multiple components into a single content component.
  • Bug Fixes

    • Improved accuracy and clarity of system status indicators within the visualization.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 15, 2025

Walkthrough

This update introduces a collapsible tree context for resource relationship visualization, restructures the relationships diagram to consume context-based state, and simplifies the layout logic by removing focused node centering. Several new hooks, types, and components are added, while sidebar and status logic is modularized or refactored for clarity and maintainability.

Changes

File(s) Change Summary
.../reactflow/layout.ts Removes focusedNodeId from layout config, deletes setDefaultView, and simplifies view fitting logic.
.../visualize/CollapsibleTreeContext.tsx Adds context, provider, and hook for managing collapsible resource dependency trees and layout state.
.../visualize/PageContent.tsx Adds PageContent component orchestrating visualization and sidebar with multiple providers.
.../visualize/RelationshipsDiagram.tsx Refactors diagram to consume nodes/edges from context, removes local state and helper functions, updates props.
.../visualize/page.tsx Replaces sidebar layout and diagram composition with single PageContent component.
.../visualize/resource-node/ResourceNode.tsx Refactors node header for collapsible toggles, removes inline status logic, imports SystemStatus component.
.../visualize/resource-node/SystemStatus.tsx Adds SystemStatus component for displaying system job status with icons based on job state.
.../visualize/resource-node/useResourceCollapsibleToggle.ts Adds hook for managing expand/collapse state of resource nodes in the collapsible tree.
.../visualize/types.ts Adds types for ResourceNodeData, System, and Edge for visualization.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant PageContent
  participant CollapsibleTreeProvider
  participant RelationshipsDiagram
  participant SystemStatus

  User->>PageContent: Load with focusedResource, resources, edges
  PageContent->>CollapsibleTreeProvider: Provide context (resources, edges, focusedResource)
  CollapsibleTreeProvider->>RelationshipsDiagram: Provide nodes, edges, expand/collapse handlers
  RelationshipsDiagram->>SystemStatus: For each node, show system job status
  User->>RelationshipsDiagram: Expand/collapse resource nodes
  RelationshipsDiagram->>CollapsibleTreeProvider: Update expanded/collapsed state
Loading

Possibly related PRs

  • ctrlplanedev/ctrlplane#247: Modifies the same layout file to add focusedNodeId and centering logic, which this PR now removes.
  • ctrlplanedev/ctrlplane#568: Introduces the original RelationshipsDiagram with local state, which this PR refactors to use context and new state management.
  • ctrlplanedev/ctrlplane#620: Updates the same diagram component and layout logic, but with a different approach to state and sidebar handling.

Suggested reviewers

  • jsbroks

Poem

In the garden of nodes where resources grow,
A rabbit hops where dependencies flow.
Collapsible trees now bloom with ease,
Context and hooks in the summer breeze.
Sidebars trimmed, layouts neat—
Visualization’s never been so sweet!
🐇🌳✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37fa542 and a3844b6.

📒 Files selected for processing (9)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/reactflow/layout.ts (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/PageContent.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/RelationshipsDiagram.tsx (3 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/page.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/ResourceNode.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/SystemStatus.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/useResourceCollapsibleToggle.ts (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/types.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md

⚙️ CodeRabbit Configuration File

**/*.{js,jsx,ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
**/*.{js,jsx,ts,tsx,json,css,md,yml,yaml}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • CLAUDE.md
🧠 Learnings (10)
📓 Common learnings
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: e2e/tests/api/policies/retry-policy.spec.ts:23-24
Timestamp: 2025-06-24T23:52:50.732Z
Learning: The user adityachoudhari26 prefers not to add null safety checks or defensive programming in test code, particularly in e2e tests, as they prioritize simplicity and focus on the main functionality being tested rather than comprehensive error handling within the test itself.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: e2e/tests/api/policies/retry-policy.spec.ts:117-130
Timestamp: 2025-06-24T23:53:25.398Z
Learning: User adityachoudhari26 prefers to keep non-null assertions in e2e test code without extensive null safety checks, reasoning that test failures serve the same purpose of catching issues and the extra validation doesn't add much value in test contexts.
apps/webservice/src/app/[workspaceSlug]/(app)/_components/reactflow/layout.ts (2)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#183
File: apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/Overview.tsx:46-57
Timestamp: 2024-10-30T00:03:57.878Z
Learning: Accessibility and validation feedback improvements are not desired for form fields in the `Overview` component within `apps/webservice/src/app/[workspaceSlug]/_components/environment-drawer/Overview.tsx`.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/page.tsx (4)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#363
File: apps/webservice/tsconfig.json:14-15
Timestamp: 2025-03-09T08:56:53.603Z
Learning: In the ctrlplane project, they use Next.js standalone output mode, which means they intentionally exclude `.next/types` in their tsconfig.json despite including `.next/types/**/*.ts` in their include pattern.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/ResourceNode.tsx (2)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/SystemStatus.tsx (3)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#287
File: packages/validators/src/jobs/conditions/status-condition.ts:4-4
Timestamp: 2025-01-21T19:52:22.838Z
Learning: In apps/webservice/src/app/api/github/webhook/workflow/handler.ts, the external "completed" status is intentionally mapped to JobStatus.Successful to handle GitHub workflow status conversions.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/types.ts (3)
Learnt from: CR
PR: ctrlplanedev/ctrlplane#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T21:36:42.935Z
Learning: Applies to **/*.{ts,tsx} : Consistent type imports: `import type { Type } from "module"`
Learnt from: CR
PR: ctrlplanedev/ctrlplane#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T21:36:42.935Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript with explicit types (prefer interfaces for public APIs)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/PageContent.tsx (2)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/RelationshipsDiagram.tsx (3)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/useResourceCollapsibleToggle.ts (2)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#165
File: apps/webservice/src/app/[workspaceSlug]/_components/relationships/RelationshipsDiagramDependencies.tsx:185-189
Timestamp: 2024-10-24T21:31:17.820Z
Learning: In `RelationshipsDiagramDependencies.tsx`, when using React Flow's `BaseEdge`, the `markerStart` prop may intentionally use the `markerEnd` value to flip the arrow direction because 'source depends on target' logic is applied. These are intrinsic attributes of the React Flow `BaseEdge` component and cannot be renamed or changed.
🧬 Code Graph Analysis (4)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/SystemStatus.tsx (3)
packages/db/src/schema/job.ts (1)
  • JobStatus (149-149)
packages/validators/src/jobs/index.ts (2)
  • failedStatuses (54-59)
  • activeStatus (32-32)
packages/ui/src/skeleton.tsx (1)
  • Skeleton (15-15)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/types.ts (2)
packages/api/src/index.ts (1)
  • RouterOutputs (33-33)
packages/db/src/schema/resource-relationship-rule.ts (1)
  • ResourceRelationshipRule (232-233)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/RelationshipsDiagram.tsx (1)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (1)
  • useCollapsibleTree (43-51)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/useResourceCollapsibleToggle.ts (2)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/types.ts (1)
  • Edge (9-13)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (1)
  • useCollapsibleTree (43-51)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
🔇 Additional comments (15)
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/types.ts (1)

1-13: LGTM! Well-structured type definitions.

The type definitions follow TypeScript best practices with proper import type syntax and efficient use of indexed access types to extract nested structures. The Edge type clearly defines the relationship structure with appropriate schema references.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/page.tsx (2)

5-5: LGTM! Clean import addition.

The import follows the established pattern and supports the architectural refactoring.


32-36: LGTM! Excellent refactoring to centralize layout logic.

The simplification from multiple sidebar components to a single PageContent component improves maintainability and follows the single responsibility principle. The props being passed match the expected data structure.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/reactflow/layout.ts (3)

61-61: LGTM! Dual position assignment for React Flow compatibility.

The assignment of both direct x, y properties and nested position object appears intentional for React Flow compatibility, supporting the new collapsible tree architecture.


110-112: LGTM! Configurable fitView parameters.

The configurable padding and maxZoom parameters provide better control over the view fitting behavior, with reasonable defaults.


115-115: LGTM! Correct dependency update.

The addition of config to the useEffect dependencies is correct and prevents stale closures.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/ResourceNode.tsx (4)

13-17: LGTM! Good import organization.

The imports are well-organized with proper type imports and the new modular components support the improved architecture.


19-25: LGTM! Clean integration of collapsible toggle functionality.

The NodeHeader component cleanly integrates the collapsible toggle hook, following the new context-driven architecture.


40-57: LGTM! Intuitive expand/collapse UI logic.

The conditional rendering of expand/collapse buttons based on hidden children count provides a clear and intuitive user experience. The logic correctly handles both states.


118-118: LGTM! Good separation of concerns.

The extraction of SystemStatus to its own component improves modularity and maintainability.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/useResourceCollapsibleToggle.ts (3)

4-7: LGTM! Correct edge filtering for direct children.

The function correctly identifies direct children by filtering edges where the resource is the target.


9-23: LGTM! Proper BFS implementation for descendants.

The breadth-first search implementation correctly finds all descendants using a queue and Set for visited tracking. The algorithm handles the graph traversal properly.


25-49: LGTM! Well-structured hook with clear logic.

The hook provides a clean interface for managing collapsible state with proper integration of the context. The expand/collapse logic is intuitive - expand shows hidden direct children, collapse removes all descendants.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/RelationshipsDiagram.tsx (1)

36-52: Clean refactor to use context-based state management.

The migration from local state to context-based state management via useCollapsibleTree is well executed. The component is now more focused and delegates graph state management appropriately.

apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/CollapsibleTreeContext.tsx (1)

156-168: Correct implementation of edge reversal pattern.

The source/target reversal is properly implemented and well-documented. This aligns with the established pattern where the target represents the parent in ctrlplane's relationship model.

Comment on lines +66 to +68
const statuses = (data ?? []).map((d) => d.status);
const { numSuccessful, Icon } = getStatusInfo(
statuses as (JobStatus | null)[],
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify if the type assertion is necessary.

The type assertion as (JobStatus | null)[] on line 68 might be redundant if the TRPC query response is properly typed. Consider verifying the API response type definition to ensure type safety without explicit assertions.


🏁 Script executed:

#!/bin/bash
# Description: Check the API response type for systemOverview query

# Search for the systemOverview query definition
ast-grep --pattern 'systemOverview: $_'

# Also search with ripgrep for broader context
rg -A 10 "systemOverview.*useQuery|systemOverview.*query" --type ts

Length of output: 1699


🏁 Script executed:

#!/bin/bash
# Search for the systemOverview procedure definition in TRPC routers
rg -n "systemOverview" --type ts

Length of output: 311


🏁 Script executed:

#!/bin/bash
# Show the definition and return type of resourceSystemOverview
rg -n "resourceSystemOverview" -A5 -B5 packages/api/src/router/resource/resources.ts

Length of output: 1099


🏁 Script executed:

#!/bin/bash
# Show the definition and resourceSystemOverview procedure including its return type
rg -n "export const resourceSystemOverview" -A20 -B5 packages/api/src/router/resource/resource-system-overview.ts

Length of output: 989


🏁 Script executed:

#!/bin/bash
# Print the implementation of resourceSystemOverview to inspect its return type
sed -n '1,200p' packages/api/src/router/resource/resource-system-overview.ts

Length of output: 2223


Remove unnecessary type assertion on statuses

The TRPC systemOverview query already returns items typed as { status: JobStatus | null }[], so this cast is redundant. You can safely drop the as (JobStatus | null)[] on line 68.

• apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/SystemStatus.tsx:68

🤖 Prompt for AI Agents
In
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/resource-node/SystemStatus.tsx
around lines 66 to 68, remove the unnecessary type assertion "as (JobStatus |
null)[]" on the "statuses" variable passed to getStatusInfo, since the TRPC
systemOverview query already types the data correctly. Simply pass "statuses"
without casting.

defaultOpen={[]}
>
<div className="relative flex h-full w-full">
<SidebarInset className="h-[calc(100vh-56px-64px-2px)] min-w-0">
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace hardcoded height calculation with a more maintainable approach.

The height calculation h-[calc(100vh-56px-64px-2px)] uses magic numbers that could break if UI element heights change. Consider using CSS variables or a flexbox/grid layout that automatically adjusts to available space.

-              <SidebarInset className="h-[calc(100vh-56px-64px-2px)] min-w-0">
+              <SidebarInset className="flex-1 min-h-0 min-w-0">

Additionally, ensure the parent container uses flex flex-col h-full to enable proper height distribution.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<SidebarInset className="h-[calc(100vh-56px-64px-2px)] min-w-0">
<SidebarInset className="flex-1 min-h-0 min-w-0">
🤖 Prompt for AI Agents
In
apps/webservice/src/app/[workspaceSlug]/(app)/resources/(raw)/[resourceId]/visualize/PageContent.tsx
at line 39, replace the hardcoded height calculation
h-[calc(100vh-56px-64px-2px)] with a more maintainable layout using flexbox or
grid. Remove the fixed height and instead ensure the parent container uses flex
flex-col h-full to allow the SidebarInset component to automatically fill the
available space without relying on magic numbers.

@adityachoudhari26 adityachoudhari26 merged commit 88c32a2 into main Jul 15, 2025
4 of 6 checks passed
@adityachoudhari26 adityachoudhari26 deleted the collapsible-react-flow branch July 15, 2025 21:40
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.

2 participants