Skip to content

Fix unable to open AI agent service when extra functions exist#2303

Draft
dan-niles wants to merge 1 commit into
wso2:release/ballerina-5.12.xfrom
dan-niles:fix-1525-open-ai-agent-service
Draft

Fix unable to open AI agent service when extra functions exist#2303
dan-niles wants to merge 1 commit into
wso2:release/ballerina-5.12.xfrom
dan-niles:fix-1525-open-ai-agent-service

Conversation

@dan-niles

@dan-niles dan-niles commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes wso2/product-integrator#1525

The AI Agent Service entry node in the component diagram picked the first function (remotes first, then resources). A stray remote function chat — e.g. one mistakenly generated by Copilot alongside the real resource function post chat — would be selected, sending navigation to a location no AI service artifact covers, so the editor failed to open.

Now the click target is found by an exact match on accessor === "post" && path === "chat", which is the only valid ai:Listener entry point.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected AI service widget functionality in component diagrams to accurately identify and select chat service entry points based on specific connection parameters. Previously, the system aggregated multiple function types and selected the first available option. Updated visual port connections to properly reflect the selected resource.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ca18b973-6043-4300-a40d-7c5ebecda5e4

📥 Commits

Reviewing files that changed from the base of the PR and between a395cbc and cd62e73.

📒 Files selected for processing (1)
  • workspaces/ballerina/component-diagram/src/components/nodes/EntryNode/components/AIServiceWidget.tsx

📝 Walkthrough

Walkthrough

This PR updates AIServiceWidget to handle AI service chat functions specifically by selecting the resource function with POST accessor and chat path on click and in port rendering, replacing generic first-function selection logic.

Changes

AI Service Chat Resource Widget

Layer / File(s) Summary
Chat Resource Function Selection and Port Wiring
workspaces/ballerina/component-diagram/src/components/nodes/EntryNode/components/AIServiceWidget.tsx
Click handler and port rendering updated to find and use the specific chat resource function (POST accessor, chat path) instead of generic first-function selection from an aggregated list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • hevayo
  • gigara

Poem

🐰 A widget refactored with surgical care,
No more first-function guessing in the air,
Chat posts now find their destined way,
AI services bloom in visual display! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Title check ✅ Passed Title accurately describes the main fix: preventing incorrect function selection when extra functions exist in AI agent services.
Description check ✅ Passed PR description clearly explains the problem, root cause, and solution with a reference to the linked issue.
Linked Issues check ✅ Passed Code changes directly address issue #1525 by implementing exact match logic for the valid AI service entry point.
Out of Scope Changes check ✅ Passed Changes are narrowly scoped to the AIServiceWidget component and directly address the specific issue without introducing unrelated modifications.

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

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@dan-niles dan-niles requested a review from Copilot May 28, 2026 13:35
@dan-niles

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI 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.

Pull request overview

Fixes navigation for AI Agent Service nodes in the component diagram by selecting the correct AI chat entry resource (resource function post chat) rather than defaulting to the first discovered function (which could be an unrelated remote function).

Changes:

  • Replace “first function wins” selection with an exact match on accessor === "post" && path === "chat".
  • Ensure the extra bottom port rendered for the AI service corresponds specifically to the post chat resource.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +108 to 116
// ai:Listener entry point is fixed to `post chat`.
const chatResource = (model.node as CDService).resourceFunctions?.find(
(r) => r.accessor === "post" && r.path === "chat"
);

const handleOnClick = () => {
if (serviceFunctions.length > 0) {
onFunctionSelect(serviceFunctions[0]);
if (chatResource) {
onFunctionSelect(chatResource);
}
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

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.

2 participants