Skip to content

Conversation

@gigara
Copy link
Contributor

@gigara gigara commented Nov 10, 2025

Purpose

$subject
Resolves wso2/mi-vscode#1346

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 [email protected] 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 [email protected] 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 a configurable logging level setting (off, error, warn, info, debug).
  • Improvements

    • Better loading-state propagation so views respect active loading.
    • Default initial view changed to Overview for a clearer start.
    • Popup opening now defers until initialization completes.
    • Visualizer avoids switching views while a load is in progress.
    • Reduced runtime noise by gating debug logs unless enabled.
  • Tests

    • E2E diagram view test refreshed to reopen the webview before interactions.

@gigara gigara requested a review from hevayo as a code owner November 10, 2025 13:23
@gigara gigara added the Checks/Enable UI Tests Tests run on the diff; skipped if there are no extension or related changes. label Nov 10, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Walkthrough

Adds an optional isLoading flag to VisualizerLocation and threads it through RPC, state machine, and visualizer guards; introduces a typed LogLevel and a configurable MI.logging.loggingLevel setting; updates logging callsites to use the enum; adjusts state-machine flows and popup timing; minor test and default settings tweaks.

Changes

Cohort / File(s) Summary
Visualizer location type & plumbing
workspaces/mi/mi-core/src/state-machine-types.ts, workspaces/mi/mi-extension/src/RPCLayer.ts
Added optional isLoading?: boolean to VisualizerLocation and populated it from RPC/context responses.
State machine core & flow
workspaces/mi/mi-extension/src/stateMachine.ts, workspaces/mi/mi-extension/src/stateMachinePopup.ts
getStateMachine gains optional context?: VisualizerLocation and returned sendEvent; transitions/guards updated to set/clear isLoading, removed viewStacking, and OPEN_VIEW may be deferred until ready.
Visualizer guard
workspaces/mi/mi-visualizer/src/Visualizer.tsx
Added guard to avoid applying incoming viewReady state while initialState.isLoading is true.
Logging infra & config
workspaces/mi/mi-extension/src/util/logger.ts, workspaces/mi/mi-extension/package.json
Added exported LogLevel enum; logDebug now accepts LogLevel (default DEBUG), gates output via MI.logging.loggingLevel (new setting in package.json).
Logging callsite updates
workspaces/mi/mi-extension/src/debugger/debugHelper.ts, workspaces/mi/mi-extension/src/debugger/debugger.ts, workspaces/mi/mi-extension/src/debugger/tasks.ts
Replaced ERROR_LOG/INFO_LOG string constants with LogLevel.ERROR/LogLevel.INFO and updated imports/usages.
State-machine types/public API
workspaces/mi/mi-extension/src/stateMachine.ts
Public getStateMachine signature updated to accept optional context and return sendEvent method.
Tests / small fixes
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/artifactTests/artifact.spec.ts, workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/ArtifactTest/APITests.ts
Tests now close and reopen diagram webview before interactions; replaced some click steps with waits; fixed comment typos and minor formatting.
Default VS Code settings & tsconfig
workspaces/common-libs/playwright-vscode-tester/src/browser.ts, workspaces/mi/mi-extension/tsconfig.json
Added "workbench.secondarySideBar.defaultVisibility": "hidden" to default settings; tsconfig excludes ./src/test/test-resources.

Sequence Diagram(s)

sequenceDiagram
    participant Ext as VS Code Extension
    participant SM as StateMachine
    participant RPC as RPCLayer
    participant UI as Visualizer

    Ext->>SM: getStateMachine(projectUri, context?)
    SM->>SM: merge provided VisualizerLocation (may include isLoading)
    SM->>RPC: checkIfMiProject(view?)
    RPC-->>SM: detection result + metadata
    SM->>SM: set context.isLoading = true
    SM->>UI: notify context (isLoading:true)
    note right of UI `#f0f7ff`: Visualizer ignores viewReady while isLoading
    UI--xSM: skip applying viewReady if initialState.isLoading
    SM->>SM: finish detection, set context.isLoading = false
    SM->>RPC: update VisualizerLocation
    RPC->>UI: send state (isLoading:false / viewReady)
    UI->>UI: accept viewReady and render
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25-35 minutes

Areas to focus:

  • workspaces/mi/mi-extension/src/stateMachine.ts — new getStateMachine signature, sendEvent wiring, and isLoading lifecycle across transitions.
  • workspaces/mi/mi-extension/src/util/logger.ts — level gating logic and reading MI.logging.loggingLevel.
  • workspaces/mi/mi-extension/src/RPCLayer.ts & workspaces/mi/mi-visualizer/src/Visualizer.tsx — ensure isLoading propagation and guard consistency.
  • Tests under src/test/e2e-playwright-tests — verify timing/interaction changes won't flake.

Suggested reviewers

  • hevayo
  • kanushka

Poem

🐇 I nudged a flag, then hopped away,
Guarded the view while loaders held sway,
Logs now speak in ordered tone and tune,
Tabs reopen steady — no crash by noon,
Hooray — the visualizer sings with noonlight!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete; it contains only the issue reference and placeholder text without filling in critical sections like Goals, Approach, test coverage, environment details, or other required information. Fill in the Goals, Approach, Release note, Documentation, Automation tests, Security checks, and Test environment sections with concrete details about the fix and its validation.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Out of Scope Changes check ❓ Inconclusive Most changes align with the fix objective, but test modifications (artifact.spec.ts, APITests.ts) and some unrelated refactorings (secondary sidebar hiding, tsconfig exclusions) appear tangential to the core issue. Clarify whether test and configuration changes in artifact.spec.ts, APITests.ts, browser.ts, and tsconfig.json are necessary for fixing the diagram opening error or should be separated into a distinct PR.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main fix: addressing an error when opening diagram views on new tabs, which aligns with the primary changeset focus.
Linked Issues check ✅ Passed The code changes address the linked issue #1346 by implementing loading state tracking, improved state management, and UI guards to prevent errors when opening diagrams in new tabs.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aad5194 and 30ecf65.

📒 Files selected for processing (2)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/ArtifactTest/APITests.ts (1 hunks)
  • workspaces/mi/mi-extension/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-05T10:31:47.583Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 830
File: workspaces/ballerina/ballerina-extension/test/ai/post_proccess/post.test.ts:0-0
Timestamp: 2025-11-05T10:31:47.583Z
Learning: In the workspaces/ballerina/ballerina-extension project, the tsconfig.json uses "rootDirs": ["src", "test"], which allows test files to import from src using shorter relative paths. For example, from test/ai/post_proccess/, the import '../../stateMachine' correctly resolves to src/stateMachine.ts due to this configuration.

Applied to files:

  • workspaces/mi/mi-extension/tsconfig.json
🔇 Additional comments (2)
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/ArtifactTest/APITests.ts (1)

402-410: Test change aligns with the loading fix.

The modification correctly adjusts the test to verify that the diagram view loads successfully rather than attempting to interact with it immediately. Removing the navigation step and changing from click() to waitFor() helps avoid the race condition that likely caused the error described in issue #1346.

However, consider whether additional assertions would strengthen this test. Currently, it only verifies the "Start" text appears. You might want to confirm the iframe is fully rendered or that no error dialogs are present.

If you'd like to add defensive checks, consider:

 await webView.getByText('Start').waitFor();
+ // Verify no error dialogs appeared during load
+ const errorDialog = this._page.getByRole('dialog', { name: /error/i });
+ await expect(errorDialog).not.toBeVisible({ timeout: 1000 });
workspaces/mi/mi-extension/tsconfig.json (1)

21-25: This review comment is analyzing pre-existing code that is not being modified by the PR.

The tsconfig.json file and its exclude array (including the ./src/test/test-resources entry) are not being changed as part of this PR. Git confirms no modifications to this file. The exclusion already exists in the codebase and is not a new addition. The review should either be removed or redirected if there are actual tsconfig.json changes elsewhere in the PR.

Likely an incorrect or invalid review comment.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
workspaces/mi/mi-extension/src/stateMachine.ts (2)

809-824: updateProjectExplorer may inadvertently create state machines with incorrect context.

Line 819 calls getStateMachine(projectRoot, location), which will create a new state machine if one doesn't exist. Since updateProjectExplorer is a utility function called from multiple places (lines 617, 664, 728), this could initialize state machines with transient or incorrect context (e.g., isLoading: true).

This may be contributing to the error described in the PR where opening a diagram in a new tab triggers an error.

Apply this fix to only retrieve existing state machines without creating new ones:

         } else if (projectRoot && !extension.preserveActivity) {
             location.projectUri = projectRoot;
-            if (!getStateMachine(projectRoot, location).context().isOldProject) {
+            // Only check if state machine already exists
+            if (stateMachines.has(projectRoot) && !getStateMachine(projectRoot).context().isOldProject) {
                 vscode.commands.executeCommand(COMMANDS.REVEAL_ITEM_COMMAND, location);
             }
         }

Alternatively, add a parameter-less getter:

export const hasStateMachine = (projectUri: string): boolean => {
    return stateMachines.has(projectUri);
};

Then use:

if (hasStateMachine(projectRoot) && !getStateMachine(projectRoot).context().isOldProject) {
    // ...
}

681-714: Context parameter silently ignored for cached state machines; default view changed from Welcome to Overview.

The context parameter is only applied when creating a new state machine. For existing machines retrieved from the cache, the parameter is silently ignored. This creates a subtle bug at line 819 where getStateMachine(projectRoot, location) passes context expecting initialization, but if the machine already exists for that projectUri, the location parameter is discarded without warning.

Additionally, the default view changed from MACHINE_VIEW.Welcome (line 50) to MACHINE_VIEW.Overview (line 698), which may affect initial user experience, especially for new projects.

To address this:

  1. Document the caching behavior if intentional, clarifying that context only applies to new machines.
  2. Warn when context is ignored for existing machines to catch caller mistakes.
  3. Re-evaluate whether machines should be reused or if fresh initialization is needed in certain flows (e.g., at line 819).
🧹 Nitpick comments (2)
workspaces/mi/mi-extension/src/stateMachine.ts (2)

24-24: Inconsistent logging approach throughout the file.

State entry points use logDebug (which respects configuration), while runtime detection and operation messages use console.log (which bypasses configuration). This means users cannot control the verbosity of detection logs even when logging is set to OFF.

Consider replacing all console.log statements with logDebug for consistency:

-                console.log("Waiting for LS to be ready " + new Date().toLocaleTimeString());
+                logDebug("Waiting for LS to be ready " + new Date().toLocaleTimeString());
-                    console.log("LS is ready " + new Date().toLocaleTimeString());
+                    logDebug("LS is ready " + new Date().toLocaleTimeString());
-                    console.log("Error occured while waiting for LS to be ready " + new Date().toLocaleTimeString());
+                    logDebug("Error occured while waiting for LS to be ready " + new Date().toLocaleTimeString());
-    console.log(`Detecting project in ${projectUri} - ${new Date().toLocaleTimeString()}`);
+    logDebug(`Detecting project in ${projectUri} - ${new Date().toLocaleTimeString()}`);

Apply similar changes to lines 838, 900-901, 904, 925, 930, and 936.

Also applies to: 392-392, 404-404, 406-406, 827-827, 838-838, 900-901, 904-904, 925-925, 930-930, 936-936


58-58: Simplify redundant nullish coalescing.

The expression context.view ?? undefined is redundant since the default parameter value is already MACHINE_VIEW.Overview (line 826).

-                src: (context) => checkIfMiProject(context.projectUri!, context.view ?? undefined),
+                src: (context) => checkIfMiProject(context.projectUri!, context.view),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ad515f and f8cbb09.

📒 Files selected for processing (9)
  • workspaces/mi/mi-core/src/state-machine-types.ts (1 hunks)
  • workspaces/mi/mi-extension/package.json (1 hunks)
  • workspaces/mi/mi-extension/src/RPCLayer.ts (1 hunks)
  • workspaces/mi/mi-extension/src/debugger/debugHelper.ts (16 hunks)
  • workspaces/mi/mi-extension/src/debugger/debugger.ts (16 hunks)
  • workspaces/mi/mi-extension/src/debugger/tasks.ts (3 hunks)
  • workspaces/mi/mi-extension/src/stateMachine.ts (25 hunks)
  • workspaces/mi/mi-extension/src/util/logger.ts (2 hunks)
  • workspaces/mi/mi-visualizer/src/Visualizer.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-05T10:31:47.583Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 830
File: workspaces/ballerina/ballerina-extension/test/ai/post_proccess/post.test.ts:0-0
Timestamp: 2025-11-05T10:31:47.583Z
Learning: In the workspaces/ballerina/ballerina-extension project, the tsconfig.json uses "rootDirs": ["src", "test"], which allows test files to import from src using shorter relative paths. For example, from test/ai/post_proccess/, the import '../../stateMachine' correctly resolves to src/stateMachine.ts due to this configuration.

Applied to files:

  • workspaces/mi/mi-extension/src/stateMachine.ts
🧬 Code graph analysis (4)
workspaces/mi/mi-extension/src/debugger/debugger.ts (1)
workspaces/mi/mi-extension/src/util/logger.ts (1)
  • logDebug (49-61)
workspaces/mi/mi-extension/src/debugger/tasks.ts (1)
workspaces/mi/mi-extension/src/util/logger.ts (1)
  • logDebug (49-61)
workspaces/mi/mi-extension/src/stateMachine.ts (3)
workspaces/mi/mi-extension/src/util/logger.ts (1)
  • logDebug (49-61)
workspaces/mi/mi-core/src/state-machine-types.ts (1)
  • VisualizerLocation (252-273)
workspaces/mi/mi-extension/src/util/migrationUtils.ts (2)
  • containsMultiModuleNatureInPomFile (1685-1690)
  • findMultiModuleProjectsInWorkspaceDir (1704-1734)
workspaces/mi/mi-extension/src/debugger/debugHelper.ts (1)
workspaces/mi/mi-extension/src/util/logger.ts (1)
  • logDebug (49-61)
🔇 Additional comments (13)
workspaces/mi/mi-extension/src/util/logger.ts (1)

23-28: LGTM! Clean enum definition.

The LogLevel enum provides a type-safe way to specify logging levels across the extension.

workspaces/mi/mi-extension/src/debugger/tasks.ts (1)

23-23: LGTM! Correct migration to the new logging API.

The import and usage of LogLevel.ERROR are appropriate for the error scenarios in this file.

Also applies to: 154-154, 180-180

workspaces/mi/mi-core/src/state-machine-types.ts (1)

272-272: LGTM! Appropriate type extension.

Adding the optional isLoading property enables tracking of loading state in the visualizer location context, which supports the fix for the diagram view error.

workspaces/mi/mi-extension/src/RPCLayer.ts (1)

102-102: LGTM! Correct propagation of loading state.

The isLoading field is properly passed through from the state machine context to the RPC client, enabling the frontend to access the loading state.

workspaces/mi/mi-extension/src/debugger/debugHelper.ts (2)

32-32: LGTM! Correct import update.

The import correctly brings in the new LogLevel enum from the updated logger module.


107-107: LGTM! Consistent migration to the new logging API.

All logDebug calls correctly use LogLevel.INFO for success/informational messages and LogLevel.ERROR for error scenarios. The log level choices are appropriate for each context.

Also applies to: 118-118, 129-129, 227-227, 236-236, 429-429, 447-447, 460-460, 522-522, 537-537, 552-552, 584-584, 593-593, 625-625, 659-659

workspaces/mi/mi-visualizer/src/Visualizer.tsx (1)

96-96: LGTM! Correct loading guard implementation.

The added condition && !initialState.isLoading prevents visualizer state updates during active loading operations. This addresses the error when opening diagrams in new tabs by ensuring the state machine doesn't transition until loading completes.

The logic correctly handles the optional isLoading property:

  • When isLoading is undefined (not set), !initialState.isLoading evaluates to true, allowing the update
  • When isLoading is true, the update is blocked
  • When isLoading is false, the update is allowed
workspaces/mi/mi-extension/src/debugger/debugger.ts (2)

29-29: LGTM! Correct import update.

The import correctly brings in the new LogLevel enum from the updated logger module.


86-86: LGTM! Consistent migration to the new logging API.

All logDebug calls correctly use:

  • LogLevel.ERROR for error conditions (workspace not found, breakpoint issues, connection errors, etc.)
  • LogLevel.INFO for informational messages (events received, commands sent, responses)

The log level assignments are appropriate for each context.

Also applies to: 136-136, 168-168, 181-181, 190-190, 228-228, 260-260, 277-277, 394-394, 399-399, 404-404, 422-422, 433-433, 453-453, 594-594, 612-612, 647-647

workspaces/mi/mi-extension/src/stateMachine.ts (4)

268-286: Consider adding guards for isLoading state.

The isLoading flag is set to true on OPEN_VIEW (line 284) and reset to false in various completion states (lines 181, 246, 261). However, there are no guards preventing new OPEN_VIEW, REPLACE_VIEW, or NAVIGATE events from being processed while isLoading is true.

If the intent is to prevent concurrent view transitions, add a guard condition:

                        OPEN_VIEW: {
                            target: "viewLoading",
+                           cond: (context) => !context.isLoading,
                            actions: assign({

Alternatively, if XState's built-in event queuing is sufficient, document this behavior to clarify the design intent.


235-249: LGTM: Loading state properly managed in view transitions.

The additions of dataMapperProps and isLoading: false assignments ensure state is properly propagated and loading flags are reset when view finding completes. The target change to viewReady (line 240) correctly reflects the state machine structure.


283-283: LGTM: Previous context tracking enables proper history management.

Storing previousContext (line 283) allows the history service (line 627) to maintain accurate navigation state when opening new views. This is essential for the back/forward navigation feature.


826-915: LGTM: View parameter and scope-based view selection implemented correctly.

The addition of the view parameter with default MACHINE_VIEW.Overview (line 826) aligns with the state machine initialization changes. The scope-based view selection logic (lines 858-873) appropriately determines which view to display for empty projects based on their configured scope.

The function correctly returns all necessary properties including isEnvironmentSetUp for proper state machine transitions.

Note: Console logging consistency is addressed in a separate comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
workspaces/mi/mi-extension/src/util/logger.ts (1)

49-61: Type safety issue: unsafe cast when configuredLevel is undefined.

The cast configuredLevel as LogLevel on line 58 is unsafe. When config.get() returns undefined (e.g., if the setting hasn't been explicitly configured yet), the cast is invalid and indexOf will return -1, breaking the comparison logic.

Apply this diff to fix the type safety issue:

 export function logDebug(message: string, logLevel: LogLevel = LogLevel.DEBUG): void {
     const config = vscode.workspace.getConfiguration('MI');
     const configuredLevel = config.get<string>('logging.loggingLevel');
 
     if (configuredLevel === 'off') {
         return;
     }
     // Only log if the message's level is >= configured level
     const levels = [LogLevel.ERROR, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG];
-    if (levels.indexOf(logLevel) <= levels.indexOf(configuredLevel as LogLevel)) {
+    const effectiveLevel = (configuredLevel as LogLevel) || LogLevel.ERROR;
+    if (levels.indexOf(logLevel) <= levels.indexOf(effectiveLevel)) {
         logWithDebugLevel(message, 'MI Debug', logLevel);
     }
 }
🧹 Nitpick comments (1)
workspaces/mi/mi-extension/package.json (1)

166-178: Configuration looks good; minor typo in description.

The logging configuration properly includes all log levels including "info", which addresses the previous review concern. The enum values align correctly with the LogLevel enum in logger.ts.

Minor nitpick: Line 176, "Order" could be lowercase "order" for consistency with typical descriptions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8cbb09 and 374e9bf.

📒 Files selected for processing (4)
  • workspaces/mi/mi-extension/package.json (1 hunks)
  • workspaces/mi/mi-extension/src/stateMachinePopup.ts (8 hunks)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/artifactTests/artifact.spec.ts (4 hunks)
  • workspaces/mi/mi-extension/src/util/logger.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-05T10:31:47.583Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 830
File: workspaces/ballerina/ballerina-extension/test/ai/post_proccess/post.test.ts:0-0
Timestamp: 2025-11-05T10:31:47.583Z
Learning: In the workspaces/ballerina/ballerina-extension project, the tsconfig.json uses "rootDirs": ["src", "test"], which allows test files to import from src using shorter relative paths. For example, from test/ai/post_proccess/, the import '../../stateMachine' correctly resolves to src/stateMachine.ts due to this configuration.

Applied to files:

  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/artifactTests/artifact.spec.ts
🔇 Additional comments (3)
workspaces/mi/mi-extension/src/stateMachinePopup.ts (2)

26-26: LGTM! Debug logging improves observability.

The addition of debug logging at state entry points provides valuable observability for tracking state machine transitions, which will help diagnose issues like the one this PR addresses.

Also applies to: 45-45, 63-63, 80-80, 101-101, 113-113, 124-124


224-236: Fix correctly defers OPEN_VIEW and safely handles error states.

The state machine confirms that initialize has two guaranteed transitions: onDoneready or onErrordisabled. Your implementation properly waits for the ready state and sends the event only then.

The edge case mentioned (listener remaining attached if initialization fails) is very minor: the listener won't execute when the state transitions to disabled since the condition checks for "ready", so the OPEN_VIEW event won't be sent to a disabled state machine. The listener attachment is inert in error scenarios but represents a small memory overhead if initialization repeatedly fails. For better resource hygiene, consider cleaning up the listener on disabled state transitions as well, but this is not critical since the current behavior is safe.

workspaces/mi/mi-extension/src/util/logger.ts (1)

23-28: LGTM! Well-defined LogLevel enum.

The enum provides type-safe log levels that align with the configuration schema.

@gigara gigara added Checks/Run MI UI Tests Force run MI UI tests and removed Checks/Enable UI Tests Tests run on the diff; skipped if there are no extension or related changes. labels Nov 11, 2025
@gigara gigara merged commit 6015ed7 into wso2:main Nov 15, 2025
18 of 24 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 17, 2025
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when opening a diagram view on a new tab

2 participants