-
Notifications
You must be signed in to change notification settings - Fork 67
Add support for configuring default Devant chunker in vscode #902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request adds a new VS Code command to configure default Devant chunker settings in Config.toml. The implementation refactors the configuration system to support multiple AI provider types through a new enum, while adding command registration, constants, and RPC integration following existing patterns. Changes
Sequence DiagramsequenceDiagram
actor User
participant VSCode as VS Code
participant Activator as activator.ts
participant Utils as utils.ts
participant Config as Config.toml
User->>VSCode: Execute "Configure default Devant chunker"
VSCode->>Activator: Trigger command handler
Activator->>Activator: Call addConfigFile with<br/>AIProviderConfigType.DEVANT_CHUNKER
Activator->>Utils: addConfigFile(configPath, DEVANT_CHUNKER)
Utils->>Utils: getConfigDetails(DEVANT_CHUNKER)<br/>returns: configTable, serviceUrl, progressMessage
Utils->>Utils: Show progress bar
Utils->>Config: Update/Write [ballerina.ai.devant.chunkerConfig]<br/>serviceUrl = "..."<br/>accessToken = ""
alt Success
Utils-->>Activator: return true
Activator-->>User: Show "Default Devant chunker<br/>configuration added"
else Token Refresh Error
Utils-->>Activator: throw error (REFRESH_TOKEN_NOT_AVAILABLE)
Activator-->>User: Prompt "Sign in to BI Copilot"
User->>Activator: Click "Sign In"
Activator->>Activator: Trigger LOGIN state
else Other Error
Utils-->>Activator: throw error
Activator-->>User: Display error message
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Areas requiring attention:
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
ee9de65 to
9331173
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts (1)
89-133: Shared configPath handling can misbehave when no Ballerina project is openBoth configuration commands use:
const configPath = await getConfigFilePath(ballerinaExternalInstance, projectPath); if (configPath !== null) { // ... }However,
getConfigFilePathcan resolve toundefined(e.g., when there is no Ballerina project and only a warning is shown). In that case the!== nullcheck passes andaddConfigFileis called with a non-string path, which will end up throwing a low-level fs error and surfacing a confusing error message to the user.You’re reusing this pattern for the new Devant chunker command as well, so the edge case now affects both flows.
A more robust guard would be to bail out on any falsy/invalid value:
const configPath = await getConfigFilePath(ballerinaExternalInstance, projectPath); if (!configPath) { return; } const result = await addConfigFile(configPath, AIProviderConfigType.WSO2_MODEL_PROVIDER); // ...and similarly for the Devant chunker command.
🧹 Nitpick comments (2)
workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts (1)
25-31: Minor import path nit for auth utilities
'../..//utils/ai/auth'will resolve correctly, but the double slash is unnecessary and slightly inconsistent with other imports. Consider normalizing to'../../utils/ai/auth'for clarity.workspaces/ballerina/ballerina-extension/src/features/ai/utils.ts (1)
182-245: Config file mutation helper correctly handles both WSO2 and Devant chunker tables
addAIProviderConfig:
- Uses
CONFIG_FILE_NAMEwith a case-insensitive lookup, so it works withconfig.tomlvsConfig.toml.- Creates the target table if missing, and otherwise updates it in-place.
- Ensures
serviceUrlandaccessTokenlines are present and keepsaccessTokenimmediately afterserviceUrl, which keeps the table structure predictable.Combined with
addConfigFileand the shared token retrieval, this covers both WSO2 model provider and Devant chunker without duplicating file-IO logic.If you want to harden it further, an optional improvement would be to early-return
falsefromaddAIProviderConfigwhenprojectPathdoes not exist (instead of relying onfs.readdirSyncto throw), but that’s already mitigated in practice bygetConfigFilePath.Also applies to: 247-283
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
workspaces/ballerina/ballerina-extension/package.json(1 hunks)workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts(3 hunks)workspaces/ballerina/ballerina-extension/src/features/ai/constants.ts(2 hunks)workspaces/ballerina/ballerina-extension/src/features/ai/utils.ts(7 hunks)workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-agent/rpc-manager.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-10T15:05:11.309Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:224-242
Timestamp: 2025-11-10T15:05:11.309Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate VS Code extensions that are packaged and distributed independently, so they cannot share code via imports and must maintain their own implementations of common utilities.
Applied to files:
workspaces/ballerina/ballerina-extension/package.json
📚 Learning: 2025-11-10T15:04:50.474Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:153-169
Timestamp: 2025-11-10T15:04:50.474Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate, independently deployable VSCode extensions in the wso2/vscode-extensions repository. Code duplication between these extensions is acceptable and often necessary to maintain their independence, rather than creating cross-extension dependencies.
Applied to files:
workspaces/ballerina/ballerina-extension/package.json
🧬 Code graph analysis (3)
workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-agent/rpc-manager.ts (1)
workspaces/ballerina/ballerina-extension/src/features/ai/constants.ts (1)
CONFIGURE_DEFAULT_DEVANT_CHUNKER_COMMAND(21-21)
workspaces/ballerina/ballerina-extension/src/features/ai/utils.ts (2)
workspaces/ballerina/ballerina-extension/src/features/ai/constants.ts (7)
CONFIG_KEY_SERVICE_URL(38-38)CONFIG_KEY_ACCESS_TOKEN(39-39)WSO2_PROVIDER_CONFIG_TABLE(35-35)PROGRESS_BAR_MESSAGE_FROM_WSO2_DEFAULT_MODEL(25-25)DEVANT_CHUNKER_CONFIG_TABLE(36-36)DEVANT_CHUNKER_SERVICE_URL(37-37)PROGRESS_BAR_MESSAGE_FROM_DEFAULT_DEVANT_CHUNKER(26-26)workspaces/ballerina/ballerina-extension/src/features/natural-programming/utils.ts (1)
addConfigFile(703-725)
workspaces/ballerina/ballerina-extension/src/features/ai/activator.ts (3)
workspaces/ballerina/ballerina-extension/src/features/ai/utils.ts (2)
addConfigFile(247-283)getConfigFilePath(103-145)workspaces/ballerina/ballerina-extension/src/features/ai/constants.ts (4)
CONFIGURE_DEFAULT_DEVANT_CHUNKER_COMMAND(21-21)DEFAULT_DEVANT_CHUNKER_ADDED(32-32)LOGIN_REQUIRED_WARNING_FOR_DEFAULT_DEVANT_CHUNKER(31-31)SIGN_IN_BI_COPILOT(24-24)workspaces/ballerina/ballerina-extension/src/utils/ai/auth.ts (2)
REFRESH_TOKEN_NOT_AVAILABLE_ERROR_MESSAGE(26-26)TOKEN_REFRESH_ONLY_SUPPORTED_FOR_BI_INTEL(27-27)
🔇 Additional comments (4)
workspaces/ballerina/ballerina-extension/package.json (1)
485-493: New Devant chunker command contribution is consistent and correctly wiredThe new
ballerina.configureDefaultDevantChunkercontribution matches the constant inconstants.ts, follows the existing naming pattern (Configure default ...), and is categorized under "Ballerina". No issues here.workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-agent/rpc-manager.ts (1)
49-50: RPC wiring for Devant chunker configuration is clean and symmetric
configureDefaultDevantChunker()mirrorsconfigureDefaultModelProvider()and correctly usesCONFIGURE_DEFAULT_DEVANT_CHUNKER_COMMAND. This keeps the RPC manager thin and consistent with existing patterns.Also applies to: 512-518
workspaces/ballerina/ballerina-extension/src/features/ai/utils.ts (1)
27-37: Enum‑based provider configuration details are well-structuredThe introduction of
AIProviderConfigTypeplusgetConfigDetailscleanly separates provider-specific concerns (table name, service URL, progress message) from the generic config-writing logic. This will make it straightforward to add more provider types later without touching the core flow.Also applies to: 51-55, 285-309
workspaces/ballerina/ballerina-extension/src/features/ai/constants.ts (1)
21-39: Devant chunker and shared config constants align with usage and specThe new constants for:
CONFIGURE_DEFAULT_DEVANT_CHUNKER_COMMAND- Devant chunker progress/login/default-added messages
- Provider config tables, keys, and
DEVANT_CHUNKER_SERVICE_URLare consistent with the PR description and with how they’re consumed in
utils.ts,activator.ts,rpc-manager.ts, andpackage.json. No issues spotted.
9331173 to
f8d8cb5
Compare
f8d8cb5 to
521be6c
Compare
Purpose
Closes wso2/product-ballerina-integrator#1487
Adds support to configure the default Devant chunker by adding the following values to
Config.toml:Introduced a new vscode command palette command:
Ballerina: Configure default Devant chunkerSummary by CodeRabbit