Skip to content

Conversation

@axewilledge
Copy link
Contributor

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.
Fixes:
wso2/product-ballerina-integrator#1891
wso2/product-ballerina-integrator#1892

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 15, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a 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.

@axewilledge axewilledge changed the title Update project info interface and enhance state machine actions Update package configurable view and enhance state machine actions Nov 15, 2025
@kanushka kanushka requested a review from Copilot November 16, 2025 03:22
Copilot finished reviewing on behalf of kanushka November 16, 2025 03:31
@kanushka kanushka merged commit 2aaf69b into wso2:bi-1.5.x Nov 16, 2025
12 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the Ballerina package configurable view and improves state machine actions for better org/package tracking. The changes focus on fixing the state management for organization and package information across views, adding loading states, and improving error handling.

  • Added proper org/package name tracking through state machine transitions
  • Introduced loading indicators for configurable variables view
  • Enhanced error handling in DMC file formatting
  • Added string value wrapping logic for configurable variables

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts Added error handling for DMC file formatting operations
workspaces/ballerina/ballerina-visualizer/src/views/BI/Configurables/ViewConfigurableVariables/index.tsx Added loading state management and refined useEffect dependencies for org/package changes
workspaces/ballerina/ballerina-visualizer/src/views/BI/Configurables/ConfigurableItem/index.tsx Implemented string value wrapping/unwrapping logic for configurable variables
workspaces/ballerina/ballerina-visualizer/src/views/BI/Configurables/ConfigurableItem/ConfigObjectEditor.tsx Added string value quote wrapping for parsed configuration objects
workspaces/ballerina/ballerina-extension/src/utils/config.ts Refactored getPackageName to getOrgAndPackageName to return both org and package information
workspaces/ballerina/ballerina-extension/src/stateMachine.ts Enhanced state machine to track and assign org/package through state transitions and view operations
workspaces/ballerina/ballerina-core/src/interfaces/extended-lang-client.ts Added org field to ProjectInfo interface to support org tracking alongside orgName

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +132 to +139
}

const getPlainValue = (value: string) => {
if (configVariable.properties?.type?.value === 'string' && /^".*"$/.test(value)) {
return value.replace(/^"|"$/g, '');
}
return value;
}
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Missing semicolons after function declarations. While JavaScript/TypeScript allows this, it's inconsistent with the coding style used elsewhere in the file where semicolons are present after other statements. Add semicolons at the end of both function declarations for consistency.

Suggested change
}
const getPlainValue = (value: string) => {
if (configVariable.properties?.type?.value === 'string' && /^".*"$/.test(value)) {
return value.replace(/^"|"$/g, '');
}
return value;
}
};
const getPlainValue = (value: string) => {
if (configVariable.properties?.type?.value === 'string' && /^".*"$/.test(value)) {
return value.replace(/^"|"$/g, '');
}
return value;
};

Copilot uses AI. Check for mistakes.

const handleTextAreaChange = (value: any) => {
if (configVariable.properties?.type?.value === 'string' && !/^".*"$/.test(value)) {
value = `"${value}"`;
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

The string wrapping logic doesn't handle strings that already contain internal quotes or need escaping. For example:

  • he said "hello""he said "hello"" (produces invalid JSON/string literal)
  • Values with newlines or special characters may not be properly escaped

Consider escaping internal quotes before wrapping, or validate that the value doesn't contain unescaped quotes:

if (configVariable.properties?.type?.value === 'string' && !/^".*"$/.test(value)) {
    // Escape internal quotes
    value = `"${value.replace(/"/g, '\\"')}"`;
}
Suggested change
value = `"${value}"`;
value = JSON.stringify(value);

Copilot uses AI. Check for mistakes.
// Check if there are string values that are not wrapped in quotes
Object.keys(parsedValue).forEach(key => {
if (typeof parsedValue[key] === 'string' && !/^".*"$/.test(parsedValue[key])) {
parsedValue[key] = `"${parsedValue[key]}"`;
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Same issue as in ConfigurableItem/index.tsx: The string wrapping logic doesn't escape internal quotes. When wrapping string values that contain quotes, this will produce invalid JSON. Consider escaping quotes before wrapping:

if (typeof parsedValue[key] === 'string' && !/^".*"$/.test(parsedValue[key])) {
    parsedValue[key] = `"${parsedValue[key].replace(/"/g, '\\"')}"`;
}
Suggested change
parsedValue[key] = `"${parsedValue[key]}"`;
parsedValue[key] = JSON.stringify(parsedValue[key]);

Copilot uses AI. Check for mistakes.
Comment on lines 123 to +126
useEffect(() => {
getConfigVariables();
}, [props]);
setIsLoading(true);
getConfigVariables(true);
}, [props.org, props.package]);
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

The useEffect hook calls getConfigVariables(true) but doesn't include it in the dependency array. This can lead to stale closures where the function captures old values of state variables like rpcClient, selectedModule, etc.

Consider either:

  1. Wrapping getConfigVariables with useCallback and adding it to the dependency array
  2. Disabling the ESLint rule with a comment if the omission is intentional
  3. Refactoring to avoid the dependency by inlining the logic

Copilot uses AI. Check for mistakes.
}
extension.hasPullModuleResolved = false;
extension.hasPullModuleNotification = false;
const { orgName, packageName } = getOrgAndPackageName(StateMachine.context().projectInfo, viewLocation.projectPath);
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Potential issue: The getOrgAndPackageName function is called with viewLocation.projectPath which might be undefined. While the function handles this by returning empty strings, this could lead to incorrect org/package information being set in the view location. Consider validating that viewLocation.projectPath exists before calling this function, or provide a fallback to StateMachine.context().projectPath.

Suggested change
const { orgName, packageName } = getOrgAndPackageName(StateMachine.context().projectInfo, viewLocation.projectPath);
const { orgName, packageName } = getOrgAndPackageName(
StateMachine.context().projectInfo,
viewLocation.projectPath || StateMachine.context().projectPath
);

Copilot uses AI. Check for mistakes.
} catch (error) {
console.error("Error occurred while formatting DMC file: ", error);
return;
}
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Potential issue: If edits is null or undefined (which can happen if no formatter is available for the document type), calling workspaceEdit.set(uri, edits) at line 181 may cause an error. Add a null check after the try-catch block:

if (!edits) {
    console.warn("No formatting edits returned for DMC file");
    return;
}
Suggested change
}
}
if (!edits) {
console.warn("No formatting edits returned for DMC file");
return;
}

Copilot uses AI. Check for mistakes.
data = (variables as any).configVariables;
errorMsg = (variables as any).errorMsg;
});
})
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

Avoid automated semicolon insertion (90% of all statements in the enclosing function have an explicit semicolon).

Suggested change
})
});

Copilot uses AI. Check for mistakes.
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.

4 participants