Skip to content

Feat/acm 32322 fleet search subscription#6444

Open
zlayne wants to merge 14 commits into
stolostron:mainfrom
zlayne:feat/ACM-32322-fleet-search-subscription
Open

Feat/acm 32322 fleet search subscription#6444
zlayne wants to merge 14 commits into
stolostron:mainfrom
zlayne:feat/ACM-32322-fleet-search-subscription

Conversation

@zlayne

@zlayne zlayne commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Ticket Summary (Title):

Co-Authored with Cursor (Sonnet 5)

Ticket Link:
https://issues.redhat.com/browse/ACM-32322

Type of Change:

  • 🐞 Bug Fix
  • ✨ Feature
  • 🔧 Refactor
  • 💸 Tech Debt
  • 🧪 Test-related
  • 📄 Docs

✅ Checklist

General

  • PR title follows the convention (e.g. ACM-12340 Fix bug with...)
  • Code builds and runs locally without errors
  • No console logs, commented-out code, or unnecessary files
  • All commits are meaningful and well-labeled
  • All new display strings are externalized for localization (English only)
  • (Nice to have) JSDoc comments added for new functions and interfaces

If Feature

  • UI/UX reviewed (if applicable)
  • All acceptance criteria met
  • Unit test coverage added or updated
  • Relevant documentation or comments included

If Bugfix

  • Root cause and fix summary are documented in the ticket (for future reference / errata)
  • Fix tested thoroughly and resolves the issue
  • Test(s) added to prevent regression

🗒️ Notes for Reviewers

Summary by CodeRabbit

  • New Features
    • Added useFleetSearch for fleet-wide search with pagination and a refetch action.
    • Added useFleetSearchSubscription for live INSERT/UPDATE/DELETE result patching via WebSocket.
    • Extended search input support (e.g., SearchInput now includes offset and orderBy).
  • Bug Fixes
    • Improved search item parsing to accept pre-built key/value objects.
  • Documentation
    • Updated the multicluster SDK README with the new hook and expanded search types.
  • Tests
    • Added Jest coverage for useFleetSearch and useFleetSearchSubscription, including export verification.

zlayne added 6 commits July 7, 2026 09:53
… to multicluster-sdk

ACM-32322 — Add GraphQL subscription support to the multicluster-sdk.

- useFleetSearchSubscription: wraps the generated useSearchSubscription
  Apollo hook; returns [latestEvent, loading, error]; skips the WebSocket
  connection when input is undefined.
- useFleetSearch: one-shot query hook with optional real-time patching via
  useFleetSearchSubscription; handles INSERT/UPDATE/DELETE events; supports
  pagination through SearchInput.limit and SearchInput.offset.
- Re-export SearchInput from src/types/search.ts so callers can type their
  input without reaching into internal packages.
- Update src/api/index.ts and src/index.test.ts public-API guard.
- Regenerate README.md API docs.

Signed-off-by: zlayne <zlayne@redhat.com>
Verifies:
- Search page loads and returns results via Apollo HTTP link
- Search WebSocket proxy endpoint is reachable (WS transport for subscriptions)

Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>
@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zlayne

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

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 fleet-wide search hooks with optional GraphQL WebSocket updates. It extends search contracts and Apollo transport, applies subscription events to local query results, exposes new hooks and types, and updates tests and README documentation.

Changes

Fleet Search API

Layer / File(s) Summary
Search contracts and subscription transport
frontend/packages/multicluster-sdk/src/internal/search/*, frontend/packages/multicluster-sdk/src/types/search.ts
Adds search event and subscription types, pagination fields, GraphQL subscription definitions, WebSocket routing, and object-valued search-item parsing.
Fleet subscription hook
frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.ts, frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.test.ts
Adds conditional subscription setup and latest-event handling with loading, error, skip, event-type, and client-forwarding tests.
Fleet search query and event patching
frontend/packages/multicluster-sdk/src/api/useFleetSearch.ts, frontend/packages/multicluster-sdk/src/api/useFleetSearch.test.ts
Combines query results with optional INSERT, UPDATE, and DELETE patches, reset behavior, pagination, error precedence, and refetch handling.
Public exports and documentation
frontend/packages/multicluster-sdk/src/api/index.ts, frontend/packages/multicluster-sdk/src/index.test.ts, frontend/packages/multicluster-sdk/src/types/search.ts, frontend/packages/multicluster-sdk/README.md, frontend/packages/multicluster-sdk/generate-doc.mjs
Exports the new hook, updates export assertions and documentation generation, and documents fleet search behavior and input contracts.

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

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant useFleetSearch
  participant useSearchResultItemsQuery
  participant useFleetSearchSubscription
  Consumer->>useFleetSearch: provide SearchInput and subscriptionEnabled
  useFleetSearch->>useSearchResultItemsQuery: execute base query
  useSearchResultItemsQuery-->>useFleetSearch: return search items
  useFleetSearch->>useFleetSearchSubscription: provide input when enabled
  useFleetSearchSubscription-->>useFleetSearch: return FleetSearchEvent
  useFleetSearch->>useFleetSearch: patch localData by operation and UID
  useFleetSearch-->>Consumer: return data, loaded, error, refetch
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and clearly refers to the fleet search subscription feature added in this PR.
Description check ✅ Passed The template structure is present and most required fields are filled, though the Ticket Summary field is not actually summarized.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.test.ts (1)

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

Use import type for SearchInput.

SearchInput is used only as a type annotation (line 20).

🔧 Proposed fix
-import { SearchInput } from '../types/search'
+import type { SearchInput } from '../types/search'

As per coding guidelines, "Use import type for type-only imports to avoid generating runtime imports."

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

In
`@frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.test.ts`
at line 5, The import of SearchInput in useFleetSearchSubscription.test.ts is
type-only and should not generate a runtime dependency. Update the top-level
import in useFleetSearchSubscription.test.ts to use import type for SearchInput,
and keep the existing type annotation usage in the test unchanged.

Source: Coding guidelines

frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.ts (1)

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

Use import type for type-only imports.

FleetSearchEvent and SearchInput are used purely as types here.

🔧 Proposed fix
-import { FleetSearchEvent, SearchInput } from '../types/search'
+import type { FleetSearchEvent, SearchInput } from '../types/search'

As per coding guidelines, "Use import type for type-only imports to avoid generating runtime imports."

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

In `@frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.ts` at
line 5, The import in useFleetSearchSubscription is type-only, so update the
existing FleetSearchEvent and SearchInput import to use an import type form
instead of a runtime import. Keep the symbol names the same and ensure any
references in the hook remain type annotations only, so this module does not
generate unnecessary runtime imports.

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 `@frontend/packages/multicluster-sdk/src/api/useFleetSearch.test.ts`:
- Line 2: Update the test setup in useFleetSearch.test to stop importing
renderHook and act from the archived `@testing-library/react-hooks` package.
Replace that import with the equivalents from `@testing-library/react`, and ensure
the rest of the test continues to use renderHook and act through the new source
so the React 18-compatible API is used consistently.

In `@frontend/packages/multicluster-sdk/src/api/useFleetSearch.ts`:
- Around line 122-137: The INSERT and UPDATE branches in useFleetSearch are
mutating latestEvent.newData in place, which should be avoided for Apollo
subscription payloads. Update the logic to copy latestEvent.newData into a new
object before setting cluster and _uid, then pass that copied object into
convertSearchItemToResource<T> in both branches. Keep the duplicate-check
behavior unchanged and apply the same non-mutating pattern consistently in the
UPDATE case.

In `@frontend/packages/multicluster-sdk/src/internal/search/search-client.ts`:
- Around line 25-27: The SSR fallback in search-client’s URL builder is
hardcoded and drops the BACKEND_URL prefix, making it inconsistent with the
httpEndpoint/httpLink path. Update the window-undefined branch in
search-client’s endpoint construction to derive the websocket URL from the same
BACKEND_URL-based prefix used elsewhere, so the SSR fallback resolves to the
correct /proxy/search route instead of ws://localhost/proxy/search.

---

Nitpick comments:
In
`@frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.test.ts`:
- Line 5: The import of SearchInput in useFleetSearchSubscription.test.ts is
type-only and should not generate a runtime dependency. Update the top-level
import in useFleetSearchSubscription.test.ts to use import type for SearchInput,
and keep the existing type annotation usage in the test unchanged.

In `@frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.ts`:
- Line 5: The import in useFleetSearchSubscription is type-only, so update the
existing FleetSearchEvent and SearchInput import to use an import type form
instead of a runtime import. Keep the symbol names the same and ensure any
references in the hook remain type annotations only, so this module does not
generate unnecessary runtime imports.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3d6fff10-a4ca-4c9d-a783-76a9353a880f

📥 Commits

Reviewing files that changed from the base of the PR and between c6c98b0 and 56d078c.

📒 Files selected for processing (12)
  • frontend/packages/multicluster-sdk/README.md
  • frontend/packages/multicluster-sdk/src/api/index.ts
  • frontend/packages/multicluster-sdk/src/api/useFleetSearch.test.ts
  • frontend/packages/multicluster-sdk/src/api/useFleetSearch.ts
  • frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.test.ts
  • frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.ts
  • frontend/packages/multicluster-sdk/src/index.test.ts
  • frontend/packages/multicluster-sdk/src/internal/search/convertSearchItemToResource.ts
  • frontend/packages/multicluster-sdk/src/internal/search/search-client.ts
  • frontend/packages/multicluster-sdk/src/internal/search/search-sdk.ts
  • frontend/packages/multicluster-sdk/src/internal/search/subscription.graphql
  • frontend/packages/multicluster-sdk/src/types/search.ts

Comment thread frontend/packages/multicluster-sdk/src/api/useFleetSearch.test.ts Outdated
Comment thread frontend/packages/multicluster-sdk/src/api/useFleetSearch.ts Outdated
Comment on lines +25 to +27
if (typeof window === 'undefined') {
return 'ws://localhost/proxy/search'
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

SSR fallback URL drops the BACKEND_URL prefix.

httpEndpoint is ${BACKEND_URL}/proxy/search (e.g. /api/proxy/plugin/mce/console/multicloud/proxy/search), but the window === undefined fallback hardcodes 'ws://localhost/proxy/search', silently dropping the BACKEND_URL prefix. This makes the WS URL inconsistent with httpLink's URI whenever this branch is hit (e.g. non-jsdom test runs).

🔧 Proposed fix
   if (typeof window === 'undefined') {
-    return 'ws://localhost/proxy/search'
+    return `ws://localhost${httpEndpoint}`
   }
📝 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
if (typeof window === 'undefined') {
return 'ws://localhost/proxy/search'
}
if (typeof window === 'undefined') {
return `ws://localhost${httpEndpoint}`
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/packages/multicluster-sdk/src/internal/search/search-client.ts`
around lines 25 - 27, The SSR fallback in search-client’s URL builder is
hardcoded and drops the BACKEND_URL prefix, making it inconsistent with the
httpEndpoint/httpLink path. Update the window-undefined branch in
search-client’s endpoint construction to derive the websocket URL from the same
BACKEND_URL-based prefix used elsewhere, so the SSR fallback resolves to the
correct /proxy/search route instead of ws://localhost/proxy/search.

zlayne added 2 commits July 9, 2026 18:39
Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

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

Inline comments:
In `@frontend/packages/multicluster-sdk/generate-doc.mjs`:
- Line 113: Replace the substring check in the documentation export filtering
condition with a path-boundary-aware comparison: exclude only when resolvedPath
equals the resolved search directory or starts with that directory followed by
the platform separator. Update the condition around resolvedPath and the
src/internal/search path to avoid filtering sibling directories such as
searching.

In `@frontend/packages/multicluster-sdk/README.md`:
- Around line 896-898: Replace the raw TSDoc {`@link` convertSearchItemToResource}
markup in the README descriptions, including the corresponding occurrence near
the later referenced section, with valid Markdown link syntax or an inline
code-formatted identifier; ensure no {`@link` ...} markup remains visible in the
generated documentation.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 96783233-3ddd-434a-af2a-7b49aacbbfec

📥 Commits

Reviewing files that changed from the base of the PR and between a416dc8 and 0494beb.

📒 Files selected for processing (2)
  • frontend/packages/multicluster-sdk/README.md
  • frontend/packages/multicluster-sdk/generate-doc.mjs

const modulePath = node.moduleSpecifier.text
const resolvedPath = resolveModulePath(modulePath, absolutePath)
if (resolvedPath) {
if (resolvedPath && !resolvedPath.includes(`${resolve(baseDir, 'src/internal/search')}`)) { // avoid adding search-sdk exports into readme - not all functions are used.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use a path-boundary check instead of includes.

resolvedPath.includes(...) also matches sibling paths such as src/internal/searching, causing unrelated modules to be omitted from generated documentation. Compare against the directory itself or a separator-delimited descendant path.

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

In `@frontend/packages/multicluster-sdk/generate-doc.mjs` at line 113, Replace the
substring check in the documentation export filtering condition with a
path-boundary-aware comparison: exclude only when resolvedPath equals the
resolved search directory or starts with that directory followed by the platform
separator. Update the condition around resolvedPath and the src/internal/search
path to avoid filtering sibling directories such as searching.

Comment thread frontend/packages/multicluster-sdk/README.md
@zlayne
zlayne requested a review from KevinFCormier July 10, 2026 13:16

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

@zlayne still looking over this... but I left a couple preliminary questions/comments.

* const [latestEvent, loading, error] = useFleetSearchSubscription(undefined)
* ```
*/
export function useFleetSearchSubscription(

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.

Is it useful for us to provide this hook as a public API?

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.

Likely users will opt to use the useFleetSearch hook instead of this hook, as this one only returns the change events.
I was exporting it because I am not sure what contexts users may want to utilize it. Maybe they want to understand when search results become stale, for instance, but don't necessarily need the updated result set?
We can make it private initially and open it if the need arises?

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.

Yeah, let's keep it private for now.

const modulePath = node.moduleSpecifier.text
const resolvedPath = resolveModulePath(modulePath, absolutePath)
if (resolvedPath) {
if (resolvedPath && !resolvedPath.includes(`${resolve(baseDir, 'src/internal/search')}`)) { // avoid adding search-sdk exports into readme - not all functions are used.

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.

This should not be needed. The SearchInput type needs to be moved to types/search.ts so that it becomes part of the API without pulling in everything else from search-sdk.ts. (Same for Event if we need to keep useFleetSearchSubscription as a public API.)

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.

Makes sense. I will get this updated.

Signed-off-by: zlayne <zlayne@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
frontend/packages/multicluster-sdk/src/types/search.ts (3)

14-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

any used for Date/Map scalar mappings.

Per coding guidelines, "Avoid any; use unknown when the type is truly unknown." These scalar values aren't codegen output (this file is hand-copied per the comment on line 22/43), so unknown should be preferable here to avoid silently widening types downstream.

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

In `@frontend/packages/multicluster-sdk/src/types/search.ts` around lines 14 - 15,
Replace the any types in the Date and Map scalar mappings with unknown in the
corresponding type definitions. Keep both input and output fields aligned and
leave the remaining scalar mappings unchanged.

Source: Coding guidelines


5-6: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Missing TSDoc on public exports Maybe/InputMaybe.

SearchFilter and SearchInput have doc comments but Maybe/InputMaybe don't. As per path instructions, "Use TSDoc comments on all public exports, since the README API section is generated from them," which applies to files under types/**/*.ts in this package.

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

In `@frontend/packages/multicluster-sdk/src/types/search.ts` around lines 5 - 6,
Add TSDoc comments to the public type aliases Maybe and InputMaybe in the search
types module, documenting each alias and its nullability/relationship. Keep
their existing type definitions and behavior unchanged.

Source: Path instructions


22-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Hand-duplicated types risk drifting from the internal SDK contract.

SearchFilter/SearchInput are copy-pasted from internal/search/search-sdk.ts rather than derived from it. Any future field change to the internal generated types (e.g. new filter fields) won't be reflected here automatically, silently breaking the public API contract.

Also applies to: 42-44

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

In `@frontend/packages/multicluster-sdk/src/types/search.ts` around lines 22 - 23,
Replace the hand-duplicated SearchFilter and SearchInput definitions in the
types module with types derived from the internal search SDK exports, reusing
the existing SearchFilter/SearchInput symbols or their property types as
appropriate. Remove the copied field declarations and preserve the public API
names while ensuring future internal contract changes propagate automatically.
🤖 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 `@frontend/packages/multicluster-sdk/src/types/search.ts`:
- Around line 14-15: Replace the any types in the Date and Map scalar mappings
with unknown in the corresponding type definitions. Keep both input and output
fields aligned and leave the remaining scalar mappings unchanged.
- Around line 5-6: Add TSDoc comments to the public type aliases Maybe and
InputMaybe in the search types module, documenting each alias and its
nullability/relationship. Keep their existing type definitions and behavior
unchanged.
- Around line 22-23: Replace the hand-duplicated SearchFilter and SearchInput
definitions in the types module with types derived from the internal search SDK
exports, reusing the existing SearchFilter/SearchInput symbols or their property
types as appropriate. Remove the copied field declarations and preserve the
public API names while ensuring future internal contract changes propagate
automatically.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a393de1f-6b8b-445d-a8ee-00fa5a491a3b

📥 Commits

Reviewing files that changed from the base of the PR and between 0494beb and ca1887c.

📒 Files selected for processing (7)
  • frontend/packages/multicluster-sdk/README.md
  • frontend/packages/multicluster-sdk/generate-doc.mjs
  • frontend/packages/multicluster-sdk/src/api/index.ts
  • frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.ts
  • frontend/packages/multicluster-sdk/src/index.test.ts
  • frontend/packages/multicluster-sdk/src/internal/search/search-sdk.ts
  • frontend/packages/multicluster-sdk/src/types/search.ts
💤 Files with no reviewable changes (1)
  • frontend/packages/multicluster-sdk/src/index.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/packages/multicluster-sdk/src/api/useFleetSearchSubscription.ts
  • frontend/packages/multicluster-sdk/generate-doc.mjs
  • frontend/packages/multicluster-sdk/src/internal/search/search-sdk.ts

Signed-off-by: zlayne <zlayne@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/packages/multicluster-sdk/generate-doc.mjs (1)

149-150: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Expand abbreviated parser names.

Rename typeStr, propDef, and colonIdx to typeString, propertyDefinition, and colonIndex, including callback parameters.

As per coding guidelines, functions and variables “must use descriptive camelCase names and avoid abbreviations.”

Also applies to: 169-175, 186-208, 247-249

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

In `@frontend/packages/multicluster-sdk/generate-doc.mjs` around lines 149 - 150,
Rename abbreviated identifiers throughout generate-doc.mjs to descriptive
camelCase names: update typeStr to typeString, propDef to propertyDefinition,
and colonIdx to colonIndex in simplifyType and all affected code paths,
including callback parameters, while preserving existing behavior.

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 `@frontend/packages/multicluster-sdk/generate-doc.mjs`:
- Around line 156-161: Update the replacement chain in the documentation
generation logic to preserve InputMaybe wrappers and nested generic boundaries
instead of stripping nullability or flattening nested types. Remove or revise
the InputMaybe/Array regex replacements so expressions such as
InputMaybe<Array<InputMaybe<Record<string, unknown>>>> retain their nullable
array-of-record structure; use balanced parsing only if needed to produce
correct | null unions.

---

Nitpick comments:
In `@frontend/packages/multicluster-sdk/generate-doc.mjs`:
- Around line 149-150: Rename abbreviated identifiers throughout
generate-doc.mjs to descriptive camelCase names: update typeStr to typeString,
propDef to propertyDefinition, and colonIdx to colonIndex in simplifyType and
all affected code paths, including callback parameters, while preserving
existing behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 00a160a0-1ab1-4af1-a310-4a9f9befd32d

📥 Commits

Reviewing files that changed from the base of the PR and between ca1887c and 892af14.

📒 Files selected for processing (3)
  • frontend/packages/multicluster-sdk/README.md
  • frontend/packages/multicluster-sdk/generate-doc.mjs
  • frontend/packages/multicluster-sdk/src/api/useFleetSearch.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/packages/multicluster-sdk/src/api/useFleetSearch.ts
  • frontend/packages/multicluster-sdk/README.md

Comment on lines +156 to +161
.replace(/Scalars\['Date'\]\['(?:input|output)'\]/g, 'Date')
.replace(/Scalars\['Map'\]\['(?:input|output)'\]/g, 'Record<string, unknown>')
.replace(/InputMaybe<Array<InputMaybe<([^>]+)>>>/g, '$1[]')
.replace(/Array<InputMaybe<([^>]+)>>/g, '$1[]')
.replace(/InputMaybe<Array<([^>]+)>>/g, '$1[]')
.replace(/InputMaybe<([^>]+)>/g, '$1')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve nullable wrappers and nested generic boundaries.

These regexes erase InputMaybe<T> nullability. They also misparse nested generics: after the Map replacement, InputMaybe<Array<InputMaybe<Record<string, unknown>>>> becomes Record<string, unknown[]>, changing an array of records into a record of arrays.

Keep wrappers unchanged as a minimal safe fix, or replace this with balanced parsing that emits the correct | null unions.

Minimal safe fix
     .replace(/Scalars\['Date'\]\['(?:input|output)'\]/g, 'Date')
     .replace(/Scalars\['Map'\]\['(?:input|output)'\]/g, 'Record<string, unknown>')
-    .replace(/InputMaybe<Array<InputMaybe<([^>]+)>>>/g, '$1[]')
-    .replace(/Array<InputMaybe<([^>]+)>>/g, '$1[]')
-    .replace(/InputMaybe<Array<([^>]+)>>/g, '$1[]')
-    .replace(/InputMaybe<([^>]+)>/g, '$1')
📝 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
.replace(/Scalars\['Date'\]\['(?:input|output)'\]/g, 'Date')
.replace(/Scalars\['Map'\]\['(?:input|output)'\]/g, 'Record<string, unknown>')
.replace(/InputMaybe<Array<InputMaybe<([^>]+)>>>/g, '$1[]')
.replace(/Array<InputMaybe<([^>]+)>>/g, '$1[]')
.replace(/InputMaybe<Array<([^>]+)>>/g, '$1[]')
.replace(/InputMaybe<([^>]+)>/g, '$1')
.replace(/Scalars\['Date'\]\['(?:input|output)'\]/g, 'Date')
.replace(/Scalars\['Map'\]\['(?:input|output)'\]/g, 'Record<string, unknown>')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/packages/multicluster-sdk/generate-doc.mjs` around lines 156 - 161,
Update the replacement chain in the documentation generation logic to preserve
InputMaybe wrappers and nested generic boundaries instead of stripping
nullability or flattening nested types. Remove or revise the InputMaybe/Array
regex replacements so expressions such as
InputMaybe<Array<InputMaybe<Record<string, unknown>>>> retain their nullable
array-of-record structure; use balanced parsing only if needed to produce
correct | null unions.

zlayne added 4 commits July 16, 2026 11:05
Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>
Signed-off-by: zlayne <zlayne@redhat.com>
@sonarqubecloud

Copy link
Copy Markdown

@KevinFCormier
KevinFCormier self-requested a review July 21, 2026 13:01
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