Skip to content

OU-1409: feat: fetch lazily ai proposal for each row in the alert list#1014

Open
jgbernalp wants to merge 1 commit into
openshift:mainfrom
jgbernalp:add-ai-investigation-action-to-alerts
Open

OU-1409: feat: fetch lazily ai proposal for each row in the alert list#1014
jgbernalp wants to merge 1 commit into
openshift:mainfrom
jgbernalp:add-ai-investigation-action-to-alerts

Conversation

@jgbernalp

@jgbernalp jgbernalp commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-06-25.at.14.06.55.mov

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 25, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 25, 2026

Copy link
Copy Markdown

@jgbernalp: This pull request references OU-1409 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested review from PeterYurkovich and zhuje June 25, 2026 12:08
@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jgbernalp

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 Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jgbernalp, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 40 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 96300a7d-7d4b-41c6-a8ca-7150ffaca484

📥 Commits

Reviewing files that changed from the base of the PR and between de1f063 and 9a8903d.

📒 Files selected for processing (12)
  • web/locales/en/plugin__monitoring-plugin.json
  • web/src/components/CustomIcon.tsx
  • web/src/components/ai-proposals/alert-identifier.spec.ts
  • web/src/components/ai-proposals/alert-identifier.ts
  • web/src/components/ai-proposals/constants.ts
  • web/src/components/ai-proposals/useProposalCheck.ts
  • web/src/components/alerting/AlertList/AlertTableRow.tsx
  • web/src/components/alerting/AlertsPage.tsx
  • web/src/components/console/models/index.ts
  • web/src/components/data-test.ts
  • web/src/components/hooks/usePerspective.tsx
  • web/src/components/kebab-dropdown.tsx

Walkthrough

Adds alert fingerprinting helpers and tests, a proposal lookup hook, shared React Query provider wiring for alert pages, and alert-row dropdown actions for AI investigations.

Changes

AI investigation proposals

Layer / File(s) Summary
Fingerprint helpers and tests
web/src/components/ai-proposals/constants.ts, web/src/components/ai-proposals/alert-identifier.ts, web/src/components/ai-proposals/alert-identifier.spec.ts
Defines fingerprint constants, computes and compares alert and proposal fingerprints, and adds tests for fingerprint formatting, prefixing, and matching.
Proposal lookup hook
web/src/components/console/models/index.ts, web/src/components/ai-proposals/useProposalCheck.ts
Adds ProposalModel and a useProposalCheck hook that lists proposals by fingerprint label and filters the results against the alert.
Alert page query provider
web/src/components/alerting/AlertsPage.tsx
Creates a shared QueryClient and wraps both alert page entrypoints in QueryClientProvider with the new default query options.
Alert row dropdown actions
web/src/components/hooks/usePerspective.tsx, web/src/components/CustomIcon.tsx, web/src/components/kebab-dropdown.tsx, web/src/components/data-test.ts, web/src/components/alerting/AlertList/AlertTableRow.tsx
Adds the proposals URL helper, dropdown prop changes, the AI investigation icon and test id, and alert-row menu items for viewing or loading proposal results.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant KebabDropdown
  participant AlertTableRow
  participant useProposalCheck
  participant buildQueryFn
  participant ProposalModel
  participant getProposalsUrl

  User->>KebabDropdown: hover menu toggle
  KebabDropdown->>AlertTableRow: invoke onMouseEnter
  AlertTableRow->>useProposalCheck: prefetch()
  useProposalCheck->>buildQueryFn: list ProposalModel items
  buildQueryFn->>ProposalModel: fetch by namespace and labels
  ProposalModel-->>buildQueryFn: items
  buildQueryFn-->>useProposalCheck: query result
  useProposalCheck-->>AlertTableRow: proposals, hasProposal, alertFingerprint
  AlertTableRow->>getProposalsUrl: build proposals URL
  AlertTableRow->>KebabDropdown: render "View AI Investigation"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: lazily fetching AI proposal data for alert list rows.
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.
Stable And Deterministic Test Names ✅ Passed The new spec uses only static, descriptive titles; no dates, IDs, names, or other run-to-run dynamic values appear.
Test Structure And Quality ✅ Passed Not applicable: the PR adds a Jest spec, and no Ginkgo/Gomega tests or cluster-wait patterns appear in the changed files.
Microshift Test Compatibility ✅ Passed The PR adds only TS/TSX code and Jest-style spec files; no new Ginkgo e2e tests or MicroShift-unsupported OpenShift APIs were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only new test is a Jest unit spec (alert-identifier.spec.ts); repo scan found no new Ginkgo/e2e tests or SNO-sensitive assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only frontend/web components changed; no manifests, controllers, replicas, affinity, node selectors, or topology-aware scheduling code were introduced.
Ote Binary Stdout Contract ✅ Passed The PR only changes web UI modules; none are process-level entrypoints or emit stdout, so the OTE stdout contract isn’t affected.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests or Go e2e files were added; the only new test is a Jest spec in web/src, so this check is not applicable.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB or secret/token comparisons found; the new FNV-1a fingerprint is a non-cryptographic identifier.
Container-Privileges ✅ Passed PR changes are frontend TS/TSX only; no container/K8s manifests changed and repo scans found no privileged flags, hostPID/hostNetwork/hostIPC, SYS_ADMIN, or allowPrivilegeEscalation.
No-Sensitive-Data-In-Logs ✅ Passed No console/logger calls or other logging APIs appear in the touched files; the new code only computes fingerprints and updates UI/navigation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
web/src/components/alerting/AlertsPage.tsx (1)

326-333: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Scope query defaults to proposal query instead of page-wide client defaults.

retry: false and refetchOnWindowFocus: false at client level apply to every query under Alerts; keeping these in the proposal hook avoids cross-feature coupling.

🤖 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 `@web/src/components/alerting/AlertsPage.tsx` around lines 326 - 333, The
QueryClient in AlertsPage is setting page-wide defaults that affect every query
under Alerts, but these settings should only apply to the proposal query. Remove
the query defaults from the QueryClient setup and move retry and
refetchOnWindowFocus into the specific proposal hook or query options used for
that fetch, so only that path is scoped; use the QueryClient and proposal query
hook in AlertsPage to locate the affected configuration.
web/src/components/CustomIcon.tsx (1)

18-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer a named export for the component.

The repo convention is named exports for React components (export const ErrorAlert: FC<...>). CustomIcon uses a default export, which AlertTableRow.tsx imports as import CustomIcon from '../../CustomIcon'. Consider switching both to a named export for consistency.

♻️ Proposed change
-const CustomIcon: FC<CustomIconProps> = ({ name, className }) => {
+export const CustomIcon: FC<CustomIconProps> = ({ name, className }) => {
   const icon = icons[name];
@@
 };
-
-export default CustomIcon;

Update the import in AlertTableRow.tsx:

-import CustomIcon from '../../CustomIcon';
+import { CustomIcon } from '../../CustomIcon';

As per coding guidelines: "Functional component with FC type and named export".

🤖 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 `@web/src/components/CustomIcon.tsx` around lines 18 - 34, CustomIcon is using
a default export, but the codebase convention is named exports for React FC
components. Update CustomIcon to use a named export (matching patterns like
ErrorAlert) and then change AlertTableRow to import the component by name
instead of default. Keep the component signature and behavior unchanged; only
adjust the export/import around CustomIcon.

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 `@web/src/components/alerting/AlertList/AlertTableRow.tsx`:
- Around line 75-85: The AlertTableRow dropdown is using translation calls for
AI Investigation labels that do not yet exist in the locale bundle. Add the
missing keys for “View AI Investigation” and “Loading investigations...” to the
monitoring plugin English locale so the t(...) lookups in AlertTableRow resolve
cleanly; use the existing translation structure in the locale JSON and then run
the translation test check to confirm the new keys are recognized.
- Around line 63-77: The AI Investigation dropdown link in AlertTableRow should
avoid building a query with an undefined proposal name. Update the proposalUrl
construction so the single-proposal path only uses the name when
proposals[0].metadata?.name is present, and otherwise falls back to the
fingerprint-based URL like the multi-proposal case. Keep the fix localized to
the hasProposal block and the getProposalsUrl / navigate flow.

In `@web/src/components/kebab-dropdown.tsx`:
- Around line 1-11: The KebabDropdown props currently reference the React
namespace for the dropdownItems type without importing it, which will trigger a
TypeScript error. Update the react import in KebabDropdown to bring in ReactNode
directly, and change the prop type to use that imported symbol instead of
React.ReactNode; follow the same import pattern used in TableToolbar to keep
type-only imports consistent.

---

Nitpick comments:
In `@web/src/components/alerting/AlertsPage.tsx`:
- Around line 326-333: The QueryClient in AlertsPage is setting page-wide
defaults that affect every query under Alerts, but these settings should only
apply to the proposal query. Remove the query defaults from the QueryClient
setup and move retry and refetchOnWindowFocus into the specific proposal hook or
query options used for that fetch, so only that path is scoped; use the
QueryClient and proposal query hook in AlertsPage to locate the affected
configuration.

In `@web/src/components/CustomIcon.tsx`:
- Around line 18-34: CustomIcon is using a default export, but the codebase
convention is named exports for React FC components. Update CustomIcon to use a
named export (matching patterns like ErrorAlert) and then change AlertTableRow
to import the component by name instead of default. Keep the component signature
and behavior unchanged; only adjust the export/import around CustomIcon.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: cca6579c-b991-4867-af50-a736e45a8006

📥 Commits

Reviewing files that changed from the base of the PR and between 4716e57 and de1f063.

📒 Files selected for processing (11)
  • web/src/components/CustomIcon.tsx
  • web/src/components/ai-proposals/alert-identifier.spec.ts
  • web/src/components/ai-proposals/alert-identifier.ts
  • web/src/components/ai-proposals/constants.ts
  • web/src/components/ai-proposals/useProposalCheck.ts
  • web/src/components/alerting/AlertList/AlertTableRow.tsx
  • web/src/components/alerting/AlertsPage.tsx
  • web/src/components/console/models/index.ts
  • web/src/components/data-test.ts
  • web/src/components/hooks/usePerspective.tsx
  • web/src/components/kebab-dropdown.tsx

Comment thread web/src/components/alerting/AlertList/AlertTableRow.tsx
Comment thread web/src/components/alerting/AlertList/AlertTableRow.tsx
Comment thread web/src/components/kebab-dropdown.tsx Outdated
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
@jgbernalp jgbernalp force-pushed the add-ai-investigation-action-to-alerts branch from de1f063 to 9a8903d Compare June 25, 2026 12:32
@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@jgbernalp: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn 9a8903d link true /test e2e-aws-ovn

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants