Skip to content

Vscode extension#1545

Merged
anurag91jain merged 29 commits intodevfrom
vscode-extension
Jul 22, 2025
Merged

Vscode extension#1545
anurag91jain merged 29 commits intodevfrom
vscode-extension

Conversation

@shubham-sp-07
Copy link
Copy Markdown
Contributor

Implemented Chatbot UI allowing users to perform key actions directly from the chatbot, including:
• Create New App
• Authorize New Instance
• Select Instance
• Remove Instance
• Zip and Deploy
• Zip Only
• Deploy Only
Added options for users to:
• Clear chat history
• Download user manual

How to Test
Install the extension using the .vsix file.
Once the installation is complete, look for the Semoss Assistant icon in the Activity Bar (side panel) of VS Code.
Click on the icon to open the Semoss Assistant panel.

anurag91jain and others added 24 commits June 19, 2025 16:43
* feat(vscode-extn): added vs-extension create new app command

* feat(vscode-extn): added option for choosing location to download the app and also download git repo

---------

Co-authored-by: Pallabi Pati <pallabipati232@gmail.com>
* feat(vscode-extension): changes for chatbot

* feat(vscode-extension): adding missing modules and updating gitignore

* feat(vscode-extension): fixing order of imports and removing unused line
@shubham-sp-07 shubham-sp-07 requested a review from a team as a code owner July 18, 2025 06:53
@github-actions
Copy link
Copy Markdown

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

Vscode extension


User description

Implemented Chatbot UI allowing users to perform key actions directly from the chatbot, including:
• Create New App
• Authorize New Instance
• Select Instance
• Remove Instance
• Zip and Deploy
• Zip Only
• Deploy Only
Added options for users to:
• Clear chat history
• Download user manual

How to Test
Install the extension using the .vsix file.
Once the installation is complete, look for the Semoss Assistant icon in the Activity Bar (side panel) of VS Code.
Click on the icon to open the Semoss Assistant panel.


PR Type

Enhancement


Description

  • Add responsive chatbot UI script for VS Code Webview

  • Implement commands: create app, authorize/select/remove instance

  • Introduce createNewApp utility with GitHub assets support

  • Enhance deployment and project utilities (zip, deploy)


File Walkthrough

Relevant files

@github-actions
Copy link
Copy Markdown

@CodiumAI-Agent /review

@github-actions
Copy link
Copy Markdown

@CodiumAI-Agent /improve

@QodoAI-Agent
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
🧪 No relevant tests
🔒 Security concerns

Cross-site scripting:
Using innerHTML with partially processed message text allows injection if message.text contains malicious HTML. Ensure full sanitization or use textContent/text nodes for untrusted content.

⚡ Recommended focus areas for review

XSS Risk

The method appendMessage sets bubble.innerHTML using processedContent derived from message.text without fully escaping general text. Untrusted input may inject HTML or scripts. Consider sanitizing all user-supplied text or rendering via textContent.

if (typeof text === 'string') {
    // Create a container for the processed content
    let processedContent = text;

    // Handle code blocks for better mobile display
    const codeBlockRegex = /```([\s\S]*?)```/g;
    processedContent = processedContent.replace(codeBlockRegex, (match, code) => {
        // Apply special formatting for code blocks on mobile
        if (isMobile && isSmallPhone) {
            return `<pre class="code-block small-device-code"><code>${this.escapeHtml(code.trim())}</code></pre>`;
        } else if (isMobile) {
            return `<pre class="code-block mobile-code"><code>${this.escapeHtml(code.trim())}</code></pre>`;
        } else {
            return `<pre class="code-block"><code>${this.escapeHtml(code.trim())}</code></pre>`;
        }
    });
Performance

Resize and orientation change handlers are attached directly without debouncing. Frequent events may trigger expensive reflows and layout adjustments. Consider adding a debounce/throttle around handleViewportChange.

    // Handle viewport changes for responsive design
    window.addEventListener('resize', () => this.handleViewportChange());
    window.addEventListener('orientationchange', () => this.handleViewportChange());
}
Logic Bug

The DeleteAsset error check uses && and || without grouping, causing the “not found” clause to always evaluate in certain cases. Wrap conditions properly to avoid skipping real errors.

// If the error is just that the folder doesn't exist, that's fine - continue
if (errorOutput && errorOutput.includes('does not exist') || errorOutput.includes('not found')) {
    console.log('Assets folder does not exist, continuing with upload...');
} else {

@QodoAI-Agent
Copy link
Copy Markdown

PR Code Suggestions ✨

CategorySuggestion                                                                                                                                    Impact
Security
Escape message text early

Escape the initial message text to avoid injecting raw HTML and prevent XSS
vulnerabilities. Apply the existing escapeHtml method before applying regex
replacements. This ensures any user‐supplied content is sanitized.

packages/vscode-extension/src/components/Chatbot-ui/script.js [348]

-let processedContent = text;
+let processedContent = this.escapeHtml(text);
Suggestion importance[1-10]: 8

__

Why: Early HTML escaping with escapeHtml prevents potential XSS by sanitizing user‐supplied messages before any regex-based formatting.

Medium
Possible issue
Populate folderCommands array

The folderCommands array is empty, so folder‐based commands like zip or deploy never
trigger folder prompts or proper handling. Populate it with the relevant command IDs
to ensure those commands are recognized and processed correctly.

packages/vscode-extension/src/components/ChatbotWebview/ChatbotWebview.js [136-137]

-// Remove deployonly from folderCommands so it never prompts for a folder
-const folderCommands = [];
+// Commands that operate on workspace folders
+const folderCommands = ['semoss.zipanddeploy', 'semoss.ziponly', 'semoss.deployonly'];
Suggestion importance[1-10]: 8

__

Why: Filling folderCommands ensures ZIP and deploy commands are recognized as folder-based operations and properly prompt for or default to a workspace folder.

Medium
Close style attribute quote

The inline style attribute is missing a closing quote, causing malformed HTML. Add a
closing quote before the ending semicolon. This fixes the rendering of conditional
input groups.

packages/vscode-extension/src/components/Chatbot-ui/script.js [927]

 if (input.conditional) {
-    inputHTML += ' conditional-field" data-depends-on="' + input.conditional + '" style="display: none;';
+    inputHTML += ' conditional-field" data-depends-on="' + input.conditional + '" style="display: none;"';
 }
Suggestion importance[1-10]: 7

__

Why: The missing closing quote in the style attribute breaks the generated HTML for conditional input fields, so adding it fixes rendering issues.

Medium
Use fs.promises.access for existence

The use of promisify(fs.exists) is problematic because fs.exists doesn’t follow the
Node error-first callback convention and is deprecated. Replace it with
fs.promises.access wrapped in a try/catch to reliably check for existence.

packages/vscode-extension/src/utils/zip.js [11-26]

-const fsExists = promisify(fs.exists);
+// Replace fsExists with a proper promise-based existence check
+async function fsExists(pathToCheck) {
+  try {
+    await fs.promises.access(pathToCheck);
+    return true;
+  } catch {
+    return false;
+  }
+}
 ...
 const exists = await fsExists(startPath);
Suggestion importance[1-10]: 7

__

Why: This replaces the deprecated fs.exists with a robust fs.promises.access check, improving compatibility and correctness.

Medium
Fix invalid calc syntax

Wrap the multiplication in parentheses in the calc() expression to ensure valid CSS
syntax and proper calculation.

packages/vscode-extension/src/components/Chatbot-ui/style.css [148-149]

 #chat-container {
     ...
-    width: calc(100% - 2 * var(--space-md));
+    width: calc(100% - (2 * var(--space-md)));
     /* Adjust for margins */
     ...
 }
Suggestion importance[1-10]: 3

__

Why: Wrapping the multiplication in parentheses is a minor syntax preference—calc(100% - 2 * var(...)) is valid—so the impact is low.

Low
General
Return null instead of throwing

Throwing on user cancellation prevents createNewApp from returning false as
intended. Return null instead so the caller can handle cancellation gracefully.

packages/vscode-extension/src/utils/createApp.js [183-195]

 async function selectDownloadFolder() {
     const uri = await vscode.window.showOpenDialog({ ... });
     if (!uri || uri.length === 0) {
-        throw new Error('No folder selected');
+        return null;
     }
     return uri[0].fsPath;
 }
Suggestion importance[1-10]: 8

__

Why: Returning null on cancellation allows createNewApp to handle user aborts gracefully instead of triggering an exception.

Medium
Return false on validation errors

Throwing on validation failure bypasses the if (!isValid) return false check in
createNewApp. Catch and display the error, then return false to allow graceful early
exit.

packages/vscode-extension/src/utils/createApp.js [223-239]

 async function validateGithubRepository(githubLink, isPrivateRepo, accessToken) {
     try {
         ...
         return true;
     } catch (err) {
-        throw new Error(`GitHub validation failed: ${err.message || err}`);
+        const msg = `GitHub validation failed: ${err.message || err}`;
+        vscode.window.showErrorMessage(msg);
+        return false;
     }
 }
Suggestion importance[1-10]: 7

__

Why: Catching validation errors and returning false aligns with the existing early-exit pattern in createNewApp, improving UX.

Medium
Define initial isSmallPhone

The initial viewport state omits isSmallPhone, leading to undefined checks before
the first resize. Add isSmallPhone based on width (e.g., ≤ 375px). This aligns
responsive logic with later updates.

packages/vscode-extension/src/components/Chatbot-ui/script.js [17-21]

 this.state = {
     chatStarted: false,
     currentState: 'start',
     lastCommand: null,
     chatHistory: [],
     isLoading: false,
     // Add viewport state
     viewport: {
         width: window.innerWidth,
         height: window.innerHeight,
+        isSmallPhone: window.innerWidth <= 375,
         isMobile: window.innerWidth <= 768,
         isLandscape: window.innerWidth > window.innerHeight
     }
 };
Suggestion importance[1-10]: 6

__

Why: Including isSmallPhone in the initial viewport state aligns with later responsive logic and avoids undefined checks before the first resize event.

Low
Consolidate header styles

Merge these two #chat-header rules into one to avoid conflicting padding and
min-height definitions.

packages/vscode-extension/src/components/Chatbot-ui/style.css [163-179]

 #chat-header {
     display: flex;
     justify-content: space-between;
     align-items: center;
     background: var(--bg-tertiary);
     border: 1px solid var(--border-primary);
     border-bottom: none;
     border-radius: var(--radius-lg) var(--radius-lg) 0 0;
-    padding: var(--space-sm) var(--space-md);
-    min-height: 44px;
+    padding: var(--space-xs) var(--space-sm);
+    min-height: 36px;
     backdrop-filter: blur(10px);
 }
 
-#chat-header {
-    padding: var(--space-xs) var(--space-sm);
-    min-height: 36px;
-}
-
Suggestion importance[1-10]: 6

__

Why: Two separate #chat-header rules define conflicting padding and min-height; merging them improves maintainability and prevents override issues.

Low
Scope toggle selectors

Scope the checked selector to the toggle component by prefixing with .toggle-switch
so unrelated inputs aren’t affected.

packages/vscode-extension/src/components/Chatbot-ui/style.css [846-853]

-input:checked + .toggle-slider {
+.toggle-switch input:checked + .toggle-slider {
     background: var(--color-primary);
 }
-input:checked + .toggle-slider:before {
+.toggle-switch input:checked + .toggle-slider:before {
     transform: translateX(24px);
 }
Suggestion importance[1-10]: 6

__

Why: Prefixing with .toggle-switch correctly scopes the selectors to the toggle component and prevents unintended styling of unrelated inputs.

Low
Define extra-small spacing

Define --space-xxs in :root for consistency instead of relying on the fallback
inside each rule.

packages/vscode-extension/src/components/Chatbot-ui/style.css [187-189]

+:root {
+    /* ...existing variables... */
+    --space-xxs: 2px;
+}
 .header-buttons {
-    gap: var(--space-xxs, 2px);
+    gap: var(--space-xxs);
 }
Suggestion importance[1-10]: 5

__

Why: Adding --space-xxs in :root removes reliance on fallbacks and keeps the spacing variables consistent across the theme.

Low
Remove duplicate file-check block

The duplicate if (!smssFile) blocks are redundant and can be consolidated into a
single check to simplify the code and avoid unreachable paths.

packages/vscode-extension/src/utils/projectUtils.js [24-31]

 export function getProjectId() {
-    let projectId = "";
     const projectFolderPath = assetsFolderPath.replace(/\\assets|\/assets/g, "");
-    const smssFile = fs.readdirSync(projectFolderPath).find((file) => file.endsWith('.smss'));
+    const smssFile = fs.readdirSync(projectFolderPath).find(file => file.endsWith('.smss'));
     if (!smssFile) {
         throw new Error(`No .smss file found in project folder: ${projectFolderPath}`);
     }
-    if (!smssFile) {
-        throw new Error('No .smss file found in the project folder');
-    }
+    const smssContent = fs.readFileSync(path.join(projectFolderPath, smssFile), 'utf8');
     ...
 }
Suggestion importance[1-10]: 4

__

Why: Consolidating the duplicate if (!smssFile) checks simplifies the code and removes unreachable paths with minimal impact.

Low

package.json Outdated
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@commitlint/cli": "^19.8.1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

@@ -0,0 +1,16 @@
node_modules
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have removed the file and added the necessary entries to the parent folder's .gitignore file.

@@ -0,0 +1,7 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove comments from JSON

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed Unwanted comments

@@ -0,0 +1,26 @@
// A launch configuration that launches the extension inside a new window
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove comments

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed Unwanted comments

@@ -0,0 +1,36 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are we using these tasks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The unused file has been successfully removed.

"semoss.createNewApp",
async (args) => {
// If called from chatbot, use args; otherwise, prompt
const getSecretsWithValidation = async (context) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this function as it is duplicate of 122

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed Duplicate Function

@anurag91jain anurag91jain merged commit 5589abc into dev Jul 22, 2025
3 checks passed
@anurag91jain anurag91jain deleted the vscode-extension branch July 22, 2025 15:22
@github-actions
Copy link
Copy Markdown

@CodiumAI-Agent /update_changelog

@QodoAI-Agent
Copy link
Copy Markdown

Changelog updates: 🔄

2025-07-22 *

Added

  • VSCode extension with integrated Chatbot UI for Semoss workflows
  • Commands via chatbot: create app, authorize/select/remove instance, zip & deploy variants
  • Chat features: clear history and download user manual

to commit the new content to the CHANGELOG.md file, please type:
'/update_changelog --pr_update_changelog.push_changelog_changes=true'

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.

Download a folder with template in the extension Create new app via the vscode extension

4 participants