Skip to content

Conversation

@adityathebe
Copy link
Member

@adityathebe adityathebe commented Dec 1, 2025

resolves: flanksource/mission-control#2545

Summary by CodeRabbit

  • New Features

    • Multi-section views: main section plus additional sections with their own headers and data.
    • Fetch views by namespace/name in addition to ID.
    • New layout wrapper for view pages with header, title, refresh and centered options.
    • New per-section view component and hook to aggregate section variables.
  • Improvements

    • Optional hide-variables control to hide global variable filters.
    • Aggregated variable handling across sections for unified filtering.
    • Improved table/card/panel rendering and flex layout behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
aws-preview Ready Ready Preview Dec 2, 2025 0:55am
flanksource-ui Ready Ready Preview Dec 2, 2025 0:55am

@coderabbitai
Copy link

coderabbitai bot commented Dec 1, 2025

Warning

Rate limit exceeded

@adityathebe has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a261b3e and 3656139.

📒 Files selected for processing (10)
  • src/api/services/views.ts (2 hunks)
  • src/pages/audit-report/components/View/View.tsx (6 hunks)
  • src/pages/audit-report/types/index.ts (2 hunks)
  • src/pages/views/components/SingleView.tsx (4 hunks)
  • src/pages/views/components/ViewLayout.tsx (1 hunks)
  • src/pages/views/components/ViewSection.tsx (1 hunks)
  • src/pages/views/constants.ts (1 hunks)
  • src/pages/views/hooks/useAggregatedViewVariables.ts (1 hunks)
  • src/pages/views/utils/aggregateVariables.ts (1 hunks)
  • src/ui/MRTDataTable/MRTDataTable.tsx (2 hunks)

Walkthrough

Adds support for multi-section views: API helpers for namespace-based view retrieval, new types for section references, components and layout for per-section rendering, a hook and util to aggregate variables across sections, and refactors single-view rendering to orchestrate sections and unified variable handling.

Changes

Cohort / File(s) Change Summary
API Service
src/api/services/views.ts
Added private fetchViewData helper centralizing POST/fetch logic; getViewDataById now wraps it with encoded path; new exported getViewDataByNamespace(namespace, name, variables?, headers?).
Types
src/pages/audit-report/types/index.ts
Added ViewRef (namespace,name) and ViewSection (title, icon?, viewRef); extended ViewResult with optional sections?: ViewSection[].
View component
src/pages/audit-report/components/View/View.tsx
Added hideVariables?: boolean prop; use shared VIEW_VAR_PREFIX; conditional rendering of global filters; reorganized title, panel grid, card/table rendering and integrated ViewTableFilterForm.
Single view orchestration
src/pages/views/components/SingleView.tsx
Refactored to gather section refs, use useAggregatedViewVariables, fetch main metadata then per-section data, render aggregated global filters and ViewSections, and invalidate section queries on refresh.
New layout component
src/pages/views/components/ViewLayout.tsx
New default-export ViewLayout rendering header/breadcrumb, supports centered layout, accepts title, icon, onRefresh, loading, extra, children.
Section component
src/pages/views/components/ViewSection.tsx
New default-export ViewSection that fetches per-section data with getViewDataByNamespace(namespace,name,currentViewVariables) and renders a header + nested View; handles loading/error; query enabled when namespace/name exist.
Shared constants
src/pages/views/constants.ts
Added export const VIEW_VAR_PREFIX = "viewvar";.
Aggregated variables hook
src/pages/views/hooks/useAggregatedViewVariables.ts
New useAggregatedViewVariables(sections: ViewRef[]): reads prefixed search params, issues parallel section queries, aggregates variables via aggregateVariables, returns { variables, isLoading, currentVariables }.
Variable aggregation util
src/pages/views/utils/aggregateVariables.ts
New `aggregateVariables(variableArrays: (ViewVariable[]
Layout tweak
src/ui/MRTDataTable/MRTDataTable.tsx
Adjusted flex basis from 0 to auto for mantinePaperProps.sx and mantineTableContainerProps.sx.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SingleView
    participant Hook as useAggregatedViewVariables
    participant API as Views API
    participant ViewSection
    participant View

    User->>SingleView: Open view page (with sections)
    SingleView->>Hook: Request aggregated variables (all section refs)
    par Parallel per-section variable fetches
        Hook->>API: getViewDataByNamespace(sectionA, currentVariables?)
        Hook->>API: getViewDataByNamespace(sectionB, currentVariables?)
        Hook->>API: getViewDataByNamespace(sectionN, currentVariables?)
    end
    API-->>Hook: ViewResult[] (per-section variables)
    Hook-->>SingleView: aggregatedVariables, currentVariables
    SingleView->>View: Render main View with aggregatedVariables (if shown)
    SingleView->>ViewSection: Render each ViewSection (pass currentVariables)
    ViewSection->>API: getViewDataByNamespace(namespace,name,currentVariables)
    API-->>ViewSection: ViewResult (section data)
    ViewSection->>View: Render nested View (hideVariables true)
    View-->>User: Rendered content
Loading

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'feat: view sections' clearly and concisely describes the main feature addition in the changeset.
Linked Issues check ✅ Passed The PR successfully implements view sections functionality and enables referencing other views through new ViewRef/ViewSection types and APIs.
Out of Scope Changes check ✅ Passed All changes align with the view sections feature scope; minor flex property adjustments support the new layout structure.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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

🧹 Nitpick comments (8)
src/api/services/views.ts (1)

101-129: Namespace-based view fetch is correct; consider URL-encoding and DRYing with getViewDataById

The implementation mirrors getViewDataById and looks functionally correct. Two small hardening/refactor suggestions:

  • To be robust against special characters in namespace / name, it’s safer to URL-encode them when building the path:
-  const response = await fetch(`/api/view/${namespace}/${name}`, {
+  const response = await fetch(
+    `/api/view/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`,
+    {
       method: "POST",
       credentials: "include",
       headers: {
         "Content-Type": "application/json",
         ...headers
       },
       body: JSON.stringify(body)
-  });
+    }
+  );
  • The body/error-handling logic is now duplicated with getViewDataById; consider extracting a small internal helper (e.g., fetchView(path, variables, headers)) to keep behavior consistent in one place.
src/pages/audit-report/types/index.ts (1)

368-377: ViewRef/ViewSection typing is sound; reuse ViewRef instead of redefining elsewhere

The new ViewRef, ViewSection, and ViewResult.sections?: ViewSection[] types line up well with the new /api/view/{namespace}/{name} behavior and the ViewSection UI component.

One follow-up to keep things consistent: src/pages/views/hooks/useAggregatedViewVariables.ts defines its own ViewRef interface with the same shape. It would be cleaner to import and reuse this exported ViewRef here instead of duplicating the type, so any future changes to the contract happen in a single place.

Also applies to: 393-394

src/pages/views/utils/aggregateVariables.ts (1)

7-33: Clarify merge semantics when the same variable key appears in multiple views

The aggregation logic is clean and efficient, but its conflict behavior is worth calling out:

  • When a key appears multiple times, you union the options arrays, which is great.
  • For all other fields (type, label, default, value, etc.), the first occurrence “wins” and later ones are ignored.

If that “first writer wins” rule is intentional, it might be good to document it explicitly in the comment so future changes don’t accidentally assume some other merge strategy. If it’s not intentional, consider either:

  • Detecting and logging/handling mismatches between variable definitions for the same key, or
  • Defining a consistent resolution rule (e.g., prefer non-empty labels/defaults, or prefer a particular namespace).
src/pages/views/hooks/useAggregatedViewVariables.ts (1)

8-56: Reuse the shared ViewRef type instead of redefining it locally

The hook logic around usePrefixedSearchParams, useQueries, and aggregateVariables looks good for aggregating variables across sections.

Given that ViewRef is already exported from src/pages/audit-report/types/index.ts, it would be better to import and use that here instead of redefining a local interface ViewRef. That keeps section/view references strongly typed from a single source of truth and avoids subtle divergence if the backend contract ever changes.

For example:

-import { VIEW_VAR_PREFIX } from "../constants";
-
-interface ViewRef {
-  namespace: string;
-  name: string;
-}
+import { VIEW_VAR_PREFIX } from "../constants";
+import type { ViewRef } from "../../audit-report/types";
src/pages/views/components/ViewSection.tsx (1)

15-83: Section rendering is correct; consider avoiding double-fetching when combined with aggregated variables

The per-section fetch and rendering flow here looks solid: variables come from prefixed params, the query is keyed by namespace/name plus variables, and loading/error/success UI is well-handled.

One thing to be aware of in the broader design: useAggregatedViewVariables also calls getViewDataByNamespace for each section (to collect variables), and ViewSection then calls the same endpoint again to render the actual content. For views with several sections this means each section will be fetched at least twice.

If this becomes noticeable under load, a couple of options to reduce duplication would be:

  • Have useAggregatedViewVariables return the full ViewResults (or the underlying queries) so ViewSection can reuse the same data instead of refetching, or
  • Introduce a lighter-weight endpoint for “variables only” and reserve full ViewResult calls for the actual section rendering.

Not urgent for correctness, but worth considering if you see extra traffic or latency from sectional views.

src/pages/views/components/SingleView.tsx (3)

44-60: Minor redundancy in namespace fallback.

Line 49 uses viewResult.namespace || "" but line 45 already guards against falsy namespace values, so the || "" fallback is never reached. Consider simplifying:

     const refs = [
-      { namespace: viewResult.namespace || "", name: viewResult.name }
+      { namespace: viewResult.namespace, name: viewResult.name }
     ];

90-112: Consider combining invalidation calls for efficiency.

The three Promise.all blocks run sequentially, but since these invalidations are independent, they can be combined into a single parallel operation:

-    await Promise.all(
-      sectionsToRefresh.map((section) =>
-        queryClient.invalidateQueries({
-          queryKey: ["view-result", section.namespace, section.name]
-        })
-      )
-    );
-
-    await Promise.all(
-      sectionsToRefresh.map((section) =>
-        queryClient.invalidateQueries({
-          queryKey: ["view-table", section.namespace, section.name]
-        })
-      )
-    );
-
-    await Promise.all(
-      sectionsToRefresh.map((section) =>
-        queryClient.invalidateQueries({
-          queryKey: ["view-variables", section.namespace, section.name]
-        })
-      )
-    );
+    await Promise.all(
+      sectionsToRefresh.flatMap((section) => [
+        queryClient.invalidateQueries({
+          queryKey: ["view-result", section.namespace, section.name]
+        }),
+        queryClient.invalidateQueries({
+          queryKey: ["view-table", section.namespace, section.name]
+        }),
+        queryClient.invalidateQueries({
+          queryKey: ["view-variables", section.namespace, section.name]
+        })
+      ])
+    );

171-179: Consider documenting the CSS issue.

The comment mentions "CSS issues that I couldn't solve" but doesn't explain what the issues are. This could make future maintenance harder. Consider either:

  1. Adding a brief description of the CSS issue
  2. Creating a follow-up issue to properly fix it
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a5663f and f0acbe5.

📒 Files selected for processing (10)
  • src/api/services/views.ts (1 hunks)
  • src/pages/audit-report/components/View/View.tsx (6 hunks)
  • src/pages/audit-report/types/index.ts (2 hunks)
  • src/pages/views/components/SingleView.tsx (4 hunks)
  • src/pages/views/components/ViewLayout.tsx (1 hunks)
  • src/pages/views/components/ViewSection.tsx (1 hunks)
  • src/pages/views/constants.ts (1 hunks)
  • src/pages/views/hooks/useAggregatedViewVariables.ts (1 hunks)
  • src/pages/views/utils/aggregateVariables.ts (1 hunks)
  • src/ui/MRTDataTable/MRTDataTable.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
src/api/services/views.ts (1)
src/pages/audit-report/types/index.ts (1)
  • ViewResult (379-394)
src/pages/views/utils/aggregateVariables.ts (1)
src/pages/audit-report/types/index.ts (1)
  • ViewVariable (351-358)
src/pages/views/hooks/useAggregatedViewVariables.ts (5)
src/pages/audit-report/types/index.ts (1)
  • ViewRef (368-371)
src/hooks/usePrefixedSearchParams.ts (1)
  • usePrefixedSearchParams (14-70)
src/pages/views/constants.ts (1)
  • VIEW_VAR_PREFIX (2-2)
src/api/services/views.ts (1)
  • getViewDataByNamespace (101-129)
src/pages/views/utils/aggregateVariables.ts (1)
  • aggregateVariables (7-33)
src/pages/audit-report/components/View/View.tsx (5)
src/pages/views/constants.ts (1)
  • VIEW_VAR_PREFIX (2-2)
src/pages/audit-report/components/View/GlobalFiltersForm.tsx (1)
  • GlobalFiltersForm (65-90)
src/pages/audit-report/components/View/ViewTableFilterForm.tsx (1)
  • ViewTableFilterForm (55-80)
src/pages/audit-report/components/ViewColumnDropdown.tsx (1)
  • ViewColumnDropdown (13-67)
src/pages/audit-report/components/View/panels/utils.ts (1)
  • formatDisplayLabel (127-132)
src/pages/views/components/ViewLayout.tsx (3)
src/ui/Head.tsx (1)
  • Head (8-18)
src/ui/Layout/SearchLayout.tsx (1)
  • SearchLayout (23-77)
src/ui/BreadcrumbNav/index.tsx (2)
  • BreadcrumbNav (10-64)
  • BreadcrumbRoot (70-90)
src/pages/views/components/SingleView.tsx (5)
src/api/services/views.ts (1)
  • getViewDataById (72-99)
src/pages/views/hooks/useAggregatedViewVariables.ts (1)
  • useAggregatedViewVariables (13-57)
src/pages/audit-report/components/View/GlobalFiltersForm.tsx (1)
  • GlobalFiltersForm (65-90)
src/pages/views/constants.ts (1)
  • VIEW_VAR_PREFIX (2-2)
src/pages/audit-report/types/index.ts (1)
  • ViewSection (373-377)
🔇 Additional comments (9)
src/ui/MRTDataTable/MRTDataTable.tsx (1)

123-135: Flex basis change to "1 1 auto" looks good

Switching the paper and table container flex from "1 1 0" to "1 1 auto" should make them size more naturally within flex layouts without introducing functional issues, assuming no callers relied on the old zero-basis behavior.

src/pages/views/constants.ts (1)

1-2: VIEW_VAR_PREFIX constant is clear and well-placed

Centralizing "viewvar" in VIEW_VAR_PREFIX is a good move for keeping view-variable URL handling consistent across hooks/components.

src/pages/views/components/SingleView.tsx (2)

1-11: LGTM!

The imports are well-organized, bringing in the new aggregated variable hook, section components, and the shared constant. The consolidation of VIEW_VAR_PREFIX into a constants file is a good practice.


212-231: LGTM!

The section rendering logic is well-structured. Proper keys are used to ensure React can efficiently reconcile the list, and hideVariables is correctly passed to prevent duplicate filter display since aggregated variables are rendered at the top level.

src/pages/audit-report/components/View/View.tsx (5)

25-42: LGTM!

The new hideVariables prop is properly typed as optional boolean, and the import of VIEW_VAR_PREFIX from the shared constants file ensures consistency across components.


161-167: Verify intended behavior for undefined/null titles.

The condition title !== "" will render the title block when title is undefined or null, showing undefined/null in the UI. If the intent is to only show the title when it's a non-empty string, consider:

-        {title !== "" && (
+        {title && (

If the empty string specifically means "hide title" while undefined means "show default", the current logic is correct but could benefit from a comment explaining this distinction.


197-248: LGTM!

The ViewTableFilterForm correctly wraps the filterable column dropdowns while the display mode toggle appropriately uses URL params for state management. The form structure is clean and the conditional rendering for hasCardMode is well-implemented.


271-280: LGTM!

The min-h-0 flex-1 wrapper is a proper CSS fix for allowing the data table to be scrollable within a flex container. The min-h-0 overrides the default min-height: auto that would prevent the flex item from shrinking.


183-195: LGTM!

The grid layout with auto-fit and minmax provides responsive panel sizing. The inline styles are acceptable here since the values are dynamic and specific to this component's needs.

Copy link

@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: 1

🧹 Nitpick comments (1)
src/api/services/views.ts (1)

91-96: Consider handling non-JSON error responses.

If the server returns a non-JSON error response (e.g., HTML error page from a proxy), response.json() will throw, masking the original HTTP error. Consider adding a fallback.

   if (!response.ok) {
-    const errorData = await response.json();
-    throw new Error(
-      errorData.error || `HTTP ${response.status}: ${response.statusText}`
-    );
+    let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
+    try {
+      const errorData = await response.json();
+      if (errorData.error) {
+        errorMessage = errorData.error;
+      }
+    } catch {
+      // Response wasn't JSON, use default HTTP error message
+    }
+    throw new Error(errorMessage);
   }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0acbe5 and d18a5ae.

📒 Files selected for processing (5)
  • src/api/services/views.ts (2 hunks)
  • src/pages/views/components/SingleView.tsx (4 hunks)
  • src/pages/views/components/ViewLayout.tsx (1 hunks)
  • src/pages/views/hooks/useAggregatedViewVariables.ts (1 hunks)
  • src/pages/views/utils/aggregateVariables.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/views/components/ViewLayout.tsx
  • src/pages/views/hooks/useAggregatedViewVariables.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/pages/views/utils/aggregateVariables.ts (1)
src/pages/audit-report/types/index.ts (1)
  • ViewVariable (351-358)
src/api/services/views.ts (1)
src/pages/audit-report/types/index.ts (1)
  • ViewResult (379-394)
🔇 Additional comments (7)
src/pages/views/utils/aggregateVariables.ts (1)

1-34: LGTM! Clean implementation for variable aggregation.

The deduplication logic using Map is appropriate, and merging options via Set union is correct. The first-definition-wins strategy for other fields (label, default) is well-documented in the comment.

src/api/services/views.ts (1)

101-124: Good refactoring with proper path encoding.

The extraction of fetchViewData eliminates duplication, and both public functions correctly encode their path segments to handle special characters in IDs, namespaces, and names.

src/pages/views/components/SingleView.tsx (5)

30-41: Good query configuration for metadata-only fetch.

Passing undefined for variables and using keepPreviousData: true is appropriate for this orchestrating component where per-section queries handle their own data fetching.


43-63: Proper hook placement and memoization.

Calling hooks before early returns satisfies React's rules, and the useMemo dependencies correctly capture all values that affect the computed allSectionRefs.


79-104: Query invalidation now properly includes the main view.

The previous concern about query key mismatch has been addressed. Line 90 now invalidates ["view-result", id] for the main metadata query, and the subsequent invalidations handle all section-specific queries.


212-223: Clean section rendering with proper key strategy.

Each section has a unique key based on its namespace and name, and hideVariables correctly prevents duplicate filter UI since aggregated variables are rendered once at the top.


189-202: Appropriate conditional rendering for aggregated variables.

The global filters are correctly rendered once at the top when variables exist, avoiding duplication across sections. The separator provides clear visual distinction.

Copy link

@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: 0

♻️ Duplicate comments (1)
src/pages/views/components/SingleView.tsx (1)

163-171: Avoid passing an empty‑string namespace into ViewSection

Using namespace: namespace || "" still constructs a ViewRef with an invalid namespace when viewResult.namespace is missing, and ViewSection will then operate on that bogus value (likely resulting in failed namespace‑based fetches). It would be safer to guard and only build/render the primary section when both namespace and name are present:

-  const primaryViewSection = {
-    title: "",
-    viewRef: {
-      namespace: namespace || "",
-      name: name
-    }
-  };
+  const hasViewRef = !!namespace && !!name;
+  const primaryViewSection = hasViewRef
+    ? {
+        title: "",
+        viewRef: {
+          namespace,
+          name
+        }
+      }
+    : null;

and below:

-        <div>
-          <ViewSection
-            key={`${namespace || "default"}:${name}`}
-            section={primaryViewSection}
-            hideVariables
-          />
-        </div>
+        {primaryViewSection && (
+          <div>
+            <ViewSection
+              key={`${namespace}:${name}`}
+              section={primaryViewSection}
+              hideVariables
+            />
+          </div>
+        )}

This aligns with the earlier review concern about not passing an unsafe namespace through to ViewSection.

🧹 Nitpick comments (2)
src/pages/views/components/SingleView.tsx (2)

43-63: Section ref collection and variable aggregation look correct (small optional tidy‑up)

The allSectionRefs memo plus useAggregatedViewVariables(allSectionRefs) wiring is sound and ensures the main view and all sections contribute to the aggregated variable set. If you want to tighten it up a bit, you could build refs in a more declarative way:

-  const allSectionRefs = useMemo<ViewRef[]>(() => {
-    if (!viewResult?.namespace || !viewResult?.name) {
-      return [];
-    }
-    const refs = [{ namespace: viewResult.namespace, name: viewResult.name }];
-    if (viewResult?.sections) {
-      viewResult.sections.forEach((section) => {
-        refs.push({
-          namespace: section.viewRef.namespace,
-          name: section.viewRef.name
-        });
-      });
-    }
-    return refs;
-  }, [viewResult?.namespace, viewResult?.name, viewResult?.sections]);
+  const allSectionRefs = useMemo<ViewRef[]>(() => {
+    if (!viewResult?.namespace || !viewResult?.name) {
+      return [];
+    }
+    const sectionRefs =
+      viewResult.sections?.map((section) => section.viewRef) ?? [];
+    return [{ namespace: viewResult.namespace, name: viewResult.name }, ...sectionRefs];
+  }, [viewResult?.namespace, viewResult?.name, viewResult?.sections]);

65-104: Force refresh may use stale section refs and likely double‑fetches metadata

Two things to consider here:

  1. sectionsToRefresh prefers allSectionRefs, which is the snapshot from the render when the button was clicked; after await refetch() you already have fresh result.data, so you might want to derive sections from that first and only fall back to allSectionRefs if result.data is missing, to better reflect any changes in sections:
-    const sectionsToRefresh =
-      allSectionRefs.length > 0 &&
-      allSectionRefs[0].namespace &&
-      allSectionRefs[0].name
-        ? allSectionRefs
-        : result.data?.namespace && result.data.name
-          ? [{ namespace: result.data.namespace, name: result.data.name }]
-          : [];
+    const sectionsToRefresh =
+      result.data?.namespace && result.data.name
+        ? [
+            { namespace: result.data.namespace, name: result.data.name },
+            ...(result.data.sections?.map((s) => s.viewRef) ?? [])
+          ]
+        : allSectionRefs;
  1. Calling await refetch() and then invalidateQueries({ queryKey: ["view-result", id] }) means the main metadata query will typically be fetched twice per refresh. You could rely solely on invalidateQueries (with forceRefreshRef set during that call) or drop the extra invalidation for ["view-result", id] to avoid the duplicate network hit.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d18a5ae and a261b3e.

📒 Files selected for processing (4)
  • src/api/services/views.ts (2 hunks)
  • src/pages/views/components/SingleView.tsx (4 hunks)
  • src/pages/views/hooks/useAggregatedViewVariables.ts (1 hunks)
  • src/pages/views/utils/aggregateVariables.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/views/hooks/useAggregatedViewVariables.ts
  • src/api/services/views.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/pages/views/utils/aggregateVariables.ts (1)
src/pages/audit-report/types/index.ts (1)
  • ViewVariable (351-358)
src/pages/views/components/SingleView.tsx (5)
src/api/services/views.ts (1)
  • getViewDataById (101-111)
src/pages/audit-report/types/index.ts (2)
  • ViewRef (368-371)
  • ViewSection (373-377)
src/pages/views/hooks/useAggregatedViewVariables.ts (1)
  • useAggregatedViewVariables (9-53)
src/pages/audit-report/components/View/GlobalFiltersForm.tsx (1)
  • GlobalFiltersForm (65-90)
src/pages/views/constants.ts (1)
  • VIEW_VAR_PREFIX (2-2)
🔇 Additional comments (1)
src/pages/views/utils/aggregateVariables.ts (1)

1-34: Aggregation helper correctly deduplicates and merges options

The aggregateVariables implementation cleanly dedupes by key, unions options, and avoids mutating inputs while preserving the first definition’s other fields; this matches the intended behavior for cross‑section aggregation.

@moshloop moshloop merged commit 1f1d7e0 into main Dec 2, 2025
14 of 16 checks passed
@moshloop moshloop deleted the feat/view-sections branch December 2, 2025 13:51
@netlify
Copy link

netlify bot commented Dec 4, 2025

Deploy Preview for clerk-saas-ui failed. Why did it fail? →

Name Link
🔨 Latest commit 3656139
🔍 Latest deploy log https://app.netlify.com/projects/clerk-saas-ui/deploys/692ee04410d7dd0008a40730

@netlify
Copy link

netlify bot commented Dec 4, 2025

Deploy Preview for flanksource-demo-stable failed. Why did it fail? →

Name Link
🔨 Latest commit 3656139
🔍 Latest deploy log https://app.netlify.com/projects/flanksource-demo-stable/deploys/692ee0442af65900089e71e8

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.

View sections

3 participants