Skip to content

fix: active subgraph not shown on the subgraph details page - #3063

Merged
wilsonrivera merged 7 commits into
mainfrom
wilson/eng-9332-studio-active-feature-subgraph-not-shown-in-header
Jul 14, 2026
Merged

fix: active subgraph not shown on the subgraph details page#3063
wilsonrivera merged 7 commits into
mainfrom
wilson/eng-9332-studio-active-feature-subgraph-not-shown-in-header

Conversation

@wilsonrivera

@wilsonrivera wilsonrivera commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Workspace data now exposes feature subgraphs per namespace, including an optional reference to a related base subgraph.
    • Workspace selection recognizes feature subgraphs and connects them to their base subgraphs.
  • Bug Fixes
    • Improved workspace navigation by resolving the active graph/subgraph more reliably from route details, with fallback based on feature subgraphs.
    • Enhanced workspace retrieval to clearly distinguish feature subgraphs from regular subgraphs.
  • UI/Style
    • Refined graph selector trigger spacing and icon alignment.

Checklist

Open Source AI Manifesto

This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.

Steps for testing

  • Create a subgraph
  • Create a feature subgraph with the new subgraph as base
  • Navigate to Subgraphs on the sidebar
  • Select the Feature Subgraphs tab
  • Click on any subgraph
  • Observe the header rendering the active subgraph correctly.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.63291% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.72%. Comparing base (6288994) to head (4189535).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...io/src/components/dashboard/workspace-selector.tsx 0.00% 27 Missing ⚠️
controlplane/src/core/services/WorkspaceService.ts 80.00% 10 Missing ⚠️
studio/src/components/dashboard/graph-selector.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3063       +/-   ##
===========================================
- Coverage   71.03%   43.72%   -27.31%     
===========================================
  Files         335     1069      +734     
  Lines       49283   139516    +90233     
  Branches     6027     7315     +1288     
===========================================
+ Hits        35006    61002    +25996     
- Misses      14251    76661    +62410     
- Partials       26     1853     +1827     
Files with missing lines Coverage Δ
studio/src/components/dashboard/graph-selector.tsx 0.00% <0.00%> (ø)
controlplane/src/core/services/WorkspaceService.ts 91.56% <80.00%> (-5.05%) ⬇️
...io/src/components/dashboard/workspace-selector.tsx 0.00% <0.00%> (ø)

... and 733 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Router-nonroot image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-723454d0b81aab5da86634cb9bf557e2ce0aec29-nonroot

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6504b846-65e9-41db-a870-5300d83d2aba

📥 Commits

Reviewing files that changed from the base of the PR and between 3f3939d and cbb528c.

📒 Files selected for processing (1)
  • controlplane/src/core/services/WorkspaceService.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • controlplane/src/core/services/WorkspaceService.ts

Walkthrough

Adds feature subgraph fields to the platform schema, fetches and populates feature subgraphs in WorkspaceService, and updates studio workspace selection logic to use the new namespace data.

Changes

Feature Subgraph Support

Layer / File(s) Summary
Proto schema additions for feature subgraphs
proto/wg/cosmo/platform/v1/platform.proto
WorkspaceNamespace gains a featureSubgraphs field and WorkspaceSubgraph gains an optional baseSubgraphId field.
WorkspaceService namespace fetch flow
controlplane/src/core/services/WorkspaceService.ts
getWorkspaceNamespaces() adds a feature-subgraph fetch step, and the regular and federated subgraph queries are updated to separate feature subgraphs from regular subgraphs while preserving the filtered federated-graph path.
Feature subgraph hydration
controlplane/src/core/services/WorkspaceService.ts
A new fetchFeatureSubgraphs() method filters feature subgraphs, joins base-subgraph mappings, and assigns namespace.featureSubgraphs from the mapped rows.
Studio subgraph resolution
studio/src/components/dashboard/workspace-selector.tsx
workspace-selector.tsx imports WorkspaceSubgraph and refactors its route-based memo logic to resolve activeSubgraph from namespace.featureSubgraphs and derive baseSubgraph from baseSubgraphId.
Graph selector spacing
studio/src/components/dashboard/graph-selector.tsx
graph-selector.tsx changes the trigger button and icon spacing classes without altering behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the user-facing fix to show the active subgraph on the subgraph details page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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

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

🧹 Nitpick comments (1)
controlplane/src/core/services/WorkspaceService.ts (1)

172-203: 📐 Maintainability & Code Quality | 🔵 Trivial

No try/catch around the new DB call.

The coding guidelines require error handling with try-catch blocks for .ts files; this new method has none around execute(). Existing sibling methods share this omission, so this may be intentional (relying on an upstream error boundary) — worth confirming rather than enforcing per-method here.

As per coding guidelines: "Add proper error handling with try-catch blocks."

🤖 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 `@controlplane/src/core/services/WorkspaceService.ts` around lines 172 - 203,
The new database read in WorkspaceService.fetchFeatureSubgraphs() calls
.execute() without any local error handling, which conflicts with the TypeScript
error-handling guideline. Update fetchFeatureSubgraphs() to wrap the query
execution and any related DB work in a try-catch, and log/propagate the failure
consistently with the surrounding WorkspaceService methods so the new
feature-subgraph fetch path handles errors explicitly.

Source: Coding guidelines

🤖 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 `@controlplane/src/core/services/WorkspaceService.ts`:
- Around line 171-212: fetchFeatureSubgraphs currently does one query per
namespace, creating an N+1 pattern on the workspace-selector path. Refactor it
to batch all namespaces in one query like
fetchFederatedGraphs/fetchSubgraphsForFederatedGraphs: collect namespace IDs,
use inArray(...) in the conditions, query feature subgraphs once, then group the
returned rows in memory and assign namespace.featureSubgraphs per namespace.
Keep the existing RBAC check via SubgraphRepository.applyRbacConditionsToQuery
and preserve the fromJson(WorkspaceSubgraphSchema, ...) mapping when building
each feature subgraph.

In `@studio/src/components/dashboard/workspace-selector.tsx`:
- Around line 22-57: The `baseSubgraph` lookup in `workspace-selector.tsx` is
currently dead code because `GraphSelector` only consumes `activeGraph` and
`activeSubgraph`. Remove the `baseSubgraph` state from the `useMemo` return and
related lookup logic, or if feature-subgraph pages need it, thread it through
`GraphSelectorProps` and the `GraphSelector` component instead of leaving it
unused. Keep the fix centered around `useMemo`, `activeSubgraph`, and
`GraphSelector`.

---

Nitpick comments:
In `@controlplane/src/core/services/WorkspaceService.ts`:
- Around line 172-203: The new database read in
WorkspaceService.fetchFeatureSubgraphs() calls .execute() without any local
error handling, which conflicts with the TypeScript error-handling guideline.
Update fetchFeatureSubgraphs() to wrap the query execution and any related DB
work in a try-catch, and log/propagate the failure consistently with the
surrounding WorkspaceService methods so the new feature-subgraph fetch path
handles errors explicitly.
🪄 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: 53456a35-23be-43af-81a7-60ec70807488

📥 Commits

Reviewing files that changed from the base of the PR and between 6c2dc0f and 7454692.

⛔ Files ignored due to path filters (1)
  • connect-go/gen/proto/wg/cosmo/platform/v1/platform.pb.go is excluded by !**/*.pb.go, !**/gen/**
📒 Files selected for processing (5)
  • connect/src/wg/cosmo/platform/v1/platform_pb.ts
  • controlplane/src/core/services/WorkspaceService.ts
  • proto/wg/cosmo/platform/v1/platform.proto
  • studio/src/components/dashboard/graph-selector.tsx
  • studio/src/components/dashboard/workspace-selector.tsx

Comment thread controlplane/src/core/services/WorkspaceService.ts
Comment thread studio/src/components/dashboard/workspace-selector.tsx
@wilsonrivera
wilsonrivera merged commit 96663cc into main Jul 14, 2026
50 checks passed
@wilsonrivera
wilsonrivera deleted the wilson/eng-9332-studio-active-feature-subgraph-not-shown-in-header branch July 14, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants