-
Notifications
You must be signed in to change notification settings - Fork 59
Fix treeview in WI mode #1029
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
Fix treeview in WI mode #1029
Conversation
… wso2-integrator
WalkthroughThe PR refactors refresh command registration in both BI and MI extensions from conditional compile-time wiring to runtime branching. Commands are always registered under a unified name, but execution checks the WI context at runtime to delegate appropriately. Minor logging cleanup and event parameter typing fixes are included. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
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/mi/mi-extension/src/visualizer/activate.ts (1)
211-255: Usee.documentis correct; add aprojectUriguard in the pom.xml branchTyping the
onDidChangeTextDocumenthandler ase: vscode.TextDocumentChangeEventand switching all usage toe.documentis the right way to consume this event and aligns the logic with VS Code’s API.In the
pom.xmlbranch, though:if (e.document.uri.fsPath.endsWith('pom.xml')) { const projectUri = vscode.workspace.getWorkspaceFolder(e.document.uri)?.uri.fsPath; const langClient = getStateMachine(projectUri!).context().langClient; … }If the user edits a
pom.xmlthat is not in any workspace folder,workspace.getWorkspaceFolder(...)will beundefined,projectUriwill beundefined, andprojectUri!passed togetStateMachinewill throw.A small guard avoids this crash:
- if (e.document.uri.fsPath.endsWith('pom.xml')) { - const projectUri = vscode.workspace.getWorkspaceFolder(e.document.uri)?.uri.fsPath; - const langClient = getStateMachine(projectUri!).context().langClient; + if (e.document.uri.fsPath.endsWith('pom.xml')) { + const projectUri = vscode.workspace.getWorkspaceFolder(e.document.uri)?.uri.fsPath; + if (!projectUri) { + return; + } + const langClient = getStateMachine(projectUri).context().langClient;
🧹 Nitpick comments (1)
workspaces/mi/mi-extension/src/stateMachine.ts (1)
695-710: WI mode detection in state machine context looks consistentInitializing
isInWIviavscode.extensions.getExtension(WI_EXTENSION_ID)and threading it through the state machine context lines up with howwaitForLS,activateOtherFeatures, andfocusProjectExplorerchoose the tree view ID. This should allow MI logic to correctly distinguish WI vs standalone at runtime.If you later need more nuanced detection (e.g., WI extension installed but not actually hosting MI), consider centralizing this check behind a helper, but the current approach is fine for now.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
workspaces/bi/bi-extension/src/project-explorer/activate.ts(1 hunks)workspaces/mi/mi-extension/src/constants/index.ts(2 hunks)workspaces/mi/mi-extension/src/project-explorer/activate.ts(2 hunks)workspaces/mi/mi-extension/src/stateMachine.ts(1 hunks)workspaces/mi/mi-extension/src/visualizer/activate.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-11-26T06:35:19.217Z
Learnt from: KCSAbeywickrama
Repo: wso2/vscode-extensions PR: 653
File: workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts:173-178
Timestamp: 2025-11-26T06:35:19.217Z
Learning: In workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts, the commented-out debugging block in the verifyFileContent function (lines 172-177 containing console.log, page.pause, and updateDataFileSync) is intentionally kept as a developer utility for updating test data files when needed. It should not be removed.
Applied to files:
workspaces/mi/mi-extension/src/stateMachine.ts
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Define all constants (node types, sizing, spacing) in src/resources/constants.ts and import them where needed instead of hardcoding values
Applied to files:
workspaces/mi/mi-extension/src/constants/index.ts
📚 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/mi/mi-extension/src/constants/index.ts
🧬 Code graph analysis (2)
workspaces/mi/mi-extension/src/project-explorer/activate.ts (1)
workspaces/mi/mi-extension/src/constants/index.ts (1)
COMMANDS(19-118)
workspaces/bi/bi-extension/src/project-explorer/activate.ts (2)
workspaces/ballerina/ballerina-core/src/interfaces/constants.ts (1)
BI_COMMANDS(31-58)workspaces/bi/bi-extension/src/constants/index.ts (1)
WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND(24-24)
🔇 Additional comments (3)
workspaces/bi/bi-extension/src/project-explorer/activate.ts (1)
72-94: BI refresh delegation is aligned with WI mode; consider returning the underlying promises and verify WI doesn't loop backThe new
registerCoreCommandswiring forBI_COMMANDS.REFRESH_COMMAND:
- In WI mode:
commands.executeCommand(WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND);- Otherwise:
dataProvider.refresh();Functionally this matches the MI pattern and should make BI refresh behave correctly under WI.
Two follow‑ups worth considering:
Avoid potential recursion with WI
Ensure that WI'swso2-integrator.explorer.refreshhandler does not callBI_COMMANDS.REFRESH_COMMANDagain; otherwise, the two commands could recurse.Optionally return the underlying promise
If any callersawait commands.executeCommand(BI_COMMANDS.REFRESH_COMMAND), you may want to:commands.registerCommand(BI_COMMANDS.REFRESH_COMMAND, () => { if (isInWI) { return commands.executeCommand(WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND); } return dataProvider.refresh(); });This mirrors the MI implementation style and propagates completion.
workspaces/mi/mi-extension/src/constants/index.ts (1)
55-57: Command and refresh-document constants are wired consistently
- Adding
COMMANDS.WI_PROJECT_EXPLORER_VIEW_REFRESH = 'wso2-integrator.explorer.refresh'centralizes the WI refresh command string and is correctly consumed in the MI project-explorer refresh handler.- Updating
REFRESH_ENABLED_DOCUMENTSto["xml", "SynapseXml", "typescript", "markdown", "json"]correctly aligns with the visualizer's languageId filtering in bothonDidChangeTextDocument(line 223) andonDidSaveTextDocument(line 324) handlers in visualizer/activate.ts.workspaces/mi/mi-extension/src/project-explorer/activate.ts (1)
23-61: Unified refresh command wiring for MI is correct and safeThe new
COMMANDS.REFRESH_COMMANDhandler correctly branches onisInWI:
- In WI mode: delegates to
COMMANDS.WI_PROJECT_EXPLORER_VIEW_REFRESH(wso2-integrator.explorer.refresh) with early return.- Otherwise: calls and returns
projectExplorerDataProvider.refresh().Verification confirms this pattern is sound. The BI extension uses the identical delegation approach (BI.project-explorer.refresh → wso2-integrator.explorer.refresh), indicating this is a tested and intentional design. The early return in WI mode prevents double-refresh, and there is no evidence of cross-extension recursion within the MI codebase. The one-way delegation structure is secure.
Purpose
Goals
Approach
UI Component Development
npm run storybookfrom the root directory to view current components.Manage Icons
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning
Summary by CodeRabbit
Refactor
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.