Skip to content

Fix skill toggle and MCP tools config storage scopes#2380

Open
VellummyilumVinoth wants to merge 1 commit into
wso2:release/ballerina-5.12.xfrom
VellummyilumVinoth:restructure-config-storage
Open

Fix skill toggle and MCP tools config storage scopes#2380
VellummyilumVinoth wants to merge 1 commit into
wso2:release/ballerina-5.12.xfrom
VellummyilumVinoth:restructure-config-storage

Conversation

@VellummyilumVinoth

@VellummyilumVinoth VellummyilumVinoth commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description

Corrects which settings file each Copilot UI toggle writes to:

  • USER skills (custom skills created by the user) — always written to the global user settings.json. These are personal preferences and must not appear in .vscode/settings.json.
  • BUILTIN skills (built-in / slash-command skills) and PROJECT skills — written to .vscode/settings.json (workspace scope) when a project is open, falling back to global when no workspace is open.
  • MCP tools enable/disable — reverted to always write to global settings.json. Enabling MCP tools is a user-wide preference, not project-specific.

Also adds bidirectional stale-entry cleanup in setSkillEnabled: when a toggle writes to workspace scope it removes any prior entry for that skill from global settings, and vice versa. This prevents the same skill key from appearing in both files simultaneously, which caused confusing duplicates after the storage layer was migrated.

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

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.

UI Component Development

Specify the reason if following are not followed.

  • Added reusable UI components to the ui-toolkit. Follow the intructions when adding the componenent.
  • Use ui-toolkit components wherever possible. Run npm run storybook from the root directory to view current components.
  • Matches with the native VSCode look and feel.

Manage Icons

Specify the reason if following are not followed.

  • Added Icons to the font-wso2-vscode. Follow the instructions.

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 chat-based skill enablement and skill file parsing for the AI panel.
    • Introduced MCP tools configuration support, including enabling/disabling MCP tools and managing MCP server lists.
  • Chores

    • Migrated skill and MCP server enable/disable persistence to VS Code settings with proper user vs workspace scoping.
    • Renamed ballerina.ai.showContextUsage to ballerina.copilot.showContextUsage.
    • Updated checkpoint-related settings to use resource scope.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

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

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ 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 refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f7a11716-67c8-4210-9ce2-41381896fcd9

📥 Commits

Reviewing files that changed from the base of the PR and between 767c693 and b32fda1.

⛔ Files ignored due to path filters (1)
  • common/config/rush/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (23)
  • common/config/rush/pnpm-config.json
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/index.ts
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/interfaces.ts
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/rpc-type.ts
  • workspaces/ballerina/ballerina-core/src/state-machine-types.ts
  • workspaces/ballerina/ballerina-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/agent/AgentExecutor.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/agent/skills/context.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/skill-tool/skill-writer.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/data-mapper/orchestrator.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/documentation/index.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/executors/base/AICommandExecutor.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/openapi/index.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/service/prompt-enhancement/promptEnhancement.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/utils/ai-client.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/utils/ai-utils.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/utils/events.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-handler.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/ai-panel/rpc-client.ts
  • workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/CodeUtils.ts
  • workspaces/ballerina/ballerina-visualizer/src/views/AIPanel/components/AIChat/index.tsx
📝 Walkthrough

Walkthrough

The PR removes the getSkillsEnabled/setSkillsEnabled RPC methods and SetSkillsEnabledRequest type across the AI panel contract, handler, manager, and RPC client. Skill enable/disable state and MCP server override storage are migrated from filesystem JSON files and globalState to VS Code workspace/global configuration settings, with new package.json contribution points and scope-aware config updates throughout.

Changes

Skills and MCP Config Migration to VS Code Settings

Layer / File(s) Summary
RPC contract and interface changes
workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/interfaces.ts, workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/index.ts, workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/rpc-type.ts
SetSkillsEnabledRequest replaced with SetMcpToolsEnabledRequest; getSkillsEnabled/setSkillsEnabled removed from AIPanelAPI and RPC type exports; new enableSkillFromChat, cancelSkillEnable, parseSkillFile method signatures added to the API contract.
VS Code configuration schema additions
workspaces/ballerina/ballerina-extension/package.json
Adds ballerina.copilot.enableMcpTools, ballerina.copilot.skills, and ballerina.copilot.mcp settings with scope annotations; adds scope: "resource" to checkpoint settings; renames ballerina.ai.showContextUsage to ballerina.copilot.showContextUsage.
skill-writer: filesystem config replaced with VS Code settings
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/skill-tool/skill-writer.ts
getSkillsConfig reads from ballerina.copilot VS Code configuration instead of a JSON file; setSkillEnabled is rewritten as an async scope-aware VS Code config updater with cross-scope cleanup; GLOBAL_SKILLS_CONFIG_PATH constant removed.
MCP EnabledOverrideStore migrated to VS Code config
workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts
Adds vscode namespace import; removes MCP_ENABLED_OVERRIDE_KEY globalState constant; EnabledOverrideStore now reads/writes ballerina.copilot.mcp enabledServers/disabledServers with workspace-vs-global scope selection and opposite-scope clearing.
Skill context simplified via unified getSkillsConfig
workspaces/ballerina/ballerina-extension/src/features/ai/agent/skills/context.ts
buildAllDisabledSet calls getSkillsConfig(projectRootPath) once; buildProjectSkillsConfigPath helper and path/GLOBAL_SKILLS_CONFIG_PATH imports removed.
RpcManager: scope-driven skill persistence and config key migration
workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
Removes getSkillsEnabled/setSkillsEnabled methods; updates getShowContextUsage to read ballerina.copilot.showContextUsage; removes path-helper imports; updates getSkills, toggleSkill, and enableSkillFromChat to compute and pass scope to setSkillEnabled.
RPC handler and client: remove getSkillsEnabled/setSkillsEnabled wiring
workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-handler.ts, workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/ai-panel/rpc-client.ts
Removes handler registrations and client forwarding methods for getSkillsEnabled/setSkillsEnabled; updates the watched config key for showContextUsage in the handler from ballerina.ai to ballerina.copilot.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

  • wso2/vscode-extensions#2321: Adds enableSkillFromChat, cancelSkillEnable, and parseSkillFile to the AI Panel RPC contract—the same new method signatures this PR references in AIPanelAPI.
  • wso2/vscode-extensions#2352: Introduced getSkillsEnabled/setSkillsEnabled and SetSkillsEnabledRequest that this PR removes from the RPC surface.

Suggested labels

Extension/MI

Suggested reviewers

  • hevayo
  • gigara
  • xlight05

Poem

🐇 Hopping through config files, old JSON must go,
VS Code settings now hold what skills need to know.
No more .copilot paths polluting the tree,
Workspace and global scope set the skill free!
The RPC contract trimmed, the override store new—
This bunny approves every line that you drew! 🌿

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description provides a detailed explanation of the changes and their rationale, but most required template sections are not filled out (Goals, Approach, UI/Icons, User stories, Release notes, Documentation, etc.). Complete missing template sections including Goals, Approach, Release notes, Documentation, and other required sections, or clarify why they are not applicable.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main focus of the PR: correcting configuration storage scopes for skill toggles and MCP tools settings.
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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 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 `@workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts`:
- Around line 281-307: The `set` and `delete` methods currently clear the entire
global MCP configuration when performing workspace-scoped writes by setting
'mcp' to undefined in the Global scope. Instead of this wholesale clear, perform
per-key cleanup by retrieving the global MCP configuration, removing only the
specific scopedKey from both enabledServers and disabledServers arrays in the
global scope, and then updating only those arrays. Apply this per-key removal
logic to both the `set` and `delete` methods to prevent users from losing
unrelated global MCP preferences when toggling a single server in a workspace
scope.

In
`@workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/skill-tool/skill-writer.ts`:
- Around line 28-33: The wsSkills assignment on line 33 unconditionally reads
from di?.workspaceValue even when projectRootPath is null, which allows
workspace overrides to leak into the global-only fallback path. Gate the
workspace settings access on the projectRootPath variable by only reading
di?.workspaceFolderValue and di?.workspaceValue when projectRootPath is not
null, otherwise set wsSkills to null to ensure the global-only behavior is
preserved when no project context is available.

In
`@workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts`:
- Around line 1023-1027: The resolvedScope determination at line 1023 only
considers whether projectRootPath exists, but this can incorrectly scope user
skills to workspace settings instead of global settings. Before determining the
scope, classify whether the skill being enabled is a user skill or a builtin
skill. If the skill is a user skill, explicitly set resolvedScope to 'user' to
ensure it is saved to global settings. If the skill is a builtin skill, then
apply the existing projectRootPath logic to determine whether scope should be
'workspace' or 'user'. Update the conditional logic around the resolvedScope
assignment and the two setSkillEnabled calls to account for this skill type
classification.
🪄 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: Pro

Run ID: 05e2e8e4-1562-45ed-a9da-5d73fa0e3d8a

📥 Commits

Reviewing files that changed from the base of the PR and between 07300ab and 0ebd9d6.

📒 Files selected for processing (10)
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/index.ts
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/interfaces.ts
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/rpc-type.ts
  • workspaces/ballerina/ballerina-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/agent/skills/context.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/skill-tool/skill-writer.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-handler.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/ai-panel/rpc-client.ts
💤 Files with no reviewable changes (4)
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/interfaces.ts
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/rpc-type.ts
  • workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/ai-panel/rpc-client.ts
  • workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/index.ts

Comment thread workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts Outdated
@VellummyilumVinoth VellummyilumVinoth force-pushed the restructure-config-storage branch 2 times, most recently from 767c693 to 3cf6ba2 Compare June 24, 2026 04:01
@VellummyilumVinoth VellummyilumVinoth changed the base branch from release/ballerina-5.12.1 to release/ballerina-5.12.x June 24, 2026 04:08
@VellummyilumVinoth VellummyilumVinoth changed the base branch from release/ballerina-5.12.x to release/ballerina-5.12.1 June 24, 2026 04:09
@VellummyilumVinoth VellummyilumVinoth force-pushed the restructure-config-storage branch from 3cf6ba2 to b32fda1 Compare June 24, 2026 04:15
@VellummyilumVinoth VellummyilumVinoth changed the base branch from release/ballerina-5.12.1 to release/ballerina-5.12.x June 24, 2026 04:17
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.

1 participant