Skip to content

feat:add deployment status investigation support for portal assistant#638

Open
yashodgayashan wants to merge 1 commit into
openchoreo:mainfrom
yashodgayashan:portal-assistant
Open

feat:add deployment status investigation support for portal assistant#638
yashodgayashan wants to merge 1 commit into
openchoreo:mainfrom
yashodgayashan:portal-assistant

Conversation

@yashodgayashan

@yashodgayashan yashodgayashan commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Purpose

We have added investigation support for deployment status of OpenChoreo.

Goals

Add investigation button and provide the solution and the prompt whenever needed.

Screen.Recording.2026-06-17.at.10.57.17.mov

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • New Features

    • Added an “Investigate with AI” button to environment detail panels for pending and failed deployments.
    • Drawer prompts are now deployment-aware, including support for investigations blocked by pending outbound endpoint dependencies.
    • Exposed a typed render-slot so hosts can inject the investigate action into the Environments panel; assistant tools are warmed on hover/focus.
  • Tests

    • Expanded Jest coverage for conditional rendering, correct drawer payloads (case type/status/scope), and warmup error handling.

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

Changeset detected — the following file(s) will be released with this PR:

.changeset/lazy-olives-repeat.md

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 322237ec-c250-4e72-bd0d-2dca27be554b

📥 Commits

Reviewing files that changed from the base of the PR and between c25e9b5 and 7a7b9f7.

📒 Files selected for processing (11)
  • .changeset/lazy-olives-repeat.md
  • packages/app/src/components/catalog/EntityPage.tsx
  • plugins/openchoreo-portal-assistant/src/api/PerchAgentApi.ts
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.test.tsx
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.tsx
  • plugins/openchoreo-portal-assistant/src/index.ts
  • plugins/openchoreo/src/components/Environments/Environments.tsx
  • plugins/openchoreo/src/components/Environments/EnvironmentsContext.tsx
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.tsx
  • plugins/openchoreo/src/index.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/lazy-olives-repeat.md
🚧 Files skipped from review as they are similar to previous changes (10)
  • plugins/openchoreo-portal-assistant/src/index.ts
  • plugins/openchoreo/src/index.ts
  • plugins/openchoreo/src/components/Environments/Environments.tsx
  • plugins/openchoreo/src/components/Environments/EnvironmentsContext.tsx
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.tsx
  • plugins/openchoreo-portal-assistant/src/api/PerchAgentApi.ts
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.test.tsx
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.tsx
  • packages/app/src/components/catalog/EntityPage.tsx

📝 Walkthrough

Walkthrough

Establishes a render-prop contract for investigation actions in the Environments component, extends the assistant API with a dependency_pending case type, implements the InvestigateDependencyButton component with throttled warmup and suggestion/message logic, integrates it into EnvironmentDetailPanel for pending/failed deployments, and wires it through the host application's entity page.

Changes

InvestigateDependencyButton investigation feature

Layer / File(s) Summary
Investigation render-prop contract and exports
plugins/openchoreo/src/components/Environments/EnvironmentsContext.tsx, plugins/openchoreo/src/index.ts
Defines InvestigateScope interface (namespace, project, component, environment, caseType, status) and RenderInvestigateAction render-prop type. Extends EnvironmentsContextValue with optional renderInvestigateAction field. Both plugins re-export these types for host application use.
Render-prop threading through Environments
plugins/openchoreo/src/components/Environments/Environments.tsx
Adds EnvironmentsProps interface with optional renderInvestigateAction, updates component signature to accept and destructure the prop, forwards it into EnvironmentsProvider context value, and adds it to the useMemo dependency array.
ChatCaseType with dependency_pending
plugins/openchoreo-portal-assistant/src/api/PerchAgentApi.ts
Extends ChatCaseType union to include 'dependency_pending' with JSDoc describing deployment/K8s-artifacts investigation for components blocked by unresolved outbound endpoint dependencies.
InvestigateDependencyButton component
plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.tsx, plugins/openchoreo-portal-assistant/src/index.ts
Implements React component with MUI warning-palette styling, module-level documentation, setup reading assistant enabled state and registering a 30s-throttled warmup() trigger on hover/focus with error swallowing, click handler that defaults caseType to dependency_pending, builds scopeOverrides and conversationKey, and opens the assistant drawer with suggestion chips (when component + trimmed status present) or pre-drafted initialMessage (when status missing). Exports from plugin index.
InvestigateDependencyButton tests
plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.test.tsx
Full Jest/React Testing Library suite: mocks Backstage API, assistant enabled flag, and drawer; tests render gating, drawer opening with suggestion chips for dependency_pending/runtime_debug with status, default caseType, partial scopeOverrides, initialMessage fallback, warmup trigger on hover, and warmup rejection error handling.
EnvironmentDetailPanel integration
plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.tsx
Imports CHOREO_ANNOTATIONS, reads renderInvestigateAction from useEnvironmentsContext(), conditionally renders it in status row when status is pending/failed. Selects caseType from statusReason === 'ConnectionsPending' (→ dependency_pending) vs runtime_debug. Scope includes namespace/project from annotations, component from entity name, environment resource.
EnvironmentDetailPanel tests
plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx
Updates context mock to provide renderInvestigateAction probe. New test block verifies button presence/absence and correct data-casetype/data-status/data-component/data-environment for pending-connection and failed-deployment scenarios; hidden for healthy deployments.
Host application wiring
packages/app/src/components/catalog/EntityPage.tsx
Imports RenderInvestigateAction type and InvestigateDependencyButton component. Defines renderInvestigateDependencyAction render-prop function returning the button. Passes it into Environments component for service and generic component entity /environments routes.
Changeset version bump
.changeset/lazy-olives-repeat.md
Marks patch for @openchoreo/backstage-plugin-openchoreo-portal-assistant-backend and @openchoreo/backstage-plugin-openchoreo-portal-assistant with changelog entry for investigation support.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • sameerajayasoma
  • kaviththiranga
  • stefinie123
  • Mirage20

Poem

🐇 A button hops through the deploy pipeline bright,
"Investigate with AI!" shines a beacon of light.
When connections are pending or deployments turn red,
The rabbit warms caches while suggestions are spread.
Through render-prop slots, investigation flows free—
Dependency pending solved with bot expertise! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete. While it includes a valid Purpose and Goals section with a video demo, most required template sections (Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Related PRs, Migrations, Test environment, Learning) are left as unfilled template placeholders. Complete the missing sections of the PR description template, particularly Approach, Automation tests, Security checks, Documentation, and Test environment, to provide comprehensive context for reviewers.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding deployment status investigation support for the portal assistant, which aligns with the substantial changes to enable investigation capabilities across multiple components.
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.

✏️ 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 and usage tips.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@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)
plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx (1)

46-47: ⚡ Quick win

Add explicit assertions for the new investigate-button branch.

This mock update is necessary, but the suite still doesn’t validate the newly added pending/failed integration path (including caseType mapping). Adding a couple of focused assertions here would prevent silent regressions.

Suggested test direction
+jest.mock(
+  '`@openchoreo/backstage-plugin-openchoreo-portal-assistant`',
+  () => ({
+    InvestigateDependencyButton: (props: any) => (
+      <div data-testid="investigate-btn-props">{JSON.stringify(props)}</div>
+    ),
+  }),
+);
+
+it('passes dependency_pending when statusReason is ConnectionsPending', () => {
+  // render with deployment.status = 'Pending', statusReason = 'ConnectionsPending'
+  // assert rendered props.caseType === 'dependency_pending'
+});
+
+it('passes runtime_debug for failed non-ConnectionsPending status', () => {
+  // render with deployment.status = 'Failed', statusReason != 'ConnectionsPending'
+  // assert rendered props.caseType === 'runtime_debug'
+});
🤖 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
`@plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx`
around lines 46 - 47, Add explicit test assertions in the EnvironmentDetailPanel
test suite to validate the newly added pending/failed integration path for the
investigate-button branch. Specifically, create focused test cases that assert
the correct behavior when handling pending or failed states, including
validation of the caseType mapping and verification that the investigate button
renders appropriately in these scenarios. These assertions should directly test
the conditional logic that was introduced with the useAssistantEnabled mock
update to prevent silent regressions as the code evolves.
🤖 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
`@plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.tsx`:
- Around line 79-85: The warmup() call in the warmIfStale function is
fired-and-forgotten with the void operator, but any promise rejection from
assistantApi.warmup() can still propagate as an unhandled rejection. Add a
.catch() handler to the assistantApi.warmup() call chain to gracefully handle
any rejections and keep this best-effort warming path from causing unhandled
promise rejection errors. The catch handler should suppress the error without
throwing or logging, since warmup failures should not impact the user
experience.

---

Nitpick comments:
In
`@plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx`:
- Around line 46-47: Add explicit test assertions in the EnvironmentDetailPanel
test suite to validate the newly added pending/failed integration path for the
investigate-button branch. Specifically, create focused test cases that assert
the correct behavior when handling pending or failed states, including
validation of the caseType mapping and verification that the investigate button
renders appropriately in these scenarios. These assertions should directly test
the conditional logic that was introduced with the useAssistantEnabled mock
update to prevent silent regressions as the code evolves.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 02b7ed8f-5a75-4ee2-b63e-a8d0d944ffab

📥 Commits

Reviewing files that changed from the base of the PR and between 39d264c and 276ae96.

📒 Files selected for processing (6)
  • plugins/openchoreo-portal-assistant/src/api/PerchAgentApi.ts
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.test.tsx
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.tsx
  • plugins/openchoreo-portal-assistant/src/index.ts
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.tsx

@yashodgayashan yashodgayashan force-pushed the portal-assistant branch 3 times, most recently from 12eabd4 to 13d6214 Compare June 17, 2026 08:24
Comment thread .changeset/lazy-olives-repeat.md Outdated
@@ -0,0 +1,6 @@
---
'@openchoreo/backstage-plugin-openchoreo-portal-assistant-backend': major

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.

Any reason for bumping major? can't we consider minor?

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.

Updated to patch

@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 (1)
plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx (1)

683-734: ⚡ Quick win

Add coverage for pending-without-ConnectionsPending routing (Line 683).

The suite currently misses the pending + non-ConnectionsPending branch, which should map to runtime_debug. Adding that test will lock the branch behavior and prevent silent regressions.

Suggested test addition
 describe('Investigate with AI', () => {
+  it('uses runtime_debug for pending deployments without ConnectionsPending reason', () => {
+    renderPanel({
+      selection: {
+        kind: 'env',
+        environment: makeEnv({
+          name: 'staging',
+          deployment: {
+            status: 'NotReady',
+            statusReason: 'ImagePullBackOff',
+          },
+        }),
+      },
+    });
+    const btn = screen.getByTestId('investigate-dependency-button');
+    expect(btn).toHaveAttribute('data-casetype', 'runtime_debug');
+    expect(btn).toHaveAttribute('data-status', 'Pending');
+  });
🤖 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
`@plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx`
around lines 683 - 734, The test suite for 'Investigate with AI' is missing
coverage for the case where a deployment has a pending status but without the
ConnectionsPending reason, which should map to the runtime_debug case type. Add
a new test case within the describe block that creates an environment with a
pending status (NotReady) but a different statusReason than ConnectionsPending,
then verify that the investigate-dependency-button is displayed with
data-casetype set to runtime_debug. This test should follow the same pattern as
the existing test cases using renderPanel, makeEnv, screen.getByTestId, and
expect statements to assert the correct data attributes are present.
🤖 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
`@plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx`:
- Around line 683-734: The test suite for 'Investigate with AI' is missing
coverage for the case where a deployment has a pending status but without the
ConnectionsPending reason, which should map to the runtime_debug case type. Add
a new test case within the describe block that creates an environment with a
pending status (NotReady) but a different statusReason than ConnectionsPending,
then verify that the investigate-dependency-button is displayed with
data-casetype set to runtime_debug. This test should follow the same pattern as
the existing test cases using renderPanel, makeEnv, screen.getByTestId, and
expect statements to assert the correct data attributes are present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 831b5e8f-62c2-4ca5-98f2-c3986f45079e

📥 Commits

Reviewing files that changed from the base of the PR and between 276ae96 and c25e9b5.

📒 Files selected for processing (11)
  • .changeset/lazy-olives-repeat.md
  • packages/app/src/components/catalog/EntityPage.tsx
  • plugins/openchoreo-portal-assistant/src/api/PerchAgentApi.ts
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.test.tsx
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.tsx
  • plugins/openchoreo-portal-assistant/src/index.ts
  • plugins/openchoreo/src/components/Environments/Environments.tsx
  • plugins/openchoreo/src/components/Environments/EnvironmentsContext.tsx
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.test.tsx
  • plugins/openchoreo/src/components/Environments/components/EnvironmentDetailPanel.tsx
  • plugins/openchoreo/src/index.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/lazy-olives-repeat.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • plugins/openchoreo-portal-assistant/src/index.ts
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.test.tsx
  • plugins/openchoreo-portal-assistant/src/api/PerchAgentApi.ts
  • plugins/openchoreo-portal-assistant/src/components/InvestigateDependencyButton/InvestigateDependencyButton.tsx

Signed-off-by: yashodgayashan <yashodgayashan@gmail.com>
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.

Integrate Portal assistant to the Deploy Page

2 participants