Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f546c76
Add WI extension and related packages
gigara Oct 31, 2025
c02ef8d
Merge branch 'main' of https://github.com/wso2/vscode-extensions into…
gigara Oct 31, 2025
20b0106
Support Bal project open
kaumini Nov 7, 2025
771070c
Support Bal project open
kaumini Nov 7, 2025
d76490c
Add treeview commands
kaumini Nov 7, 2025
77864b7
Render Bi treeview and webviews if bal projecct
kaumini Nov 7, 2025
6a71aaa
Add svgs and codicons
kaumini Nov 7, 2025
a1fc49e
Support MI project open
kaumini Nov 9, 2025
2d3a9bf
Add new welcome view to WSO2 Integrator
kaumini Nov 9, 2025
4af1d2a
Render wi welcome view
kaumini Nov 10, 2025
40a63a2
Revert "Add new welcome view to WSO2 Integrator"
kaumini Nov 10, 2025
164ba05
Add BI creation form and add default integrator setting
kaumini Nov 10, 2025
dc1f1d9
Add import external view
kaumini Nov 10, 2025
f986372
Support samples view
kaumini Nov 10, 2025
146906f
Add context provider
kaumini Nov 11, 2025
aba040c
Add ui changes
kaumini Nov 11, 2025
00b0793
Add mi project form ui changes
kaumini Nov 11, 2025
b43e816
Complete bi project creation flow
kaumini Nov 11, 2025
0f16660
Show only wso2-integrator on activity bar
kaumini Nov 11, 2025
189f45d
Complete mi creation flow
kaumini Nov 11, 2025
6280c5b
Add statemachine and refactor base logic
gigara Nov 11, 2025
b55f298
Merge branch 'wso2-integrator' of https://github.com/wso2/vscode-exte…
kaumini Nov 12, 2025
2cf0ab8
Complete mi samples flow
kaumini Nov 12, 2025
195f1e9
Complete Migrate Integration
kaumini Nov 12, 2025
43dcd6b
Refactor webview rendering logic and remove unused methods
gigara Nov 13, 2025
a239a01
Enhance project type handling and update welcome screen content in st…
gigara Nov 13, 2025
c5876ec
Merge branch 'wso2-integrator' of https://github.com/wso2/vscode-exte…
gigara Nov 13, 2025
f5da3b4
Dynamically activate project explorer
gigara Nov 13, 2025
bc2a2cd
Enhance default integrator mode handling
gigara Nov 13, 2025
f11af15
Hide welcome view in WI mode
gigara Nov 13, 2025
eaa8145
Merge branch 'main' of https://github.com/wso2/vscode-extensions into…
gigara Nov 13, 2025
c708556
Revert BI ext changes
gigara Nov 14, 2025
55c0b9f
ignore env
kaumini Nov 14, 2025
7d6d438
Fix build failure
gigara Nov 14, 2025
2edac1c
Show welcome screen when no project open
kaumini Nov 14, 2025
b9906c5
Merge branch 'wso2-integrator' of https://github.com/wso2/vscode-exte…
kaumini Nov 14, 2025
a5344c9
remove redundant code
kaumini Nov 14, 2025
a9858b4
Fix extension activation issue
gigara Nov 14, 2025
820bb6a
Merge branch 'wso2-integrator' of https://github.com/wso2/vscode-exte…
gigara Nov 14, 2025
46c9bb7
Remove home icon
gigara Nov 14, 2025
e518b1e
Fix bi treeview in wi
kaumini Nov 14, 2025
98f4aab
Merge branch 'wso2-integrator' of https://github.com/wso2/vscode-exte…
gigara Nov 14, 2025
0b79b6d
Update workspaces/mi/mi-extension/src/visualizer/activate.ts
gigara Nov 17, 2025
eac7056
Update types
gigara Nov 17, 2025
df8b0db
Update repo
gigara Nov 17, 2025
a9393b7
Fix import
gigara Nov 17, 2025
6831a9a
Rename logger to bal logger
gigara Nov 17, 2025
44ebf1b
Use a js script to package vsix to avoid cross paltform issues
gigara Nov 17, 2025
fec6f55
Merge branch 'main' of https://github.com/wso2/vscode-extensions into…
gigara Nov 17, 2025
ff93bdf
Merge branch 'wso2-integrator' of https://github.com/wso2/vscode-exte…
gigara Nov 17, 2025
c0aeeb5
Improve package script
gigara Nov 17, 2025
31db42e
Improve WI detection logic
gigara Nov 17, 2025
7a3e9f6
Move WI ext id into a constant
gigara Nov 17, 2025
1066a3c
Sort log files before remove
gigara Nov 17, 2025
852c401
Add migration report for wi
kaumini Nov 17, 2025
b18201c
Merge branch 'main' of https://github.com/wso2/vscode-extensions into…
gigara Nov 19, 2025
c963d82
Remove BI extension's duplicate code from WI
gigara Nov 19, 2025
637c9f6
Update BI to contribute to the WI activity
gigara Nov 19, 2025
d4632a4
Refactor project explorer commands and add new view IDs for better co…
gigara Nov 19, 2025
cd4e45d
Hide BI activity in WI mode
gigara Nov 19, 2025
ed39df1
Remove WI packages from vscode repo
gigara Nov 19, 2025
807b1f8
Merge branch 'main' of https://github.com/wso2/vscode-extensions into…
gigara Nov 19, 2025
b7dd186
Merge branch 'wso2-integrator' of https://github.com/wso2/vscode-exte…
gigara Nov 19, 2025
2102269
Remove WSO2 Integrator Extension configuration and related watch task…
gigara Nov 19, 2025
80b7526
Add WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND to constants and update …
gigara Nov 19, 2025
70dad0c
Fix mock services pane visibility condition
gigara Nov 20, 2025
e13cf7c
Enhance command visibility conditions for Ballerina and Micro Integra…
gigara Nov 20, 2025
d2dcfa4
Merge branch 'main' of https://github.com/wso2/vscode-extensions into…
gigara Nov 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@
"--extensionTestsPath=${workspaceFolder}/workspaces/ballerina/ballerina-extension/out/test",
"${workspaceFolder}/workspaces/ballerina/ballerina-extension/test/data/bi_empty_project",
"${workspaceFolder}/workspaces/ballerina/ballerina-extension/test/data/bi_init",
"${workspaceFolder}/workspaces/ballerina/ballerina-extension/test/data/simple_order_management_system","${workspaceFolder}/workspaces/ballerina/ballerina-extension/test/data/ai_datamapper"
"${workspaceFolder}/workspaces/ballerina/ballerina-extension/test/data/simple_order_management_system",
"${workspaceFolder}/workspaces/ballerina/ballerina-extension/test/data/ai_datamapper"
],
"env": {
"LS_EXTENSIONS_PATH": "",
Expand Down Expand Up @@ -294,4 +295,4 @@
"preLaunchTask": "npm: watch-apk"
},
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"clean": "rimraf ./dist",
"compile": "tsc -p .",
"watch": "tsc -p . -w",
"package": "if [ $isPreRelease = true ]; then vsce package --no-dependencies --pre-release; else vsce package --no-dependencies; fi",
"package": "node ../../common-libs/scripts/package-vsix.js",
"build": "pnpm clean && pnpm run copyFonts && webpack --mode production --devtool hidden-source-map && pnpm run package && pnpm run postbuild",
"compile-tests": "pnpm run compile",
"watch-tests": "pnpm run watch",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/apk/apk-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"build": "if [ $isPreRelease = true ]; then vsce package --no-dependencies --pre-release; else vsce package --no-dependencies; fi && pnpm run postbuild",
"build": "node ../../common-libs/scripts/package-vsix.js && pnpm run postbuild",
"postbuild": "pnpm run copyVSIX",
"copyVSIX": "copyfiles *.vsix ./vsix",
"copyVSIXToRoot": "copyfiles -f ./vsix/* ../../.."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const BI_COMMANDS = {
BI_RUN_PROJECT: 'BI.project.run',
BI_DEBUG_PROJECT: 'BI.project.debug',
REFRESH_COMMAND: 'BI.project-explorer.refresh',
FOCUS_PROJECT_EXPLORER: 'BI.project-explorer.focus',
PROJECT_EXPLORER: 'BI.project-explorer',
ADD_CONNECTIONS: 'BI.project-explorer.add-connection',
ADD_CUSTOM_CONNECTOR: 'BI.project-explorer.add-custom-connector',
Expand All @@ -52,6 +51,8 @@ export const BI_COMMANDS = {
BI_EDIT_TEST_FUNCTION_DEF: 'BI.test.edit.function.def',
ADD_NATURAL_FUNCTION: 'BI.project-explorer.add-natural-function',
TOGGLE_TRACE_LOGS: 'BI.toggle.trace.logs',
CREATE_BI_PROJECT: 'BI.project.createBIProjectPure',
CREATE_BI_MIGRATION_PROJECT: 'BI.project.createBIProjectMigration',
ADD_INTEGRATION: 'BI.project-explorer.add-integration',
NOTIFY_PROJECT_EXPLORER: 'BI.project-explorer.notify',
};
7 changes: 4 additions & 3 deletions workspaces/ballerina/ballerina-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@
},
{
"view": "testing",
"contents": "[Add Unit Test](command:BI.test.add.function)"
"contents": "[Add Unit Test](command:BI.test.add.function)",
"when": "isBIProject || isBallerinaProject"
Comment on lines +768 to +769
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

Verify context variables isBIProject and isBallerinaProject are properly registered and maintained.

The visibility gating for testing view commands relies on context variables isBIProject and isBallerinaProject. These must be:

  1. Registered in VS Code's context
  2. Set/updated during extension activation and workspace changes
  3. Aligned with the PR objective to hide BI/MI items when WI is active

Run the following script to locate and verify context variable management in the extension source:

Also applies to: 813-813


🏁 Script executed:

#!/bin/bash
# Description: Verify context variables are defined and set during extension lifecycle

# Search for context variable registration (setContext calls)
echo "=== Searching for context variable registration ==="
fd -e ts -e tsx -x grep -n 'setContext.*\(isBIProject\|isBallerinaProject\)' {}

# Search for context evaluation patterns
echo ""
echo "=== Searching for context variable definitions ==="
fd -e ts -e tsx -x grep -n 'registerExtensionCommands\|activateExtension\|setContext' {} | head -20

# Verify these are referenced in extension activation
echo ""
echo "=== Checking for extension.ts or main activation file ==="
fd -e ts -path '*/src/*' | grep -E '(extension|activation|main)\.ts' | head -5

Length of output: 2522


I'll search for more context around these context variable setups to verify they're properly coordinated and maintained during workspace changes.


🏁 Script executed:

#!/bin/bash
# Find file locations and get context around setContext calls

echo "=== Finding files containing setContext calls ==="
fd -e ts -e tsx | xargs grep -l "setContext.*\(isBIProject\|isBallerinaProject\)"

echo ""
echo "=== Context around isBallerinaProject setContext (line 2497) ==="
fd -e ts -e tsx | xargs grep -B5 -A5 "setContext.*isBallerinaProject"

echo ""
echo "=== Context around isBIProject setContext (line 1052) ==="
fd -e ts -e tsx | xargs grep -B5 -A5 "setContext.*isBIProject" | grep -v "isBIProjectRunning"

echo ""
echo "=== Find extension entry point ==="
fd -e ts -path '*/src/*' -name 'extension.ts'

Length of output: 4664



🏁 Script executed:

#!/bin/bash
# Find where these context-setting functions are called

echo "=== Where is setCurrentProject() called? ==="
fd -e ts -e tsx | xargs grep -n "setCurrentProject" | grep -v "public setCurrentProject"

echo ""
echo "=== Where is setBIContext() called? ==="
fd -e ts -e tsx | xargs grep -n "setBIContext"

echo ""
echo "=== Workspace listeners and change handlers ==="
fd -e ts -e tsx | xargs grep -n "onDidChangeWorkspaceFolders\|onDidOpenTextDocument\|workspaceState\|updateContext" | head -15

echo ""
echo "=== Check extension.ts for initialization of context variables ==="
cat workspaces/ballerina/ballerina-extension/src/core/extension.ts | grep -n "isBallerinaProject\|isBIProject" | head -10

Length of output: 3603



🏁 Script executed:

#!/bin/bash
# Get context around the setBIContext calls to understand the flow

echo "=== Context around setBIContext calls in stateMachine.ts (lines 996, 1009, 1019) ==="
sed -n '985,1030p' workspaces/ballerina/ballerina-extension/src/stateMachine.ts

echo ""
echo "=== Look for project unload/close handlers ==="
fd -e ts -e tsx | xargs grep -n "unload\|closeProject\|projectClose\|clearProject" | grep -i "project\|context" | head -15

echo ""
echo "=== Search for where isBallerinaProject might be reset ==="
fd -e ts -e tsx | xargs grep -n "isBallerinaProject.*false\|setContext.*isBallerinaProject.*false"

echo ""
echo "=== Check stateMachine.ts for workspace change listeners ==="
sed -n '1,100p' workspaces/ballerina/ballerina-extension/src/stateMachine.ts | grep -n "onDidChange\|listener\|workspace"

Length of output: 2071



🏁 Script executed:

#!/bin/bash
# Check extension activation and workspace listeners

echo "=== Extension activation function in extension.ts ==="
sed -n '1,150p' workspaces/ballerina/ballerina-extension/src/core/extension.ts | head -60

echo ""
echo "=== Search for activate function ==="
fd -e ts -e tsx | xargs grep -n "export.*activate\|function activate"

echo ""
echo "=== Full stateMachine.ts for workspace listeners and context initialization ==="
fd -e ts -e tsx -path '*/stateMachine.ts' | xargs grep -n "onDidChange\|workspace\|activate" | head -20

echo ""
echo "=== Check if isBallerinaProject is set to false anywhere ==="
fd -e ts -e tsx | xargs grep -n "setContext.*isBallerinaProject"

Length of output: 14194


Verify and fix asymmetric context variable management for isBallerinaProject.

The context variables isBIProject and isBallerinaProject are registered and maintained during extension lifecycle, but there's a critical asymmetry:

  • isBIProject is properly managed via setBIContext(isBI) in workspaces/ballerina/ballerina-extension/src/stateMachine.ts:1051, allowing it to reset to false when a workspace is not a BI project.
  • isBallerinaProject is set to true in workspaces/ballerina/ballerina-extension/src/core/extension.ts:2497 via setCurrentProject(), but is never reset to false.

This one-way toggle breaks the visibility gating logic. Conditions like "isBIProject || isBallerinaProject" will remain true even after switching to a non-Ballerina workspace, defeating the PR's objective to properly hide/show items based on project type.

Required: Add a corresponding mechanism to reset isBallerinaProject to false when the workspace is not a Ballerina project, mirroring the pattern used for isBIProject.

🤖 Prompt for AI Agents
In workspaces/ballerina/ballerina-extension/package.json around lines 768-769
and code paths in workspaces/ballerina/ballerina-extension/src/core/extension.ts
(around line 2497) and
workspaces/ballerina/ballerina-extension/src/stateMachine.ts (around line 1051),
the isBallerinaProject context is only ever set true and never reset to false;
add a symmetric reset like setBIContext does: introduce or call a
setBallerinaContext/isBallerinaContext setter that calls
vscode.commands.executeCommand('setContext', 'isBallerinaProject', boolean) and
ensure it’s invoked with false when workspace/project detection shows the
current workspace is not a Ballerina project (e.g., in workspace change
handlers, in setCurrentProject when no project found, or where
setBIContext(false) is called) so the `"isBIProject || isBallerinaProject"`
conditions correctly reflect current workspace state.

}
],
"viewsContainers": {
Expand Down Expand Up @@ -809,7 +810,7 @@
},
{
"command": "BI.test.add.function",
"when": "view == workbench.view.testing",
"when": "(isBIProject || isBallerinaProject) && view == workbench.view.testing",
"group": "navigation"
},
{
Expand Down Expand Up @@ -1175,7 +1176,7 @@
"test-coverage": "cross-env COVER_CONFIG=html pnpm run test",
"build-tm-grammar": "js-yaml grammar/ballerina-grammar/syntaxes/ballerina.tmLanguage.yaml > grammar/ballerina-grammar/syntaxes/ballerina.tmLanguage.json",
"lint": "tslint --fix 'src/**/*{.ts,.tsx}'",
"package": "if [ $isPreRelease = true ]; then vsce package --no-dependencies --pre-release; else vsce package --no-dependencies; fi",
"package": "node ../../common-libs/scripts/package-vsix.js",
"copyFonts": "copyfiles -f ./node_modules/@wso2/font-wso2-vscode/dist/* ./resources/font-wso2-vscode/dist/",
"copyVSIX": "copyfiles *.vsix ./vsix",
"copyVSIXToRoot": "copyfiles -f ./vsix/*.vsix ../../..",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { readFileSync, readdirSync, statSync } from "fs";
import path from "path";
import { isPositionEqual, isPositionWithinDeletedComponent } from "../../utils/history/util";
import { startDebugging } from "../editor-support/activator";
import { createBIProjectFromMigration, createBIProjectPure } from "../../utils/bi";
import { createVersionNumber, isSupportedSLVersion } from ".././../utils";
import { extension } from "../../BalExtensionContext";

Expand All @@ -60,7 +61,7 @@ function handleCommandWithContext(
// Scenario 1: Multi-package workspace invoked from command palette
if (isBalWorkspace && !item) {
const packageList = StateMachine.context().projectInfo?.children.map((child) => child.projectPath);

if (!packageList || packageList.length === 0) {
openView(EVENT_TYPE.OPEN_VIEW, { view, ...additionalViewParams });
return;
Expand All @@ -70,23 +71,23 @@ function handleCommandWithContext(
placeHolder: "Select a package"
}).then((selectedPackage) => {
if (selectedPackage) {
openView(EVENT_TYPE.OPEN_VIEW, {
view,
projectPath: selectedPackage,
...additionalViewParams
openView(EVENT_TYPE.OPEN_VIEW, {
view,
projectPath: selectedPackage,
...additionalViewParams
});
}
});
}
// Scenario 2: Invoked from tree view with item context
else if (item?.resourceUri) {
const projectPath = item.resourceUri.fsPath;
openView(EVENT_TYPE.OPEN_VIEW, {
view,
projectPath,
...additionalViewParams
openView(EVENT_TYPE.OPEN_VIEW, {
view,
projectPath,
...additionalViewParams
});
}
}
// Scenario 3: Default - no specific context
else {
openView(EVENT_TYPE.OPEN_VIEW, { view, ...additionalViewParams });
Expand All @@ -95,7 +96,7 @@ function handleCommandWithContext(

export function activate(context: BallerinaExtension) {
const isWorkspaceSupported = isSupportedSLVersion(extension.ballerinaExtInstance, createVersionNumber(2201, 13, 0));

// Set context for command visibility
commands.executeCommand('setContext', 'ballerina.bi.workspaceSupported', isWorkspaceSupported);

Expand Down Expand Up @@ -154,7 +155,7 @@ export function activate(context: BallerinaExtension) {
window.showErrorMessage('This command requires Ballerina version 2201.13.0 or higher. ');
return;
}

const projectPath = StateMachine.context().projectPath || StateMachine.context().workspacePath;
if (projectPath) {
openView(EVENT_TYPE.OPEN_VIEW, { view: MACHINE_VIEW.BIAddProjectForm });
Expand All @@ -173,6 +174,14 @@ export function activate(context: BallerinaExtension) {

commands.registerCommand(BI_COMMANDS.TOGGLE_TRACE_LOGS, toggleTraceLogs);

commands.registerCommand(BI_COMMANDS.CREATE_BI_PROJECT, (params) => {
return createBIProjectPure(params);
});

commands.registerCommand(BI_COMMANDS.CREATE_BI_MIGRATION_PROJECT, (params) => {
return createBIProjectFromMigration(params);
});

commands.registerCommand(BI_COMMANDS.DELETE_COMPONENT, async (item?: TreeItem & { info?: string }) => {
// Guard: DELETE requires a tree item context
if (!item) {
Expand Down
7 changes: 4 additions & 3 deletions workspaces/bi/bi-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"ballerina-integrator": [
{
"id": "BI.project-explorer",
"name": ""
"name": "",
"when": "!config.integrator.defaultIntegrator"
}
]
},
Expand Down Expand Up @@ -162,7 +163,7 @@
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"build": "pnpm run compile && pnpm run lint && pnpm run postbuild",
"package": "if [ $isPreRelease = true ]; then vsce package --no-dependencies --pre-release; else vsce package --no-dependencies; fi",
"package": "node ../../common-libs/scripts/package-vsix.js",
"copyFonts": "copyfiles -f ./node_modules/@wso2/font-wso2-vscode/dist/* ./resources/font-wso2-vscode/dist/",
"rebuild": "pnpm run clean && pnpm run compile && pnpm run postbuild",
"postbuild": "pnpm run copyFonts && pnpm run package && pnpm run copyVSIX",
Expand Down Expand Up @@ -200,4 +201,4 @@
"@playwright/test": "~1.55.1",
"@wso2/playwright-vscode-tester": "workspace:*"
}
}
}
6 changes: 6 additions & 0 deletions workspaces/bi/bi-extension/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
* under the License.
*/

import { BI_COMMANDS } from "@wso2/ballerina-core";

// ADD ALL THE NON-SHARED BI ONLY ATTRIBUTES HERE.
export const WI_EXTENSION_ID = 'wso2.wso2-integrator';
export const WI_PROJECT_EXPLORER_VIEW_ID = 'wso2-integrator.explorer';
export const WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND = 'wso2-integrator.explorer.refresh';
export const BI_PROJECT_EXPLORER_VIEW_ID = BI_COMMANDS.PROJECT_EXPLORER;
27 changes: 16 additions & 11 deletions workspaces/bi/bi-extension/src/project-explorer/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,35 @@ import { SHARED_COMMANDS, BI_COMMANDS, MACHINE_VIEW, NodePosition } from '@wso2/
import { ProjectExplorerEntry, ProjectExplorerEntryProvider } from './project-explorer-provider';
import { ExtensionContext, TreeView, commands, window, workspace } from 'vscode';
import { extension } from '../biExtentionContext';
import { BI_PROJECT_EXPLORER_VIEW_ID, WI_PROJECT_EXPLORER_VIEW_ID, WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND } from '../constants';

interface ExplorerActivationConfig {
context: ExtensionContext;
isBI: boolean;
isBallerinaPackage?: boolean;
isBallerinaWorkspace?: boolean;
isEmptyWorkspace?: boolean;
isInWI: boolean;
}

export function activateProjectExplorer(config: ExplorerActivationConfig) {
const { context, isBI, isBallerinaPackage, isBallerinaWorkspace, isEmptyWorkspace } = config;
const { context, isBI, isBallerinaPackage, isBallerinaWorkspace, isEmptyWorkspace, isInWI } = config;

if (extension.langClient && extension.biSupported) {
setLoadingStatus();
}

const treeviewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID;
const projectExplorerDataProvider = new ProjectExplorerEntryProvider();
const projectTree = createProjectTree(projectExplorerDataProvider);
const projectTree = createProjectTree(projectExplorerDataProvider, treeviewId);

projectExplorerDataProvider.setTreeView(projectTree);

// Always register core commands so they're available to the Ballerina extension
registerCoreCommands(projectExplorerDataProvider);
registerCoreCommands(projectExplorerDataProvider, isInWI);

if (isBallerinaPackage || isBallerinaWorkspace) {
registerBallerinaCommands(projectExplorerDataProvider, isBI, isBallerinaWorkspace, isEmptyWorkspace);
registerBallerinaCommands(projectExplorerDataProvider, isBI, isInWI, isBallerinaWorkspace, isEmptyWorkspace);
}

handleVisibilityChangeEvents(
Expand All @@ -62,11 +65,11 @@ function setLoadingStatus() {
commands.executeCommand('setContext', 'BI.status', 'loading');
}

function createProjectTree(dataProvider: ProjectExplorerEntryProvider) {
return window.createTreeView(BI_COMMANDS.PROJECT_EXPLORER, { treeDataProvider: dataProvider });
function createProjectTree(dataProvider: ProjectExplorerEntryProvider, treeviewId: string) {
return window.createTreeView(treeviewId, { treeDataProvider: dataProvider });
}

function registerCoreCommands(dataProvider: ProjectExplorerEntryProvider) {
function registerCoreCommands(dataProvider: ProjectExplorerEntryProvider, isInWI: boolean) {
// Register the notify command that's called by the Ballerina extension
commands.registerCommand(
BI_COMMANDS.NOTIFY_PROJECT_EXPLORER,
Expand All @@ -81,12 +84,13 @@ function registerCoreCommands(dataProvider: ProjectExplorerEntryProvider) {
);

// Register the refresh command
commands.registerCommand(BI_COMMANDS.REFRESH_COMMAND, () => dataProvider.refresh());
commands.registerCommand(isInWI ? WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND : BI_COMMANDS.REFRESH_COMMAND, () => dataProvider.refresh());
}

function registerBallerinaCommands(
dataProvider: ProjectExplorerEntryProvider,
isBI: boolean,
isInWI: boolean,
isBallerinaWorkspace?: boolean,
isEmptyWorkspace?: boolean
) {
Expand All @@ -99,7 +103,7 @@ function registerBallerinaCommands(
}
}
if (isBI) {
registerBICommands();
registerBICommands(isInWI);
}
}

Expand Down Expand Up @@ -153,8 +157,9 @@ function handleNonBallerinaVisibility() {
commands.executeCommand(SHARED_COMMANDS.OPEN_BI_WELCOME);
}

function registerBICommands() {
commands.executeCommand(BI_COMMANDS.FOCUS_PROJECT_EXPLORER);
function registerBICommands(isInWI) {
const treeViewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID;
commands.executeCommand(`${treeViewId}.focus`);
commands.executeCommand(SHARED_COMMANDS.SHOW_VISUALIZER);
commands.executeCommand('setContext', 'BI.project', true);
Comment on lines +160 to 164
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add missing type annotation for isInWI parameter.

The parameter lacks a TypeScript type annotation, which is inconsistent with the rest of the file and may reduce type safety.

-function registerBICommands(isInWI) {
+function registerBICommands(isInWI: boolean) {
 	const treeViewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID;
 	commands.executeCommand(`${treeViewId}.focus`);
 	commands.executeCommand(SHARED_COMMANDS.SHOW_VISUALIZER);
 	commands.executeCommand('setContext', 'BI.project', true);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function registerBICommands(isInWI) {
const treeViewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID;
commands.executeCommand(`${treeViewId}.focus`);
commands.executeCommand(SHARED_COMMANDS.SHOW_VISUALIZER);
commands.executeCommand('setContext', 'BI.project', true);
function registerBICommands(isInWI: boolean) {
const treeViewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID;
commands.executeCommand(`${treeViewId}.focus`);
commands.executeCommand(SHARED_COMMANDS.SHOW_VISUALIZER);
commands.executeCommand('setContext', 'BI.project', true);
}
🤖 Prompt for AI Agents
In workspaces/bi/bi-extension/src/project-explorer/activate.ts around lines 160
to 164, the function parameter isInWI is missing a TypeScript type annotation;
update the function signature to include an explicit boolean type (e.g. isInWI:
boolean) to match the file's typing conventions and improve type safety, and
then run type-check to ensure no downstream signature issues.

}
9 changes: 7 additions & 2 deletions workspaces/bi/bi-extension/src/stateMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ import { assign, createMachine, interpret } from 'xstate';
import { activateProjectExplorer } from './project-explorer/activate';
import { extension } from './biExtentionContext';
import { fetchProjectInfo, ProjectInfo } from './utils';
import { WI_EXTENSION_ID } from './constants';
import * as vscode from 'vscode';

interface MachineContext {
isBI: boolean;
isBallerinaPackage?: boolean;
isBallerinaWorkspace?: boolean;
isEmptyWorkspace?: boolean;
isInWI: boolean;
}

const stateMachine = createMachine<MachineContext>({
Expand All @@ -34,7 +37,8 @@ const stateMachine = createMachine<MachineContext>({
initial: 'initialize',
predictableActionArguments: true,
context: {
isBI: false
isBI: false,
isInWI: vscode.extensions.getExtension(WI_EXTENSION_ID) ? true : false
},
states: {
initialize: {
Expand Down Expand Up @@ -71,7 +75,8 @@ const stateMachine = createMachine<MachineContext>({
isBI: context.isBI,
isBallerinaPackage: context.isBallerinaPackage,
isBallerinaWorkspace: context.isBallerinaWorkspace,
isEmptyWorkspace: context.isEmptyWorkspace
isEmptyWorkspace: context.isEmptyWorkspace,
isInWI: context.isInWI
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion workspaces/common-libs/rpc-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ const handlerFunction = handlerSourceFile.addFunction({
}]
});
handleImportStatment(handlerSourceFile, 'vscode-messenger', 'Messenger');

// Add statements to the function
const managerObject = `const rpcManger = new ${managerClassName}();`
handlerFunction.addStatements(managerObject);
typeMethods.forEach(value => {
handleMessengerTypes(handlerFunction, value, handlerSourceFile);
})

console.log(`Adding handler function: ${headerComment}...`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix incorrect variable in log message.

The log message uses headerComment, which is the multi-line license header text (lines 37-56), instead of a meaningful identifier. This will print the entire license to the console rather than identifying which handler is being added.

Apply this diff to fix the log message:

-console.log(`Adding handler function: ${headerComment}...`);
+console.log(`Adding handler function: ${handlerName}...`);

The handlerName variable (defined at line 316) contains the actual function name that's being registered.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log(`Adding handler function: ${headerComment}...`);
console.log(`Adding handler function: ${handlerName}...`);
🤖 Prompt for AI Agents
In workspaces/common-libs/rpc-generator/index.js around line 334, the
console.log uses headerComment (the multi-line license header defined around
lines 37-56) instead of the actual handler identifier; replace the logged value
with handlerName (defined at line 316) so the message reads that the specific
handler function is being added rather than printing the license header.

handleImportStatment(handlerSourceFile, './rpc-manager', managerClassName);

// Format imports into new lines
Expand Down
10 changes: 5 additions & 5 deletions workspaces/common-libs/rpc-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"description": "Generate rpc-manager,rpc-handler and rpc-client ts files in relevant libraries",
"main": "index.js",
"config": {
"CORE_RPC_TYPE_FILE": "ai-panel/index.ts",
"CORE_RPC_TYPE_DIR": "../../ballerina/ballerina-core/",
"EXT_RPC_MANAGER_DIR": "../../ballerina/ballerina-extension/",
"RPC_CLIENT_DIR": "../../ballerina/ballerina-rpc-client/",
"CORE_MODULE_NAME": "@wso2/ballerina-core"
"CORE_RPC_TYPE_FILE": "main/index.ts",
"CORE_RPC_TYPE_DIR": "../../wi/wi-core/",
"EXT_RPC_MANAGER_DIR": "../../wi/wi-extension/",
"RPC_CLIENT_DIR": "../../wi/wi-rpc-client/",
"CORE_MODULE_NAME": "@wso2/wi-core"
},
"scripts": {
"generate": "node index.js"
Expand Down
24 changes: 24 additions & 0 deletions workspaces/common-libs/scripts/package-vsix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { spawnSync } = require('child_process');

const isPreRelease = process.env.isPreRelease === 'true';
const args = ['vsce', 'package', '--no-dependencies'];

if (isPreRelease) {
args.push('--pre-release');
}

console.log(`Packaging VSIX with args: ${args.join(' ')}`);

const result = spawnSync('npx', args, { stdio: 'inherit' });

if (result.error) {
console.error(`Failed to spawn vsce: ${result.error.message}`);
process.exit(1);
}

if (result.status === null) {
console.error('vsce process was terminated by a signal');
process.exit(1);
}

process.exit(result.status);
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"lint": "eslint src",
"test": "node ./out/test/runTest.js",
"build": "pnpm run compile && pnpm run lint && pnpm run postbuild",
"package": "if [ $isPreRelease = true ]; then vsce package --no-dependencies --pre-release; else vsce package --no-dependencies; fi",
"package": "node ../../common-libs/scripts/package-vsix.js",
"rebuild": "pnpm run clean && pnpm run compile && pnpm run postbuild",
"postbuild": "pnpm run package && pnpm run copyVSIX",
"copyVSIX": "copyfiles *.vsix ./vsix",
Expand Down
Loading
Loading